Revision 9278
Added by Jing Tao over 9 years ago
test/edu/ucsb/nceas/metacat/dataone/MNodeServiceTest.java | ||
---|---|---|
138 | 138 |
public static Test suite() { |
139 | 139 |
|
140 | 140 |
TestSuite suite = new TestSuite(); |
141 |
suite.addTest(new MNodeServiceTest("initialize")); |
|
141 |
/*suite.addTest(new MNodeServiceTest("initialize"));
|
|
142 | 142 |
// MNStorage tests |
143 | 143 |
suite.addTest(new MNodeServiceTest("testCreate")); |
144 | 144 |
suite.addTest(new MNodeServiceTest("testCreateInvalidIdentifier")); |
... | ... | |
173 | 173 |
suite.addTest(new MNodeServiceTest("testCreateAndUpdateXMLWithUnmatchingEncoding")); |
174 | 174 |
suite.addTest(new MNodeServiceTest("testGetSID")); |
175 | 175 |
suite.addTest(new MNodeServiceTest("testListViews")); |
176 |
suite.addTest(new MNodeServiceTest("testUpdateSystemMetadata")); |
|
176 |
suite.addTest(new MNodeServiceTest("testUpdateSystemMetadata"));*/
|
|
177 | 177 |
suite.addTest(new MNodeServiceTest("testUpdateObsoletesAndObsoletedBy")); |
178 | 178 |
|
179 | 179 |
return suite; |
... | ... | |
2169 | 2169 |
|
2170 | 2170 |
|
2171 | 2171 |
|
2172 |
//update obsolets and obsoletedBy sucessfully |
|
2172 |
//update obsolets and obsoletedBy sucessfully - set p2 obsoletes p1
|
|
2173 | 2173 |
sysmeta1.setObsoletedBy(guid2); |
2174 | 2174 |
MNodeService.getInstance(request).updateSystemMetadata(session, guid1, sysmeta1); |
2175 | 2175 |
metadata = MNodeService.getInstance(request).getSystemMetadata(session, guid1); |
... | ... | |
2189 | 2189 |
|
2190 | 2190 |
|
2191 | 2191 |
|
2192 |
//update obsolets and obsoletedBy sucessfully |
|
2192 |
//update obsolets and obsoletedBy sucessfully - set p1 obsoletedBy p2
|
|
2193 | 2193 |
sysmeta1.setObsoletedBy(guid2); |
2194 | 2194 |
MNodeService.getInstance(request).updateSystemMetadata(session, guid1, sysmeta1); |
2195 | 2195 |
metadata = MNodeService.getInstance(request).getSystemMetadata(session, guid1); |
... | ... | |
2227 | 2227 |
MNodeService.getInstance(request).updateSystemMetadata(session, guid2, sysmeta2); |
2228 | 2228 |
fail("We shouldn't get there"); |
2229 | 2229 |
} catch (Exception e) { |
2230 |
e.printStackTrace(); |
|
2230 | 2231 |
assertTrue(e instanceof InvalidRequest); |
2231 | 2232 |
} |
2233 |
|
|
2234 |
|
|
2235 |
|
|
2236 |
|
|
2237 |
//insert another object |
|
2238 |
Identifier guid5 = new Identifier(); |
|
2239 |
guid5.setValue(generateDocumentId()); |
|
2240 |
object1 = new ByteArrayInputStream(str1.getBytes("UTF-8")); |
|
2241 |
SystemMetadata sysmeta5 = createSystemMetadata(guid5, session.getSubject(), object1); |
|
2242 |
MNodeService.getInstance(request).create(session, guid5, object1, sysmeta5); |
|
2243 |
//Test the generating object succeeded. |
|
2244 |
metadata = MNodeService.getInstance(request).getSystemMetadata(session, guid5); |
|
2245 |
assertTrue(metadata.getIdentifier().equals(guid5)); |
|
2246 |
assertTrue(metadata.getSize().equals(sysmeta5.getSize())); |
|
2247 |
|
|
2248 |
|
|
2249 |
|
|
2250 |
//Setting p5 obosletes p1 fails since p2 already obsoletes p1 |
|
2251 |
sysmeta5.setObsoletes(guid1); |
|
2252 |
try { |
|
2253 |
MNodeService.getInstance(request).updateSystemMetadata(session, guid5, sysmeta5); |
|
2254 |
fail("We shouldn't get there"); |
|
2255 |
} catch (Exception e) { |
|
2256 |
e.printStackTrace(); |
|
2257 |
|
|
2258 |
} |
|
2259 |
|
|
2260 |
|
|
2261 |
|
|
2262 |
//Setting p5 obosletedBy p2 fails since p1 already is obsoletedBy p2 |
|
2263 |
sysmeta5.setObsoletes(null); |
|
2264 |
sysmeta5.setObsoletedBy(guid2); |
|
2265 |
try { |
|
2266 |
MNodeService.getInstance(request).updateSystemMetadata(session, guid5, sysmeta5); |
|
2267 |
fail("We shouldn't get there"); |
|
2268 |
} catch (Exception e) { |
|
2269 |
e.printStackTrace(); |
|
2270 |
|
|
2271 |
} |
|
2272 |
|
|
2273 |
|
|
2274 |
|
|
2275 |
//Setting p5 obsoletes p2 succeeds since the obosoletes of p5 is null and noone obsoletes p2. |
|
2276 |
sysmeta5.setObsoletedBy(null); |
|
2277 |
sysmeta5.setObsoletes(guid2); |
|
2278 |
MNodeService.getInstance(request).updateSystemMetadata(session, guid5, sysmeta5); |
|
2279 |
metadata = MNodeService.getInstance(request).getSystemMetadata(session, guid5); |
|
2280 |
assertTrue(metadata.getIdentifier().equals(guid5)); |
|
2281 |
assertTrue(metadata.getObsoletes().equals(guid2)); |
|
2282 |
assertTrue(metadata.getObsoletedBy() == null); |
|
2283 |
assertTrue(metadata.getChecksum().getValue().equals(sysmeta5.getChecksum().getValue())); |
|
2284 |
|
|
2285 |
|
|
2286 |
|
|
2287 |
//Setting p2 obsoletedBy p5 succeeds since the obosoletedBy of p2 is null and p5 doesn't obsolete anything |
|
2288 |
sysmeta2.setObsoletes(guid1); |
|
2289 |
sysmeta2.setObsoletedBy(guid5); |
|
2290 |
MNodeService.getInstance(request).updateSystemMetadata(session, guid2, sysmeta2); |
|
2291 |
metadata = MNodeService.getInstance(request).getSystemMetadata(session, guid2); |
|
2292 |
assertTrue(metadata.getIdentifier().equals(guid2)); |
|
2293 |
assertTrue(metadata.getObsoletes().equals(guid1)); |
|
2294 |
assertTrue(metadata.getObsoletedBy().equals(guid5)); |
|
2295 |
assertTrue(metadata.getChecksum().getValue().equals(sysmeta2.getChecksum().getValue())); |
|
2232 | 2296 |
} |
2233 | 2297 |
|
2234 | 2298 |
} |
Also available in: Unified diff
Add more test to test the code to create branch obsolete chain.