@Test
public void deleteAndCreateContent() throws IOException {
// verify content
String path = "/" + Fixture.TEST_ROOT_FOLDER_NAME + "/" + FixtureData.DOCUMENT1_NAME;
Document document = (Document) this.session.getObjectByPath(path);
assertNotNull("Document not found: " + path, document);
// check default content
ContentStream contentStream = document.getContentStream();
assertNotNull(contentStream);
String contentString = this.getContentAsString(contentStream);
assertNotNull(contentString);
// delete and set new content
// ObjectId id = (return id not supported by AtomPub)
document.deleteContentStream();
// assertNotNull(id);
String filename = UUID.randomUUID().toString();
String mimetype = "text/html; charset=UTF-8";
String content1 = "Im Walde rauscht ein Wasserfall. Wenn's nicht mehr rauscht ist's Wasser all.";
byte[] buf1 = content1.getBytes("UTF-8");
ByteArrayInputStream in1 = new ByteArrayInputStream(buf1);
contentStream = this.session.getObjectFactory().createContentStream(filename, buf1.length, mimetype, in1);
assertNotNull(contentStream);
document.setContentStream(contentStream, true);
// check default content
ContentStream contentStream2 = document.getContentStream();
assertNotNull(contentStream2);
String contentString2 = this.getContentAsString(contentStream2);
assertNotNull(contentString2);
assertEquals(content1, contentString2);