/*
* 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);
byte[] newBytes = (byte[]) newResource.getContent();
byte[] foundBytes = (byte[]) foundResource.getContent();
assertEquals("The size of the found and saved resource should be the same...", newBytes.length, foundBytes.length);
for (int i = 0; i < newBytes.length; ++i) {
assertEquals("The resources differ in byte " + i, newBytes[i], foundBytes[i]);
}