Revision 6349
Added by ben leinfelder over 13 years ago
test/edu/ucsb/nceas/metacat/dataone/MockCNode.java | ||
---|---|---|
63 | 63 |
// always return true |
64 | 64 |
return true; |
65 | 65 |
} |
66 |
|
|
67 |
/** |
|
68 |
* we only want to test against ourselves |
|
69 |
*/ |
|
70 |
@Override |
|
71 |
public String lookupNodeBaseUrl(String nodeId) throws ServiceFailure, NotImplemented { |
|
72 |
|
|
73 |
try { |
|
74 |
return MNodeService.getInstance().getCapabilities().getBaseURL(); |
|
75 |
} catch (Exception e) { |
|
76 |
// TODO Auto-generated catch block |
|
77 |
e.printStackTrace(); |
|
78 |
} |
|
79 |
return null; |
|
80 |
} |
|
66 | 81 |
} |
test/edu/ucsb/nceas/metacat/dataone/MNodeServiceTest.java | ||
---|---|---|
470 | 470 |
} |
471 | 471 |
} |
472 | 472 |
|
473 |
/** |
|
474 |
* We currently expect this unit test to fail because it should rely on a different member node |
|
475 |
* to retrieve the object from. Currently it gets the object from itself and throws |
|
476 |
* and expected error for duplicate entry. |
|
477 |
* |
|
478 |
*/ |
|
473 | 479 |
public void testReplicate() { |
474 | 480 |
printTestHeader("testReplicate"); |
475 | 481 |
try { |
... | ... | |
480 | 486 |
SystemMetadata sysmeta = createSystemMetadata(guid, session.getSubject(), object); |
481 | 487 |
// save locally |
482 | 488 |
Identifier pid = MNodeService.getInstance().create(session, guid, object, sysmeta); |
483 |
// get our node reference (attempting to replicate with self |
|
489 |
// get our node reference (attempting to replicate with self)
|
|
484 | 490 |
NodeReference sourceNode = MNodeService.getInstance().getCapabilities().getIdentifier(); |
485 | 491 |
// attempt to replicate with ourselves -- this should fail! |
486 |
boolean result = MNodeService.getInstance().replicate(session, sysmeta, sourceNode ); |
|
492 |
boolean result = false; |
|
493 |
try { |
|
494 |
result = MNodeService.getInstance().replicate(session, sysmeta, sourceNode); |
|
495 |
} catch (Exception inu) { |
|
496 |
// we are expecting this to fail since we already have the doc |
|
497 |
result = true; |
|
498 |
} |
|
487 | 499 |
assertTrue(result); |
488 | 500 |
} catch (Exception e) { |
489 | 501 |
e.printStackTrace(); |
Also available in: Unified diff
include Mock version of looking up the base url for our own node - for testReplicate().
still expecting a failure during MN.replicate() since we are trying to add the replica to the same MN from which it came.