this.client.createCollection(XmlDbClientSetup.INSTANCE_NAME + "/" + XmlDbClientSetup.TEST_COLLECTION_NAME,
name, DOMParser.toDocument(cfg));
}
public void testRoundTrip() throws Exception {
Collection collection = client.getCollection(TEST_COLLECTION_PATH);
if (collection == null) {
throw new Exception("getCollection(" + TEST_COLLECTION_PATH + ") returned null");
}
/*
* Create a binary resource, save it in the 'current' collection,
* then retrieve it and verify that the data comes back right.
*/
Resource newResource = collection.createResource(null, "BinaryResource");
newResource.setContent(new byte[] { 0x00, 0x10, 0x01, 0x11 });
collection.storeResource(newResource);
String id = newResource.getId();
Resource foundResource = collection.getResource(id);
assertNotNull("We know you're in there...", foundResource);
assertEquals("The resource type is supposed be 'BinaryResource'", "BinaryResource", foundResource.getResourceType());
assertTrue("The resource is an instance of BinaryResource", foundResource instanceof BinaryResource);