Revision 4127
Added by daigle about 16 years ago
HarvesterTest.java | ||
---|---|---|
30 | 30 |
import edu.ucsb.nceas.metacat.harvesterClient.Harvester; |
31 | 31 |
import edu.ucsb.nceas.metacat.service.PropertyService; |
32 | 32 |
import edu.ucsb.nceas.metacat.util.MetaCatUtil; |
33 |
import edu.ucsb.nceas.utilities.Options; |
|
34 |
import java.io.File; |
|
35 |
import java.io.FileInputStream; |
|
36 |
import java.io.IOException; |
|
33 |
import edu.ucsb.nceas.utilities.PropertyNotFoundException; |
|
37 | 34 |
import junit.framework.Test; |
38 | 35 |
import junit.framework.TestCase; |
39 | 36 |
import junit.framework.TestSuite; |
... | ... | |
46 | 43 |
public class HarvesterTest extends TestCase { |
47 | 44 |
|
48 | 45 |
private Harvester harvester; |
49 |
/* Initialize Options*/ |
|
50 |
static |
|
51 |
{ |
|
52 |
try |
|
53 |
{ |
|
54 |
Options.initialize(new File("build/tests/metacat.properties")); |
|
55 |
MetaCatUtil.pathsForIndexing |
|
56 |
= MetaCatUtil.getOptionList(PropertyService.getProperty("indexPaths")); |
|
57 |
} |
|
58 |
catch(Exception e) |
|
59 |
{ |
|
60 |
System.err.println("Exception in initialize option in MetacatServletNetTest "+e.getMessage()); |
|
61 |
} |
|
62 |
} |
|
46 |
/* Initialize Properties */ |
|
47 |
static { |
|
48 |
try { |
|
49 |
PropertyService.getInstance("build/tests"); |
|
50 |
MetaCatUtil.pathsForIndexing = MetaCatUtil.getOptionList( |
|
51 |
PropertyService.getProperty("indexPaths")); |
|
52 |
} catch (Exception e) { |
|
53 |
System.err.println("Exception in initialize option in MetacatServletNetTest " |
|
54 |
+ e.getMessage()); |
|
55 |
} |
|
56 |
} |
|
63 | 57 |
|
64 | 58 |
/** |
65 |
* Constructor for this test. |
|
66 |
* |
|
67 |
* @param name name of the test case |
|
68 |
*/ |
|
59 |
* Constructor for this test. |
|
60 |
* |
|
61 |
* @param name |
|
62 |
* name of the test case |
|
63 |
*/ |
|
69 | 64 |
public HarvesterTest(String name) { |
70 | 65 |
super(name); |
71 | 66 |
} |
... | ... | |
109 | 104 |
} |
110 | 105 |
|
111 | 106 |
|
112 |
/** |
|
113 |
* Tests loading of Harvester properties from a configuration file. |
|
114 |
*/ |
|
115 |
public void testLoadOptions() { |
|
116 |
Options options; |
|
117 |
String ctm; |
|
118 |
boolean test = true; |
|
119 |
|
|
120 |
Harvester.loadOptions(test); |
|
121 |
options = Harvester.options; |
|
122 |
ctm = options.getOption("connectToMetacat"); |
|
123 |
assertTrue(ctm.equals("true") || ctm.equals("false")); |
|
124 |
} |
|
107 |
/** |
|
108 |
* Tests loading of Harvester properties from a configuration file. |
|
109 |
*/ |
|
110 |
public void testLoadProperties() { |
|
111 |
String ctm = null; |
|
112 |
boolean test = true; |
|
113 |
|
|
114 |
Harvester.loadProperties(test); |
|
115 |
try { |
|
116 |
ctm = PropertyService.getProperty("connectToMetacat"); |
|
117 |
} catch (PropertyNotFoundException pnfe) { |
|
118 |
fail("Could not get connectToMetacat property: "+ pnfe.getMessage()); |
|
119 |
} |
|
120 |
assertTrue(ctm.equals("true") || ctm.equals("false")); |
|
121 |
} |
|
125 | 122 |
|
126 | 123 |
|
127 | 124 |
/** |
128 |
* Prints the files in the current working directory. This may be useful
|
|
129 |
* for determining which directory all other tests are running in.
|
|
130 |
*/
|
|
125 |
* Prints the files in the current working directory. This may be useful for
|
|
126 |
* determining which directory all other tests are running in.
|
|
127 |
*/
|
|
131 | 128 |
public void testWorkingDirectory() { |
132 | 129 |
String[] dir = new java.io.File(".").list(); // Get files in current dir |
133 | 130 |
|
Also available in: Unified diff
Replace Options class with PropertyService and create PropertyService using log directory name instead of servlet context