Revision 5387
Added by berkley about 14 years ago
CrudServiceTest.java | ||
---|---|---|
95 | 95 |
suite.addTest(new CrudServiceTest("testAccessControl")); |
96 | 96 |
suite.addTest(new CrudServiceTest("testGenerateMissingSystemMetadata")); |
97 | 97 |
suite.addTest(new CrudServiceTest("testGetLogRecords")); |
98 |
suite.addTest(new CrudServiceTest("testChecksumError")); |
|
98 | 99 |
return suite; |
99 | 100 |
} |
100 | 101 |
|
101 | 102 |
/** |
103 |
* test for an error where the checksum algorithm gets appended onto the checksum. |
|
104 |
*/ |
|
105 |
public void testChecksumError() |
|
106 |
{ |
|
107 |
printTestHeader("testChecksumError"); |
|
108 |
try |
|
109 |
{ |
|
110 |
Date d1 = new Date(); |
|
111 |
CrudService cs = CrudService.getInstance(); |
|
112 |
AuthToken token = getToken(); |
|
113 |
ObjectFormat of1 = ObjectFormat.convert("eml://ecoinformatics.org/eml-2.1.0"); |
|
114 |
//create docs at different times |
|
115 |
|
|
116 |
Identifier id = new Identifier(); |
|
117 |
String docid = generateDocumentId(); |
|
118 |
id.setValue(docid); |
|
119 |
|
|
120 |
//create the system metadata then run the create method |
|
121 |
String testDoc = getTestDoc(); |
|
122 |
StringBufferInputStream sbis = new StringBufferInputStream(testDoc); |
|
123 |
SystemMetadata sm = createSystemMetadata(id, testDoc, of1); |
|
124 |
assertFalse(sm.getChecksum().getValue().startsWith("MD5")); |
|
125 |
//create the doc |
|
126 |
Identifier idC = cs.create(token, id, sbis, sm); |
|
127 |
assertTrue(idC.getValue().equals(id.getValue())); |
|
128 |
SystemMetadata smC = getSystemMetadata(token, idC); |
|
129 |
assertFalse(smC.getChecksum().getValue().startsWith("MD5")); |
|
130 |
|
|
131 |
Date d2 = new Date(); |
|
132 |
ObjectList ol = cs.listObjects(token, d1, d2, of1); |
|
133 |
assertTrue(ol.sizeObjectInfoList() == 1); |
|
134 |
ObjectInfo oi = ol.getObjectInfo(0); |
|
135 |
//this will fail if the error state exists. |
|
136 |
assertFalse(oi.getChecksum().getValue().startsWith("MD5")); |
|
137 |
} |
|
138 |
catch(Exception e) |
|
139 |
{ |
|
140 |
fail("Unexpected exception: " + e.getMessage()); |
|
141 |
} |
|
142 |
|
|
143 |
} |
|
144 |
|
|
145 |
/** |
|
102 | 146 |
* test CrudService.getLogRecords |
103 | 147 |
*/ |
104 | 148 |
public void testGetLogRecords() |
... | ... | |
253 | 297 |
|
254 | 298 |
ObjectList list = cs.listObjects(token, null, null, null); |
255 | 299 |
//System.out.println("list size: " + list.sizeObjectInfoList()); |
256 |
|
|
300 |
|
|
257 | 301 |
//should return sm1 and sm2 |
258 | 302 |
ObjectList list1 = cs.listObjects(token, d1, d3, null); |
259 | 303 |
assertTrue(list1.sizeObjectInfoList() == 2); |
260 | 304 |
assertTrue(idInObjectList(id1, list1)); |
261 | 305 |
assertTrue(idInObjectList(id2, list1)); |
262 | 306 |
|
307 |
ObjectInfo info = list1.getObjectInfo(0); |
|
308 |
|
|
309 |
|
|
263 | 310 |
//should only return sm1 |
264 | 311 |
ObjectList list2 = cs.listObjects(token, d1, d3, of1); |
265 | 312 |
assertTrue(list2.sizeObjectInfoList() == 1); |
Also available in: Unified diff
fixed bug in metacat that allowed attribute data to be appended to element data in returnfields