Revision 9316
Added by Jing Tao about 9 years ago
test/edu/ucsb/nceas/metacat/dataone/CNodeServiceTest.java | ||
---|---|---|
473 | 473 |
assertTrue(result); |
474 | 474 |
// get it |
475 | 475 |
sysmeta = CNodeService.getInstance(request).getSystemMetadata(session, guid); |
476 |
BigInteger version = sysmeta.getSerialVersion(); |
|
477 |
System.out.println("the version of system metadata is "+version.intValue()); |
|
476 | 478 |
assertNotNull(sysmeta); |
477 | 479 |
// check it |
478 | 480 |
assertEquals(status, sysmeta.getReplica(0).getReplicationStatus()); |
479 | 481 |
|
482 |
//set it failed. |
|
483 |
status = ReplicationStatus.FAILED; |
|
484 |
result = CNodeService.getInstance(request).setReplicationStatus(session, guid, replicaMemberNode, status, failure); |
|
485 |
assertTrue(result); |
|
486 |
// get it |
|
487 |
sysmeta = CNodeService.getInstance(request).getSystemMetadata(session, guid); |
|
488 |
BigInteger version1 = sysmeta.getSerialVersion(); |
|
489 |
System.out.println("the version of system metadata is "+version1.intValue()); |
|
490 |
assertTrue(version1.compareTo(version) == 1); |
|
491 |
assertNotNull(sysmeta); |
|
492 |
// check it |
|
493 |
assertEquals(status, sysmeta.getReplica(0).getReplicationStatus()); |
|
494 |
|
|
495 |
//set it failed again |
|
496 |
status = ReplicationStatus.FAILED; |
|
497 |
result = CNodeService.getInstance(request).setReplicationStatus(session, guid, replicaMemberNode, status, failure); |
|
498 |
assertTrue(result); |
|
499 |
// get it |
|
500 |
sysmeta = CNodeService.getInstance(request).getSystemMetadata(session, guid); |
|
501 |
BigInteger version2 = sysmeta.getSerialVersion(); |
|
502 |
System.out.println("the version of system metadata is "+version2.intValue()); |
|
503 |
assertTrue(version2.compareTo(version1) ==0); |
|
504 |
assertNotNull(sysmeta); |
|
505 |
// check it |
|
506 |
assertEquals(status, sysmeta.getReplica(0).getReplicationStatus()); |
|
507 |
|
|
508 |
//requeque it |
|
509 |
status = ReplicationStatus.QUEUED; |
|
510 |
result = CNodeService.getInstance(request).setReplicationStatus(session, guid, replicaMemberNode, status, failure); |
|
511 |
assertTrue(result); |
|
512 |
// get it |
|
513 |
sysmeta = CNodeService.getInstance(request).getSystemMetadata(session, guid); |
|
514 |
BigInteger version3 = sysmeta.getSerialVersion(); |
|
515 |
System.out.println("the version of system metadata is "+version3.intValue()); |
|
516 |
assertTrue(version3.compareTo(version2) ==1); |
|
517 |
assertNotNull(sysmeta); |
|
518 |
// check it |
|
519 |
assertEquals(status, sysmeta.getReplica(0).getReplicationStatus()); |
|
520 |
|
|
521 |
|
|
480 | 522 |
//Test the success of setReplicationStatus by a register mn subject |
481 | 523 |
Session mnSession = getMNSessionFromCN(); |
482 | 524 |
status = ReplicationStatus.COMPLETED; |
483 | 525 |
result = CNodeService.getInstance(request).setReplicationStatus(mnSession, guid, replicaMemberNode, status, failure); |
484 | 526 |
sysmeta = CNodeService.getInstance(request).getSystemMetadata(session, guid); |
527 |
BigInteger version4 = sysmeta.getSerialVersion(); |
|
528 |
System.out.println("the version of system metadata is "+version4.intValue()); |
|
529 |
assertTrue(version4.compareTo(version3) ==1); |
|
485 | 530 |
assertNotNull(sysmeta); |
486 | 531 |
// check it |
487 | 532 |
assertEquals(status, sysmeta.getReplica(0).getReplicationStatus()); |
Also available in: Unified diff
Add the test case to test the setting of same status twice wouldn't increase the system metadata version.