Revision 9039
Added by Jing Tao almost 10 years ago
test/edu/ucsb/nceas/metacat/dataone/MNodeServiceTest.java | ||
---|---|---|
273 | 273 |
Identifier pid = MNodeService.getInstance(request).create(session, guid, object, sysmeta); |
274 | 274 |
SystemMetadata newsysmeta = MNodeService.getInstance(request).getSystemMetadata(session, pid); |
275 | 275 |
assertEquals(newsysmeta.getIdentifier().getValue(), sysmeta.getIdentifier().getValue()); |
276 |
assertEquals(newsysmeta.getSeriesId(), null); |
|
276 | 277 |
|
277 | 278 |
} catch (UnsupportedEncodingException e) { |
278 | 279 |
e.printStackTrace(); |
... | ... | |
1436 | 1437 |
} catch (NotFound ee) { |
1437 | 1438 |
|
1438 | 1439 |
} |
1440 |
SystemMetadata metadata = MNodeService.getInstance(request).getSystemMetadata(session, seriesId); |
|
1441 |
assertTrue(metadata.getIdentifier().getValue().equals(guid.getValue())); |
|
1442 |
assertTrue(metadata.getSeriesId().getValue().equals(seriesId.getValue())); |
|
1443 |
DescribeResponse describeResponse = MNodeService.getInstance(request).describe(session, seriesId); |
|
1444 |
assertEquals(describeResponse.getDataONE_Checksum().getValue(), metadata.getChecksum().getValue()); |
|
1445 |
assertEquals(describeResponse.getDataONE_ObjectFormatIdentifier().getValue(), metadata.getFormatId().getValue()); |
|
1439 | 1446 |
|
1447 |
metadata = MNodeService.getInstance(request).getSystemMetadata(session, guid); |
|
1448 |
assertTrue(metadata.getIdentifier().getValue().equals(guid.getValue())); |
|
1449 |
assertTrue(metadata.getSeriesId().getValue().equals(seriesId.getValue())); |
|
1450 |
describeResponse = MNodeService.getInstance(request).describe(session, guid); |
|
1451 |
assertEquals(describeResponse.getDataONE_Checksum().getValue(), metadata.getChecksum().getValue()); |
|
1452 |
assertEquals(describeResponse.getDataONE_ObjectFormatIdentifier().getValue(), metadata.getFormatId().getValue()); |
|
1453 |
|
|
1454 |
org.dataone.service.types.v1.SystemMetadata sys1=edu.ucsb.nceas.metacat.dataone.v1.MNodeService.getInstance(request).getSystemMetadata(session, guid); |
|
1455 |
assertTrue(metadata.getIdentifier().getValue().equals(guid.getValue())); |
|
1456 |
|
|
1457 |
try { |
|
1458 |
org.dataone.service.types.v1.SystemMetadata sys2=edu.ucsb.nceas.metacat.dataone.v1.MNodeService.getInstance(request).getSystemMetadata(session, seriesId); |
|
1459 |
fail("the getSystemMetadata(sid) methoud should throw a not found exception for the sid "+seriesId.getValue()); |
|
1460 |
} catch(NotFound nf2) { |
|
1461 |
|
|
1462 |
} |
|
1463 |
|
|
1464 |
describeResponse = edu.ucsb.nceas.metacat.dataone.v1.MNodeService.getInstance(request).describe(session, guid); |
|
1465 |
assertEquals(describeResponse.getDataONE_Checksum().getValue(), sys1.getChecksum().getValue()); |
|
1466 |
assertEquals(describeResponse.getDataONE_ObjectFormatIdentifier().getValue(), sys1.getFormatId().getValue()); |
|
1467 |
try { |
|
1468 |
describeResponse = edu.ucsb.nceas.metacat.dataone.v1.MNodeService.getInstance(request).describe(session, seriesId); |
|
1469 |
fail("the describe(sid) methoud should throw a not found exception for the sid "+seriesId.getValue()); |
|
1470 |
} catch(NotFound nf2) { |
|
1471 |
|
|
1472 |
} |
|
1473 |
|
|
1440 | 1474 |
//do a update with the same series id |
1441 | 1475 |
Thread.sleep(1000); |
1442 | 1476 |
Identifier newPid = new Identifier(); |
... | ... | |
1493 | 1527 |
|
1494 | 1528 |
} |
1495 | 1529 |
|
1496 |
|
|
1530 |
SystemMetadata metadata1 = MNodeService.getInstance(request).getSystemMetadata(session, seriesId); |
|
1531 |
assertTrue(metadata1.getIdentifier().getValue().equals(newPid.getValue())); |
|
1532 |
assertTrue(metadata1.getSeriesId().getValue().equals(seriesId.getValue())); |
|
1533 |
describeResponse = MNodeService.getInstance(request).describe(session, seriesId); |
|
1534 |
assertEquals(describeResponse.getDataONE_Checksum().getValue(), metadata1.getChecksum().getValue()); |
|
1535 |
assertEquals(describeResponse.getDataONE_ObjectFormatIdentifier().getValue(), metadata1.getFormatId().getValue()); |
|
1536 |
|
|
1537 |
SystemMetadata metadata2 = MNodeService.getInstance(request).getSystemMetadata(session, guid); |
|
1538 |
assertTrue(metadata2.getIdentifier().getValue().equals(guid.getValue())); |
|
1539 |
assertTrue(metadata2.getSeriesId().getValue().equals(seriesId.getValue())); |
|
1540 |
describeResponse = MNodeService.getInstance(request).describe(session, guid); |
|
1541 |
assertEquals(describeResponse.getDataONE_Checksum().getValue(), metadata2.getChecksum().getValue()); |
|
1542 |
assertEquals(describeResponse.getDataONE_ObjectFormatIdentifier().getValue(), metadata2.getFormatId().getValue()); |
|
1543 |
|
|
1544 |
SystemMetadata metadata3 = MNodeService.getInstance(request).getSystemMetadata(session, newPid); |
|
1545 |
assertTrue(metadata3.getIdentifier().getValue().equals(newPid.getValue())); |
|
1546 |
assertTrue(metadata3.getSeriesId().getValue().equals(seriesId.getValue())); |
|
1547 |
describeResponse = MNodeService.getInstance(request).describe(session, newPid); |
|
1548 |
assertEquals(describeResponse.getDataONE_Checksum().getValue(), metadata3.getChecksum().getValue()); |
|
1549 |
assertEquals(describeResponse.getDataONE_ObjectFormatIdentifier().getValue(), metadata3.getFormatId().getValue()); |
|
1550 |
|
|
1497 | 1551 |
//do another update with different series id |
1498 | 1552 |
Thread.sleep(1000); |
1499 | 1553 |
String sid2 = "sid."+System.nanoTime(); |
... | ... | |
1570 | 1624 |
assertTrue(result15.available() > 0); |
1571 | 1625 |
assertTrue(IOUtils.contentEquals(result15, object3)); |
1572 | 1626 |
|
1627 |
SystemMetadata metadata4 = MNodeService.getInstance(request).getSystemMetadata(session, seriesId); |
|
1628 |
assertTrue(metadata4.getIdentifier().getValue().equals(newPid.getValue())); |
|
1629 |
assertTrue(metadata4.getSeriesId().getValue().equals(seriesId.getValue())); |
|
1630 |
describeResponse = MNodeService.getInstance(request).describe(session, seriesId); |
|
1631 |
assertEquals(describeResponse.getDataONE_Checksum().getValue(), metadata4.getChecksum().getValue()); |
|
1632 |
assertEquals(describeResponse.getDataONE_ObjectFormatIdentifier().getValue(), metadata4.getFormatId().getValue()); |
|
1573 | 1633 |
|
1634 |
SystemMetadata metadata5 = MNodeService.getInstance(request).getSystemMetadata(session, seriesId2); |
|
1635 |
assertTrue(metadata5.getIdentifier().getValue().equals(newPid2.getValue())); |
|
1636 |
assertTrue(metadata5.getSeriesId().getValue().equals(seriesId2.getValue())); |
|
1637 |
describeResponse = MNodeService.getInstance(request).describe(session, seriesId2); |
|
1638 |
assertEquals(describeResponse.getDataONE_Checksum().getValue(), metadata5.getChecksum().getValue()); |
|
1639 |
assertEquals(describeResponse.getDataONE_ObjectFormatIdentifier().getValue(), metadata5.getFormatId().getValue()); |
|
1640 |
|
|
1641 |
SystemMetadata metadata6 = MNodeService.getInstance(request).getSystemMetadata(session, guid); |
|
1642 |
assertTrue(metadata6.getIdentifier().getValue().equals(guid.getValue())); |
|
1643 |
assertTrue(metadata6.getSeriesId().getValue().equals(seriesId.getValue())); |
|
1644 |
describeResponse = MNodeService.getInstance(request).describe(session, guid); |
|
1645 |
assertEquals(describeResponse.getDataONE_Checksum().getValue(), metadata6.getChecksum().getValue()); |
|
1646 |
assertEquals(describeResponse.getDataONE_ObjectFormatIdentifier().getValue(), metadata6.getFormatId().getValue()); |
|
1647 |
|
|
1648 |
SystemMetadata metadata7 = MNodeService.getInstance(request).getSystemMetadata(session, newPid); |
|
1649 |
assertTrue(metadata7.getIdentifier().getValue().equals(newPid.getValue())); |
|
1650 |
assertTrue(metadata7.getSeriesId().getValue().equals(seriesId.getValue())); |
|
1651 |
describeResponse = MNodeService.getInstance(request).describe(session, newPid); |
|
1652 |
assertEquals(describeResponse.getDataONE_Checksum().getValue(), metadata7.getChecksum().getValue()); |
|
1653 |
assertEquals(describeResponse.getDataONE_ObjectFormatIdentifier().getValue(), metadata7.getFormatId().getValue()); |
|
1654 |
|
|
1655 |
SystemMetadata metadata8 = MNodeService.getInstance(request).getSystemMetadata(session, newPid2); |
|
1656 |
assertTrue(metadata8.getIdentifier().getValue().equals(newPid2.getValue())); |
|
1657 |
assertTrue(metadata8.getSeriesId().getValue().equals(seriesId2.getValue())); |
|
1658 |
describeResponse = MNodeService.getInstance(request).describe(session, newPid2); |
|
1659 |
assertEquals(describeResponse.getDataONE_Checksum().getValue(), metadata8.getChecksum().getValue()); |
|
1660 |
assertEquals(describeResponse.getDataONE_ObjectFormatIdentifier().getValue(), metadata8.getFormatId().getValue()); |
|
1661 |
|
|
1662 |
|
|
1663 |
|
|
1664 |
|
|
1574 | 1665 |
//test the get(sid) for v1 |
1575 | 1666 |
try { |
1576 | 1667 |
InputStream result3 = edu.ucsb.nceas.metacat.dataone.v1.MNodeService.getInstance(request).get(session, seriesId); |
... | ... | |
1597 | 1688 |
} catch (NotFound ee) { |
1598 | 1689 |
|
1599 | 1690 |
} |
1691 |
|
|
1692 |
try { |
|
1693 |
// the pid should be null when we try to get a no-exist sid |
|
1694 |
Identifier non_exist_sid = new Identifier(); |
|
1695 |
non_exist_sid.setValue("no-sid-exist-123qwe"); |
|
1696 |
SystemMetadata result3 = MNodeService.getInstance(request).getSystemMetadata(session, non_exist_sid); |
|
1697 |
fail("the getSystemMetadata(sid) methoud should throw a not found exception for the sid "+seriesId.getValue()); |
|
1698 |
} catch (NotFound ee) { |
|
1699 |
|
|
1700 |
} |
|
1701 |
|
|
1702 |
try { |
|
1703 |
// the pid should be null when we try to get a no-exist sid |
|
1704 |
Identifier non_exist_sid = new Identifier(); |
|
1705 |
non_exist_sid.setValue("no-sid-exist-123qwe"); |
|
1706 |
MNodeService.getInstance(request).describe(session, non_exist_sid); |
|
1707 |
fail("the describe(sid) methoud should throw a not found exception for the sid "+seriesId.getValue()); |
|
1708 |
} catch (NotFound ee) { |
|
1709 |
|
|
1710 |
} |
|
1600 | 1711 |
|
1601 | 1712 |
|
1602 | 1713 |
} catch (Exception e) { |
Also available in: Unified diff
Add the test code for getSystemMetadata(sid) and describe(sid).