Revision 9129
Added by Jing Tao almost 10 years ago
test/edu/ucsb/nceas/metacattest/IdentifierManagerTest.java | ||
---|---|---|
51 | 51 |
import edu.ucsb.nceas.metacat.dataone.MNodeService; |
52 | 52 |
|
53 | 53 |
import org.dataone.service.exceptions.InvalidSystemMetadata; |
54 |
import org.dataone.service.exceptions.NotFound; |
|
54 | 55 |
import org.dataone.service.exceptions.ServiceFailure; |
55 | 56 |
|
56 | 57 |
public class IdentifierManagerTest extends D1NodeServiceTest { |
... | ... | |
280 | 281 |
newSysMeta.setObsoletes(guid); |
281 | 282 |
newSysMeta.setSeriesId(seriesId); |
282 | 283 |
MNodeService.getInstance(request).update(session, guid, object, newPid, newSysMeta); |
284 |
|
|
285 |
//check |
|
286 |
SystemMetadata meta = CNodeService.getInstance(request).getSystemMetadata(session, guid); |
|
287 |
assertTrue(meta.getObsoletedBy().equals(newPid)); |
|
288 |
assertTrue(meta.getObsoletes() == null); |
|
289 |
|
|
290 |
meta = CNodeService.getInstance(request).getSystemMetadata(session, newPid); |
|
291 |
assertTrue(meta.getObsoletedBy() == null); |
|
292 |
assertTrue(meta.getObsoletes().equals(guid)); |
|
293 |
|
|
283 | 294 |
System.out.println("case 1: ======="); |
284 | 295 |
// the pid should be the newPid when we try to get the sid1 |
285 | 296 |
head = IdentifierManager.getInstance().getHeadPID(seriesId); |
... | ... | |
312 | 323 |
CNodeService.getInstance(request).create(session, pid2_case2, object, sysmeta); |
313 | 324 |
fail("we shouldn't get here and an InvalidSystemMetacat exception should be thrown."); |
314 | 325 |
} catch (InvalidSystemMetadata e) { |
315 |
System.out.println("case 2======= Invalid system metadata"); |
|
326 |
System.out.println("case 2======= Invalid system metadata to insert the second object"); |
|
327 |
//check |
|
328 |
meta = CNodeService.getInstance(request).getSystemMetadata(session, pid1_case2); |
|
329 |
assertTrue(meta.getObsoletedBy() == null); |
|
330 |
assertTrue(meta.getObsoletes() == null); |
|
331 |
// the pid should be the newPid when we try to get the sid1 |
|
332 |
head = IdentifierManager.getInstance().getHeadPID(sid_case2); |
|
333 |
assertTrue(head.getValue().equals(pid1_case2.getValue())); |
|
316 | 334 |
} |
317 | 335 |
|
318 | 336 |
|
... | ... | |
335 | 353 |
sysmeta2_case3.setSeriesId(sid_case3); |
336 | 354 |
sysmeta2_case3.setObsoletes(pid1_case3); |
337 | 355 |
CNodeService.getInstance(request).create(session, pid2_case3, object, sysmeta2_case3); |
356 |
|
|
357 |
//check |
|
358 |
meta = CNodeService.getInstance(request).getSystemMetadata(session, pid1_case3); |
|
359 |
assertTrue(meta.getObsoletedBy() == null); |
|
360 |
assertTrue(meta.getObsoletes() == null); |
|
361 |
|
|
362 |
meta = CNodeService.getInstance(request).getSystemMetadata(session, pid2_case3); |
|
363 |
assertTrue(meta.getObsoletedBy() == null); |
|
364 |
assertTrue(meta.getObsoletes().equals(pid1_case3)); |
|
365 |
|
|
338 | 366 |
System.out.println("case 3: ======="); |
339 | 367 |
head = IdentifierManager.getInstance().getHeadPID(sid_case3); |
340 | 368 |
assertTrue(head.equals(pid2_case3)); |
... | ... | |
375 | 403 |
sysmeta2_case4.setObsoletedBy(pid3_case4); |
376 | 404 |
CNodeService.getInstance(request).updateSystemMetadata(session, pid2_case4, sysmeta2_case4); |
377 | 405 |
|
406 |
//check |
|
407 |
meta = CNodeService.getInstance(request).getSystemMetadata(session, pid1_case4); |
|
408 |
assertTrue(meta.getObsoletedBy().equals(pid2_case4)); |
|
409 |
assertTrue(meta.getObsoletes() == null); |
|
378 | 410 |
|
411 |
meta = CNodeService.getInstance(request).getSystemMetadata(session, pid2_case4); |
|
412 |
assertTrue(meta.getObsoletedBy().equals(pid3_case4)); |
|
413 |
assertTrue(meta.getObsoletes().equals(pid1_case4)); |
|
414 |
|
|
415 |
meta = CNodeService.getInstance(request).getSystemMetadata(session, pid3_case4); |
|
416 |
assertTrue(meta.getObsoletedBy() == null); |
|
417 |
assertTrue(meta.getObsoletes().equals(pid2_case4)); |
|
418 |
|
|
379 | 419 |
System.out.println("case 4: ======="); |
380 | 420 |
head = IdentifierManager.getInstance().getHeadPID(sid_case4); |
381 | 421 |
assertTrue(head.equals(pid2_case4)); |
... | ... | |
413 | 453 |
sysmeta3_case5.setObsoletes(pid2_case5); |
414 | 454 |
CNodeService.getInstance(request).create(session, pid3_case5, object, sysmeta3_case5); |
415 | 455 |
|
456 |
//check |
|
457 |
meta = CNodeService.getInstance(request).getSystemMetadata(session, pid1_case5); |
|
458 |
assertTrue(meta.getObsoletedBy() == null); |
|
459 |
assertTrue(meta.getObsoletes() == null); |
|
460 |
|
|
461 |
meta = CNodeService.getInstance(request).getSystemMetadata(session, pid2_case5); |
|
462 |
assertTrue(meta.getObsoletedBy() == null ); |
|
463 |
assertTrue(meta.getObsoletes().equals(pid1_case5)); |
|
464 |
|
|
465 |
meta = CNodeService.getInstance(request).getSystemMetadata(session, pid3_case5); |
|
466 |
assertTrue(meta.getObsoletedBy() == null); |
|
467 |
assertTrue(meta.getObsoletes().equals(pid2_case5)); |
|
468 |
|
|
416 | 469 |
System.out.println("case 5: ======="); |
417 | 470 |
head = IdentifierManager.getInstance().getHeadPID(sid_case5); |
418 | 471 |
assertTrue(head.equals(pid2_case5)); |
... | ... | |
453 | 506 |
sysmeta2_case6.setObsoletedBy(pid3_case6); |
454 | 507 |
CNodeService.getInstance(request).updateSystemMetadata(session, pid2_case6, sysmeta2_case6); |
455 | 508 |
|
509 |
//check |
|
510 |
meta = CNodeService.getInstance(request).getSystemMetadata(session, pid1_case6); |
|
511 |
assertTrue(meta.getObsoletedBy().equals(pid2_case6)); |
|
512 |
assertTrue(meta.getObsoletes() == null); |
|
513 |
|
|
514 |
meta = CNodeService.getInstance(request).getSystemMetadata(session, pid2_case6); |
|
515 |
assertTrue(meta.getObsoletedBy().equals(pid3_case6)); |
|
516 |
assertTrue(meta.getObsoletes().equals(pid1_case6)); |
|
517 |
|
|
518 |
meta = CNodeService.getInstance(request).getSystemMetadata(session, pid3_case6); |
|
519 |
assertTrue(meta.getObsoletedBy() == null); |
|
520 |
assertTrue(meta.getObsoletes().equals(pid2_case6)); |
|
521 |
|
|
456 | 522 |
System.out.println("case 6: ======="); |
457 | 523 |
head = IdentifierManager.getInstance().getHeadPID(sid_case6); |
458 | 524 |
assertTrue(head.equals(pid2_case6)); |
... | ... | |
505 | 571 |
sysmeta3_case7.setObsoletedBy(pid4_case7); |
506 | 572 |
CNodeService.getInstance(request).updateSystemMetadata(session, pid3_case7, sysmeta3_case7); |
507 | 573 |
|
574 |
//check |
|
575 |
meta = CNodeService.getInstance(request).getSystemMetadata(session, pid1_case7); |
|
576 |
assertTrue(meta.getObsoletedBy().equals(pid2_case7)); |
|
577 |
assertTrue(meta.getObsoletes() == null); |
|
578 |
|
|
579 |
meta = CNodeService.getInstance(request).getSystemMetadata(session, pid2_case7); |
|
580 |
assertTrue(meta.getObsoletedBy().equals(pid3_case7)); |
|
581 |
assertTrue(meta.getObsoletes().equals(pid1_case7)); |
|
582 |
|
|
583 |
meta = CNodeService.getInstance(request).getSystemMetadata(session, pid3_case7); |
|
584 |
assertTrue(meta.getObsoletedBy().equals(pid4_case7)); |
|
585 |
assertTrue(meta.getObsoletes().equals(pid2_case7)); |
|
586 |
|
|
587 |
meta = CNodeService.getInstance(request).getSystemMetadata(session, pid4_case7); |
|
588 |
assertTrue(meta.getObsoletedBy() == null); |
|
589 |
assertTrue(meta.getObsoletes().equals(pid3_case7)); |
|
590 |
|
|
508 | 591 |
System.out.println("case 7: ======="); |
509 | 592 |
head = IdentifierManager.getInstance().getHeadPID(sid_case7); |
510 | 593 |
assertTrue(head.equals(pid2_case7)); |
... | ... | |
566 | 649 |
//e.printStackTrace(); |
567 | 650 |
assertTrue(true); |
568 | 651 |
} |
652 |
|
|
653 |
//check |
|
654 |
meta = CNodeService.getInstance(request).getSystemMetadata(session, pid1_case8); |
|
655 |
assertTrue(meta.getObsoletedBy().equals(pid2_case8)); |
|
656 |
assertTrue(meta.getObsoletes() == null); |
|
657 |
|
|
658 |
meta = CNodeService.getInstance(request).getSystemMetadata(session, pid2_case8); |
|
659 |
assertTrue(meta.getObsoletedBy().equals(pid3_case8)); |
|
660 |
assertTrue(meta.getObsoletes().equals(pid1_case8)); |
|
661 |
|
|
662 |
meta = CNodeService.getInstance(request).getSystemMetadata(session, pid4_case8); |
|
663 |
assertTrue(meta.getObsoletedBy() == null); |
|
664 |
assertTrue(meta.getObsoletes().equals(pid3_case8)); |
|
665 |
|
|
569 | 666 |
System.out.println("case 8: ======="); |
570 | 667 |
head = IdentifierManager.getInstance().getHeadPID(sid_case8); |
571 | 668 |
assertTrue(head.equals(pid4_case8)); |
... | ... | |
593 | 690 |
sysmeta_case9.setObsoletedBy(pid2_case9); |
594 | 691 |
CNodeService.getInstance(request).updateSystemMetadata(session, pid1_case9, sysmeta_case9); |
595 | 692 |
//check |
596 |
SystemMetadata meta = CNodeService.getInstance(request).getSystemMetadata(session, pid1_case9);
|
|
693 |
meta = CNodeService.getInstance(request).getSystemMetadata(session, pid1_case9); |
|
597 | 694 |
assertTrue(meta.getObsoletedBy().equals(pid2_case9)); |
598 | 695 |
|
599 | 696 |
Thread.sleep(1000); |
... | ... | |
628 | 725 |
//e.printStackTrace(); |
629 | 726 |
assertTrue(true); |
630 | 727 |
} |
728 |
|
|
729 |
//check |
|
730 |
meta = CNodeService.getInstance(request).getSystemMetadata(session, pid1_case9); |
|
731 |
assertTrue(meta.getObsoletedBy().equals(pid2_case9)); |
|
732 |
assertTrue(meta.getObsoletes() == null); |
|
733 |
|
|
734 |
meta = CNodeService.getInstance(request).getSystemMetadata(session, pid2_case9); |
|
735 |
assertTrue(meta.getObsoletedBy() == null); |
|
736 |
assertTrue(meta.getObsoletes().equals(pid1_case9)); |
|
737 |
|
|
738 |
meta = CNodeService.getInstance(request).getSystemMetadata(session, pid4_case9); |
|
739 |
assertTrue(meta.getObsoletedBy() == null); |
|
740 |
assertTrue(meta.getObsoletes().equals(pid3_case9)); |
|
741 |
|
|
631 | 742 |
System.out.println("case 9: ======="); |
632 | 743 |
head = IdentifierManager.getInstance().getHeadPID(sid_case9); |
633 | 744 |
assertTrue(head.equals(pid4_case9)); |
... | ... | |
690 | 801 |
//e.printStackTrace(); |
691 | 802 |
assertTrue(true); |
692 | 803 |
} |
804 |
|
|
805 |
//check |
|
806 |
meta = CNodeService.getInstance(request).getSystemMetadata(session, pid1_case10); |
|
807 |
assertTrue(meta.getObsoletedBy().equals(pid2_case10)); |
|
808 |
assertTrue(meta.getObsoletes() == null); |
|
809 |
|
|
810 |
meta = CNodeService.getInstance(request).getSystemMetadata(session, pid2_case10); |
|
811 |
assertTrue(meta.getObsoletedBy().equals(pid3_case10)); |
|
812 |
assertTrue(meta.getObsoletes().equals(pid1_case10)); |
|
813 |
|
|
814 |
meta = CNodeService.getInstance(request).getSystemMetadata(session, pid4_case10); |
|
815 |
assertTrue(meta.getObsoletedBy() == null); |
|
816 |
assertTrue(meta.getObsoletes().equals(pid3_case10)); |
|
817 |
|
|
693 | 818 |
System.out.println("case 10: ======="); |
694 | 819 |
head = IdentifierManager.getInstance().getHeadPID(sid_case10); |
695 | 820 |
assertTrue(head.equals(pid4_case10)); |
... | ... | |
734 | 859 |
|
735 | 860 |
//archive pid3_case11 |
736 | 861 |
CNodeService.getInstance(request).archive(session, pid3_case11); |
862 |
|
|
863 |
//check |
|
864 |
meta = CNodeService.getInstance(request).getSystemMetadata(session, pid1_case11); |
|
865 |
assertTrue(meta.getObsoletedBy().equals(pid2_case11)); |
|
866 |
assertTrue(meta.getObsoletes() == null); |
|
867 |
|
|
868 |
meta = CNodeService.getInstance(request).getSystemMetadata(session, pid2_case11); |
|
869 |
assertTrue(meta.getObsoletedBy().equals(pid3_case11)); |
|
870 |
assertTrue(meta.getObsoletes().equals(pid1_case11)); |
|
871 |
|
|
737 | 872 |
meta = CNodeService.getInstance(request).getSystemMetadata(session, pid3_case11); |
738 | 873 |
assertTrue(meta.getArchived()); |
874 |
assertTrue(meta.getObsoletedBy() == null); |
|
875 |
assertTrue(meta.getObsoletes().equals(pid2_case11)); |
|
876 |
|
|
739 | 877 |
System.out.println("case 11: ======="); |
740 | 878 |
head = IdentifierManager.getInstance().getHeadPID(sid_case11); |
741 | 879 |
assertTrue(head.equals(pid3_case11)); |
880 |
|
|
881 |
|
|
882 |
//case-12 P1(S1) <-> P2(S1) -> ??, S1 = P2, (Type 2) (Error, but will happen) |
|
883 |
object = new ByteArrayInputStream("test".getBytes("UTF-8")); |
|
884 |
Identifier pid1_case12 = new Identifier(); |
|
885 |
pid1_case12.setValue(generateDocumentId()); |
|
886 |
Identifier sid_case12 = new Identifier(); |
|
887 |
sid_case12.setValue("sid."+System.nanoTime()); |
|
888 |
SystemMetadata sysmeta_case12 = createSystemMetadata(pid1_case12, session.getSubject(), object); |
|
889 |
sysmeta_case12.setSeriesId(sid_case12); |
|
890 |
CNodeService.getInstance(request).create(session, pid1_case12, object, sysmeta_case12); |
|
891 |
|
|
892 |
Thread.sleep(1000); |
|
893 |
object = new ByteArrayInputStream("test".getBytes("UTF-8")); |
|
894 |
Identifier pid2_case12 = new Identifier(); |
|
895 |
pid2_case12.setValue(generateDocumentId()); |
|
896 |
SystemMetadata sysmeta2_case12 = createSystemMetadata(pid2_case12, session.getSubject(), object); |
|
897 |
sysmeta2_case12.setSeriesId(sid_case12); |
|
898 |
sysmeta2_case12.setObsoletes(pid1_case12); |
|
899 |
CNodeService.getInstance(request).create(session, pid2_case12, object, sysmeta2_case12); |
|
900 |
|
|
901 |
sysmeta_case12.setObsoletedBy(pid2_case12); |
|
902 |
CNodeService.getInstance(request).updateSystemMetadata(session, pid1_case12, sysmeta_case12); |
|
903 |
//check |
|
904 |
meta = CNodeService.getInstance(request).getSystemMetadata(session, pid1_case12); |
|
905 |
assertTrue(meta.getObsoletedBy().equals(pid2_case12)); |
|
906 |
|
|
907 |
Thread.sleep(1000); |
|
908 |
object = new ByteArrayInputStream("test".getBytes("UTF-8")); |
|
909 |
Identifier pid3_case12 = new Identifier(); |
|
910 |
pid3_case12.setValue(generateDocumentId()); |
|
911 |
SystemMetadata sysmeta3_case12 = createSystemMetadata(pid3_case12, session.getSubject(), object); |
|
912 |
sysmeta3_case12.setObsoletes(pid2_case12); |
|
913 |
sysmeta3_case12.setSeriesId(sid_case12); |
|
914 |
CNodeService.getInstance(request).create(session, pid3_case12, object, sysmeta3_case12); |
|
915 |
|
|
916 |
sysmeta2_case12.setObsoletedBy(pid3_case12); |
|
917 |
CNodeService.getInstance(request).updateSystemMetadata(session, pid2_case12, sysmeta2_case12); |
|
918 |
|
|
919 |
//archive pid3_case12 |
|
920 |
CNodeService.getInstance(request).delete(session, pid3_case12); |
|
921 |
try { |
|
922 |
meta = CNodeService.getInstance(request).getSystemMetadata(session, pid3_case12); |
|
923 |
fail("The pid "+pid3_case12.getValue()+" should be deleted."); |
|
924 |
} catch (NotFound ee) { |
|
925 |
assertTrue(true); |
|
926 |
} |
|
927 |
|
|
928 |
//check |
|
929 |
meta = CNodeService.getInstance(request).getSystemMetadata(session, pid1_case12); |
|
930 |
assertTrue(meta.getObsoletedBy().equals(pid2_case12)); |
|
931 |
assertTrue(meta.getObsoletes() == null); |
|
932 |
|
|
933 |
meta = CNodeService.getInstance(request).getSystemMetadata(session, pid2_case12); |
|
934 |
assertTrue(meta.getObsoletedBy().equals(pid3_case12)); |
|
935 |
assertTrue(meta.getObsoletes().equals(pid1_case12)); |
|
936 |
|
|
937 |
System.out.println("case 12: ======="); |
|
938 |
head = IdentifierManager.getInstance().getHeadPID(sid_case12); |
|
939 |
assertTrue(head.equals(pid2_case12)); |
|
940 |
|
|
941 |
|
|
942 |
|
|
943 |
//case-13 P1(S1) <- P2(S1) -> ??, S1 = P2 (P1 is a type 1 end and P2 is a type 2 end, not an ideal chain) |
|
944 |
object = new ByteArrayInputStream("test".getBytes("UTF-8")); |
|
945 |
Identifier pid1_case13 = new Identifier(); |
|
946 |
pid1_case13.setValue(generateDocumentId()); |
|
947 |
Identifier sid_case13 = new Identifier(); |
|
948 |
sid_case13.setValue("sid."+System.nanoTime()); |
|
949 |
SystemMetadata sysmeta_case13 = createSystemMetadata(pid1_case13, session.getSubject(), object); |
|
950 |
sysmeta_case13.setSeriesId(sid_case13); |
|
951 |
CNodeService.getInstance(request).create(session, pid1_case13, object, sysmeta_case13); |
|
952 |
|
|
953 |
Thread.sleep(1000); |
|
954 |
object = new ByteArrayInputStream("test".getBytes("UTF-8")); |
|
955 |
Identifier pid2_case13 = new Identifier(); |
|
956 |
pid2_case13.setValue(generateDocumentId()); |
|
957 |
Thread.sleep(1000); |
|
958 |
Identifier pid3_case13 = new Identifier(); |
|
959 |
pid3_case13.setValue(generateDocumentId()); |
|
960 |
SystemMetadata sysmeta2_case13 = createSystemMetadata(pid2_case13, session.getSubject(), object); |
|
961 |
sysmeta2_case13.setSeriesId(sid_case13); |
|
962 |
sysmeta2_case13.setObsoletes(pid1_case13); |
|
963 |
sysmeta2_case13.setObsoletedBy(pid3_case13); |
|
964 |
CNodeService.getInstance(request).create(session, pid2_case13, object, sysmeta2_case13); |
|
965 |
|
|
966 |
meta = CNodeService.getInstance(request).getSystemMetadata(session, pid2_case13); |
|
967 |
assertTrue(meta.getObsoletedBy().equals(pid3_case13)); |
|
968 |
assertTrue(meta.getObsoletes().equals(pid1_case13)); |
|
969 |
|
|
970 |
meta = CNodeService.getInstance(request).getSystemMetadata(session, pid1_case13); |
|
971 |
assertTrue(meta.getObsoletedBy() == null); |
|
972 |
assertTrue(meta.getObsoletes() == null); |
|
973 |
|
|
974 |
System.out.println("case 13: ======="); |
|
975 |
head = IdentifierManager.getInstance().getHeadPID(sid_case13); |
|
976 |
assertTrue(head.equals(pid2_case13)); |
|
977 |
|
|
978 |
|
|
979 |
|
|
980 |
//case-14 P1(S1) <- P2(S1) -> P3(S2), S1 = P2 (P1 is a type one end and P2 is a type 2 end, not an ideal chain) |
|
981 |
object = new ByteArrayInputStream("test".getBytes("UTF-8")); |
|
982 |
Identifier pid1_case14 = new Identifier(); |
|
983 |
pid1_case14.setValue(generateDocumentId()); |
|
984 |
Identifier sid_case14 = new Identifier(); |
|
985 |
sid_case14.setValue("sid."+System.nanoTime()); |
|
986 |
SystemMetadata sysmeta_case14 = createSystemMetadata(pid1_case14, session.getSubject(), object); |
|
987 |
sysmeta_case14.setSeriesId(sid_case14); |
|
988 |
CNodeService.getInstance(request).create(session, pid1_case14, object, sysmeta_case14); |
|
989 |
|
|
990 |
Thread.sleep(1000); |
|
991 |
object = new ByteArrayInputStream("test".getBytes("UTF-8")); |
|
992 |
Identifier pid2_case14 = new Identifier(); |
|
993 |
pid2_case14.setValue(generateDocumentId()); |
|
994 |
SystemMetadata sysmeta2_case14 = createSystemMetadata(pid2_case14, session.getSubject(), object); |
|
995 |
sysmeta2_case14.setSeriesId(sid_case14); |
|
996 |
sysmeta2_case14.setObsoletes(pid1_case14); |
|
997 |
CNodeService.getInstance(request).create(session, pid2_case14, object, sysmeta2_case14); |
|
998 |
|
|
999 |
Thread.sleep(1000); |
|
1000 |
object = new ByteArrayInputStream("test".getBytes("UTF-8")); |
|
1001 |
Identifier pid3_case14 = new Identifier(); |
|
1002 |
pid3_case14.setValue(generateDocumentId()); |
|
1003 |
Identifier sid2_case14 = new Identifier(); |
|
1004 |
sid2_case14.setValue("sid."+System.nanoTime()); |
|
1005 |
SystemMetadata sysmeta3_case14 = createSystemMetadata(pid3_case14, session.getSubject(), object); |
|
1006 |
sysmeta3_case14.setSeriesId(sid2_case14); |
|
1007 |
CNodeService.getInstance(request).create(session, pid3_case14, object, sysmeta3_case14); |
|
1008 |
|
|
1009 |
sysmeta2_case14.setObsoletedBy(pid3_case14); |
|
1010 |
CNodeService.getInstance(request).updateSystemMetadata(session, pid2_case14, sysmeta2_case14); |
|
1011 |
|
|
1012 |
meta = CNodeService.getInstance(request).getSystemMetadata(session, pid2_case14); |
|
1013 |
assertTrue(meta.getObsoletedBy().equals(pid3_case14)); |
|
1014 |
assertTrue(meta.getObsoletes().equals(pid1_case14)); |
|
1015 |
|
|
1016 |
meta = CNodeService.getInstance(request).getSystemMetadata(session, pid1_case14); |
|
1017 |
assertTrue(meta.getObsoletedBy() == null); |
|
1018 |
assertTrue(meta.getObsoletes() == null); |
|
1019 |
|
|
1020 |
meta = CNodeService.getInstance(request).getSystemMetadata(session, pid3_case14); |
|
1021 |
assertTrue(meta.getObsoletedBy() == null); |
|
1022 |
assertTrue(meta.getObsoletes() == null); |
|
1023 |
|
|
1024 |
System.out.println("case 14: ======="); |
|
1025 |
head = IdentifierManager.getInstance().getHeadPID(sid_case14); |
|
1026 |
assertTrue(head.equals(pid2_case14)); |
|
1027 |
head = IdentifierManager.getInstance().getHeadPID(sid2_case14); |
|
1028 |
assertTrue(head.equals(pid3_case14)); |
|
1029 |
|
|
1030 |
|
|
1031 |
//case-15 P1(S1) <-> P2(S1) ?? <- P4(S1) <-> P5(S2), S1 = P4 (P2 is a type 1 end and P4 is a type 2 end, not an ideal chain) |
|
1032 |
object = new ByteArrayInputStream("test".getBytes("UTF-8")); |
|
1033 |
Identifier pid1_case15 = new Identifier(); |
|
1034 |
pid1_case15.setValue(generateDocumentId()); |
|
1035 |
Identifier sid_case15 = new Identifier(); |
|
1036 |
sid_case15.setValue("sid."+System.nanoTime()); |
|
1037 |
SystemMetadata sysmeta_case15 = createSystemMetadata(pid1_case15, session.getSubject(), object); |
|
1038 |
sysmeta_case15.setSeriesId(sid_case15); |
|
1039 |
CNodeService.getInstance(request).create(session, pid1_case15, object, sysmeta_case15); |
|
1040 |
|
|
1041 |
Thread.sleep(1000); |
|
1042 |
object = new ByteArrayInputStream("test".getBytes("UTF-8")); |
|
1043 |
Identifier pid2_case15 = new Identifier(); |
|
1044 |
pid2_case15.setValue(generateDocumentId()); |
|
1045 |
SystemMetadata sysmeta2_case15 = createSystemMetadata(pid2_case15, session.getSubject(), object); |
|
1046 |
sysmeta2_case15.setSeriesId(sid_case15); |
|
1047 |
sysmeta2_case15.setObsoletes(pid1_case15); |
|
1048 |
CNodeService.getInstance(request).create(session, pid2_case15, object, sysmeta2_case15); |
|
1049 |
|
|
1050 |
sysmeta_case15.setObsoletedBy(pid2_case15); |
|
1051 |
CNodeService.getInstance(request).updateSystemMetadata(session, pid1_case15, sysmeta_case15); |
|
1052 |
//check |
|
1053 |
meta = CNodeService.getInstance(request).getSystemMetadata(session, pid1_case15); |
|
1054 |
assertTrue(meta.getObsoletedBy().equals(pid2_case15)); |
|
1055 |
|
|
1056 |
Thread.sleep(1000); |
|
1057 |
object = new ByteArrayInputStream("test".getBytes("UTF-8")); |
|
1058 |
Identifier pid3_case15 = new Identifier(); |
|
1059 |
pid3_case15.setValue(generateDocumentId()); |
|
1060 |
SystemMetadata sysmeta3_case15 = createSystemMetadata(pid3_case15, session.getSubject(), object); |
|
1061 |
sysmeta3_case15.setSeriesId(sid_case15); |
|
1062 |
sysmeta3_case15.setObsoletes(pid2_case15); |
|
1063 |
CNodeService.getInstance(request).create(session, pid3_case15, object, sysmeta3_case15); |
|
1064 |
|
|
1065 |
Thread.sleep(1000); |
|
1066 |
object = new ByteArrayInputStream("test".getBytes("UTF-8")); |
|
1067 |
Identifier pid4_case15 = new Identifier(); |
|
1068 |
pid4_case15.setValue(generateDocumentId()); |
|
1069 |
SystemMetadata sysmeta4_case15 = createSystemMetadata(pid4_case15, session.getSubject(), object); |
|
1070 |
sysmeta4_case15.setSeriesId(sid_case15); |
|
1071 |
sysmeta4_case15.setObsoletes(pid3_case15); |
|
1072 |
CNodeService.getInstance(request).create(session, pid4_case15, object, sysmeta4_case15); |
|
1073 |
|
|
1074 |
Thread.sleep(1000); |
|
1075 |
object = new ByteArrayInputStream("test".getBytes("UTF-8")); |
|
1076 |
Identifier pid5_case15 = new Identifier(); |
|
1077 |
pid5_case15.setValue(generateDocumentId()); |
|
1078 |
Identifier sid2_case15 = new Identifier(); |
|
1079 |
sid2_case15.setValue("sid."+System.nanoTime()); |
|
1080 |
SystemMetadata sysmeta5_case15 = createSystemMetadata(pid5_case15, session.getSubject(), object); |
|
1081 |
sysmeta5_case15.setSeriesId(sid2_case15); |
|
1082 |
sysmeta5_case15.setObsoletes(pid4_case15); |
|
1083 |
CNodeService.getInstance(request).create(session, pid5_case15, object, sysmeta5_case15); |
|
1084 |
|
|
1085 |
sysmeta4_case15.setObsoletedBy(pid5_case15); |
|
1086 |
CNodeService.getInstance(request).updateSystemMetadata(session, pid4_case15, sysmeta4_case15); |
|
1087 |
|
|
1088 |
CNodeService.getInstance(request).delete(session, pid3_case15); |
|
1089 |
try { |
|
1090 |
meta = CNodeService.getInstance(request).getSystemMetadata(session, pid3_case15); |
|
1091 |
fail("The pid "+pid3_case15.getValue()+" should be deleted."); |
|
1092 |
} catch (NotFound ee) { |
|
1093 |
assertTrue(true); |
|
1094 |
} |
|
1095 |
//check |
|
1096 |
meta = CNodeService.getInstance(request).getSystemMetadata(session, pid1_case15); |
|
1097 |
assertTrue(meta.getObsoletedBy().equals(pid2_case15)); |
|
1098 |
assertTrue(meta.getObsoletes() == null); |
|
1099 |
|
|
1100 |
meta = CNodeService.getInstance(request).getSystemMetadata(session, pid2_case15); |
|
1101 |
assertTrue(meta.getObsoletedBy() == null); |
|
1102 |
assertTrue(meta.getObsoletes().equals(pid1_case15)); |
|
1103 |
|
|
1104 |
meta = CNodeService.getInstance(request).getSystemMetadata(session, pid4_case15); |
|
1105 |
assertTrue(meta.getObsoletedBy().equals(pid5_case15)); |
|
1106 |
assertTrue(meta.getObsoletes().equals(pid3_case15)); |
|
1107 |
|
|
1108 |
meta = CNodeService.getInstance(request).getSystemMetadata(session, pid5_case15); |
|
1109 |
assertTrue(meta.getObsoletedBy() == null); |
|
1110 |
assertTrue(meta.getObsoletes().equals(pid4_case15)); |
|
1111 |
|
|
1112 |
System.out.println("case 15: ======="); |
|
1113 |
head = IdentifierManager.getInstance().getHeadPID(sid_case15); |
|
1114 |
assertTrue(head.equals(pid4_case15)); |
|
1115 |
head = IdentifierManager.getInstance().getHeadPID(sid2_case15); |
|
1116 |
assertTrue(head.equals(pid5_case15)); |
|
1117 |
|
|
1118 |
|
|
1119 |
|
|
1120 |
|
|
1121 |
//case-16 P1(S1) <- P2(S1) -> ?? <-P4(S2) S1 = P2 (P1 is a type 1 end and P2 is a type 2 ends, not an ideal chain), S2=P4 (rule1) |
|
1122 |
object = new ByteArrayInputStream("test".getBytes("UTF-8")); |
|
1123 |
Identifier pid1_case16 = new Identifier(); |
|
1124 |
pid1_case16.setValue(generateDocumentId()); |
|
1125 |
Identifier sid_case16 = new Identifier(); |
|
1126 |
sid_case16.setValue("sid."+System.nanoTime()); |
|
1127 |
SystemMetadata sysmeta_case16 = createSystemMetadata(pid1_case16, session.getSubject(), object); |
|
1128 |
sysmeta_case16.setSeriesId(sid_case16); |
|
1129 |
CNodeService.getInstance(request).create(session, pid1_case16, object, sysmeta_case16); |
|
1130 |
|
|
1131 |
Thread.sleep(1000); |
|
1132 |
object = new ByteArrayInputStream("test".getBytes("UTF-8")); |
|
1133 |
Identifier pid2_case16 = new Identifier(); |
|
1134 |
pid2_case16.setValue(generateDocumentId()); |
|
1135 |
SystemMetadata sysmeta2_case16 = createSystemMetadata(pid2_case16, session.getSubject(), object); |
|
1136 |
sysmeta2_case16.setSeriesId(sid_case16); |
|
1137 |
sysmeta2_case16.setObsoletes(pid1_case16); |
|
1138 |
CNodeService.getInstance(request).create(session, pid2_case16, object, sysmeta2_case16); |
|
1139 |
|
|
1140 |
Thread.sleep(1000); |
|
1141 |
object = new ByteArrayInputStream("test".getBytes("UTF-8")); |
|
1142 |
Identifier pid3_case16 = new Identifier(); |
|
1143 |
pid3_case16.setValue(generateDocumentId()); |
|
1144 |
SystemMetadata sysmeta3_case16 = createSystemMetadata(pid3_case16, session.getSubject(), object); |
|
1145 |
sysmeta3_case16.setSeriesId(sid_case16); |
|
1146 |
sysmeta3_case16.setObsoletes(pid2_case16); |
|
1147 |
CNodeService.getInstance(request).create(session, pid3_case16, object, sysmeta3_case16); |
|
1148 |
|
|
1149 |
sysmeta2_case16.setObsoletedBy(pid3_case16); |
|
1150 |
CNodeService.getInstance(request).updateSystemMetadata(session, pid2_case16, sysmeta2_case16); |
|
1151 |
|
|
1152 |
Thread.sleep(1000); |
|
1153 |
object = new ByteArrayInputStream("test".getBytes("UTF-8")); |
|
1154 |
Identifier pid4_case16 = new Identifier(); |
|
1155 |
pid4_case16.setValue(generateDocumentId()); |
|
1156 |
Identifier sid2_case16 = new Identifier(); |
|
1157 |
sid2_case16.setValue("sid."+System.nanoTime()); |
|
1158 |
SystemMetadata sysmeta4_case16 = createSystemMetadata(pid4_case16, session.getSubject(), object); |
|
1159 |
sysmeta4_case16.setSeriesId(sid2_case16); |
|
1160 |
sysmeta4_case16.setObsoletes(pid3_case16); |
|
1161 |
CNodeService.getInstance(request).create(session, pid4_case16, object, sysmeta4_case16); |
|
1162 |
|
|
1163 |
CNodeService.getInstance(request).delete(session, pid3_case16); |
|
1164 |
try { |
|
1165 |
meta = CNodeService.getInstance(request).getSystemMetadata(session, pid3_case16); |
|
1166 |
fail("The pid "+pid3_case16.getValue()+" should be deleted."); |
|
1167 |
} catch (NotFound ee) { |
|
1168 |
assertTrue(true); |
|
1169 |
} |
|
1170 |
//check |
|
1171 |
meta = CNodeService.getInstance(request).getSystemMetadata(session, pid1_case16); |
|
1172 |
assertTrue(meta.getObsoletedBy() == null); |
|
1173 |
assertTrue(meta.getObsoletes() == null); |
|
1174 |
|
|
1175 |
meta = CNodeService.getInstance(request).getSystemMetadata(session, pid2_case16); |
|
1176 |
assertTrue(meta.getObsoletedBy().equals(pid3_case16)); |
|
1177 |
assertTrue(meta.getObsoletes().equals(pid1_case16)); |
|
1178 |
|
|
1179 |
meta = CNodeService.getInstance(request).getSystemMetadata(session, pid4_case16); |
|
1180 |
assertTrue(meta.getObsoletedBy() == null); |
|
1181 |
assertTrue(meta.getObsoletes().equals(pid3_case16)); |
|
1182 |
|
|
1183 |
System.out.println("case 16: ======="); |
|
1184 |
head = IdentifierManager.getInstance().getHeadPID(sid_case16); |
|
1185 |
assertTrue(head.equals(pid2_case16)); |
|
1186 |
head = IdentifierManager.getInstance().getHeadPID(sid2_case16); |
|
1187 |
assertTrue(head.equals(pid4_case16)); |
|
1188 |
|
|
1189 |
|
|
1190 |
//case-17 P1(S1) <- P2(S1) -> ?? <-P4(S1) S1 = P4 (P1 and P4 are type 1 ends, not an ideal chain) |
|
1191 |
object = new ByteArrayInputStream("test".getBytes("UTF-8")); |
|
1192 |
Identifier pid1_case17 = new Identifier(); |
|
1193 |
pid1_case17.setValue(generateDocumentId()); |
|
1194 |
Identifier sid_case17 = new Identifier(); |
|
1195 |
sid_case17.setValue("sid."+System.nanoTime()); |
|
1196 |
SystemMetadata sysmeta_case17 = createSystemMetadata(pid1_case17, session.getSubject(), object); |
|
1197 |
sysmeta_case17.setSeriesId(sid_case17); |
|
1198 |
CNodeService.getInstance(request).create(session, pid1_case17, object, sysmeta_case17); |
|
1199 |
|
|
1200 |
Thread.sleep(1000); |
|
1201 |
object = new ByteArrayInputStream("test".getBytes("UTF-8")); |
|
1202 |
Identifier pid2_case17 = new Identifier(); |
|
1203 |
pid2_case17.setValue(generateDocumentId()); |
|
1204 |
SystemMetadata sysmeta2_case17 = createSystemMetadata(pid2_case17, session.getSubject(), object); |
|
1205 |
sysmeta2_case17.setSeriesId(sid_case17); |
|
1206 |
sysmeta2_case17.setObsoletes(pid1_case17); |
|
1207 |
CNodeService.getInstance(request).create(session, pid2_case17, object, sysmeta2_case17); |
|
1208 |
|
|
1209 |
Thread.sleep(1000); |
|
1210 |
object = new ByteArrayInputStream("test".getBytes("UTF-8")); |
|
1211 |
Identifier pid3_case17 = new Identifier(); |
|
1212 |
pid3_case17.setValue(generateDocumentId()); |
|
1213 |
SystemMetadata sysmeta3_case17 = createSystemMetadata(pid3_case17, session.getSubject(), object); |
|
1214 |
sysmeta3_case17.setSeriesId(sid_case17); |
|
1215 |
sysmeta3_case17.setObsoletes(pid2_case17); |
|
1216 |
CNodeService.getInstance(request).create(session, pid3_case17, object, sysmeta3_case17); |
|
1217 |
|
|
1218 |
sysmeta2_case17.setObsoletedBy(pid3_case17); |
|
1219 |
CNodeService.getInstance(request).updateSystemMetadata(session, pid2_case17, sysmeta2_case17); |
|
1220 |
|
|
1221 |
Thread.sleep(1000); |
|
1222 |
object = new ByteArrayInputStream("test".getBytes("UTF-8")); |
|
1223 |
Identifier pid4_case17 = new Identifier(); |
|
1224 |
pid4_case17.setValue(generateDocumentId()); |
|
1225 |
SystemMetadata sysmeta4_case17 = createSystemMetadata(pid4_case17, session.getSubject(), object); |
|
1226 |
sysmeta4_case17.setSeriesId(sid_case17); |
|
1227 |
sysmeta4_case17.setObsoletes(pid3_case17); |
|
1228 |
CNodeService.getInstance(request).create(session, pid4_case17, object, sysmeta4_case17); |
|
1229 |
|
|
1230 |
CNodeService.getInstance(request).delete(session, pid3_case17); |
|
1231 |
try { |
|
1232 |
meta = CNodeService.getInstance(request).getSystemMetadata(session, pid3_case17); |
|
1233 |
fail("The pid "+pid3_case17.getValue()+" should be deleted."); |
|
1234 |
} catch (NotFound ee) { |
|
1235 |
assertTrue(true); |
|
1236 |
} |
|
1237 |
//check |
|
1238 |
meta = CNodeService.getInstance(request).getSystemMetadata(session, pid1_case17); |
|
1239 |
assertTrue(meta.getObsoletedBy() == null); |
|
1240 |
assertTrue(meta.getObsoletes() == null); |
|
1241 |
|
|
1242 |
meta = CNodeService.getInstance(request).getSystemMetadata(session, pid2_case17); |
|
1243 |
assertTrue(meta.getObsoletedBy().equals(pid3_case17)); |
|
1244 |
assertTrue(meta.getObsoletes().equals(pid1_case17)); |
|
1245 |
|
|
1246 |
meta = CNodeService.getInstance(request).getSystemMetadata(session, pid4_case17); |
|
1247 |
assertTrue(meta.getObsoletedBy() == null); |
|
1248 |
assertTrue(meta.getObsoletes().equals(pid3_case17)); |
|
1249 |
|
|
1250 |
System.out.println("case 17: ======="); |
|
1251 |
head = IdentifierManager.getInstance().getHeadPID(sid_case17); |
|
1252 |
assertTrue(head.equals(pid4_case17)); |
|
1253 |
|
|
1254 |
|
|
1255 |
|
|
1256 |
//case-18 P1(S1) <->P2(S1) -> ?? ???<-P5(S1) S1 = P5 (P2 is a type 2 end and P4 is a type 1 end, not an ideal chain) |
|
1257 |
object = new ByteArrayInputStream("test".getBytes("UTF-8")); |
|
1258 |
Identifier pid1_case18 = new Identifier(); |
|
1259 |
pid1_case18.setValue(generateDocumentId()); |
|
1260 |
Identifier sid_case18 = new Identifier(); |
|
1261 |
sid_case18.setValue("sid."+System.nanoTime()); |
|
1262 |
SystemMetadata sysmeta_case18 = createSystemMetadata(pid1_case18, session.getSubject(), object); |
|
1263 |
sysmeta_case18.setSeriesId(sid_case18); |
|
1264 |
CNodeService.getInstance(request).create(session, pid1_case18, object, sysmeta_case18); |
|
1265 |
|
|
1266 |
Thread.sleep(1000); |
|
1267 |
object = new ByteArrayInputStream("test".getBytes("UTF-8")); |
|
1268 |
Identifier pid2_case18 = new Identifier(); |
|
1269 |
pid2_case18.setValue(generateDocumentId()); |
|
1270 |
SystemMetadata sysmeta2_case18 = createSystemMetadata(pid2_case18, session.getSubject(), object); |
|
1271 |
sysmeta2_case18.setSeriesId(sid_case18); |
|
1272 |
sysmeta2_case18.setObsoletes(pid1_case18); |
|
1273 |
CNodeService.getInstance(request).create(session, pid2_case18, object, sysmeta2_case18); |
|
1274 |
|
|
1275 |
sysmeta_case18.setObsoletedBy(pid2_case18); |
|
1276 |
CNodeService.getInstance(request).updateSystemMetadata(session, pid1_case18, sysmeta_case18); |
|
1277 |
|
|
1278 |
Thread.sleep(1000); |
|
1279 |
object = new ByteArrayInputStream("test".getBytes("UTF-8")); |
|
1280 |
Identifier pid3_case18 = new Identifier(); |
|
1281 |
pid3_case18.setValue(generateDocumentId()); |
|
1282 |
SystemMetadata sysmeta3_case18 = createSystemMetadata(pid3_case18, session.getSubject(), object); |
|
1283 |
sysmeta3_case18.setSeriesId(sid_case18); |
|
1284 |
sysmeta3_case18.setObsoletes(pid2_case18); |
|
1285 |
CNodeService.getInstance(request).create(session, pid3_case18, object, sysmeta3_case18); |
|
1286 |
|
|
1287 |
sysmeta2_case18.setObsoletedBy(pid3_case18); |
|
1288 |
CNodeService.getInstance(request).updateSystemMetadata(session, pid2_case18, sysmeta2_case18); |
|
1289 |
|
|
1290 |
Thread.sleep(1000); |
|
1291 |
object = new ByteArrayInputStream("test".getBytes("UTF-8")); |
|
1292 |
Identifier pid4_case18 = new Identifier(); |
|
1293 |
pid4_case18.setValue(generateDocumentId()); |
|
1294 |
SystemMetadata sysmeta4_case18 = createSystemMetadata(pid4_case18, session.getSubject(), object); |
|
1295 |
sysmeta4_case18.setSeriesId(sid_case18); |
|
1296 |
sysmeta4_case18.setObsoletes(pid3_case18); |
|
1297 |
CNodeService.getInstance(request).create(session, pid4_case18, object, sysmeta4_case18); |
|
1298 |
|
|
1299 |
Thread.sleep(1000); |
|
1300 |
object = new ByteArrayInputStream("test".getBytes("UTF-8")); |
|
1301 |
Identifier pid5_case18 = new Identifier(); |
|
1302 |
pid5_case18.setValue(generateDocumentId()); |
|
1303 |
SystemMetadata sysmeta5_case18 = createSystemMetadata(pid5_case18, session.getSubject(), object); |
|
1304 |
sysmeta5_case18.setSeriesId(sid_case18); |
|
1305 |
sysmeta5_case18.setObsoletes(pid4_case18); |
|
1306 |
CNodeService.getInstance(request).create(session, pid5_case18, object, sysmeta5_case18); |
|
1307 |
|
|
1308 |
sysmeta4_case18.setObsoletedBy(pid5_case18); |
|
1309 |
CNodeService.getInstance(request).updateSystemMetadata(session, pid4_case18, sysmeta4_case18); |
|
1310 |
|
|
1311 |
CNodeService.getInstance(request).delete(session, pid3_case18); |
|
1312 |
try { |
|
1313 |
meta = CNodeService.getInstance(request).getSystemMetadata(session, pid3_case18); |
|
1314 |
fail("The pid "+pid3_case18.getValue()+" should be deleted."); |
|
1315 |
} catch (NotFound ee) { |
|
1316 |
assertTrue(true); |
|
1317 |
} |
|
1318 |
|
|
1319 |
CNodeService.getInstance(request).delete(session, pid4_case18); |
|
1320 |
try { |
|
1321 |
meta = CNodeService.getInstance(request).getSystemMetadata(session, pid4_case18); |
|
1322 |
fail("The pid "+pid4_case18.getValue()+" should be deleted."); |
|
1323 |
} catch (NotFound ee) { |
|
1324 |
assertTrue(true); |
|
1325 |
} |
|
1326 |
//check |
|
1327 |
meta = CNodeService.getInstance(request).getSystemMetadata(session, pid1_case18); |
|
1328 |
assertTrue(meta.getObsoletedBy().equals(pid2_case18)); |
|
1329 |
assertTrue(meta.getObsoletes() == null); |
|
1330 |
|
|
1331 |
meta = CNodeService.getInstance(request).getSystemMetadata(session, pid2_case18); |
|
1332 |
assertTrue(meta.getObsoletedBy().equals(pid3_case18)); |
|
1333 |
assertTrue(meta.getObsoletes().equals(pid1_case18)); |
|
1334 |
|
|
1335 |
meta = CNodeService.getInstance(request).getSystemMetadata(session, pid5_case18); |
|
1336 |
assertTrue(meta.getObsoletedBy() == null); |
|
1337 |
assertTrue(meta.getObsoletes().equals(pid4_case18)); |
|
1338 |
|
|
1339 |
System.out.println("case 18: ======="); |
|
1340 |
head = IdentifierManager.getInstance().getHeadPID(sid_case18); |
|
1341 |
assertTrue(head.equals(pid5_case18)); |
|
1342 |
|
|
742 | 1343 |
|
743 | 1344 |
} catch (Exception e) { |
744 | 1345 |
e.printStackTrace(); |
Also available in: Unified diff
Completed the 18 test cases.