assertEquals(containerApi.get(containerName).getChildren().contains(dataObjectNameIn), false);
// exercise create data object with none cdmi put with payload file.
value = "Hello CDMI World non-cdmi File";
Files.write(value, tmpFileIn, Charsets.UTF_8);
payloadIn = new FilePayload(tmpFileIn);
payloadIn.setContentMetadata(BaseMutableContentMetadata.fromContentMetadata(payloadIn.getContentMetadata()
.toBuilder().contentType(MediaType.PLAIN_TEXT_UTF_8.toString()).build()));
dataNonCDMIContentTypeApi.create(dataObjectNameIn, payloadIn);
System.out.println(containerApi.get(containerName));
dataObject = dataApi.get(dataObjectNameIn);
assertNotNull(dataObject);
System.out.println(dataObject);
System.out.println("value: " + dataObject.getValueAsString());
assertEquals(dataObject.getValueAsString(), value);
tmpFileOut = dataObject.getValueAsFile(Files.createTempDir());
assertEquals(true, Files.equal(tmpFileOut, tmpFileIn));
tmpFileOut.delete();
assertEquals(dataObject.getUserMetadata().isEmpty(), true);
System.out.println("My Metadata: " + dataObject.getUserMetadata());
assertEquals(Integer.parseInt(dataObject.getSystemMetadata().get("cdmi_size")), value.length());
assertEquals(dataObject.getObjectName(), dataObjectNameIn);
assertEquals(dataObject.getObjectType(), "application/cdmi-object");
assertEquals(dataObject.getParentURI(), "/" + containerName);
assertEquals(containerApi.get(containerName).getChildren().contains(dataObjectNameIn), true);
payloadOut = dataNonCDMIContentTypeApi.getValue(dataObjectNameIn);
assertNotNull(payloadOut);
// assertEquals(Strings2.toString(payloadOut), value);
// byte[] _bytes = ByteStreams.toByteArray(payloadOut);
tmpFileOut = new File(Files.createTempDir(), "temp.txt");
is = payloadOut.openStream();
try {
Files.asByteSink(tmpFileOut).writeFrom(is);
} finally {
Closeables.closeQuietly(is);
}
assertEquals(Files.equal(tmpFileOut, tmpFileIn), true);
tmpFileOut.delete();
dataNonCDMIContentTypeApi.delete(dataObjectNameIn);
assertEquals(containerApi.get(containerName).getChildren().contains(dataObjectNameIn), false);
// exercise create data object with none cdmi put with text file payload file.
inFile = new File(System.getProperty("user.dir") + "/src/test/resources/container.json");
assertEquals(true, inFile.isFile());
payloadIn = new FilePayload(inFile);
payloadIn.setContentMetadata(BaseMutableContentMetadata.fromContentMetadata(payloadIn.getContentMetadata()
.toBuilder().contentType(MediaType.JSON_UTF_8.toString()).build()));
dataNonCDMIContentTypeApi.create(inFile.getName(), payloadIn);
System.out.println(containerApi.get(containerName));
dataObject = dataApi.get(inFile.getName());
assertNotNull(dataObject);
System.out.println(dataObject);
// System.out.println("value: " + dataObject.getValueAsString());
// assertEquals(dataObject.getValueAsString(), value);
tmpFileOut = dataObject.getValueAsFile(Files.createTempDir());
assertEquals(true, Files.equal(tmpFileOut, inFile));
tmpFileOut.delete();
assertEquals(dataObject.getUserMetadata().isEmpty(), true);
// System.out.println("My Metadata: "+dataObject.getUserMetadata());
assertEquals(Integer.parseInt(dataObject.getSystemMetadata().get("cdmi_size")), inFile.length());
assertEquals(dataObject.getObjectName(), inFile.getName());
assertEquals(dataObject.getObjectType(), "application/cdmi-object");
assertEquals(dataObject.getParentURI(), "/" + containerName);
assertEquals(containerApi.get(containerName).getChildren().contains(inFile.getName()), true);
dataApi.delete(inFile.getName());
assertEquals(containerApi.get(containerName).getChildren().contains(dataObjectNameIn), false);
// exercise create data object with none cdmi put with text file payload file.
// inFile = new File(System.getProperty("user.dir")
// + "/src/test/resources/Jellyfish.jpg"); // takes too long when working from home
inFile = new File(System.getProperty("user.dir") + "/src/test/resources/yellow-flowers.jpg");
assertEquals(true, inFile.isFile());
payloadIn = new FilePayload(inFile);
payloadIn.setContentMetadata(BaseMutableContentMetadata.fromContentMetadata(payloadIn.getContentMetadata()
.toBuilder().contentType(MediaType.JPEG.toString()).build()));
dataNonCDMIContentTypeApi.create(inFile.getName(), payloadIn);
System.out.println(containerApi.get(containerName));
// note dataApi.get when the data object is not a string