Revision 9049
Added by Jing Tao about 10 years ago
test/edu/ucsb/nceas/metacat/dataone/MNodeServiceTest.java | ||
---|---|---|
341 | 341 |
SystemMetadata sysmeta = createSystemMetadata(guid, session.getSubject(), object); |
342 | 342 |
Identifier pid = MNodeService.getInstance(request).create(session, guid, object, sysmeta); |
343 | 343 |
assertEquals(guid.getValue(), pid.getValue()); |
344 |
|
|
345 |
Thread.sleep(1000); |
|
346 |
try { |
|
347 |
Identifier guid2 = new Identifier(); |
|
348 |
guid2.setValue("testCreate." + System.currentTimeMillis()); |
|
349 |
SystemMetadata sysmeta2 = createSystemMetadata(guid2, session.getSubject(), object); |
|
350 |
sysmeta2.setSeriesId(guid); |
|
351 |
MNodeService.getInstance(request).create(session, guid2, object, sysmeta2); |
|
352 |
fail("It should fail since the system metadata using an existing id as the sid"); |
|
353 |
} catch (InvalidSystemMetadata ee) { |
|
354 |
|
|
355 |
} |
|
356 |
|
|
357 |
Thread.sleep(1000); |
|
358 |
try { |
|
359 |
Identifier guid3 = new Identifier(); |
|
360 |
guid3.setValue("testCreate." + System.currentTimeMillis()); |
|
361 |
SystemMetadata sysmeta3 = createSystemMetadata(guid3, session.getSubject(), object); |
|
362 |
sysmeta3.setSeriesId(guid3); |
|
363 |
MNodeService.getInstance(request).create(session, guid3, object, sysmeta3); |
|
364 |
fail("It should fail since the system metadata using the pid as the sid"); |
|
365 |
} catch (InvalidSystemMetadata ee) { |
|
366 |
|
|
367 |
} |
|
344 | 368 |
} catch (UnsupportedEncodingException e) { |
345 | 369 |
e.printStackTrace(); |
346 | 370 |
fail("Unexpected error: " + e.getMessage()); |
... | ... | |
1730 | 1754 |
} catch (NotFound ee) { |
1731 | 1755 |
|
1732 | 1756 |
} |
1733 |
|
|
1734 | 1757 |
|
1758 |
|
|
1759 |
//do another update with invalid series ids |
|
1760 |
Thread.sleep(1000); |
|
1761 |
Identifier newPid3 = new Identifier(); |
|
1762 |
newPid3.setValue(generateDocumentId()+"3"); |
|
1763 |
System.out.println("the third pid is "+newPid3.getValue()); |
|
1764 |
InputStream object4 = new ByteArrayInputStream(str3.getBytes("UTF-8")); |
|
1765 |
SystemMetadata sysmeta4 = createSystemMetadata(newPid3, session.getSubject(), object4); |
|
1766 |
sysmeta4.setObsoletes(newPid2); |
|
1767 |
sysmeta4.setSeriesId(seriesId); |
|
1768 |
try { |
|
1769 |
MNodeService.getInstance(request).update(session, newPid2, object4, newPid3, sysmeta4); |
|
1770 |
fail("we can't reach here since the sid is using an old one "); |
|
1771 |
} catch (InvalidSystemMetadata eee) { |
|
1772 |
|
|
1773 |
} |
|
1774 |
|
|
1775 |
sysmeta4.setSeriesId(newPid3); |
|
1776 |
try { |
|
1777 |
MNodeService.getInstance(request).update(session, newPid2, object4, newPid3, sysmeta4); |
|
1778 |
fail("we can't reach here since the sid is using the pid "); |
|
1779 |
} catch (InvalidSystemMetadata eee) { |
|
1780 |
|
|
1781 |
} |
|
1782 |
|
|
1735 | 1783 |
} catch (Exception e) { |
1736 | 1784 |
fail(e.getMessage()); |
1737 | 1785 |
} |
1738 | 1786 |
|
1787 |
|
|
1788 |
|
|
1789 |
|
|
1739 | 1790 |
} |
1740 | 1791 |
} |
Also available in: Unified diff
Add the code to test the create and update methods using invalid sid in the system metadata.