Revision 6333
Added by ben leinfelder over 13 years ago
test/edu/ucsb/nceas/metacat/dataone/MNodeServiceTest.java | ||
---|---|---|
46 | 46 |
import org.dataone.service.exceptions.NotFound; |
47 | 47 |
import org.dataone.service.exceptions.NotImplemented; |
48 | 48 |
import org.dataone.service.exceptions.ServiceFailure; |
49 |
import org.dataone.service.exceptions.SynchronizationFailed; |
|
49 | 50 |
import org.dataone.service.exceptions.UnsupportedType; |
50 | 51 |
import org.dataone.service.types.AccessPolicy; |
51 | 52 |
import org.dataone.service.types.AccessRule; |
... | ... | |
111 | 112 |
suite.addTest(new MNodeServiceTest("testGetSystemMetadata")); |
112 | 113 |
suite.addTest(new MNodeServiceTest("testDescribe")); |
113 | 114 |
suite.addTest(new MNodeServiceTest("testListObjects")); |
114 |
// suite.addTest(new MNodeServiceTest("testSynchronizationFailed"));
|
|
115 |
suite.addTest(new MNodeServiceTest("testSynchronizationFailed")); |
|
115 | 116 |
// MNCore tests |
116 | 117 |
suite.addTest(new MNodeServiceTest("testPing")); |
117 | 118 |
suite.addTest(new MNodeServiceTest("testGetLogRecords")); |
... | ... | |
303 | 304 |
InputStream object = new ByteArrayInputStream("test".getBytes("UTF-8")); |
304 | 305 |
SystemMetadata sysmeta = createSystemMetadata(guid, session.getSubject(), object); |
305 | 306 |
Identifier pid = MNodeService.getInstance().create(session, guid, object, sysmeta); |
306 |
assertEquals(guid, pid);
|
|
307 |
assertEquals(guid.getValue(), pid.getValue());
|
|
307 | 308 |
} catch (UnsupportedEncodingException e) { |
308 | 309 |
e.printStackTrace(); |
309 | 310 |
fail("Unexpected error: " + e.getMessage()); |
... | ... | |
366 | 367 |
SystemMetadata sysmeta = createSystemMetadata(guid, session.getSubject(), object); |
367 | 368 |
Identifier pid = MNodeService.getInstance().create(session, guid, object, sysmeta); |
368 | 369 |
Identifier deletedPid = MNodeService.getInstance().delete(session, pid); |
369 |
assertEquals(pid, deletedPid);
|
|
370 |
assertEquals(pid.getValue(), deletedPid.getValue());
|
|
370 | 371 |
|
371 | 372 |
} catch (UnsupportedEncodingException e) { |
372 | 373 |
e.printStackTrace(); |
... | ... | |
713 | 714 |
} |
714 | 715 |
|
715 | 716 |
public void testSynchronizationFailed() { |
716 |
fail("Not yet implemented"); |
|
717 |
printTestHeader("testSynchronizationFailed"); |
|
718 |
try { |
|
719 |
Session session = getTestSession(); |
|
720 |
|
|
721 |
// create the object |
|
722 |
Identifier pid = new Identifier(); |
|
723 |
pid.setValue("testSynchronizationFailed." + System.currentTimeMillis()); |
|
724 |
InputStream object = new ByteArrayInputStream("test".getBytes("UTF-8")); |
|
725 |
SystemMetadata sysmeta = createSystemMetadata(pid, session.getSubject(), object); |
|
726 |
Identifier retPid = MNodeService.getInstance().create(session, pid, object, sysmeta); |
|
727 |
assertEquals(retPid.getValue(), pid.getValue()); |
|
728 |
|
|
729 |
// pretend the sync failed |
|
730 |
SynchronizationFailed syncFailed = |
|
731 |
new SynchronizationFailed("0000", "Testing Synch Failure"); |
|
732 |
syncFailed.setPid(pid); |
|
733 |
MNodeService.getInstance().synchronizationFailed(session, syncFailed ); |
|
734 |
} catch (Exception e) { |
|
735 |
e.printStackTrace(); |
|
736 |
fail("Unexpected error: " + e.getMessage()); |
|
737 |
} |
|
738 |
|
|
717 | 739 |
} |
718 | 740 |
|
719 | 741 |
public void testGetLogRecords() { |
Also available in: Unified diff
add test for synchronization failed -- TODO: verify that the log record made it in the logs