openjpa-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mtyle...@apache.org
Subject svn commit: r819658 - /openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/kernel/
Date Mon, 28 Sep 2009 17:37:54 GMT
Author: mtylenda
Date: Mon Sep 28 17:37:54 2009
New Revision: 819658

URL: http://svn.apache.org/viewvc?rev=819658&view=rev
Log:
OPENJPA-1153: Speed tests up by using only needed entities rather than all entities from persistence.xml

Modified:
    openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/kernel/TestFetchGroups.java
    openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/kernel/TestFieldState.java
    openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/kernel/TestIncrementalFlushesDeletes.java
    openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/kernel/TestInheritance.java
    openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/kernel/TestInitialValueFetching.java
    openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/kernel/TestPCClass.java
    openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/kernel/TestPessimisticLocking.java
    openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/kernel/TestProxies2.java

Modified: openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/kernel/TestFetchGroups.java
URL: http://svn.apache.org/viewvc/openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/kernel/TestFetchGroups.java?rev=819658&r1=819657&r2=819658&view=diff
==============================================================================
--- openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/kernel/TestFetchGroups.java
(original)
+++ openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/kernel/TestFetchGroups.java
Mon Sep 28 17:37:54 2009
@@ -68,8 +68,9 @@
     public TestFetchGroups() {
     }
 
-    public void setUp() {
-        deleteAll(FetchGroupTestObject.class);
+    public void setUp() throws Exception {
+        super.setUp(FetchGroupTestObject.class, FetchGroupTestObjectChild.class,
+            AttachA.class, AttachB.class, AttachC.class, AttachD.class, AttachE.class, AttachF.class);
 
         FetchGroupTestObject o1 = new FetchGroupTestObject();
         // the value that 'a' is set to is important -- TestFetchGroupsExtent
@@ -128,8 +129,7 @@
         props.put("openjpa.FetchGroups", "default,fg1,fg2");
         OpenJPAEntityManagerFactory factory = getEmf(props);
 
-        OpenJPAEntityManager pm =
-            (OpenJPAEntityManager) factory.createEntityManager();
+        OpenJPAEntityManager pm = factory.createEntityManager();
         checkGroups(pm, new String[]{ "fg1", "fg2" });
         factory.close();
     }
@@ -359,16 +359,7 @@
      * managed object.
      */
     public void testFetchGroupInstantiated() {
-        deleteAll(AttachA.class);
-        deleteAll(AttachB.class);
-        deleteAll(AttachC.class);
-        deleteAll(AttachD.class);
-        deleteAll(AttachE.class);
-        deleteAll(AttachF.class);
-
-        OpenJPAEntityManager pm;
-
-        pm = getPM();
+        OpenJPAEntityManager pm = getPM();
         startTx(pm);
         AttachE e = new AttachE();
         AttachB b = new AttachB();
@@ -378,12 +369,10 @@
         endTx(pm);
         endEm(pm);
 
-        Object ob;
-
         pm = getPM();
         startTx(pm);
         assertSize(0, pm.getManagedObjects());
-        ob = pm.createExtent(AttachE.class, true).iterator().next();
+        pm.createExtent(AttachE.class, true).iterator().next();
         // make sure relation is not loaded
         assertSize(1, pm.getManagedObjects());
         rollbackTx(pm);
@@ -394,7 +383,7 @@
         // now make sure we load relations
         pm.getFetchPlan().addFetchGroup("all");
         assertSize(0, pm.getManagedObjects());
-        ob = pm.createExtent(AttachE.class, true).iterator().next();
+        pm.createExtent(AttachE.class, true).iterator().next();
         // make sure relation is loaded
         assertSize(2, pm.getManagedObjects());
         rollbackTx(pm);

Modified: openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/kernel/TestFieldState.java
URL: http://svn.apache.org/viewvc/openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/kernel/TestFieldState.java?rev=819658&r1=819657&r2=819658&view=diff
==============================================================================
--- openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/kernel/TestFieldState.java
(original)
+++ openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/kernel/TestFieldState.java
Mon Sep 28 17:37:54 2009
@@ -30,6 +30,8 @@
 
 
 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.kernel.OpenJPAStateManager;
 import org.apache.openjpa.meta.FieldMetaData;
@@ -49,8 +51,8 @@
         super(name);
     }
 
-    public void setUp() {
-        deleteAll(RuntimeTest1.class);
+    public void setUp() throws Exception {
+        super.setUp(RuntimeTest1.class, RuntimeTest2.class, RuntimeTest3.class);
 
         OpenJPAEntityManager pm = getPM();
         startTx(pm);
@@ -69,7 +71,7 @@
         OpenJPAEntityManager pm = getPM();
         startTx(pm);
 
-        RuntimeTest1 a = (RuntimeTest1) pm.find(RuntimeTest1.class, oid);
+        RuntimeTest1 a = pm.find(RuntimeTest1.class, oid);
         a.setStringField(a.getStringField());
         OpenJPAStateManager sm = getStateManager(a, pm);
         FieldMetaData fmd = sm.getMetaData().getField("stringField");

Modified: openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/kernel/TestIncrementalFlushesDeletes.java
URL: http://svn.apache.org/viewvc/openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/kernel/TestIncrementalFlushesDeletes.java?rev=819658&r1=819657&r2=819658&view=diff
==============================================================================
--- openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/kernel/TestIncrementalFlushesDeletes.java
(original)
+++ openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/kernel/TestIncrementalFlushesDeletes.java
Mon Sep 28 17:37:54 2009
@@ -30,6 +30,8 @@
 
 
 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.kernel.OpenJPAStateManager;
 import org.apache.openjpa.kernel.PCState;
@@ -51,8 +53,8 @@
     public TestIncrementalFlushesDeletes() {
     }
 
-    public void setUp() {
-        deleteAll(RuntimeTest1.class);
+    public void setUp() throws Exception {
+        super.setUp(RuntimeTest1.class, RuntimeTest2.class, RuntimeTest3.class);
 
         pm = getPM(true, false);
         startTx(pm);

Modified: openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/kernel/TestInheritance.java
URL: http://svn.apache.org/viewvc/openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/kernel/TestInheritance.java?rev=819658&r1=819657&r2=819658&view=diff
==============================================================================
--- openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/kernel/TestInheritance.java
(original)
+++ openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/kernel/TestInheritance.java
Mon Sep 28 17:37:54 2009
@@ -51,9 +51,7 @@
 
     public void setUp()
         throws Exception {
-        deleteAll(RuntimeTest1.class);
-        deleteAll(RuntimeTest2.class);
-        deleteAll(RuntimeTest3.class);
+        super.setUp(RuntimeTest1.class, RuntimeTest2.class, RuntimeTest3.class);
 
         // create some instances to query on
         OpenJPAEntityManager pm = getPM();
@@ -71,7 +69,7 @@
     public void testGetAllRuntimeTest1s() {
         OpenJPAEntityManager pm = getPM();
         OpenJPAQuery q = pm.createQuery("SELECT o FROM RuntimeTest1 o");
-        Collection c = (Collection) q.getResultList();
+        Collection c = q.getResultList();
         assertEquals(3, c.size());
         endEm(pm);
     }
@@ -82,7 +80,7 @@
     public void testGetAllRuntimeTest2s() {
         OpenJPAEntityManager pm = getPM();
         OpenJPAQuery q = pm.createQuery("SELECT o FROM RuntimeTest2 o");
-        Collection c = (Collection) q.getResultList();
+        Collection c = q.getResultList();
         assertEquals(2, c.size());
         endEm(pm);
     }
@@ -93,7 +91,7 @@
     public void testGetAllRuntimeTest3s() {
         OpenJPAEntityManager pm = getPM();
         OpenJPAQuery q = pm.createQuery("SELECT o FROM RuntimeTest3 o");
-        Collection c = (Collection) q.getResultList();
+        Collection c = q.getResultList();
         assertEquals(1, c.size());
         endEm(pm);
     }
@@ -109,7 +107,7 @@
 //        OpenJPAQuery q = pm.createNativeQuery("",RuntimeTest1.class);
 //        FIXME jthomas
 //        q.setCandidates(pm.getExtent(RuntimeTest1.class, false));
-        Collection c = (Collection) q.getResultList();
+        Collection c = q.getResultList();
         assertEquals(1, c.size());
         endEm(pm);
     }
@@ -125,7 +123,7 @@
 //        FIXME jthomas        
 //        OpenJPAQuery q = pm.createNativeQuery("",RuntimeTest2.class);
 //        q.setCandidates(pm.createExtent(RuntimeTest2.class, false));
-        Collection c = (Collection) q.getResultList();
+        Collection c = q.getResultList();
         assertEquals(1, c.size());
         endEm(pm);
     }
@@ -141,7 +139,7 @@
 //      FIXME jthomas
 //        OpenJPAQuery q = pm.createNativeQuery("",RuntimeTest3.class);
 //        q.setCandidates(pm.getExtent(RuntimeTest3.class, false));
-        Collection c = (Collection) q.getResultList();
+        Collection c = q.getResultList();
         assertEquals(1, c.size());
         endEm(pm);
     }

Modified: openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/kernel/TestInitialValueFetching.java
URL: http://svn.apache.org/viewvc/openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/kernel/TestInitialValueFetching.java?rev=819658&r1=819657&r2=819658&view=diff
==============================================================================
--- openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/kernel/TestInitialValueFetching.java
(original)
+++ openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/kernel/TestInitialValueFetching.java
Mon Sep 28 17:37:54 2009
@@ -34,6 +34,8 @@
 
 
 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.test.AllowFailure;
 
 import org.apache.openjpa.kernel.OpenJPAStateManager;
@@ -52,8 +54,8 @@
         super(name);
     }
 
-    public void setUp() {
-        deleteAll(RuntimeTest1.class);
+    public void setUp() throws Exception {
+        super.setUp(RuntimeTest1.class, RuntimeTest2.class, RuntimeTest3.class);
         OpenJPAEntityManager pm = getPM();
         startTx(pm);
         RuntimeTest1 rt1 = new RuntimeTest1("TestInitialValueFetching", 10);
@@ -102,14 +104,12 @@
     public void testInitialValueMutableValueFailures() {
         Map props = new HashMap();
         props.put("openjpa.RestoreMutableValues", "false");
-        OpenJPAEntityManagerFactory pmf = (OpenJPAEntityManagerFactory)
-            getEmf(props);
+        OpenJPAEntityManagerFactory pmf = getEmf(props);
 
-        OpenJPAEntityManager pm = (OpenJPAEntityManager)
-            pmf.createEntityManager();
+        OpenJPAEntityManager pm = pmf.createEntityManager();
         RuntimeTest1 rt1 = getObject(pm);
 
-        Date d = rt1.getDateField();
+        rt1.getDateField();
         OpenJPAStateManager sm = getStateManager(rt1, pm);
         FieldMetaData fmd = sm.getMetaData().getField("dateField");
         try {
@@ -126,10 +126,8 @@
     public void testInitialValueDate() {
         Map props = new HashMap();
         props.put("openjpa.RestoreState", "all");
-        OpenJPAEntityManagerFactory pmf = (OpenJPAEntityManagerFactory)
-            getEmf(props);
-        OpenJPAEntityManager pm = (OpenJPAEntityManager)
-            pmf.createEntityManager();
+        OpenJPAEntityManagerFactory pmf = getEmf(props);
+        OpenJPAEntityManager pm = pmf.createEntityManager();
         startTx(pm);
         RuntimeTest1 rt1 = getObject(pm);
 

Modified: openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/kernel/TestPCClass.java
URL: http://svn.apache.org/viewvc/openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/kernel/TestPCClass.java?rev=819658&r1=819657&r2=819658&view=diff
==============================================================================
--- openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/kernel/TestPCClass.java
(original)
+++ openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/kernel/TestPCClass.java
Mon Sep 28 17:37:54 2009
@@ -52,8 +52,8 @@
         super(test);
     }
 
-    public void setUp() {
-        deleteAll(PCClassPC.class);
+    public void setUp() throws Exception {
+        super.setUp(PCClassPC.class);
     }
 
     public void testMetaData() {
@@ -138,7 +138,7 @@
 
         pm = getPM();
 
-        pc = (PCClassPC) pm.find(PCClassPC.class, oid);
+        pc = pm.find(PCClassPC.class, oid);
 
         assertTrue(pc == pc.getSpecificPC());
         assertTrue(pc == pc.getGenericPC());

Modified: openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/kernel/TestPessimisticLocking.java
URL: http://svn.apache.org/viewvc/openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/kernel/TestPessimisticLocking.java?rev=819658&r1=819657&r2=819658&view=diff
==============================================================================
--- openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/kernel/TestPessimisticLocking.java
(original)
+++ openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/kernel/TestPessimisticLocking.java
Mon Sep 28 17:37:54 2009
@@ -33,6 +33,8 @@
 
 
 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;
 
 import org.apache.openjpa.jdbc.conf.JDBCConfiguration;
@@ -82,11 +84,11 @@
     }
 
     public void setUp() throws Exception {
-        deleteAll(RuntimeTest1.class);
+        super.setUp(RuntimeTest1.class, RuntimeTest2.class, RuntimeTest3.class);
 
         Map propsMap = new HashMap();
         propsMap.put("openjpa.LockManager", "pessimistic");
-        _factory = (OpenJPAEntityManagerFactory) getEmf(propsMap);
+        _factory = getEmf(propsMap);
 
         OpenJPAEntityManager pm = getLockingPM();
         startTx(pm);
@@ -188,7 +190,7 @@
 
         getLog().trace("verifying pessimistic locking worked...");
         OpenJPAEntityManager pm = getLockingPM();
-        RuntimeTest1 a = (RuntimeTest1) pm.find(RuntimeTest1.class, _id);
+        RuntimeTest1 a = pm.find(RuntimeTest1.class, _id);
         assertEquals(20 - _bugCount, a.getIntField1());
         getLog().trace("closing pm");
         endEm(pm);

Modified: openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/kernel/TestProxies2.java
URL: http://svn.apache.org/viewvc/openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/kernel/TestProxies2.java?rev=819658&r1=819657&r2=819658&view=diff
==============================================================================
--- openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/kernel/TestProxies2.java
(original)
+++ openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/kernel/TestProxies2.java
Mon Sep 28 17:37:54 2009
@@ -44,8 +44,8 @@
         super(casename);
     }
 
-    public void setUp() {
-        deleteAll(ProxiesPC.class);
+    public void setUp() throws Exception {
+        super.setUp(ProxiesPC.class);
 
         OpenJPAEntityManager pm = getPM(false, false);
         startTx(pm);



Mime
View raw message