OPENJPA-1153: Speed tests up by using only needed entities rather than all entities from persistence.xml

git-svn-id: https://svn.apache.org/repos/asf/openjpa/trunk@826264 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Milosz Tylenda 2009-10-17 14:49:54 +00:00
parent 18f0e74899
commit c95593d8e2
6 changed files with 35 additions and 38 deletions

View File

@ -23,19 +23,18 @@ import javax.persistence.EntityManager;
import org.apache.openjpa.persistence.kernel.common.apps.AImplB;
import org.apache.openjpa.persistence.kernel.common.apps.RuntimeTest1;
import org.apache.openjpa.persistence.kernel.common.apps.RuntimeTest2;
import org.apache.openjpa.persistence.kernel.common.apps.RuntimeTest3;
import org.apache.openjpa.persistence.common.utils.AbstractTestCase;
public class TestEJBGetObjectByIdValue extends AbstractTestCase {
private Object[] oids;
public TestEJBGetObjectByIdValue(String name) {
super(name, "kernelcactusapp");
}
public void setUp() throws Exception {
deleteAll(RuntimeTest1.class);
deleteAll(AImplB.class);
super.setUp(RuntimeTest1.class, RuntimeTest2.class, RuntimeTest3.class, AImplB.class);
EntityManager em = currentEntityManager();
startTx(em);
@ -56,12 +55,12 @@ public class TestEJBGetObjectByIdValue extends AbstractTestCase {
endEm(em);
em = currentEntityManager();
pc = (RuntimeTest1) em.find(RuntimeTest1.class, 1);
pc = em.find(RuntimeTest1.class, 1);
assertEquals("foo", pc.getStringField());
em.close();
em = currentEntityManager();
pc = (RuntimeTest1) em.find(RuntimeTest1.class, pc.getIntField());
pc = em.find(RuntimeTest1.class, pc.getIntField());
assertEquals("foo", pc.getStringField());
endEm(em);
}
@ -78,12 +77,12 @@ public class TestEJBGetObjectByIdValue extends AbstractTestCase {
endEm(em);
em = currentEntityManager();
pc = (AImplB) em.find(AImplB.class, oid);
pc = em.find(AImplB.class, oid);
assertEquals("foo", pc.getName());
endEm(em);
em = currentEntityManager();
pc = (AImplB) em.find(AImplB.class, oid.toString());
pc = em.find(AImplB.class, oid.toString());
assertEquals("foo", pc.getName());
endEm(em);
}

View File

@ -24,6 +24,7 @@ import javax.persistence.EntityManager;
import org.apache.openjpa.persistence.kernel.common.apps.InterfaceHolder;
import org.apache.openjpa.persistence.kernel.common.apps.InterfaceTestImpl1;
import org.apache.openjpa.persistence.kernel.common.apps.InterfaceTestImpl2;
import org.apache.openjpa.persistence.kernel.common.apps.InterfaceTestImpl3;
import org.apache.openjpa.persistence.common.utils.AbstractTestCase;
/**
@ -37,16 +38,14 @@ public class TestEJBInterfaces extends AbstractTestCase {
super(name, "kernelcactusapp");
}
@Override
public void setUp() throws Exception {
super.setUp(InterfaceTestImpl1.class, InterfaceTestImpl2.class, InterfaceTestImpl3.class,
InterfaceHolder.class);
}
@SuppressWarnings("unchecked")
public void testInterfaceField() {
try {
deleteAll(InterfaceTestImpl1.class);
deleteAll(InterfaceTestImpl2.class);
deleteAll(InterfaceHolder.class);
}
catch (Exception e) {
}
EntityManager em2 = currentEntityManager();
startTx(em2);
@ -65,8 +64,7 @@ public class TestEJBInterfaces extends AbstractTestCase {
em = currentEntityManager();
startTx(em);
InterfaceHolder hold =
(InterfaceHolder) em.find(InterfaceHolder.class, 1);
InterfaceHolder hold = em.find(InterfaceHolder.class, 1);
assertNotNull(hold.getIntf());
assertEquals("intf-1-field", hold.getIntf().getStringField());
endTx(em);
@ -74,7 +72,7 @@ public class TestEJBInterfaces extends AbstractTestCase {
em = currentEntityManager();
startTx(em);
hold = (InterfaceHolder) em.find(InterfaceHolder.class, 1);
hold = em.find(InterfaceHolder.class, 1);
hold.setIntf(null);
assertNull(hold.getIntf());
endTx(em);
@ -82,14 +80,14 @@ public class TestEJBInterfaces extends AbstractTestCase {
em = currentEntityManager();
startTx(em);
hold = (InterfaceHolder) em.find(InterfaceHolder.class, 1);
hold = em.find(InterfaceHolder.class, 1);
assertNull(hold.getIntf());
endTx(em);
endEm(em);
em = currentEntityManager();
startTx(em);
hold = (InterfaceHolder) em.find(InterfaceHolder.class, 1);
hold = em.find(InterfaceHolder.class, 1);
hold.setIntf(new InterfaceTestImpl2("intf-2-field"));
assertEquals("intf-2-field", hold.getIntf().getStringField());
endTx(em);
@ -97,7 +95,7 @@ public class TestEJBInterfaces extends AbstractTestCase {
em = currentEntityManager();
startTx(em);
hold = (InterfaceHolder) em.find(InterfaceHolder.class, 1);
hold = em.find(InterfaceHolder.class, 1);
assertNotNull(hold.getIntf());
assertEquals("intf-2-field", hold.getIntf().getStringField());
endTx(em);
@ -105,7 +103,7 @@ public class TestEJBInterfaces extends AbstractTestCase {
em = currentEntityManager();
startTx(em);
hold = (InterfaceHolder) em.find(InterfaceHolder.class, 1);
hold = em.find(InterfaceHolder.class, 1);
hold.getIntfs().add(new InterfaceTestImpl1("intf-1-set"));
endTx(em);
endEm(em);

View File

@ -25,6 +25,8 @@ import javax.persistence.EntityManager;
import org.apache.openjpa.persistence.kernel.common.apps.RuntimeTest1;
import org.apache.openjpa.persistence.kernel.common.apps.RuntimeTest2;
import org.apache.openjpa.persistence.kernel.common.apps.RuntimeTest3;
import org.apache.openjpa.persistence.common.utils.AbstractTestCase;
public class TestEJBLocales extends AbstractTestCase {
@ -33,8 +35,8 @@ public class TestEJBLocales extends AbstractTestCase {
super(name, "kernelcactusapp");
}
public void setUp() {
deleteAll(RuntimeTest1.class);
public void setUp() throws Exception {
super.setUp(RuntimeTest1.class, RuntimeTest2.class, RuntimeTest3.class);
}
public void testLocales() {

View File

@ -30,8 +30,8 @@ public class TestEJBNullValues extends AbstractTestCase {
super(name, "kernelcactusapp");
}
public void setUp() {
deleteAll(Inner.class);
public void setUp() throws Exception {
super.setUp(Inner.class);
}
public void testException() {

View File

@ -27,14 +27,12 @@ import org.apache.openjpa.persistence.common.utils.AbstractTestCase;
public class TestEJBState extends AbstractTestCase {
private static final int INSERT_COUNT = 20;
public TestEJBState(String name) {
super(name, "kernelcactusapp");
}
public void setUp() {
deleteAll(AllFieldsTypeTest.class);
public void setUp() throws Exception {
super.setUp(AllFieldsTypeTest.class);
}
public void testBigDecimalsLoseTrailingZeros() {

View File

@ -20,14 +20,13 @@ package org.apache.openjpa.persistence.kernel;
import javax.persistence.EntityManager;
import org.apache.openjpa.persistence.kernel.common.apps.UnAnnotPojo;
import org.apache.openjpa.persistence.common.utils.AbstractTestCase;
/*
* @author Afam Okeke
* Ensures that pojo that is not persistent capable cannot be persisted.
*/
import org.apache.openjpa.persistence.kernel.common.apps.UnAnnotPojo;
/**
* Ensures that pojo that is not persistent capable cannot be persisted.
* @author Afam Okeke
*/
public class TestPojoWithoutAnnotationsCannotBePersisted
extends AbstractTestCase {
@ -37,7 +36,8 @@ public class TestPojoWithoutAnnotationsCannotBePersisted
super(name, "kernelcactusapp");
}
public void setUp() {
public void setUp() throws Exception {
super.setUp(new Object[] {});
pojo = new UnAnnotPojo();
pojo.setName("failure");
pojo.setNum(0);