continuum-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ri...@apache.org
Subject svn commit: r602584 - in /maven/continuum/branches/continuum-jpa/continuum-model-jpa/src: main/java/org/apache/maven/continuum/store/jpa/ test/java/org/apache/maven/continuum/store/jpa/ test/resources/META-INF/
Date Sat, 08 Dec 2007 23:58:37 GMT
Author: rinku
Date: Sat Dec  8 15:58:36 2007
New Revision: 602584

URL: http://svn.apache.org/viewvc?rev=602584&view=rev
Log:
o  fixed test cases after switching to custom bean factory. 

Modified:
    maven/continuum/branches/continuum-jpa/continuum-model-jpa/src/main/java/org/apache/maven/continuum/store/jpa/JpaStore.java
    maven/continuum/branches/continuum-jpa/continuum-model-jpa/src/main/java/org/apache/maven/continuum/store/jpa/JpaStoreFactory.java
    maven/continuum/branches/continuum-jpa/continuum-model-jpa/src/test/java/org/apache/maven/continuum/store/jpa/JpaProjectStoreTest.java
    maven/continuum/branches/continuum-jpa/continuum-model-jpa/src/test/resources/META-INF/spring-config.xml

Modified: maven/continuum/branches/continuum-jpa/continuum-model-jpa/src/main/java/org/apache/maven/continuum/store/jpa/JpaStore.java
URL: http://svn.apache.org/viewvc/maven/continuum/branches/continuum-jpa/continuum-model-jpa/src/main/java/org/apache/maven/continuum/store/jpa/JpaStore.java?rev=602584&r1=602583&r2=602584&view=diff
==============================================================================
--- maven/continuum/branches/continuum-jpa/continuum-model-jpa/src/main/java/org/apache/maven/continuum/store/jpa/JpaStore.java
(original)
+++ maven/continuum/branches/continuum-jpa/continuum-model-jpa/src/main/java/org/apache/maven/continuum/store/jpa/JpaStore.java
Sat Dec  8 15:58:36 2007
@@ -77,7 +77,7 @@
      * 
      * @see org.apache.maven.continuum.store.api.Store#save(java.lang.Object)
      */
-    @Transactional( readOnly = false )
+    @Transactional( readOnly = true )
     public T save( T entity ) throws StoreException
     {
         if ( null != entity )

Modified: maven/continuum/branches/continuum-jpa/continuum-model-jpa/src/main/java/org/apache/maven/continuum/store/jpa/JpaStoreFactory.java
URL: http://svn.apache.org/viewvc/maven/continuum/branches/continuum-jpa/continuum-model-jpa/src/main/java/org/apache/maven/continuum/store/jpa/JpaStoreFactory.java?rev=602584&r1=602583&r2=602584&view=diff
==============================================================================
--- maven/continuum/branches/continuum-jpa/continuum-model-jpa/src/main/java/org/apache/maven/continuum/store/jpa/JpaStoreFactory.java
(original)
+++ maven/continuum/branches/continuum-jpa/continuum-model-jpa/src/main/java/org/apache/maven/continuum/store/jpa/JpaStoreFactory.java
Sat Dec  8 15:58:36 2007
@@ -3,6 +3,8 @@
  */
 package org.apache.maven.continuum.store.jpa;
 
+import javax.persistence.EntityManagerFactory;
+
 import org.apache.maven.continuum.model.project.Project;
 import org.apache.maven.continuum.model.project.ProjectGroup;
 import org.apache.maven.continuum.model.project.ProjectNotifier;
@@ -49,6 +51,7 @@
 
     public Store<ProjectNotifier, ProjectNotifierQuery<ProjectNotifier>> createProjectNotifierStoreInstance()
     {
+
         return JPA_PROJECT_NOTIFIER_STORE;
     }
 

Modified: maven/continuum/branches/continuum-jpa/continuum-model-jpa/src/test/java/org/apache/maven/continuum/store/jpa/JpaProjectStoreTest.java
URL: http://svn.apache.org/viewvc/maven/continuum/branches/continuum-jpa/continuum-model-jpa/src/test/java/org/apache/maven/continuum/store/jpa/JpaProjectStoreTest.java?rev=602584&r1=602583&r2=602584&view=diff
==============================================================================
--- maven/continuum/branches/continuum-jpa/continuum-model-jpa/src/test/java/org/apache/maven/continuum/store/jpa/JpaProjectStoreTest.java
(original)
+++ maven/continuum/branches/continuum-jpa/continuum-model-jpa/src/test/java/org/apache/maven/continuum/store/jpa/JpaProjectStoreTest.java
Sat Dec  8 15:58:36 2007
@@ -9,6 +9,7 @@
 
 import org.apache.maven.continuum.model.project.Project;
 import org.apache.maven.continuum.store.ApplicationContextAwareStoreTestCase;
+import org.apache.maven.continuum.store.api.EntityNotFoundException;
 import org.apache.maven.continuum.store.api.ProjectQuery;
 import org.apache.maven.continuum.store.api.Store;
 import org.apache.maven.continuum.store.api.StoreException;
@@ -20,6 +21,8 @@
 import org.junit.runner.RunWith;
 import org.springframework.test.context.ContextConfiguration;
 import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
+import org.springframework.test.context.transaction.AfterTransaction;
+import org.springframework.transaction.annotation.Transactional;
 
 /**
  * @author <a href='mailto:rahul.thakur.xdev@gmail.com'>Rahul Thakur</a>
@@ -73,8 +76,9 @@
 
         Assert.assertTrue( null == project.getId() );
         project = getProjectStore().save( project );
-        Assert.assertTrue( null != project.getId() );
-        Assert.assertTrue( project.getId() > 0L );
+        Assert.assertTrue( "Identifier of the persisted new Entity should not be null.",
null != project.getId() );
+        Assert.assertTrue( "Identifier of the persisted new Entity should be a valid positive
value.",
+                           project.getId() > 0L );
     }
 
     @Test
@@ -83,6 +87,32 @@
         Project project = getProjectStore().lookup( Project.class, 100L );
         Assert.assertNotNull( project );
         Assert.assertTrue( project.getId() > 0L );
+    }
+
+    @Test
+    @Transactional
+    public void testDeleteProject() throws StoreException
+    {
+        Project project = getProjectStore().lookup( Project.class, 100L );
+        Assert.assertNotNull( project );
+        Assert.assertTrue( project.getId() > 0L );
+        getProjectStore().delete( project );
+        // assertion follows in a separate transaction
+    }
+
+    @AfterTransaction
+    public void assertProjectDeleted() throws StoreException
+    {
+        try
+        {
+            getProjectStore().lookup( Project.class, 100L );
+            Assert.fail( "Expected exception: " + EntityNotFoundException.class.getSimpleName()
+                            + ". Project instance should have been deleted from the underlying
store.D" );
+        }
+        catch ( EntityNotFoundException e )
+        {
+            // expected!
+        }
     }
 
     @Override

Modified: maven/continuum/branches/continuum-jpa/continuum-model-jpa/src/test/resources/META-INF/spring-config.xml
URL: http://svn.apache.org/viewvc/maven/continuum/branches/continuum-jpa/continuum-model-jpa/src/test/resources/META-INF/spring-config.xml?rev=602584&r1=602583&r2=602584&view=diff
==============================================================================
--- maven/continuum/branches/continuum-jpa/continuum-model-jpa/src/test/resources/META-INF/spring-config.xml
(original)
+++ maven/continuum/branches/continuum-jpa/continuum-model-jpa/src/test/resources/META-INF/spring-config.xml
Sat Dec  8 15:58:36 2007
@@ -27,6 +27,9 @@
         class="org.springframework.transaction.annotation.AnnotationTransactionAttributeSource"
/>
     </property>
   </bean>
+  
+  <!-- enable the configuration of transactional behavior based on annotations -->
+  <tx:annotation-driven transaction-manager="transactionManager" />
 
   <bean id="storeFactory"
     class="org.apache.maven.continuum.store.jpa.JpaStoreFactory">



Mime
View raw message