continuum-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ri...@apache.org
Subject svn commit: r493267 - in /maven/continuum/branches/key-based-refactor/continuum-store: ./ src/main/java/org/apache/maven/continuum/store/jdo/ src/test/java/org/apache/maven/continuum/store/ibatis/ src/test/java/org/apache/maven/continuum/store/jdo/ src...
Date Sat, 06 Jan 2007 01:19:34 GMT
Author: rinku
Date: Fri Jan  5 17:19:33 2007
New Revision: 493267

URL: http://svn.apache.org/viewvc?view=rev&rev=493267
Log:
o  updates to JDO tests and store operations.

Added:
    maven/continuum/branches/key-based-refactor/continuum-store/src/test/resources/db/dataset.dtd
  (with props)
    maven/continuum/branches/key-based-refactor/continuum-store/src/test/resources/db/test-data.xml
  (with props)
Modified:
    maven/continuum/branches/key-based-refactor/continuum-store/pom.xml
    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/main/java/org/apache/maven/continuum/store/jdo/JdoProjectStore.java
    maven/continuum/branches/key-based-refactor/continuum-store/src/test/java/org/apache/maven/continuum/store/ibatis/AbstractIbatisStoreTestCase.java
    maven/continuum/branches/key-based-refactor/continuum-store/src/test/java/org/apache/maven/continuum/store/ibatis/IbatisProjectGroupTestCase.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/resources/db/schema.sql

Modified: maven/continuum/branches/key-based-refactor/continuum-store/pom.xml
URL: http://svn.apache.org/viewvc/maven/continuum/branches/key-based-refactor/continuum-store/pom.xml?view=diff&rev=493267&r1=493266&r2=493267
==============================================================================
--- maven/continuum/branches/key-based-refactor/continuum-store/pom.xml (original)
+++ maven/continuum/branches/key-based-refactor/continuum-store/pom.xml Fri Jan  5 17:19:33
2007
@@ -37,7 +37,7 @@
     <dependency>
       <groupId>dbunit</groupId>
       <artifactId>dbunit</artifactId>
-      <version>2.1</version>
+      <version>2.2</version>
       <scope>test</scope>
     </dependency>
     <dependency>
@@ -48,6 +48,12 @@
       <groupId>org.codehaus.plexus</groupId>
       <artifactId>plexus-ibatis</artifactId>
       <version>1.0-SNAPSHOT</version>
+    </dependency>
+    <dependency>
+      <groupId>org.apache.derby</groupId>
+      <artifactId>derby</artifactId>
+      <version>10.2.2.0</version>
+      <scope>test</scope>
     </dependency>
   </dependencies>
   <build>

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=493267&r1=493266&r2=493267
==============================================================================
--- 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
Fri Jan  5 17:19:33 2007
@@ -28,13 +28,14 @@
 import javax.jdo.FetchPlan;
 import javax.jdo.PersistenceManager;
 import javax.jdo.PersistenceManagerFactory;
+import javax.jdo.Query;
 import javax.jdo.Transaction;
 
 import java.util.List;
 
 /**
- * Covenience base class that consolidates some common methods used by
- * JDO specific extensions.
+ * Covenience base class that consolidates some common methods used by JDO
+ * specific extensions.
  * 
  * @author <a href='mailto:rahul.thakur.xdev@gmail.com'>Rahul Thakur</a>
  * @version $Id$

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=493267&r1=493266&r2=493267
==============================================================================
--- 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
Fri Jan  5 17:19:33 2007
@@ -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.jdo.PlexusJdoUtils;
+import org.codehaus.plexus.jdo.PlexusStoreException;
 
 import java.util.List;
 
@@ -65,7 +67,17 @@
      */
     public ProjectGroup saveProjectGroup( ProjectGroup group ) throws ContinuumStoreException
     {
-        updateObject( group );
+        try
+        {
+            if ( group.getId() > 0 )
+                PlexusJdoUtils.saveObject( getPersistenceManager(), group, null );
+            else
+                PlexusJdoUtils.addObject( getPersistenceManager(), group, null );
+        }
+        catch ( PlexusStoreException e )
+        {
+            throw new ContinuumStoreException( "Error saving Project Group.", e );
+        }
         return group;
     }
 

Modified: maven/continuum/branches/key-based-refactor/continuum-store/src/main/java/org/apache/maven/continuum/store/jdo/JdoProjectStore.java
URL: http://svn.apache.org/viewvc/maven/continuum/branches/key-based-refactor/continuum-store/src/main/java/org/apache/maven/continuum/store/jdo/JdoProjectStore.java?view=diff&rev=493267&r1=493266&r2=493267
==============================================================================
--- maven/continuum/branches/key-based-refactor/continuum-store/src/main/java/org/apache/maven/continuum/store/jdo/JdoProjectStore.java
(original)
+++ maven/continuum/branches/key-based-refactor/continuum-store/src/main/java/org/apache/maven/continuum/store/jdo/JdoProjectStore.java
Fri Jan  5 17:19:33 2007
@@ -22,6 +22,8 @@
 import org.apache.maven.continuum.store.ContinuumObjectNotFoundException;
 import org.apache.maven.continuum.store.ContinuumStoreException;
 import org.apache.maven.continuum.store.ProjectStore;
+import org.codehaus.plexus.jdo.PlexusJdoUtils;
+import org.codehaus.plexus.jdo.PlexusStoreException;
 
 import javax.jdo.Extent;
 import javax.jdo.PersistenceManager;
@@ -77,7 +79,7 @@
 
             query.declareParameters( "String groupKey, String projectKey" );
 
-            query.setFilter( "this.project.groupkey == groupKey && this.project.key
== projectKey" );
+            query.setFilter( "this.project.groupKey == groupKey && this.project.key
== projectKey" );
 
             List result = (List) query.execute( key.getGroupKey(), key.getProjectKey() );
 
@@ -105,7 +107,17 @@
      */
     public Project saveProject( Project project ) throws ContinuumStoreException
     {
-        updateObject( project );
+        try
+        {
+            if ( project.getId() > 0 )
+                PlexusJdoUtils.saveObject( getPersistenceManager(), project, new String[0]
);
+            else
+                PlexusJdoUtils.addObject( getPersistenceManager(), project );
+        }
+        catch ( PlexusStoreException e )
+        {
+            throw new ContinuumStoreException( "Error saving Project.", e );
+        }
         return project;
     }
 

Modified: maven/continuum/branches/key-based-refactor/continuum-store/src/test/java/org/apache/maven/continuum/store/ibatis/AbstractIbatisStoreTestCase.java
URL: http://svn.apache.org/viewvc/maven/continuum/branches/key-based-refactor/continuum-store/src/test/java/org/apache/maven/continuum/store/ibatis/AbstractIbatisStoreTestCase.java?view=diff&rev=493267&r1=493266&r2=493267
==============================================================================
--- maven/continuum/branches/key-based-refactor/continuum-store/src/test/java/org/apache/maven/continuum/store/ibatis/AbstractIbatisStoreTestCase.java
(original)
+++ maven/continuum/branches/key-based-refactor/continuum-store/src/test/java/org/apache/maven/continuum/store/ibatis/AbstractIbatisStoreTestCase.java
Fri Jan  5 17:19:33 2007
@@ -17,6 +17,11 @@
  */
 
 import org.codehaus.plexus.PlexusTestCase;
+import org.dbunit.IDatabaseTester;
+import org.dbunit.JdbcDatabaseTester;
+import org.dbunit.dataset.xml.FlatXmlDataSet;
+import org.dbunit.dataset.xml.XmlDataSet;
+import org.dbunit.operation.DatabaseOperation;
 
 import java.io.BufferedReader;
 import java.io.File;
@@ -31,12 +36,15 @@
 
 /**
  * @author <a href='mailto:rahul.thakur.xdev@gmail.com'>Rahul Thakur</a>
- * @version $Id$
+ * @version $Id: AbstractIbatisStoreTestCase.java 491397 2006-12-31 06:32:52Z
+ *          rinku $
  * @since 1.1
  */
 public abstract class AbstractIbatisStoreTestCase extends PlexusTestCase
 {
 
+    private static final String TEST_DATA_XML = "src/test/resources/db/test-data.xml";
+
     /**
      * Default location for SQL test data.
      */
@@ -55,17 +63,22 @@
     /**
      * Driver class to connect to the target database instance.
      */
-    private static final String DRIVER_TEST_DATABASE = "org.hsqldb.jdbcDriver";
+    // private static final String DRIVER_TEST_DATABASE =
+    // "org.hsqldb.jdbcDriver";
+    private static final String DRIVER_TEST_DATABASE = "org.apache.derby.jdbc.EmbeddedDriver";
 
     /**
      * JDBC URL to connect to the target test database instance.
      */
-    private final String URL_TEST_DATABASE = "jdbc:hsqldb:mem:" + getName();
+    // private final String URL_TEST_DATABASE = "jdbc:hsqldb:mem:" + getName();
+    private final String URL_TEST_DATABASE = "jdbc:derby:" + getName() + ";create=true";
 
     /**
      * DDL for Database creation.
      */
-    private static final File SQL_DATABSE_SCHEMA = getTestFile( getBasedir(), "src/test/resources/db/schema.sql"
);
+    private static final String SQL_DATABSE_SCHEMA = "src/test/resources/db/schema.sql";
+
+    private IDatabaseTester dbTester;
 
     /**
      * Creates an instance of Continuum Database for test purposes and loads up
@@ -75,7 +88,19 @@
      */
     protected void createBuildDatabase() throws Exception
     {
+        dbTester =
+            new JdbcDatabaseTester( DRIVER_TEST_DATABASE, URL_TEST_DATABASE, USERNAME_TEST_DATABASE,
+                                    PASSWORD_TEST_DATABASE );
+        File testFile = getTestFile( getBasedir(), TEST_DATA_XML );
+        assertTrue( testFile.exists() );
+
+        // dbTester.setSchema( getName() );
 
+        dbTester.setDataSet( new XmlDataSet( new FileInputStream( testFile ) ) );
+
+        dbTester.setSetUpOperation( DatabaseOperation.INSERT );
+
+        dbTester.onSetup();
     }
 
     /**
@@ -85,7 +110,8 @@
      */
     protected void teardownBuildDatabase() throws Exception
     {
-
+        dbTester.setTearDownOperation( DatabaseOperation.DELETE );
+        dbTester.onTearDown();
     }
 
     /**
@@ -99,6 +125,7 @@
     {
         List list = new ArrayList();
         // add default test data source.
+        list.add( getTestFile( getBasedir(), SQL_DATABSE_SCHEMA ) );
         list.add( getTestFile( getBasedir(), SQL_TEST_DATA ) );
         return list;
     }

Modified: maven/continuum/branches/key-based-refactor/continuum-store/src/test/java/org/apache/maven/continuum/store/ibatis/IbatisProjectGroupTestCase.java
URL: http://svn.apache.org/viewvc/maven/continuum/branches/key-based-refactor/continuum-store/src/test/java/org/apache/maven/continuum/store/ibatis/IbatisProjectGroupTestCase.java?view=diff&rev=493267&r1=493266&r2=493267
==============================================================================
--- maven/continuum/branches/key-based-refactor/continuum-store/src/test/java/org/apache/maven/continuum/store/ibatis/IbatisProjectGroupTestCase.java
(original)
+++ maven/continuum/branches/key-based-refactor/continuum-store/src/test/java/org/apache/maven/continuum/store/ibatis/IbatisProjectGroupTestCase.java
Fri Jan  5 17:19:33 2007
@@ -17,7 +17,6 @@
  */
 
 import org.apache.maven.continuum.store.ProjectGroupStore;
-import org.codehaus.plexus.PlexusTestCase;
 
 import java.util.List;
 
@@ -26,8 +25,28 @@
  * @version $Id: IbatisProjectGroupTestCase.java 491371 2006-12-31 03:00:05Z
  *          rinku $
  */
-public class IbatisProjectGroupTestCase extends PlexusTestCase
+public class IbatisProjectGroupTestCase extends AbstractIbatisStoreTestCase
 {
+
+    /**
+     * {@inheritDoc}
+     * 
+     * @see org.codehaus.plexus.PlexusTestCase#setUp()
+     */
+    protected void setUp() throws Exception
+    {
+        createBuildDatabase();
+    }
+
+    /**
+     * {@inheritDoc}
+     * 
+     * @see org.codehaus.plexus.PlexusTestCase#tearDown()
+     */
+    protected void tearDown() throws Exception
+    {
+        teardownBuildDatabase();
+    }
 
     public void testLookup() throws Exception
     {

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=493267&r1=493266&r2=493267
==============================================================================
--- 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
Fri Jan  5 17:19:33 2007
@@ -86,19 +86,8 @@
         String groupKey = "AddProjectGroupKey";
         ProjectGroup group = StoreTestUtils.createTestProjectGroup( name, description, groupId,
groupKey );
 
-        ProjectGroup copy = StoreTestUtils.createTestProjectGroup( group );
-        assertNotNull( copy );
-        
-        
-        group = store.saveProjectGroup( group );        
+        group = store.saveProjectGroup( group );
         assertNotNull( group );
-        /*
-        copy.setId( group.getId() );
-
-        ProjectGroup retrievedGroup = store.lookupProjectGroup( new GroupProjectKey( group.getKey(),
null ) );
-        assertNotNull( retrievedGroup );
-        StoreTestUtils.assertProjectGroupEquals( copy, retrievedGroup );
-        */
     }
 
 }

Added: maven/continuum/branches/key-based-refactor/continuum-store/src/test/resources/db/dataset.dtd
URL: http://svn.apache.org/viewvc/maven/continuum/branches/key-based-refactor/continuum-store/src/test/resources/db/dataset.dtd?view=auto&rev=493267
==============================================================================
--- maven/continuum/branches/key-based-refactor/continuum-store/src/test/resources/db/dataset.dtd
(added)
+++ maven/continuum/branches/key-based-refactor/continuum-store/src/test/resources/db/dataset.dtd
Fri Jan  5 17:19:33 2007
@@ -0,0 +1,17 @@
+<?xml version='1.0' encoding='UTF-8' ?>
+
+<!ELEMENT dataset (table+)>
+
+<!ELEMENT table (column* , row*)>
+
+<!ATTLIST table  name CDATA  #REQUIRED >
+<!ELEMENT column (#PCDATA)>
+
+<!ELEMENT row (value | null)*>
+
+<!ELEMENT value (#PCDATA)>
+
+<!ELEMENT null EMPTY>
+
+
+

Propchange: maven/continuum/branches/key-based-refactor/continuum-store/src/test/resources/db/dataset.dtd
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: maven/continuum/branches/key-based-refactor/continuum-store/src/test/resources/db/dataset.dtd
------------------------------------------------------------------------------
    svn:keywords = "Author Date Id Revision"

Modified: maven/continuum/branches/key-based-refactor/continuum-store/src/test/resources/db/schema.sql
URL: http://svn.apache.org/viewvc/maven/continuum/branches/key-based-refactor/continuum-store/src/test/resources/db/schema.sql?view=diff&rev=493267&r1=493266&r2=493267
==============================================================================
--- maven/continuum/branches/key-based-refactor/continuum-store/src/test/resources/db/schema.sql
(original)
+++ maven/continuum/branches/key-based-refactor/continuum-store/src/test/resources/db/schema.sql
Fri Jan  5 17:19:33 2007
@@ -173,7 +173,7 @@
     GROUP_ID VARCHAR(256) NULL,
     GROUPKEY VARCHAR(256) NOT NULL,
     MODEL_ENCODING VARCHAR(256) NULL,
-    "NAME" VARCHAR(256) NULL,
+    NAME VARCHAR(256) NULL,
     PRIMARY KEY (ID)
 );
 

Added: maven/continuum/branches/key-based-refactor/continuum-store/src/test/resources/db/test-data.xml
URL: http://svn.apache.org/viewvc/maven/continuum/branches/key-based-refactor/continuum-store/src/test/resources/db/test-data.xml?view=auto&rev=493267
==============================================================================
--- maven/continuum/branches/key-based-refactor/continuum-store/src/test/resources/db/test-data.xml
(added)
+++ maven/continuum/branches/key-based-refactor/continuum-store/src/test/resources/db/test-data.xml
Fri Jan  5 17:19:33 2007
@@ -0,0 +1,126 @@
+<!DOCTYPE dataset SYSTEM "dataset.dtd">
+<dataset>
+  <table name="PROJECTGROUP">
+    <column>ID</column>
+    <column>DESCRIPTION</column>
+    <column>GROUP_ID</column>
+    <column>GROUP_KEY</column>
+    <column>GROUPKEY</column>
+    <column>MODEL_ENCODING</column>
+    <column>NAME</column>
+    <row>
+      <value>1</value>
+      <value>Default Group</value>
+      <value>default</value>
+      <value>Default</value>
+      <value>Default Group</value>
+    </row>
+    <row>
+      <value>2</value>
+      <value>Group for Maven Projects</value>
+      <value>org.apache.maven</value>
+      <value>MavenGroup</value>
+      <value>Maven Group</value>
+    </row>
+    <row>
+      <value>3</value>
+      <value>Group for Continuum Projects</value>
+      <value>org.apache.maven.continuum</value>
+      <value>ContinuumGroup</value>
+      <value>Continuum Group</value>
+    </row>
+    <row>
+      <value>999</value>
+      <value>Deleteable Group</value>
+      <value>org.group.deleteable</value>
+      <value>DeleteableGroup</value>
+      <value>Deleteable Group</value>
+    </row>
+  </table>
+ 
+  <table name="PROJECT">
+    <column>ID</column>
+    <column>DESCRIPTION</column>
+    <column>ARTIFACT_ID</column>
+    <column>GROUP_ID</column>
+    <column>GROUP_KEY</column>
+    <column>PROJECTKEY</column>
+    <column>NAME</column>
+    <column>BUILD_NUMBER</column>
+    <column>LATEST_BUILD_ID</column>
+    <column>OLD_STATE</column>
+    <column>PROJECT_GROUP_ID_OID</column>
+    <column>STATE</column>
+    <row>
+      <value>1</value>
+      <value>Test Project 1</value>
+      <value>project-1</value>
+      <value>org.test.projects</value>
+      <value>Default</value>
+      <value>project1</value>
+      <value>Project 1</value>
+      <value>0</value>
+      <value>0</value>
+      <value>0</value>
+      <value>1</value>
+      <value>0</value>
+    </row>
+    <row>
+      <value>2</value>
+      <value>Test Project 2</value>
+      <value>project-2</value>
+      <value>org.test.projects</value>
+      <value>Group1</value>
+      <value>project2</value>
+      <value>Project 2</value>
+      <value>0</value>
+      <value>0</value>
+      <value>0</value>
+      <value>2</value>
+      <value>0</value>
+    </row>
+    <row>
+      <value>3</value>
+      <value>Test Project 3</value>
+      <value>project-3</value>
+      <value>org.test.projects</value>
+      <value>MavenGroup</value>
+      <value>project3</value>
+      <value>Project 3</value>
+      <value>0</value>
+      <value>0</value>
+      <value>0</value>
+      <value>2</value>
+      <value>0</value>
+    </row>
+    <row>
+      <value>4</value>
+      <value>Test Project 4</value>
+      <value>project-4</value>
+      <value>org.test.projects</value>
+      <value>ContinuumGroup</value>
+      <value>project4</value>
+      <value>Project 4</value>
+      <value>0</value>
+      <value>0</value>
+      <value>0</value>
+      <value>3</value>
+      <value>0</value>
+    </row>
+    <row>
+      <value>5</value>
+      <value>Test Project 5</value>
+      <value>project-5</value>
+      <value>org.test.projects</value>
+      <value>ContinuumGroup</value>
+      <value>project5</value>
+      <value>Project 5</value>
+      <value>0</value>
+      <value>0</value>
+      <value>0</value>
+      <value>3</value>
+      <value>0</value>
+    </row>
+  </table>
+ 
+</dataset>
\ No newline at end of file

Propchange: maven/continuum/branches/key-based-refactor/continuum-store/src/test/resources/db/test-data.xml
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: maven/continuum/branches/key-based-refactor/continuum-store/src/test/resources/db/test-data.xml
------------------------------------------------------------------------------
    svn:keywords = "Author Date Id Revision"



Mime
View raw message