Revision 6069
Added by rnahf over 13 years ago
test/edu/ucsb/nceas/metacat/dataone/CrudServiceTest.java | ||
---|---|---|
34 | 34 |
import junit.framework.TestSuite; |
35 | 35 |
|
36 | 36 |
import org.apache.commons.io.IOUtils; |
37 |
import org.dataone.service.exceptions.BaseException; |
|
38 |
import org.dataone.service.exceptions.NotFound; |
|
37 | 39 |
import org.dataone.service.types.AuthToken; |
38 | 40 |
import org.dataone.service.types.Checksum; |
39 | 41 |
import org.dataone.service.types.ChecksumAlgorithm; |
... | ... | |
93 | 95 |
{ |
94 | 96 |
TestSuite suite = new TestSuite(); |
95 | 97 |
suite.addTest(new CrudServiceTest("initialize")); |
98 |
|
|
96 | 99 |
suite.addTest(new CrudServiceTest("testSingletonAccessor")); |
97 | 100 |
suite.addTest(new CrudServiceTest("testCreateAndGet")); |
98 | 101 |
suite.addTest(new CrudServiceTest("testGetSystemMetadata")); |
... | ... | |
445 | 448 |
getSystemMetadata(token, id); |
446 | 449 |
fail("call to getSystemMetadata should have failed."); |
447 | 450 |
} |
448 |
catch(Exception e) |
|
449 |
{} |
|
451 |
catch(org.dataone.service.exceptions.NotFound e) |
|
452 |
{ |
|
453 |
// expect an exception of this type |
|
454 |
} |
|
450 | 455 |
|
451 | 456 |
//generate missing system metadata |
452 | 457 |
cs.generateMissingSystemMetadata(token); |
453 | 458 |
//try to get system metadata again, should succeed |
454 |
getSystemMetadata(token, id); |
|
459 |
SystemMetadata smd = getSystemMetadata(token, id); |
|
460 |
assertTrue("SystemMetadata should not be null", smd != null); |
|
455 | 461 |
} |
456 | 462 |
catch(Exception e) |
457 | 463 |
{ |
458 |
fail("Unexpected error generating missing system metadata: " + e.getMessage()); |
|
464 |
System.out.println("testGenerateSystemMetadata *** exception trace:"); |
|
465 |
e.printStackTrace(); |
|
466 |
fail("Unexpected error generating missing system metadata: " + e.getClass() + ": " + e.getMessage()); |
|
459 | 467 |
} |
460 | 468 |
} |
461 | 469 |
|
... | ... | |
783 | 791 |
* return the systemMetadata object for id |
784 | 792 |
*/ |
785 | 793 |
private SystemMetadata getSystemMetadata(AuthToken token, Identifier id) |
786 |
throws Exception |
|
794 |
throws BaseException
|
|
787 | 795 |
{ |
788 | 796 |
CrudService cs = CrudService.getInstance(); |
789 | 797 |
return cs.getSystemMetadata(token, id); |
Also available in: Unified diff
updating CrudServiceTest with better exception handling (more specific) to match refactored CrudService.java class