use of org.jpox.samples.abstractclasses.AbstractSimpleClassHolder in project tests by datanucleus.
the class AbstractClassesTest method perform1to1CreationSimple.
/*
*/
/**
* Check the persistence of abstract objects and their holders.
*/
/*
public void testCreationComposite()
throws Exception
{
try
{
perform1to1CreationComposite();
}
finally
{
clean(AbstractCompositeClassHolder.class);
clean(ConcreteCompositeSub1.class);
clean(ConcreteCompositeSub2.class);
}
}
*/
/**
* Test of the retrieval of the abstract contained objects and of the
* holder with its related abstract object.
*/
/*
public void testRetrievalComposite()
throws Exception
{
try
{
perform1to1CreationComposite();
perform1to1Retrieval(AbstractCompositeClassHolder.class, AbstractCompositeBase.class,
ConcreteCompositeSub1.class, ConcreteCompositeSub2.class);
}
finally
{
clean(AbstractCompositeClassHolder.class);
clean(ConcreteCompositeSub1.class);
clean(ConcreteCompositeSub2.class);
}
}
*/
/**
* Test of the query of the abstract contained objects and of the
* holder with its related abstract object.
*/
/*
public void testQueryComposite()
throws Exception
{
try
{
perform1to1CreationComposite();
perform1to1Query(AbstractCompositeClassHolder.class, AbstractCompositeBase.class,
ConcreteCompositeSub2.class, ConcreteCompositeSub2.class);
}
finally
{
clean(AbstractCompositeClassHolder.class);
clean(ConcreteCompositeSub1.class);
clean(ConcreteCompositeSub2.class);
}
}
*/
/**
* Test of the deletion of the abstract contained objects and its holder.
*/
/*
public void testDeletionComposite()
throws Exception
{
try
{
perform1to1CreationComposite();
perform1to1Deletion(AbstractCompositeClassHolder.class, AbstractCompositeBase.class,
ConcreteCompositeSub1.class, ConcreteCompositeSub2.class);
}
finally
{
clean(AbstractSimpleClassHolder.class);
clean(ConcreteSimpleSub1.class);
clean(ConcreteSimpleSub2.class);
}
}
*/
/**
* Test for having abstract elements in a join-table Set, and creating container/elements.
*/
/*
public void testJoinTableSetCreationComposite()
throws Exception
{
try
{
perform1toNJoinTableSetCreationComposite();
}
finally
{
clean(AbstractCompositeClassHolder.class);
clean(AbstractCompositeBase.class);
clean(ConcreteCompositeSub1.class);
clean(ConcreteCompositeSub2.class);
}
}
*/
/**
* Test of the retrieval of the abstract contained objects within a Set.
*/
/*
public void testJoinTableSetRetrievalComposite()
throws Exception
{
try
{
perform1toNJoinTableSetCreationComposite();
perform1toNJoinTableSetRetrieval(AbstractCompositeClassHolder.class);
}
finally
{
clean(AbstractCompositeClassHolder.class);
clean(AbstractCompositeBase.class);
clean(ConcreteCompositeSub1.class);
clean(ConcreteCompositeSub2.class);
}
}
*/
/**
* Test for having abstract elements in a join-table List, and creating container/elements.
*/
/*
public void testJoinTableListCreationComposite()
throws Exception
{
try
{
perform1toNJoinTableListCreationComposite();
}
finally
{
clean(AbstractCompositeClassHolder.class);
clean(AbstractCompositeBase.class);
clean(ConcreteCompositeSub1.class);
clean(ConcreteCompositeSub2.class);
}
}
*/
/**
* Test of the retrieval of the abstract contained objects within a List.
*/
/*
public void testJoinTableListRetrievalComposite()
throws Exception
{
try
{
perform1toNJoinTableListCreationComposite();
perform1toNJoinTableListRetrieval(AbstractCompositeClassHolder.class,
ConcreteCompositeSub1.class, ConcreteCompositeSub2.class);
}
finally
{
clean(AbstractCompositeClassHolder.class);
clean(AbstractCompositeBase.class);
clean(ConcreteCompositeSub1.class);
clean(ConcreteCompositeSub2.class);
}
}
*/
// ------------------------------------------- Utility Methods ---------------------------------------------
/**
* Convenience method to create 2 holders with ConcreteSimpleSub1, ConcreteSimpleSub2 related objects.
*/
private void perform1to1CreationSimple() throws Exception {
PersistenceManager pm = pmf.getPersistenceManager();
Transaction tx = pm.currentTransaction();
try {
// Persist 2 1-1 relations using both concrete subclass types
tx.begin();
AbstractSimpleClassHolder holder1 = new AbstractSimpleClassHolder(1);
ConcreteSimpleSub1 sub1 = new ConcreteSimpleSub1(1);
sub1.setBaseField("Base1");
sub1.setSub1Field("Sub1");
holder1.setAbstract1(sub1);
pm.makePersistent(holder1);
AbstractSimpleClassHolder holder2 = new AbstractSimpleClassHolder(2);
ConcreteSimpleSub2 sub2 = new ConcreteSimpleSub2(2);
sub2.setBaseField("Base2");
sub2.setSub2Field("Sub2");
holder2.setAbstract1(sub2);
pm.makePersistent(holder2);
tx.commit();
assertTrue("Id of Abstract object ConcreteSimpleSub1 was null!", pm.getObjectId(sub1) != null);
assertTrue("Id of Abstract object ConcreteSimpleSub2 was null!", pm.getObjectId(sub1) != null);
assertTrue("Id of holder1 was null!", pm.getObjectId(holder1) != null);
assertTrue("Id of holder2 was null!", pm.getObjectId(holder2) != null);
} catch (Exception e) {
LOG.error("Exception thrown persisting objects with abstract superclass", e);
e.printStackTrace();
fail("Exception thrown during persistence : " + e.getMessage());
} finally {
if (tx.isActive()) {
tx.rollback();
}
pm.close();
}
}
use of org.jpox.samples.abstractclasses.AbstractSimpleClassHolder in project tests by datanucleus.
the class AbstractClassesTest method perform1toNJoinTableSetCreationSimple.
/**
* Convenience method to persist a holder with 2 elements in the set field.
*/
private void perform1toNJoinTableSetCreationSimple() throws Exception {
PersistenceManager pm = pmf.getPersistenceManager();
Transaction tx = pm.currentTransaction();
try {
// Persist holder with 2 elements in the Set field
tx.begin();
AbstractSimpleClassHolder holder = new AbstractSimpleClassHolder(1);
ConcreteSimpleSub1 sub1 = new ConcreteSimpleSub1(1);
sub1.setBaseField("Base1");
sub1.setSub1Field("Sub1");
holder.getAbstractSet1().add(sub1);
ConcreteSimpleSub2 sub2 = new ConcreteSimpleSub2(2);
sub2.setBaseField("Base2");
sub2.setSub2Field("Sub2");
holder.getAbstractSet1().add(sub2);
pm.makePersistent(holder);
tx.commit();
assertTrue("Id of Abstract object ConcreteSimpleSub1 was null!", pm.getObjectId(sub1) != null);
assertTrue("Id of Abstract object ConcreteSimpleSub2 was null!", pm.getObjectId(sub1) != null);
assertTrue("Id of holder was null!", pm.getObjectId(holder) != null);
} catch (Exception e) {
LOG.error("Exception thrown persisting objects with abstract superclass", e);
e.printStackTrace();
fail("Exception thrown during persistence : " + e.getMessage());
} finally {
if (tx.isActive()) {
tx.rollback();
}
pm.close();
}
}
use of org.jpox.samples.abstractclasses.AbstractSimpleClassHolder in project tests by datanucleus.
the class AbstractClassesTest method perform1toNJoinTableListCreationSimple.
/**
* Convenience method to persist a holder with 2 elements in the list field.
*/
private void perform1toNJoinTableListCreationSimple() throws Exception {
PersistenceManager pm = pmf.getPersistenceManager();
Transaction tx = pm.currentTransaction();
try {
// Persist holder with 2 elements in the List field
tx.begin();
AbstractSimpleClassHolder holder = new AbstractSimpleClassHolder(1);
ConcreteSimpleSub1 sub1 = new ConcreteSimpleSub1(1);
sub1.setBaseField("Base1");
sub1.setSub1Field("Sub1");
holder.getAbstractList1().add(sub1);
ConcreteSimpleSub2 sub2 = new ConcreteSimpleSub2(2);
sub2.setBaseField("Base2");
sub2.setSub2Field("Sub2");
holder.getAbstractList1().add(sub2);
pm.makePersistent(holder);
tx.commit();
assertTrue("Id of Abstract object ConcreteSimpleSub1 was null!", pm.getObjectId(sub1) != null);
assertTrue("Id of Abstract object ConcreteSimpleSub2 was null!", pm.getObjectId(sub1) != null);
assertTrue("Id of holder was null!", pm.getObjectId(holder) != null);
} catch (Exception e) {
LOG.error("Exception thrown persisting objects with abstract superclass", e);
e.printStackTrace();
fail("Exception thrown during persistence : " + e.getMessage());
} finally {
if (tx.isActive()) {
tx.rollback();
}
pm.close();
}
}
Aggregations