* In each test method, there is an instance variable 'emf'
that is based off the properties provided by your test class.
* Test cases need to ensure that EMs are cleaned up
properly
* AbstractJPATest should clean up tables after test classes
complete, but it doesn't yet.
To run a new testcase:
* Either run the default target in
eclipselink.test.jpa.jse, providing db connection details in
test.properties
* To run in Eclipse, provide db connection details as
SystemProperties -Djavax.blah bah
Example test :
public class TestInheritancePrePersist extends
AbstractJPATest {
@Override
public Class<?>[] getManagedTypes() {
return new Class<?>[] { ChildEntity.class,
ParentEntity.class };
}
@Override
public String[] getPersistentProperties() {
return new String[] { "eclipselink.log", "FINE"
};
}
@Test
public void testMultiplePrePersist() {
EntityManager em = emf.createEntityManager();
try {
em.getTransaction().begin();
ChildEntity ce = new ChildEntity();
em.persist(ce);
em.getTransaction().commit();
em.clear();
Assert.assertEquals(1,
ce.getPrePersistChild());
Assert.assertEquals(1,
ce.getPrePersistParent());
} finally {
if (em.getTransaction().isActive()) {
em.getTransaction().rollback();
}
em.close();
}
}
...
Wow, that email got a lot longer than I intended. Anyway,
I'm looking for a thumbs up / thumbs down on the direction I'm
heading. If thumbs up, I'll start committing some code to
master later this week.
Thanks,
Rick