// exercise create data object with none cdmi put with payload inputStream riginating from
// string.
value = "Hello CDMI World non-cdmi inputStream originating from string";
is = new ByteArrayInputStream(value.getBytes());
payloadIn = new InputStreamPayload(is);
payloadIn.setContentMetadata(BaseMutableContentMetadata.fromContentMetadata(payloadIn.getContentMetadata()
.toBuilder().contentType(MediaType.PLAIN_TEXT_UTF_8.toString())
.contentLength(new Long(value.length())).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);
assertNotNull(dataObject.getValueAsInputSupplier());
assertEquals(CharStreams.toString(CharStreams.newReaderSupplier(
dataObject.getValueAsInputSupplier(Charsets.UTF_8), Charsets.UTF_8)), value);
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);
dataNonCDMIContentTypeApi.delete(dataObjectNameIn);
assertEquals(containerApi.get(containerName).getChildren().contains(dataObjectNameIn), false);
// exercise create data object with none cdmi put with payload inputStream originating from
// jpeg file.
inFile = new File(System.getProperty("user.dir") + "/src/test/resources/yellow-flowers.jpg");
assertEquals(true, inFile.isFile());
FileInputStream fileInputStream = new FileInputStream(inFile);
payloadIn = new InputStreamPayload(fileInputStream);
payloadIn.setContentMetadata(BaseMutableContentMetadata.fromContentMetadata(payloadIn.getContentMetadata()
.toBuilder().contentType(MediaType.JPEG.toString()).contentLength(new Long(inFile.length())).build()));
dataNonCDMIContentTypeApi.create(inFile.getName(), payloadIn);
System.out.println(containerApi.get(containerName));
payloadOut = dataNonCDMIContentTypeApi.getValue(inFile.getName());