Revision 9232
Added by Jing Tao over 9 years ago
test/edu/ucsb/nceas/metacattest/IdentifierManagerTest.java | ||
---|---|---|
29 | 29 |
import java.sql.SQLException; |
30 | 30 |
import java.util.*; |
31 | 31 |
|
32 |
import junit.framework.Test; |
|
33 |
import junit.framework.TestSuite; |
|
34 |
|
|
32 | 35 |
import org.dataone.client.v2.itk.D1Client; |
33 | 36 |
import org.dataone.service.types.v1.Identifier; |
34 | 37 |
import org.dataone.service.types.v1.NodeType; |
... | ... | |
60 | 63 |
public IdentifierManagerTest(String name) { |
61 | 64 |
super(name); |
62 | 65 |
} |
66 |
|
|
63 | 67 |
/** |
68 |
* Create a suite of tests to be run together |
|
69 |
*/ |
|
70 |
public static Test suite() { |
|
71 |
TestSuite suite = new TestSuite(); |
|
72 |
suite.addTest(new IdentifierManagerTest("initialize")); |
|
73 |
// Test basic functions |
|
74 |
suite.addTest(new IdentifierManagerTest("testGetGUID")); |
|
75 |
suite.addTest(new IdentifierManagerTest("testGetAllLocalIds")); |
|
76 |
suite.addTest(new IdentifierManagerTest("testGetInstance")); |
|
77 |
suite.addTest(new IdentifierManagerTest("testGetLocalId")); |
|
78 |
suite.addTest(new IdentifierManagerTest("testGetLocalIdNotFound")); |
|
79 |
suite.addTest(new IdentifierManagerTest("testIdentifierExists")); |
|
80 |
suite.addTest(new IdentifierManagerTest("testCreateMapping")); |
|
81 |
suite.addTest(new IdentifierManagerTest("testGenerateLocalId")); |
|
82 |
suite.addTest(new IdentifierManagerTest("testGetHeadPID")); |
|
83 |
|
|
84 |
return suite; |
|
85 |
} |
|
86 |
/** |
|
64 | 87 |
* Initialize the connection to metacat, and insert a document to be |
65 | 88 |
* used for testing with a known docid. |
66 | 89 |
*/ |
... | ... | |
322 | 345 |
try { |
323 | 346 |
CNodeService.getInstance(request).create(session, pid2_case2, object, sysmeta); |
324 | 347 |
fail("we shouldn't get here and an InvalidSystemMetacat exception should be thrown."); |
325 |
} catch (InvalidSystemMetadata e) {
|
|
348 |
} catch (Exception e) {
|
|
326 | 349 |
System.out.println("case 2======= Invalid system metadata to insert the second object"); |
327 | 350 |
//check |
328 | 351 |
meta = CNodeService.getInstance(request).getSystemMetadata(session, pid1_case2); |
... | ... | |
331 | 354 |
// the pid should be the newPid when we try to get the sid1 |
332 | 355 |
head = IdentifierManager.getInstance().getHeadPID(sid_case2); |
333 | 356 |
assertTrue(head.getValue().equals(pid1_case2.getValue())); |
334 |
} |
|
357 |
}
|
|
335 | 358 |
|
336 | 359 |
|
337 | 360 |
//case-3 P1(S1) <- P2(S1), S1 = P2, Discouraged, but not error condition, S1 = P2 (P1 and P2 are type 1 ends, not an ideal chain ) |
Also available in: Unified diff
Add the test suite.