Revision 2255
Added by Duane Costa over 20 years ago
test/edu/ucsb/nceas/metacattest/harvesterClient/HarvestDetailLogTest.java | ||
---|---|---|
38 | 38 |
import junit.framework.TestSuite; |
39 | 39 |
|
40 | 40 |
/** |
41 |
* Test HarvestDetailLog code using JUnit. |
|
41 |
* Tests HarvestDetailLog code using JUnit.
|
|
42 | 42 |
* |
43 | 43 |
* @author costa |
44 | 44 |
*/ |
... | ... | |
50 | 50 |
private HarvestSiteSchedule harvestSiteSchedule; |
51 | 51 |
|
52 | 52 |
|
53 |
/** |
|
54 |
* Constructor for this test. |
|
55 |
* |
|
56 |
* @param name name of the test case |
|
57 |
*/ |
|
53 | 58 |
public HarvestDetailLogTest(String name) { |
54 | 59 |
super(name); |
55 | 60 |
} |
56 | 61 |
|
57 |
|
|
62 |
|
|
63 |
/** |
|
64 |
* Sets up the test by instantiating HarvestSiteSchedule, HarvestDocument, |
|
65 |
* and HarvestDetailLog objects. |
|
66 |
*/ |
|
58 | 67 |
protected void setUp() { |
59 | 68 |
Connection conn; |
60 | 69 |
String contactEmail = "jdoe@institution.edu"; |
... | ... | |
111 | 120 |
errorMessage); |
112 | 121 |
} |
113 | 122 |
|
114 |
|
|
123 |
|
|
124 |
/** |
|
125 |
* Closes the database connection when the test completes. |
|
126 |
*/ |
|
115 | 127 |
protected void tearDown() { |
116 | 128 |
harvester.closeConnection(); |
117 | 129 |
} |
test/edu/ucsb/nceas/metacattest/harvesterClient/HarvesterTest.java | ||
---|---|---|
37 | 37 |
import junit.framework.TestSuite; |
38 | 38 |
|
39 | 39 |
/** |
40 |
* Test Harvester code using JUnit. |
|
40 |
* Tests Harvester code using JUnit.
|
|
41 | 41 |
* |
42 | 42 |
* @author costa |
43 | 43 |
*/ |
... | ... | |
46 | 46 |
private Harvester harvester; |
47 | 47 |
|
48 | 48 |
|
49 |
/** |
|
50 |
* Constructor for this test. |
|
51 |
* |
|
52 |
* @param name name of the test case |
|
53 |
*/ |
|
49 | 54 |
public HarvesterTest(String name) { |
50 | 55 |
super(name); |
51 | 56 |
} |
52 | 57 |
|
53 |
|
|
58 |
|
|
59 |
/** |
|
60 |
* Sets up the test by instantiating a Harvester object. |
|
61 |
*/ |
|
54 | 62 |
protected void setUp() { |
55 | 63 |
harvester = new Harvester(); |
56 | 64 |
} |
57 | 65 |
|
58 |
|
|
66 |
|
|
67 |
/** |
|
68 |
* No clean-up actions necessary for these tests. |
|
69 |
*/ |
|
59 | 70 |
protected void tearDown() { |
60 | 71 |
} |
61 | 72 |
|
62 |
|
|
73 |
|
|
74 |
/** |
|
75 |
* Tests the dequoteText() string function. It converts single quotes to |
|
76 |
* double quotes. |
|
77 |
*/ |
|
63 | 78 |
public void testDequoteText() { |
64 | 79 |
String singleQuoteString = "I can't see how it's done!\n"; |
65 | 80 |
String compareString = "I can\"t see how it\"s done!"; |
... | ... | |
72 | 87 |
|
73 | 88 |
|
74 | 89 |
/** |
75 |
* Test that the Harvester object was created successfully. |
|
90 |
* Tests that the Harvester object was created successfully.
|
|
76 | 91 |
*/ |
77 | 92 |
public void testHarvesterObject() { |
78 | 93 |
assertTrue(harvester != null); |
test/edu/ucsb/nceas/metacattest/harvesterClient/HarvestDocumentTest.java | ||
---|---|---|
38 | 38 |
import junit.framework.TestSuite; |
39 | 39 |
|
40 | 40 |
/** |
41 |
* Test HarvestDocument code using JUnit. |
|
41 |
* Tests HarvestDocument code using JUnit.
|
|
42 | 42 |
* |
43 | 43 |
* @author costa |
44 | 44 |
*/ |
... | ... | |
49 | 49 |
private HarvestSiteSchedule harvestSiteSchedule; |
50 | 50 |
|
51 | 51 |
|
52 |
/** |
|
53 |
* Constructor for this test. |
|
54 |
* |
|
55 |
* @param name name of the test case |
|
56 |
*/ |
|
52 | 57 |
public HarvestDocumentTest(String name) { |
53 | 58 |
super(name); |
54 | 59 |
} |
55 | 60 |
|
56 |
|
|
61 |
|
|
62 |
/** |
|
63 |
* Sets up the test by instantiating HarvestSiteSchedule and HarvestDocument |
|
64 |
* objects. |
|
65 |
*/ |
|
57 | 66 |
protected void setUp() { |
58 | 67 |
String contactEmail = "jdoe@institution.edu"; |
59 | 68 |
String dateLastHarvest = "2004-04-01 00:00:00.0"; |
... | ... | |
107 | 116 |
); |
108 | 117 |
} |
109 | 118 |
|
110 |
|
|
119 |
|
|
120 |
/** |
|
121 |
* Closes the database connection after the test completes. |
|
122 |
*/ |
|
111 | 123 |
protected void tearDown() { |
112 | 124 |
harvester.closeConnection(); |
113 | 125 |
} |
114 | 126 |
|
115 |
|
|
127 |
|
|
128 |
/** |
|
129 |
* Tests the getSiteDocument() method. The test succeeds if a non-null |
|
130 |
* StringReader is returned. |
|
131 |
*/ |
|
116 | 132 |
public void testGetSiteDocument() { |
117 | 133 |
StringReader stringReader = null; |
118 | 134 |
stringReader = harvestDocument.getSiteDocument(); |
... | ... | |
121 | 137 |
|
122 | 138 |
|
123 | 139 |
/** |
124 |
* Test that the harvesterDocument object was created successfully. |
|
140 |
* Tests that the harvesterDocument object was created successfully.
|
|
125 | 141 |
*/ |
126 | 142 |
public void testHarvestDocumentObject() { |
127 | 143 |
assertTrue(harvestDocument != null); |
128 | 144 |
} |
129 | 145 |
|
130 |
|
|
146 |
|
|
147 |
/** |
|
148 |
* Tests the metacatHighestRevision() method. This test ensures that -1 |
|
149 |
* is returned for a non-existent document. |
|
150 |
*/ |
|
131 | 151 |
public void testMetacatHighestRevision() { |
132 | 152 |
int highestRevision; |
133 | 153 |
|
test/edu/ucsb/nceas/metacattest/harvesterClient/HarvestLogTest.java | ||
---|---|---|
43 | 43 |
import junit.framework.TestSuite; |
44 | 44 |
|
45 | 45 |
/** |
46 |
* Test HarvestLog code using JUnit. |
|
46 |
* Tests HarvestLog code using JUnit.
|
|
47 | 47 |
* |
48 | 48 |
* @author costa |
49 | 49 |
*/ |
... | ... | |
57 | 57 |
private HarvestSiteSchedule harvestSiteSchedule; |
58 | 58 |
|
59 | 59 |
|
60 |
/** |
|
61 |
* Constructor for this test. |
|
62 |
* |
|
63 |
* @param name name of the test case |
|
64 |
*/ |
|
60 | 65 |
public HarvestLogTest(String name) { |
61 | 66 |
super(name); |
62 | 67 |
} |
63 | 68 |
|
64 |
|
|
69 |
|
|
70 |
/** |
|
71 |
* Sets up the test by instantiating a HarvestSiteSchedule, HarvestDocument, |
|
72 |
* and two HarvestLog objects. The harvestLogShallow is a HarvestLog that |
|
73 |
* does not have an associated HarvestDetailLog. The harvestLogDeep is a |
|
74 |
* HarvestLog that does have an associated HarvestDetailLog. |
|
75 |
*/ |
|
65 | 76 |
protected void setUp() { |
66 | 77 |
String contactEmail = "jdoe@institution.edu"; |
67 | 78 |
String dateLastHarvest = "2004-04-01 00:00:00.0"; |
... | ... | |
129 | 140 |
harvestDocument, errorMessage); |
130 | 141 |
} |
131 | 142 |
|
132 |
|
|
143 |
|
|
144 |
/** |
|
145 |
* Closes the database connection after the test completes. |
|
146 |
*/ |
|
133 | 147 |
protected void tearDown() { |
134 | 148 |
harvester.closeConnection(); |
135 | 149 |
} |
136 | 150 |
|
137 |
|
|
151 |
|
|
152 |
/** |
|
153 |
* Tests the getCodeLevelValue() method by comparing the value returned for |
|
154 |
* "error" (lowest level) to the value returned for "debug" (highest level). |
|
155 |
*/ |
|
138 | 156 |
public void testGetCodeLevelValue() { |
139 | 157 |
int lowLevel = harvestLogShallow.getCodeLevelValue("error"); |
140 | 158 |
int highLevel = harvestLogShallow.getCodeLevelValue("debug"); |
... | ... | |
142 | 160 |
assertTrue(lowLevel < highLevel); |
143 | 161 |
} |
144 | 162 |
|
145 |
|
|
163 |
|
|
164 |
/** |
|
165 |
* Tests the getExplanation() method. Check that a harvest operation code is |
|
166 |
* associated with an appropriate explanation string. |
|
167 |
*/ |
|
146 | 168 |
public void testGetExplanation() { |
147 | 169 |
String harvestOperationCode = "HarvesterStartup"; |
148 | 170 |
String explanation; |
... | ... | |
151 | 173 |
assertTrue(explanation.equals("Harvester start up")); |
152 | 174 |
} |
153 | 175 |
|
154 |
|
|
176 |
|
|
177 |
/** |
|
178 |
* Tests the getHarvestOperationCodeLevel() method. Check that the method |
|
179 |
* returns an appropriate code level for a given harvest operation code. |
|
180 |
*/ |
|
155 | 181 |
public void testGetHarvestOperationCodeLevel() { |
156 | 182 |
String harvestOperationCode = "HarvesterStartup"; |
157 | 183 |
String harvestOperationCodeLevel; |
... | ... | |
163 | 189 |
|
164 | 190 |
|
165 | 191 |
/** |
166 |
* Test the construction of HarvestLog object, and a HarvestLog object |
|
192 |
* Tests the construction of HarvestLog object, and a HarvestLog object
|
|
167 | 193 |
* that contains a HarvestDetailLog object. |
168 | 194 |
*/ |
169 | 195 |
public void testHarvestLogObject() { |
test/edu/ucsb/nceas/metacattest/harvesterClient/HarvestSiteScheduleTest.java | ||
---|---|---|
37 | 37 |
import junit.framework.TestSuite; |
38 | 38 |
|
39 | 39 |
/** |
40 |
* Test HarvestSiteSchedule code using JUnit. |
|
40 |
* Tests HarvestSiteSchedule code using JUnit.
|
|
41 | 41 |
* |
42 | 42 |
* @author costa |
43 | 43 |
*/ |
... | ... | |
48 | 48 |
private HarvestSiteSchedule harvestSiteSchedulePast; // past date next harvest |
49 | 49 |
|
50 | 50 |
|
51 |
/** |
|
52 |
* Constructor for this test. |
|
53 |
* |
|
54 |
* @param name name of the test case |
|
55 |
*/ |
|
51 | 56 |
public HarvestSiteScheduleTest(String name) { |
52 | 57 |
super(name); |
53 | 58 |
} |
54 | 59 |
|
55 |
|
|
60 |
|
|
61 |
/** |
|
62 |
* Sets up the HarvestSiteScheduleTest by creating a pair of |
|
63 |
* HarvestSiteSchedule objects. The harvestSiteScheduleFuture object |
|
64 |
* is used for a site with a future date of next harvest (not due for |
|
65 |
* harvest now), while the harvestSiteSchedulePast object is used for a site |
|
66 |
* with a past date of next harvest (is due for harvest now). |
|
67 |
*/ |
|
56 | 68 |
protected void setUp() { |
57 | 69 |
String contactEmail = "jdoe@institution.edu"; |
58 | 70 |
String dateLastHarvest = "2004-04-01 00:00:00.0"; |
... | ... | |
100 | 112 |
|
101 | 113 |
} |
102 | 114 |
|
103 |
|
|
115 |
|
|
116 |
/** |
|
117 |
* Closes the database connection after the test completes. |
|
118 |
*/ |
|
104 | 119 |
protected void tearDown() { |
105 | 120 |
harvester.closeConnection(); |
106 | 121 |
} |
107 | 122 |
|
108 |
|
|
123 |
|
|
124 |
/** |
|
125 |
* Tests the dueForHarvest() method in the case where a site is not due for |
|
126 |
* a harvest. |
|
127 |
*/ |
|
109 | 128 |
public void testDueForHarvestFalse() { |
110 | 129 |
boolean dueForHarvest; |
111 | 130 |
|
... | ... | |
113 | 132 |
assertTrue(dueForHarvest == false); |
114 | 133 |
} |
115 | 134 |
|
116 |
|
|
135 |
|
|
136 |
/** |
|
137 |
* Tests the dueForHarvest() method in the case where a site is due for |
|
138 |
* a harvest. |
|
139 |
*/ |
|
140 |
public void testDueForHarvestTrue() { |
|
141 |
boolean dueForHarvest; |
|
142 |
|
|
143 |
dueForHarvest = harvestSiteSchedulePast.dueForHarvest(); |
|
144 |
assertTrue(dueForHarvest == true); |
|
145 |
} |
|
146 |
|
|
147 |
|
|
148 |
/** |
|
149 |
* Tests the parseHarvestList() method. |
|
150 |
*/ |
|
117 | 151 |
public void testParseHarvestList() { |
118 | 152 |
boolean success = false; |
119 | 153 |
String schemaLocation = |
... | ... | |
138 | 172 |
harvestSiteScheduleFuture.printOutput(System.out); |
139 | 173 |
} |
140 | 174 |
|
141 |
|
|
142 |
public void testDueForHarvestTrue() { |
|
143 |
boolean dueForHarvest; |
|
144 |
|
|
145 |
dueForHarvest = harvestSiteSchedulePast.dueForHarvest(); |
|
146 |
assertTrue(dueForHarvest == true); |
|
147 |
} |
|
148 | 175 |
|
149 |
|
|
150 | 176 |
/** |
151 |
* Test that the harvesterDocument object was created successfully. |
|
177 |
* Tests that the harvesterDocument object was created successfully.
|
|
152 | 178 |
*/ |
153 | 179 |
public void testHarvestSiteScheduleObject() { |
154 | 180 |
assertTrue(harvestSiteScheduleFuture != null); |
Also available in: Unified diff
Add additional comments to the test cases.