continuum-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ri...@apache.org
Subject svn commit: r490682 - in /maven/continuum/branches/key-based-refactor/continuum-store/src/test/java/org/apache/maven/continuum/store/jdo: AbstractJdoStoreTestCase.java JdoProjectGroupTestCase.java JdoProjectStoreTestCase.java JdoSystemStoreTestCase.java
Date Thu, 28 Dec 2006 09:13:43 GMT
Author: rinku
Date: Thu Dec 28 01:13:38 2006
New Revision: 490682

URL: http://svn.apache.org/viewvc?view=rev&rev=490682
Log:
o  more updates to tests.
o  added teardown to clean up test database. (tests are broken)

Modified:
    maven/continuum/branches/key-based-refactor/continuum-store/src/test/java/org/apache/maven/continuum/store/jdo/AbstractJdoStoreTestCase.java
    maven/continuum/branches/key-based-refactor/continuum-store/src/test/java/org/apache/maven/continuum/store/jdo/JdoProjectGroupTestCase.java
    maven/continuum/branches/key-based-refactor/continuum-store/src/test/java/org/apache/maven/continuum/store/jdo/JdoProjectStoreTestCase.java
    maven/continuum/branches/key-based-refactor/continuum-store/src/test/java/org/apache/maven/continuum/store/jdo/JdoSystemStoreTestCase.java

Modified: maven/continuum/branches/key-based-refactor/continuum-store/src/test/java/org/apache/maven/continuum/store/jdo/AbstractJdoStoreTestCase.java
URL: http://svn.apache.org/viewvc/maven/continuum/branches/key-based-refactor/continuum-store/src/test/java/org/apache/maven/continuum/store/jdo/AbstractJdoStoreTestCase.java?view=diff&rev=490682&r1=490681&r2=490682
==============================================================================
--- maven/continuum/branches/key-based-refactor/continuum-store/src/test/java/org/apache/maven/continuum/store/jdo/AbstractJdoStoreTestCase.java
(original)
+++ maven/continuum/branches/key-based-refactor/continuum-store/src/test/java/org/apache/maven/continuum/store/jdo/AbstractJdoStoreTestCase.java
Thu Dec 28 01:13:38 2006
@@ -16,10 +16,27 @@
  * limitations under the License.
  */
 
-import org.apache.maven.continuum.store.ProjectStore;
+import org.apache.maven.continuum.model.project.BuildDefinition;
+import org.apache.maven.continuum.model.project.BuildResult;
+import org.apache.maven.continuum.model.project.Profile;
+import org.apache.maven.continuum.model.project.Project;
+import org.apache.maven.continuum.model.project.ProjectDependency;
+import org.apache.maven.continuum.model.project.ProjectDeveloper;
+import org.apache.maven.continuum.model.project.ProjectGroup;
+import org.apache.maven.continuum.model.project.ProjectNotifier;
+import org.apache.maven.continuum.model.project.Schedule;
+import org.apache.maven.continuum.model.scm.ChangeFile;
+import org.apache.maven.continuum.model.scm.ChangeSet;
+import org.apache.maven.continuum.model.scm.ScmResult;
+import org.apache.maven.continuum.model.scm.SuiteResult;
+import org.apache.maven.continuum.model.scm.TestCaseFailure;
+import org.apache.maven.continuum.model.scm.TestResult;
+import org.apache.maven.continuum.model.system.Installation;
+import org.apache.maven.continuum.model.system.SystemConfiguration;
 import org.codehaus.plexus.PlexusTestCase;
 import org.codehaus.plexus.jdo.DefaultConfigurableJdoFactory;
 import org.codehaus.plexus.jdo.JdoFactory;
+import org.codehaus.plexus.jdo.PlexusJdoUtils;
 
 import javax.jdo.PersistenceManager;
 
@@ -74,14 +91,15 @@
      */
     private static final File SQL_DATABSE_SCHEMA = getTestFile( getBasedir(), "src/test/resources/schema.sql"
);
 
+    private PersistenceManager persistenceManager;
+
     /**
-     * Creates an instance of Continuum Database for test purposes and loads up
-     * the test data from the specified schema and test data SQL scripts.
-     * 
-     * @throws Exception if there was an error with test database set up.
+     * @see org.codehaus.plexus.PlexusTestCase#setUp()
      */
-    protected void createBuildDatabase() throws Exception
+    protected void setUp() throws Exception
     {
+        super.setUp();
+
         DefaultConfigurableJdoFactory jdoFactory = (DefaultConfigurableJdoFactory) lookup(
JdoFactory.ROLE );
 
         jdoFactory.setUrl( URL_TEST_DATABASE );
@@ -92,9 +110,29 @@
 
         jdoFactory.setPassword( PASSWORD_TEST_DATABASE );
 
-        PersistenceManager pm = jdoFactory.getPersistenceManagerFactory().getPersistenceManager();
+        persistenceManager = jdoFactory.getPersistenceManagerFactory().getPersistenceManager();
+    }
+
+    /**
+     * @see org.codehaus.plexus.PlexusTestCase#tearDown()
+     */
+    protected void tearDown() throws Exception
+    {
+        super.tearDown();
 
-        Connection connection = (Connection) pm.getDataStoreConnection().getNativeConnection();
+        teardownBuildDatabase();
+    }
+
+    /**
+     * Creates an instance of Continuum Database for test purposes and loads up
+     * the test data from the specified schema and test data SQL scripts.
+     * 
+     * @throws Exception if there was an error with test database set up.
+     */
+    protected void createBuildDatabase() throws Exception
+    {
+
+        Connection connection = (Connection) persistenceManager.getDataStoreConnection().getNativeConnection();
 
         loadSQL( SQL_DATABSE_SCHEMA, connection );
 
@@ -111,6 +149,42 @@
             loadSQL( script, connection );
         }
 
+    }
+
+    /**
+     * Clean up the Continuum test database.
+     * 
+     * @throws Exception
+     */
+    protected void teardownBuildDatabase() throws Exception
+    {
+        PlexusJdoUtils.removeAll( getPersistenceManager(), Project.class );
+        PlexusJdoUtils.removeAll( getPersistenceManager(), ProjectGroup.class );
+        PlexusJdoUtils.removeAll( getPersistenceManager(), Schedule.class );
+        PlexusJdoUtils.removeAll( getPersistenceManager(), Profile.class );
+        PlexusJdoUtils.removeAll( getPersistenceManager(), Installation.class );
+        PlexusJdoUtils.removeAll( getPersistenceManager(), ScmResult.class );
+        PlexusJdoUtils.removeAll( getPersistenceManager(), BuildResult.class );
+        PlexusJdoUtils.removeAll( getPersistenceManager(), TestResult.class );
+        PlexusJdoUtils.removeAll( getPersistenceManager(), SuiteResult.class );
+        PlexusJdoUtils.removeAll( getPersistenceManager(), TestCaseFailure.class );
+        PlexusJdoUtils.removeAll( getPersistenceManager(), SystemConfiguration.class );
+        PlexusJdoUtils.removeAll( getPersistenceManager(), ProjectNotifier.class );
+        PlexusJdoUtils.removeAll( getPersistenceManager(), ProjectDeveloper.class );
+        PlexusJdoUtils.removeAll( getPersistenceManager(), ProjectDependency.class );
+        PlexusJdoUtils.removeAll( getPersistenceManager(), ChangeSet.class );
+        PlexusJdoUtils.removeAll( getPersistenceManager(), ChangeFile.class );
+        PlexusJdoUtils.removeAll( getPersistenceManager(), BuildDefinition.class );
+    }
+
+    /**
+     * Returns {@link PersistenceManager} instance to interact with database
+     * 
+     * @return {@link PersistenceManager} instance to interact with database.
+     */
+    protected PersistenceManager getPersistenceManager()
+    {
+        return persistenceManager;
     }
 
     /**

Modified: maven/continuum/branches/key-based-refactor/continuum-store/src/test/java/org/apache/maven/continuum/store/jdo/JdoProjectGroupTestCase.java
URL: http://svn.apache.org/viewvc/maven/continuum/branches/key-based-refactor/continuum-store/src/test/java/org/apache/maven/continuum/store/jdo/JdoProjectGroupTestCase.java?view=diff&rev=490682&r1=490681&r2=490682
==============================================================================
--- maven/continuum/branches/key-based-refactor/continuum-store/src/test/java/org/apache/maven/continuum/store/jdo/JdoProjectGroupTestCase.java
(original)
+++ maven/continuum/branches/key-based-refactor/continuum-store/src/test/java/org/apache/maven/continuum/store/jdo/JdoProjectGroupTestCase.java
Thu Dec 28 01:13:38 2006
@@ -2,7 +2,6 @@
 
 import org.apache.maven.continuum.store.ProjectGroupStore;
 
-import java.util.ArrayList;
 import java.util.List;
 
 /**
@@ -32,5 +31,12 @@
         assertNotNull( store );
     }
 
-  
+    public void testVerifyDatabase() throws Exception
+    {
+        ProjectGroupStore store = (ProjectGroupStore) lookup( ProjectGroupStore.ROLE, "jdo"
);
+        List list = store.getAllProjectGroups();
+        assertNotNull( list );
+        assertEquals( 2, list.size() );
+    }
+
 }

Modified: maven/continuum/branches/key-based-refactor/continuum-store/src/test/java/org/apache/maven/continuum/store/jdo/JdoProjectStoreTestCase.java
URL: http://svn.apache.org/viewvc/maven/continuum/branches/key-based-refactor/continuum-store/src/test/java/org/apache/maven/continuum/store/jdo/JdoProjectStoreTestCase.java?view=diff&rev=490682&r1=490681&r2=490682
==============================================================================
--- maven/continuum/branches/key-based-refactor/continuum-store/src/test/java/org/apache/maven/continuum/store/jdo/JdoProjectStoreTestCase.java
(original)
+++ maven/continuum/branches/key-based-refactor/continuum-store/src/test/java/org/apache/maven/continuum/store/jdo/JdoProjectStoreTestCase.java
Thu Dec 28 01:13:38 2006
@@ -46,5 +46,4 @@
         assertNotNull( store );
     }
 
-  
 }

Modified: maven/continuum/branches/key-based-refactor/continuum-store/src/test/java/org/apache/maven/continuum/store/jdo/JdoSystemStoreTestCase.java
URL: http://svn.apache.org/viewvc/maven/continuum/branches/key-based-refactor/continuum-store/src/test/java/org/apache/maven/continuum/store/jdo/JdoSystemStoreTestCase.java?view=diff&rev=490682&r1=490681&r2=490682
==============================================================================
--- maven/continuum/branches/key-based-refactor/continuum-store/src/test/java/org/apache/maven/continuum/store/jdo/JdoSystemStoreTestCase.java
(original)
+++ maven/continuum/branches/key-based-refactor/continuum-store/src/test/java/org/apache/maven/continuum/store/jdo/JdoSystemStoreTestCase.java
Thu Dec 28 01:13:38 2006
@@ -18,9 +18,6 @@
 
 import org.apache.maven.continuum.store.SystemStore;
 
-import java.util.ArrayList;
-import java.util.List;
-
 /**
  * @author <a href='mailto:rahul.thakur.xdev@gmail.com'>Rahul Thakur</a>
  * @version $Id$
@@ -48,5 +45,4 @@
         assertNotNull( store );
     }
 
-   
 }



Mime
View raw message