continuum-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ri...@apache.org
Subject svn commit: r602601 - in /maven/continuum/branches/continuum-jpa/continuum-model-jpa/src/test: java/org/apache/maven/continuum/store/jpa/ resources/sql/
Date Sun, 09 Dec 2007 01:15:58 GMT
Author: rinku
Date: Sat Dec  8 17:15:57 2007
New Revision: 602601

URL: http://svn.apache.org/viewvc?rev=602601&view=rev
Log:
o  fixed issue with Project Notifier unit test, where test data in the Notifier table was
not being cleared off. 
o  Added tests for removing ProjectGroup and Notifiers.

Modified:
    maven/continuum/branches/continuum-jpa/continuum-model-jpa/src/test/java/org/apache/maven/continuum/store/jpa/JpaProjectGroupStoreTest.java
    maven/continuum/branches/continuum-jpa/continuum-model-jpa/src/test/java/org/apache/maven/continuum/store/jpa/JpaProjectNotifierStoreTest.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/sql/project-group-table-data.sql

Modified: maven/continuum/branches/continuum-jpa/continuum-model-jpa/src/test/java/org/apache/maven/continuum/store/jpa/JpaProjectGroupStoreTest.java
URL: http://svn.apache.org/viewvc/maven/continuum/branches/continuum-jpa/continuum-model-jpa/src/test/java/org/apache/maven/continuum/store/jpa/JpaProjectGroupStoreTest.java?rev=602601&r1=602600&r2=602601&view=diff
==============================================================================
--- maven/continuum/branches/continuum-jpa/continuum-model-jpa/src/test/java/org/apache/maven/continuum/store/jpa/JpaProjectGroupStoreTest.java
(original)
+++ maven/continuum/branches/continuum-jpa/continuum-model-jpa/src/test/java/org/apache/maven/continuum/store/jpa/JpaProjectGroupStoreTest.java
Sat Dec  8 17:15:57 2007
@@ -21,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>
@@ -81,25 +83,44 @@
     @Test
     public void testLookupProjectGroup() throws EntityNotFoundException, StoreException
     {
-        ProjectGroup projectGroup = getProjectGroupStore().lookup( ProjectGroup.class, 1000L
);
+        ProjectGroup projectGroup = getProjectGroupStore().lookup( ProjectGroup.class, 100L
);
         Assert.assertNotNull( projectGroup );
-        Assert.assertEquals( 1000L, projectGroup.getId().longValue() );
+        Assert.assertEquals( 100L, projectGroup.getId().longValue() );
         Assert.assertEquals( "Continuum Projects", projectGroup.getName() );
         Assert.assertEquals( "org.apache.continuum", projectGroup.getGroupId() );
     }
 
-    @Test
+    @Test( expected = EntityNotFoundException.class )
     public void testLookupInvalidProjectGroup() throws StoreException
     {
+        ProjectGroup projectGroup = getProjectGroupStore().lookup( ProjectGroup.class, 99999L
);
+        Assert.fail( "Expected " + EntityNotFoundException.class.getSimpleName()
+                        + " on account of an invalid ProjectGroup Id." );
+    }
+
+    @Test
+    @Transactional
+    public void testDeleteProjectGroup() throws StoreException
+    {
+        ProjectGroup group = getProjectGroupStore().lookup( ProjectGroup.class, 100L );
+        Assert.assertNotNull( group );
+        Assert.assertTrue( group.getId() > 0L );
+        getProjectGroupStore().delete( group );
+        // assertion follows in a separate transaction
+    }
+
+    @AfterTransaction
+    public void assertProjectGroupDeleted() throws StoreException
+    {
         try
         {
-            ProjectGroup projectGroup = getProjectGroupStore().lookup( ProjectGroup.class,
99999L );
-            Assert.fail( "Expected " + EntityNotFoundException.class.getSimpleName()
-                            + " on account of an invalid ProjectGroup Id." );
+            getProjectGroupStore().lookup( ProjectGroup.class, 100L );
+            Assert.fail( "Expected exception: " + EntityNotFoundException.class.getSimpleName()
+                            + ". ProjectNotifier instance should have been deleted from the
underlying store." );
         }
         catch ( EntityNotFoundException e )
         {
-            // Expected!
+            // expected!
         }
     }
 

Modified: maven/continuum/branches/continuum-jpa/continuum-model-jpa/src/test/java/org/apache/maven/continuum/store/jpa/JpaProjectNotifierStoreTest.java
URL: http://svn.apache.org/viewvc/maven/continuum/branches/continuum-jpa/continuum-model-jpa/src/test/java/org/apache/maven/continuum/store/jpa/JpaProjectNotifierStoreTest.java?rev=602601&r1=602600&r2=602601&view=diff
==============================================================================
--- maven/continuum/branches/continuum-jpa/continuum-model-jpa/src/test/java/org/apache/maven/continuum/store/jpa/JpaProjectNotifierStoreTest.java
(original)
+++ maven/continuum/branches/continuum-jpa/continuum-model-jpa/src/test/java/org/apache/maven/continuum/store/jpa/JpaProjectNotifierStoreTest.java
Sat Dec  8 17:15:57 2007
@@ -9,16 +9,20 @@
 
 import org.apache.maven.continuum.model.project.ProjectNotifier;
 import org.apache.maven.continuum.store.ApplicationContextAwareStoreTestCase;
+import org.apache.maven.continuum.store.api.EntityNotFoundException;
 import org.apache.maven.continuum.store.api.ProjectNotifierQuery;
 import org.apache.maven.continuum.store.api.Store;
 import org.apache.maven.continuum.store.api.StoreException;
 import org.apache.openjpa.persistence.OpenJPAQuery;
+import org.junit.After;
 import org.junit.Assert;
 import org.junit.Before;
 import org.junit.Test;
 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,6 +77,39 @@
         ProjectNotifier notifier = getProjectNotifierStore().lookup( ProjectNotifier.class,
100L );
         Assert.assertNotNull( notifier );
         Assert.assertTrue( notifier.getId() > 0L );
+    }
+
+    @Test
+    @Transactional
+    public void testDeleteProjectNotifier() throws StoreException
+    {
+        ProjectNotifier notifier = getProjectNotifierStore().lookup( ProjectNotifier.class,
100L );
+        Assert.assertNotNull( notifier );
+        Assert.assertTrue( notifier.getId() > 0L );
+        getProjectNotifierStore().delete( notifier );
+        // assertion follows in a separate transaction
+    }
+
+    @AfterTransaction
+    public void assertProjectNotifierDeleted() throws StoreException
+    {
+        try
+        {
+            ProjectNotifier notifier = getProjectNotifierStore().lookup( ProjectNotifier.class,
100L );
+            Assert.fail( "Expected exception: " + EntityNotFoundException.class.getSimpleName()
+                            + ". ProjectNotifier instance should have been deleted from the
underlying store." );
+        }
+        catch ( EntityNotFoundException e )
+        {
+            // expected!
+        }
+    }
+
+    @Override
+    @After
+    public void tearDown() throws Exception
+    {
+        super.tearDown();
     }
 
     private Store<ProjectNotifier, ProjectNotifierQuery<ProjectNotifier>> getProjectNotifierStore()

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=602601&r1=602600&r2=602601&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 17:15:57 2007
@@ -107,7 +107,7 @@
         {
             getProjectStore().lookup( Project.class, 100L );
             Assert.fail( "Expected exception: " + EntityNotFoundException.class.getSimpleName()
-                            + ". Project instance should have been deleted from the underlying
store.D" );
+                            + ". Project instance should have been deleted from the underlying
store." );
         }
         catch ( EntityNotFoundException e )
         {

Modified: maven/continuum/branches/continuum-jpa/continuum-model-jpa/src/test/resources/sql/project-group-table-data.sql
URL: http://svn.apache.org/viewvc/maven/continuum/branches/continuum-jpa/continuum-model-jpa/src/test/resources/sql/project-group-table-data.sql?rev=602601&r1=602600&r2=602601&view=diff
==============================================================================
--- maven/continuum/branches/continuum-jpa/continuum-model-jpa/src/test/resources/sql/project-group-table-data.sql
(original)
+++ maven/continuum/branches/continuum-jpa/continuum-model-jpa/src/test/resources/sql/project-group-table-data.sql
Sat Dec  8 17:15:57 2007
@@ -2,4 +2,4 @@
 
 
 INSERT INTO PROJECT_GROUP ( ID, DATE_CREATED, MODEL_ENCODING, DESCRIPTION, GROUP_ID, NAME)

-	VALUES ( 1000, 2007-11-10, 'UTF-8', 'Group for Continuum sub-projects', 'org.apache.continuum',
'Continuum Projects')
+	VALUES ( 100, 2007-11-10, 'UTF-8', 'Group for Continuum sub-projects', 'org.apache.continuum',
'Continuum Projects')



Mime
View raw message