openjpa-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Patrick Linskey" <plins...@gmail.com>
Subject Re: svn commit: r630516 - /openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/annotations/TestVersion.java
Date Sun, 24 Feb 2008 04:18:11 GMT
>  This test is very similar to (if not the same as) *.persistence.jdbc.annotation.TestVersion.

FYI, I expect that the new tests I added have a fair amount of
duplication with existing tests; I did not do any work to weed out
tests that we have copied from BEA's repository to OpenJPA after the
initial OpenJPA code drop.

-Patrick

On Sat, Feb 23, 2008 at 11:38 AM,  <allee8285@apache.org> wrote:
> Author: allee8285
>  Date: Sat Feb 23 11:38:00 2008
>  New Revision: 630516
>
>  URL: http://svn.apache.org/viewvc?rev=630516&view=rev
>  Log:
>  Fix TestVersion's "InvalidStateException: The context has been closed." problem: em1
and em2 are using the same em from currentEntityManager(). This test is very similar to (if
not the same as) *.persistence.jdbc.annotation.TestVersion.
>
>  Modified:
>     openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/annotations/TestVersion.java
>
>  Modified: openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/annotations/TestVersion.java
>  URL: http://svn.apache.org/viewvc/openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/annotations/TestVersion.java?rev=630516&r1=630515&r2=630516&view=diff
>  ==============================================================================
>  --- openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/annotations/TestVersion.java
(original)
>  +++ openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/annotations/TestVersion.java
Sat Feb 23 11:38:00 2008
>  @@ -25,9 +25,7 @@
>   import org.apache.openjpa.jdbc.meta.strats.* ;
>
>   import org.apache.openjpa.persistence.annotations.common.apps.annotApp.annotype.* ;
>  -import junit.framework.* ;
>
>  -import org.apache.openjpa.persistence.common.utils.* ;
>   import org.apache.openjpa.persistence.OpenJPAEntityManager;
>   import org.apache.openjpa.persistence.OpenJPAEntityManagerSPI;
>   import org.apache.openjpa.persistence.OpenJPAPersistence;
>  @@ -50,8 +48,6 @@
>                 super(name, "annotationcactusapp");
>         }
>
>  -
>  -
>         public void setUp()
>         {
>                 new AnnoTest1();
>  @@ -94,8 +90,7 @@
>         {
>                 OpenJPAEntityManager em1 = currentEntityManager();
>                 startTx(em1);
>  -               EntityManager em2 = currentEntityManager();
>  -
>  +               EntityManager em2 = getEmf().createEntityManager();
>
>                 AnnoTest1 pc1 = em1.find(AnnoTest1.class, oid);
>                 AnnoTest1 pc2 = em2.find(AnnoTest1.class, oid);
>  @@ -107,7 +102,7 @@
>                 endTx(em1);
>                 endEm(em1);
>
>  -               startTx(em2);
>  +               em2.getTransaction().begin();
>                 pc2.setBasic(75);
>                 em1 = (OpenJPAEntityManager) currentEntityManager();
>                 pc1 = em1.find(AnnoTest1.class, oid);
>  @@ -115,7 +110,7 @@
>                 endEm(em1);
>                 try
>                 {
>  -                       endTx(em2);
>  +                       em2.getTransaction().commit();
>                         fail("Optimistic fail");
>                 }
>                 catch (RuntimeException re)
>  @@ -124,7 +119,7 @@
>                 {}
>                 finally
>                 {
>  -                       endEm(em2);
>  +                       em2.close();
>                 }
>         }
>
>  @@ -132,7 +127,7 @@
>         {
>                 OpenJPAEntityManager em1 = currentEntityManager();
>                 startTx(em1);
>  -               OpenJPAEntityManager em2 = currentEntityManager();
>  +               OpenJPAEntityManager em2 = getEmf().createEntityManager();
>
>                 AnnoTest2 pc1 = em1.find(AnnoTest2.class, oid1);
>                 AnnoTest2 pc2 = em2.find(AnnoTest2.class, oid1);
>  @@ -143,8 +138,7 @@
>                 endTx(em1);
>                 endEm(em1);
>
>  -
>  -               startTx(em2);
>  +               em2.getTransaction().begin();
>                 pc2.setBasic("75");
>
>                 em1 = (OpenJPAEntityManager) currentEntityManager();
>  @@ -153,7 +147,7 @@
>                 endEm(em1);
>                 try
>                 {
>  -                       endTx(em2);
>  +                       em2.getTransaction().commit();
>                         fail("Optimistic fail");
>                 }
>                 catch (RuntimeException re)
>  @@ -162,7 +156,7 @@
>                 {}
>                 finally
>                 {
>  -                       endEm(em2);
>  +                       em2.close();
>                 }
>         }
>
>  @@ -170,7 +164,7 @@
>         {
>                 OpenJPAEntityManager em1 = currentEntityManager();
>                 startTx(em1);
>  -               OpenJPAEntityManager em2 = currentEntityManager();
>  +               OpenJPAEntityManager em2 = getEmf().createEntityManager();
>
>                 AnnoTest3 pc1 = em1.find(AnnoTest3.class, oid2);
>                 AnnoTest3 pc2 = em2.find(AnnoTest3.class, oid2);
>  @@ -182,7 +176,7 @@
>                 endEm(em1);
>
>
>  -               startTx(em2);
>  +               em2.getTransaction().begin();
>                 pc2.setBasic2(75);
>
>
>  @@ -192,7 +186,7 @@
>                 endEm(em1);
>                 try
>                 {
>  -                       endTx(em2);
>  +                       em2.getTransaction().commit();
>                         fail("Optimistic fail");
>                 }
>                 catch (RuntimeException re)
>  @@ -201,7 +195,7 @@
>                 {}
>                 finally
>                 {
>  -                       endEm(em2);
>  +                       em2.close();
>                 }
>         }
>
>  @@ -224,7 +218,6 @@
>                 endEm(em);
>         }
>
>  -
>            public void testNoDefaultVersionWithoutFieldOrColumn()
>            {
>                         OpenJPAEntityManager pm = (OpenJPAEntityManager) currentEntityManager();
>  @@ -244,5 +237,4 @@
>                                            cls.getVersion().getColumns().length);
>                         endEm(pm);
>            }
>  -
>   }
>
>
>



-- 
Patrick Linskey
202 669 5907

Mime
View raw message