Revision 9639
Added by Jing Tao almost 9 years ago
test/edu/ucsb/nceas/metacattest/IdentifierManagerTest.java | ||
---|---|---|
1472 | 1472 |
head = IdentifierManager.getInstance().getHeadPID(sid_case18); |
1473 | 1473 |
assertTrue(head.equals(pid5_case18)); |
1474 | 1474 |
|
1475 |
//case-19 This is about the time stamps messing up. |
|
1476 |
//P1(S1,t1) <-P2(S1,t2) <-P3(S1, t3) S1 = P3 (t1, t2 and t3 are the time stamp while t1 >t2 > t3. P1, P2 and P3 are a type 1 end, not an ideal chain. |
|
1477 |
//So we will pick up P1 as the head since t1 is the lastest one. However, if we also consider the obsoletes chain, we will pick up P3) |
|
1478 |
object = new ByteArrayInputStream("test".getBytes("UTF-8")); |
|
1479 |
Identifier pid3_case19 = new Identifier(); |
|
1480 |
pid3_case19.setValue(generateDocumentId()); |
|
1481 |
System.out.println("pid3 is "+pid3_case19.getValue()); |
|
1482 |
Thread.sleep(1000); |
|
1483 |
Identifier pid2_case19 = new Identifier(); |
|
1484 |
pid2_case19.setValue(generateDocumentId()); |
|
1485 |
System.out.println("pid2 is "+pid2_case19.getValue()); |
|
1486 |
Thread.sleep(1000); |
|
1487 |
Identifier pid1_case19 = new Identifier(); |
|
1488 |
pid1_case19.setValue(generateDocumentId()); |
|
1489 |
System.out.println("pid1 is "+pid1_case19.getValue()); |
|
1490 |
|
|
1491 |
Identifier sid_case19 = new Identifier(); |
|
1492 |
sid_case19.setValue("sid."+System.nanoTime()); |
|
1493 |
SystemMetadata sysmeta3_case19 = createSystemMetadata(pid3_case19, session.getSubject(), object); |
|
1494 |
sysmeta3_case19.setSeriesId(sid_case19); |
|
1495 |
sysmeta3_case19.setObsoletes(pid2_case19); |
|
1496 |
CNodeService.getInstance(request).create(session, pid3_case19, object, sysmeta3_case19); |
|
1497 |
SystemMetadata sys3 = CNodeService.getInstance(request).getSystemMetadata(session, pid3_case19); |
|
1498 |
Date time3 = sys3.getDateUploaded(); |
|
1499 |
|
|
1500 |
Thread.sleep(1000); |
|
1501 |
object = new ByteArrayInputStream("test".getBytes("UTF-8")); |
|
1502 |
SystemMetadata sysmeta2_case19 = createSystemMetadata(pid2_case19, session.getSubject(), object); |
|
1503 |
sysmeta2_case19.setSeriesId(sid_case19); |
|
1504 |
sysmeta2_case19.setObsoletes(pid1_case19); |
|
1505 |
CNodeService.getInstance(request).create(session, pid2_case19, object, sysmeta2_case19); |
|
1506 |
SystemMetadata sys2 = CNodeService.getInstance(request).getSystemMetadata(session, pid2_case19); |
|
1507 |
Date time2 = sys2.getDateUploaded(); |
|
1508 |
|
|
1509 |
Thread.sleep(1000); |
|
1510 |
object = new ByteArrayInputStream("test".getBytes("UTF-8")); |
|
1511 |
SystemMetadata sysmeta1_case19 = createSystemMetadata(pid1_case19, session.getSubject(), object); |
|
1512 |
sysmeta1_case19.setSeriesId(sid_case19); |
|
1513 |
CNodeService.getInstance(request).create(session, pid1_case19, object, sysmeta1_case19); |
|
1514 |
SystemMetadata sys1 = CNodeService.getInstance(request).getSystemMetadata(session, pid1_case19); |
|
1515 |
Date time1 = sys1.getDateUploaded(); |
|
1516 |
|
|
1517 |
//time1 > time2 > time3 |
|
1518 |
assertTrue(time1.getTime()>time2.getTime()); |
|
1519 |
assertTrue(time2.getTime()>time3.getTime()); |
|
1520 |
|
|
1521 |
System.out.println("case 19: ======="); |
|
1522 |
Identifier head2 = IdentifierManager.getInstance().getHeadPID(sid_case19); |
|
1523 |
assertTrue(head2.equals(pid3_case19)); |
|
1524 |
|
|
1475 | 1525 |
|
1476 | 1526 |
} catch (Exception e) { |
1477 | 1527 |
e.printStackTrace(); |
Also available in: Unified diff
Add a test case on the getHeadPID method to test the messing time stamps.