You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@continuum.apache.org by ri...@apache.org on 2006/12/28 23:05:55 UTC

svn commit: r490846 - in /maven/continuum/branches/key-based-refactor/continuum-store/src: main/java/org/apache/maven/continuum/store/jdo/ test/java/org/apache/maven/continuum/store/jdo/ test/resources/

Author: rinku
Date: Thu Dec 28 14:05:54 2006
New Revision: 490846

URL: http://svn.apache.org/viewvc?view=rev&rev=490846
Log:
o  fixes and updates to test data.

Modified:
    maven/continuum/branches/key-based-refactor/continuum-store/src/main/java/org/apache/maven/continuum/store/jdo/AbstractJdoStore.java
    maven/continuum/branches/key-based-refactor/continuum-store/src/main/java/org/apache/maven/continuum/store/jdo/JdoProjectGroupStore.java
    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/resources/testData.sql

Modified: maven/continuum/branches/key-based-refactor/continuum-store/src/main/java/org/apache/maven/continuum/store/jdo/AbstractJdoStore.java
URL: http://svn.apache.org/viewvc/maven/continuum/branches/key-based-refactor/continuum-store/src/main/java/org/apache/maven/continuum/store/jdo/AbstractJdoStore.java?view=diff&rev=490846&r1=490845&r2=490846
==============================================================================
--- maven/continuum/branches/key-based-refactor/continuum-store/src/main/java/org/apache/maven/continuum/store/jdo/AbstractJdoStore.java (original)
+++ maven/continuum/branches/key-based-refactor/continuum-store/src/main/java/org/apache/maven/continuum/store/jdo/AbstractJdoStore.java Thu Dec 28 14:05:54 2006
@@ -18,9 +18,12 @@
 
 import org.apache.maven.continuum.store.ContinuumObjectNotFoundException;
 import org.apache.maven.continuum.store.ContinuumStoreException;
+import org.codehaus.plexus.jdo.JdoFactory;
 import org.codehaus.plexus.jdo.PlexusJdoUtils;
 import org.codehaus.plexus.jdo.PlexusObjectNotFoundException;
 import org.codehaus.plexus.jdo.PlexusStoreException;
+import org.codehaus.plexus.personality.plexus.lifecycle.phase.Initializable;
+import org.codehaus.plexus.personality.plexus.lifecycle.phase.InitializationException;
 
 import javax.jdo.FetchPlan;
 import javax.jdo.PersistenceManager;
@@ -37,14 +40,29 @@
  * @version $Id$
  * @since 1.1
  */
-public class AbstractJdoStore
+public class AbstractJdoStore implements Initializable
 {
 
     /**
+     * @plexus.requirement role-hint="continuum"
+     */
+    private JdoFactory continuumJdoFactory;
+
+    /**
      * Provides hook to obtainig a {@link PersistenceManager} instance for
      * invoking operations on the underlying store.
      */
-    private PersistenceManagerFactory continuumPmf;
+    private PersistenceManagerFactory persistenceManagerFactory;
+
+    /**
+     * {@inheritDoc}
+     * 
+     * @see org.codehaus.plexus.personality.plexus.lifecycle.phase.Initializable#initialize()
+     */
+    public void initialize() throws InitializationException
+    {
+        persistenceManagerFactory = continuumJdoFactory.getPersistenceManagerFactory();
+    }
 
     /**
      * Lookup and return an Object instance from the underlying store.
@@ -114,7 +132,7 @@
      */
     protected PersistenceManager getPersistenceManager()
     {
-        PersistenceManager pm = continuumPmf.getPersistenceManager();
+        PersistenceManager pm = persistenceManagerFactory.getPersistenceManager();
 
         pm.getFetchPlan().setMaxFetchDepth( -1 );
         pm.getFetchPlan().setDetachmentOptions( FetchPlan.DETACH_LOAD_FIELDS );

Modified: maven/continuum/branches/key-based-refactor/continuum-store/src/main/java/org/apache/maven/continuum/store/jdo/JdoProjectGroupStore.java
URL: http://svn.apache.org/viewvc/maven/continuum/branches/key-based-refactor/continuum-store/src/main/java/org/apache/maven/continuum/store/jdo/JdoProjectGroupStore.java?view=diff&rev=490846&r1=490845&r2=490846
==============================================================================
--- maven/continuum/branches/key-based-refactor/continuum-store/src/main/java/org/apache/maven/continuum/store/jdo/JdoProjectGroupStore.java (original)
+++ maven/continuum/branches/key-based-refactor/continuum-store/src/main/java/org/apache/maven/continuum/store/jdo/JdoProjectGroupStore.java Thu Dec 28 14:05:54 2006
@@ -21,6 +21,8 @@
 import org.apache.maven.continuum.store.ContinuumObjectNotFoundException;
 import org.apache.maven.continuum.store.ContinuumStoreException;
 import org.apache.maven.continuum.store.ProjectGroupStore;
+import org.codehaus.plexus.personality.plexus.lifecycle.phase.Initializable;
+import org.codehaus.plexus.personality.plexus.lifecycle.phase.InitializationException;
 
 import java.util.List;
 

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=490846&r1=490845&r2=490846
==============================================================================
--- 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 14:05:54 2006
@@ -16,27 +16,9 @@
  * limitations under the License.
  */
 
-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.logging.LogEnabled;
 import org.jpox.SchemaTool;
 
 import javax.jdo.PersistenceManager;
@@ -113,8 +95,7 @@
 
         jdoFactory = createJdoFactory();
 
-        // persistenceManager =
-        // jdoFactory.getPersistenceManagerFactory().getPersistenceManager();
+        persistenceManager = jdoFactory.getPersistenceManagerFactory().getPersistenceManager();
     }
 
     /**
@@ -135,9 +116,6 @@
      */
     protected void createBuildDatabase() throws Exception
     {
-        if ( null == persistenceManager || persistenceManager.isClosed() )
-            persistenceManager = jdoFactory.getPersistenceManagerFactory().getPersistenceManager();
-
         Connection connection = (Connection) persistenceManager.getDataStoreConnection().getNativeConnection();
 
         loadSQL( SQL_DATABSE_SCHEMA, connection );
@@ -164,53 +142,16 @@
      */
     protected void teardownBuildDatabase() throws Exception
     {
-        if ( null == persistenceManager || persistenceManager.isClosed() )
-            persistenceManager = jdoFactory.getPersistenceManagerFactory().getPersistenceManager();
-
-        // deleteAllEntities( Project.class );
-        // deleteAllEntities( ProjectGroup.class );
-        // deleteAllEntities( Schedule.class );
-        // deleteAllEntities( Profile.class );
-        // deleteAllEntities( Installation.class );
-        // deleteAllEntities( ScmResult.class );
-        // deleteAllEntities( BuildResult.class );
-        // deleteAllEntities( TestResult.class );
-        // deleteAllEntities( SuiteResult.class );
-        // deleteAllEntities( TestCaseFailure.class );
-        // deleteAllEntities( SystemConfiguration.class );
-        // deleteAllEntities( ProjectNotifier.class );
-        // deleteAllEntities( ProjectDeveloper.class );
-        // deleteAllEntities( ProjectDependency.class );
-        // deleteAllEntities( ChangeSet.class );
-        // deleteAllEntities( ChangeFile.class );
-        // deleteAllEntities( BuildDefinition.class );
+        persistenceManager = jdoFactory.getPersistenceManagerFactory().getPersistenceManager();
 
         URL[] jdoFiles = new URL[] { this.getClass().getClassLoader().getResource( "META-INF/package.jdo" ) };
 
-        URL[] classFiles =
-            new URL[] { this.getClass().getClassLoader().getResource( Project.class.getCanonicalName() ),
-                this.getClass().getClassLoader().getResource( ProjectGroup.class.getCanonicalName() ),
-                this.getClass().getClassLoader().getResource( Schedule.class.getCanonicalName() ),
-                this.getClass().getClassLoader().getResource( Profile.class.getCanonicalName() ),
-                this.getClass().getClassLoader().getResource( Installation.class.getCanonicalName() ),
-                this.getClass().getClassLoader().getResource( ScmResult.class.getCanonicalName() ),
-                this.getClass().getClassLoader().getResource( BuildResult.class.getCanonicalName() ),
-                this.getClass().getClassLoader().getResource( TestResult.class.getCanonicalName() ),
-                this.getClass().getClassLoader().getResource( SuiteResult.class.getCanonicalName() ),
-                this.getClass().getClassLoader().getResource( TestCaseFailure.class.getCanonicalName() ),
-                this.getClass().getClassLoader().getResource( SystemConfiguration.class.getCanonicalName() ),
-                this.getClass().getClassLoader().getResource( ProjectNotifier.class.getCanonicalName() ),
-                this.getClass().getClassLoader().getResource( ProjectDeveloper.class.getCanonicalName() ),
-                this.getClass().getClassLoader().getResource( ProjectDependency.class.getCanonicalName() ),
-                this.getClass().getClassLoader().getResource( ChangeSet.class.getCanonicalName() ),
-                this.getClass().getClassLoader().getResource( BuildDefinition.class.getCanonicalName() ) };
-
         // prepare System properties that the SchemaTool expects
         System.setProperty( SchemaTool.JDO_DATASTORE_DRIVERNAME_PROPERTY, DRIVER_TEST_DATABASE );
         System.setProperty( SchemaTool.JDO_DATASTORE_URL_PROPERTY, URL_TEST_DATABASE );
         System.setProperty( SchemaTool.JDO_DATASTORE_USERNAME_PROPERTY, USERNAME_TEST_DATABASE );
         System.setProperty( SchemaTool.JDO_DATASTORE_PASSWORD_PROPERTY, PASSWORD_TEST_DATABASE );
-        SchemaTool.deleteSchemaTables( jdoFiles, null, true );
+        SchemaTool.deleteSchemaTables( jdoFiles, null, false );
     }
 
     /**
@@ -344,7 +285,6 @@
 
         jdoFactory.setPassword( PASSWORD_TEST_DATABASE );
 
-        jdoFactory.setProperty( "javax.jdo.option.NontransactionalRead", "true" );
         return jdoFactory;
     }
 }

Modified: maven/continuum/branches/key-based-refactor/continuum-store/src/test/resources/testData.sql
URL: http://svn.apache.org/viewvc/maven/continuum/branches/key-based-refactor/continuum-store/src/test/resources/testData.sql?view=diff&rev=490846&r1=490845&r2=490846
==============================================================================
--- maven/continuum/branches/key-based-refactor/continuum-store/src/test/resources/testData.sql (original)
+++ maven/continuum/branches/key-based-refactor/continuum-store/src/test/resources/testData.sql Thu Dec 28 14:05:54 2006
@@ -2,23 +2,24 @@
 
 # Set up Project Groups
 insert into PROJECTGROUP (ID, DESCRIPTION, GROUP_ID, GROUPKEY, NAME)
-  values (1, 'Group 1' , 'org.apache.maven.continuum', 'Continuum' , 'Continuum Group');
+  values (1, 'Default Group' , 'default', 'Default' , 'Default Group');
+insert into PROJECTGROUP (ID, DESCRIPTION, GROUP_ID, GROUPKEY, NAME)
+  values (2, 'Group 1' , 'org.apache.maven.continuum', 'Continuum' , 'Continuum Group');
   
       
 # Set up projects
 insert into PROJECT (ID, DESCRIPTION, ARTIFACT_ID, GROUP_ID, GROUP_KEY, 
     PROJECTKEY, NAME, BUILD_NUMBER, LATEST_BUILD_ID, OLD_STATE, 
     PROJECT_GROUP_ID_OID, "STATE")
-  values (1, 'Default Project for Continuum projects',
-    'default-project-artifact',  'org.group.default', 'defaultProject', 
-    'default', 'Default Project', 0, 0, 0, 1, 0);
-insert into PROJECT (ID, DESCRIPTION, ARTIFACT_ID, GROUP_ID, GROUP_KEY, 
-    PROJECTKEY, NAME, BUILD_NUMBER, LATEST_BUILD_ID, OLD_STATE, 
-    PROJECT_GROUP_ID_OID, "STATE")
-  values (2, 'Test Project 1', 'project-1',  'org.test.projects', 'project1',
+  values (1, 'Test Project 1', 'project-1',  'org.test.projects', 'project1',
     'project1', 'Project 1', 0, 0, 0, 1, 0);
 insert into PROJECT (ID, DESCRIPTION, ARTIFACT_ID, GROUP_ID, GROUP_KEY, 
     PROJECTKEY, NAME, BUILD_NUMBER, LATEST_BUILD_ID, 
     OLD_STATE, PROJECT_GROUP_ID_OID, "STATE")
-  values (3, 'Test Project 2', 'project-2',  'org.test.projects', 'project2',
+  values (2, 'Test Project 2', 'project-2',  'org.test.projects', 'project2',
     'project2', 'Project 2', 0, 0, 0, 1, 0);
+insert into PROJECT (ID, DESCRIPTION, ARTIFACT_ID, GROUP_ID, GROUP_KEY, 
+    PROJECTKEY, NAME, BUILD_NUMBER, LATEST_BUILD_ID, OLD_STATE, 
+    PROJECT_GROUP_ID_OID, "STATE")
+  values (3, 'Test Project 3', 'project-3', 'org.test.projects', 'project3',
+    'project3', 'Project 3', 0, 0, 0, 2, 0);