Revision 6097
Added by ben leinfelder almost 13 years ago
CrudServiceTest.java | ||
---|---|---|
109 | 109 |
suite.addTest(new CrudServiceTest("testDescribe")); |
110 | 110 |
suite.addTest(new CrudServiceTest("testDelete")); |
111 | 111 |
suite.addTest(new CrudServiceTest("testSemiColonsInIdentifiers")); |
112 |
suite.addTest(new CrudServiceTest("testGenerateMissingSystemMetadata")); |
|
113 | 112 |
return suite; |
114 | 113 |
} |
115 | 114 |
|
... | ... | |
422 | 421 |
} |
423 | 422 |
|
424 | 423 |
/** |
425 |
* test the generation of system metadata for docs that don't already |
|
426 |
* have it. This will be used for migration of existing object stores |
|
427 |
* to dataone. |
|
428 |
*/ |
|
429 |
public void testGenerateMissingSystemMetadata() |
|
430 |
{ |
|
431 |
printTestHeader("testGenerateMissingSystemMetadata"); |
|
432 |
try |
|
433 |
{ |
|
434 |
|
|
435 |
CrudService cs = CrudService.getInstance(); |
|
436 |
AuthToken token = getToken(); |
|
437 |
//create a document with no system metadata |
|
438 |
String testDoc = getTestDoc(); |
|
439 |
Identifier id = new Identifier(); |
|
440 |
String docid = generateDocumentId(); |
|
441 |
id.setValue(docid); |
|
442 |
|
|
443 |
cs.insertOrUpdateDocument(testDoc, id, cs.getSessionData(token), "insert", false); |
|
444 |
//try to get its system metadata, should fail |
|
445 |
try |
|
446 |
{ |
|
447 |
getSystemMetadata(token, id); |
|
448 |
fail("call to getSystemMetadata should have failed."); |
|
449 |
} |
|
450 |
catch(org.dataone.service.exceptions.NotFound e) |
|
451 |
{ |
|
452 |
// expect an exception of this type |
|
453 |
} |
|
454 |
|
|
455 |
//generate missing system metadata |
|
456 |
cs.generateMissingSystemMetadata(token); |
|
457 |
//try to get system metadata again, should succeed |
|
458 |
SystemMetadata smd = getSystemMetadata(token, id); |
|
459 |
assertTrue("SystemMetadata should not be null", smd != null); |
|
460 |
} |
|
461 |
catch(Exception e) |
|
462 |
{ |
|
463 |
System.out.println("testGenerateSystemMetadata *** exception trace:"); |
|
464 |
e.printStackTrace(); |
|
465 |
fail("Unexpected error generating missing system metadata: " + e.getClass() + ": " + e.getMessage()); |
|
466 |
} |
|
467 |
} |
|
468 |
|
|
469 |
/** |
|
470 | 424 |
* make sure that only valid sessions can update/delete |
471 | 425 |
*/ |
472 | 426 |
public void testAccessControl() |
Also available in: Unified diff
do not use XML files for storing SystemMetadata - use DB tables only.