Revision 6882
Added by ben leinfelder over 12 years ago
CNodeServiceTest.java | ||
---|---|---|
38 | 38 |
import org.apache.commons.io.IOUtils; |
39 | 39 |
import org.dataone.client.D1Client; |
40 | 40 |
import org.dataone.service.exceptions.BaseException; |
41 |
import org.dataone.service.exceptions.InsufficientResources; |
|
42 | 41 |
import org.dataone.service.exceptions.NotAuthorized; |
43 | 42 |
import org.dataone.service.exceptions.NotFound; |
44 | 43 |
import org.dataone.service.exceptions.NotImplemented; |
... | ... | |
88 | 87 |
TestSuite suite = new TestSuite(); |
89 | 88 |
suite.addTest(new CNodeServiceTest("initialize")); |
90 | 89 |
|
91 |
suite.addTest(new CNodeServiceTest("testAssertRelation")); |
|
92 | 90 |
suite.addTest(new CNodeServiceTest("testChecksum")); |
93 | 91 |
suite.addTest(new CNodeServiceTest("testCreate")); |
94 | 92 |
suite.addTest(new CNodeServiceTest("testGet")); |
... | ... | |
218 | 216 |
} |
219 | 217 |
} |
220 | 218 |
|
221 |
public void testAssertRelation() { |
|
222 |
printTestHeader("testAssertRelation"); |
|
223 |
|
|
224 |
try { |
|
225 |
Session session = getTestSession(); |
|
226 |
Identifier guid = new Identifier(); |
|
227 |
guid.setValue("testAssertRelation." + System.currentTimeMillis()); |
|
228 |
InputStream object = new ByteArrayInputStream("test".getBytes("UTF-8")); |
|
229 |
SystemMetadata sysmeta = createSystemMetadata(guid, session.getSubject(), object); |
|
230 |
Identifier describePid = new Identifier(); |
|
231 |
describePid.setValue("describePid." + System.currentTimeMillis()); |
|
232 |
sysmeta.setObsoletes(describePid); |
|
233 |
// save it |
|
234 |
Identifier retGuid = CNodeService.getInstance(request).registerSystemMetadata(session, guid, sysmeta); |
|
235 |
assertEquals(guid.getValue(), retGuid.getValue()); |
|
236 |
// save the other |
|
237 |
InputStream object2 = new ByteArrayInputStream("test".getBytes("UTF-8")); |
|
238 |
SystemMetadata describeSysmeta = createSystemMetadata(describePid, session.getSubject(), object2); |
|
239 |
Identifier retDescribePid = CNodeService.getInstance(request).registerSystemMetadata(session, describePid, describeSysmeta); |
|
240 |
assertEquals(describePid.getValue(), retDescribePid.getValue()); |
|
241 |
// check it |
|
242 |
boolean result = CNodeService.getInstance(request).assertRelation(session, guid, "obsoletes", describePid); |
|
243 |
assertTrue(result); |
|
244 |
} catch(Exception e) { |
|
245 |
e.printStackTrace(); |
|
246 |
fail("Unexpected error: " + e.getMessage()); |
|
247 |
} |
|
248 |
} |
|
249 |
|
|
250 | 219 |
public void testChecksum() { |
251 | 220 |
printTestHeader("testChecksum"); |
252 | 221 |
|
Also available in: Unified diff
remove method: assertRelation
https://redmine.dataone.org/issues/2158