ObjectContentManager ocm = this.getObjectContentManager();
//---------------------------------------------------------------------------------------------------------
// Insert a descendant object
//---------------------------------------------------------------------------------------------------------
Descendant descendant = new Descendant();
descendant.setDescendantField("descendantValue");
descendant.setAncestorField("ancestorValue");
descendant.setIntField(200);
descendant.setPath("/test");
ocm.insert(descendant);
ocm.save();
//---------------------------------------------------------------------------------------------------------
// Retrieve a descendant object
//---------------------------------------------------------------------------------------------------------
descendant = null;
descendant = (Descendant) ocm.getObject( "/test");
assertEquals("Descendant path is invalid", descendant.getPath(), "/test");
assertEquals("Descendant ancestorField is invalid", descendant.getAncestorField(), "ancestorValue");
assertEquals("Descendant descendantField is invalid", descendant.getDescendantField(), "descendantValue");
assertEquals("Descendant intField is invalid", descendant.getIntField(), 200);
//---------------------------------------------------------------------------------------------------------
// Update a descendant object
//---------------------------------------------------------------------------------------------------------
descendant.setAncestorField("anotherAncestorValue");
descendant.setIntField(123);
ocm.update(descendant);
ocm.save();
//---------------------------------------------------------------------------------------------------------
// Retrieve the updated descendant object
//---------------------------------------------------------------------------------------------------------
descendant = null;
descendant = (Descendant) ocm.getObject( "/test");
assertEquals("Descendant path is invalid", descendant.getPath(), "/test");
assertEquals("Descendant ancestorField is invalid", descendant.getAncestorField(), "anotherAncestorValue");
assertEquals("Descendant descendantField is invalid", descendant .getDescendantField(), "descendantValue");
assertEquals("Descendant intField is invalid", descendant.getIntField(), 123);
Ancestor ancestor = (Ancestor) ocm.getObject("/test");
assertTrue("Invalid object instance", ancestor instanceof Descendant );
assertEquals("Ancestor path is invalid", ancestor.getPath(), "/test");
assertEquals("Ancestor ancestorField is invalid", ancestor.getAncestorField(), "anotherAncestorValue");