ObjectContentManager ocm = this.getObjectContentManager();
//---------------------------------------------------------------------------------------------------------
// Insert a Document
//---------------------------------------------------------------------------------------------------------
DocumentExtImpl document = new DocumentExtImpl();
document.setPath("/document1");
document.setExtInfo("ext info");
document.setName("document name");
document.setContentType("plain/text");
DocumentStream documentStream = new DocumentStream();
documentStream.setEncoding("utf-8");
documentStream.setContent("Test Content".getBytes());
document.setDocumentStream(documentStream);
ocm.insert(document);
ocm.save();
//---------------------------------------------------------------------------------------------------------
// Retrieve a document object
//---------------------------------------------------------------------------------------------------------
CmsObject cmsObject = (CmsObject) ocm.getObject( CmsObject.class, "/document1" );
assertNotNull("Document not loaded", cmsObject);
assertTrue("Document of wrong type " + cmsObject.getClass().getName(), cmsObject instanceof DocumentExtImpl);
document = (DocumentExtImpl) cmsObject;
assertEquals("Document path is invalid", document.getPath(), "/document1");
assertEquals("Ext Info is invalid", document.getExtInfo(), "ext info");
assertEquals("Content type is invalid", document.getContentType(), "plain/text");
assertNotNull("document stream is null", document.getDocumentStream());
assertTrue("Invalid document stream ", document.getDocumentStream().getEncoding().equals("utf-8"));
} catch (Exception e) {
e.printStackTrace();
fail();
}