Revision 9467
Added by Jing Tao about 9 years ago
test/edu/ucsb/nceas/metacattest/IdentifierManagerTest.java | ||
---|---|---|
89 | 89 |
suite.addTest(new IdentifierManagerTest("testGetHeadPID")); |
90 | 90 |
suite.addTest(new IdentifierManagerTest("testMediaType")); |
91 | 91 |
suite.addTest(new IdentifierManagerTest("testQuerySystemMetadata")); |
92 |
suite.addTest(new IdentifierManagerTest("testSystemMetadataPIDExists")); |
|
93 |
suite.addTest(new IdentifierManagerTest("testSystemMetadataSIDExists")); |
|
92 | 94 |
return suite; |
93 | 95 |
} |
94 | 96 |
/** |
... | ... | |
276 | 278 |
assertTrue(localid != null); |
277 | 279 |
} |
278 | 280 |
|
281 |
|
|
279 | 282 |
/** |
283 |
* Test the method systemMetadataPIDExist |
|
284 |
*/ |
|
285 |
public void testSystemMetadataPIDExists() throws Exception { |
|
286 |
Session session = getTestSession(); |
|
287 |
Identifier guid = new Identifier(); |
|
288 |
guid.setValue(generateDocumentId()); |
|
289 |
InputStream object = new ByteArrayInputStream("test".getBytes("UTF-8")); |
|
290 |
SystemMetadata sysmeta = createSystemMetadata(guid, session.getSubject(), object); |
|
291 |
MNodeService.getInstance(request).create(session, guid, object, sysmeta); |
|
292 |
boolean exist = IdentifierManager.getInstance().systemMetadataPIDExists(guid); |
|
293 |
assertTrue(exist); |
|
294 |
Thread.sleep(1000); |
|
295 |
guid.setValue(generateDocumentId()); |
|
296 |
exist = IdentifierManager.getInstance().systemMetadataPIDExists(guid); |
|
297 |
assertTrue(!exist); |
|
298 |
} |
|
299 |
|
|
300 |
/** |
|
301 |
* Test the method of systemMetadataSIDExist |
|
302 |
* @throws exception |
|
303 |
*/ |
|
304 |
public void testSystemMetadataSIDExists() throws Exception { |
|
305 |
Session session = getTestSession(); |
|
306 |
Identifier guid = new Identifier(); |
|
307 |
guid.setValue(generateDocumentId()); |
|
308 |
InputStream object = new ByteArrayInputStream("test".getBytes("UTF-8")); |
|
309 |
SystemMetadata sysmeta = createSystemMetadata(guid, session.getSubject(), object); |
|
310 |
String sid1= "sid."+System.nanoTime(); |
|
311 |
Identifier seriesId = new Identifier(); |
|
312 |
seriesId.setValue(sid1); |
|
313 |
System.out.println("the first sid is "+seriesId.getValue()); |
|
314 |
sysmeta.setSeriesId(seriesId); |
|
315 |
MNodeService.getInstance(request).create(session, guid, object, sysmeta); |
|
316 |
boolean exist = IdentifierManager.getInstance().systemMetadataPIDExists(guid); |
|
317 |
assertTrue(exist); |
|
318 |
exist = IdentifierManager.getInstance().systemMetadataSIDExists(guid); |
|
319 |
assertTrue(!exist); |
|
320 |
exist = IdentifierManager.getInstance().systemMetadataSIDExists(seriesId); |
|
321 |
assertTrue(exist); |
|
322 |
exist = IdentifierManager.getInstance().systemMetadataPIDExists(seriesId); |
|
323 |
assertTrue(!exist); |
|
324 |
Thread.sleep(1000); |
|
325 |
sid1= "sid."+System.nanoTime(); |
|
326 |
seriesId.setValue(sid1); |
|
327 |
exist = IdentifierManager.getInstance().systemMetadataSIDExists(seriesId); |
|
328 |
assertTrue(!exist); |
|
329 |
} |
|
330 |
/** |
|
280 | 331 |
* Test the method - getHeadPID for a speicified SID |
281 | 332 |
*/ |
282 | 333 |
public void testGetHeadPID() { |
Also available in: Unified diff
Add two new test methods to test systemMetadataPIDExists and systemMetadataSIDExists.