continuum-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From car...@apache.org
Subject svn commit: r442733 - in /maven/continuum/branches/continuum-acegi: continuum-core/src/main/java/org/apache/maven/continuum/ continuum-core/src/main/java/org/apache/maven/continuum/initialization/ continuum-core/src/test/java/org/apache/maven/continuum...
Date Tue, 12 Sep 2006 22:10:21 GMT
Author: carlos
Date: Tue Sep 12 15:10:20 2006
New Revision: 442733

URL: http://svn.apache.org/viewvc?view=rev&rev=442733
Log:
Fix test problems with the default project group add

Modified:
    maven/continuum/branches/continuum-acegi/continuum-core/src/main/java/org/apache/maven/continuum/DefaultContinuum.java
    maven/continuum/branches/continuum-acegi/continuum-core/src/main/java/org/apache/maven/continuum/initialization/DefaultContinuumInitializer.java
    maven/continuum/branches/continuum-acegi/continuum-core/src/test/java/org/apache/maven/continuum/DefaultContinuumTest.java
    maven/continuum/branches/continuum-acegi/continuum-security/continuum-security-acegi/src/main/java/org/apache/maven/continuum/security/acegi/acl/AclInitializer.java
    maven/continuum/branches/continuum-acegi/continuum-security/continuum-security-acegi/src/test/java/org/apache/maven/continuum/security/acegi/acl/AclInitializerPlexusTest.java
    maven/continuum/branches/continuum-acegi/continuum-security/continuum-security-acegi/src/test/java/org/apache/maven/continuum/security/acegi/acl/AclInitializerTest.java
    maven/continuum/branches/continuum-acegi/continuum-security/continuum-security-acegi/src/test/resources/org/apache/maven/continuum/security/acegi/acl/AclInitializerPlexusTest.xml
    maven/continuum/branches/continuum-acegi/continuum-test/src/main/java/org/apache/maven/continuum/AbstractContinuumTest.java

Modified: maven/continuum/branches/continuum-acegi/continuum-core/src/main/java/org/apache/maven/continuum/DefaultContinuum.java
URL: http://svn.apache.org/viewvc/maven/continuum/branches/continuum-acegi/continuum-core/src/main/java/org/apache/maven/continuum/DefaultContinuum.java?view=diff&rev=442733&r1=442732&r2=442733
==============================================================================
--- maven/continuum/branches/continuum-acegi/continuum-core/src/main/java/org/apache/maven/continuum/DefaultContinuum.java
(original)
+++ maven/continuum/branches/continuum-acegi/continuum-core/src/main/java/org/apache/maven/continuum/DefaultContinuum.java
Tue Sep 12 15:10:20 2006
@@ -2557,7 +2557,7 @@
     {
         try
         {
-            return store.getProjectGroupByGroupId( Continuum.DEFAULT_PROJECT_GROUP_GROUP_ID
);
+            return store.getProjectGroupByGroupIdWithProjects( Continuum.DEFAULT_PROJECT_GROUP_GROUP_ID
);
         }
         catch ( ContinuumObjectNotFoundException e )
         {

Modified: maven/continuum/branches/continuum-acegi/continuum-core/src/main/java/org/apache/maven/continuum/initialization/DefaultContinuumInitializer.java
URL: http://svn.apache.org/viewvc/maven/continuum/branches/continuum-acegi/continuum-core/src/main/java/org/apache/maven/continuum/initialization/DefaultContinuumInitializer.java?view=diff&rev=442733&r1=442732&r2=442733
==============================================================================
--- maven/continuum/branches/continuum-acegi/continuum-core/src/main/java/org/apache/maven/continuum/initialization/DefaultContinuumInitializer.java
(original)
+++ maven/continuum/branches/continuum-acegi/continuum-core/src/main/java/org/apache/maven/continuum/initialization/DefaultContinuumInitializer.java
Tue Sep 12 15:10:20 2006
@@ -27,6 +27,7 @@
 import org.apache.maven.continuum.model.system.SystemConfiguration;
 import org.apache.maven.continuum.model.system.UserGroup;
 import org.apache.maven.continuum.security.ContinuumSecurity;
+import org.apache.maven.continuum.store.ContinuumObjectNotFoundException;
 import org.apache.maven.continuum.store.ContinuumStore;
 import org.apache.maven.continuum.store.ContinuumStoreException;
 import org.apache.maven.user.model.PasswordRuleViolationException;
@@ -315,15 +316,24 @@
     }
 
     private void createDefaultProjectGroup()
+        throws ContinuumStoreException
     {
-        ProjectGroup group = new ProjectGroup();
+        ProjectGroup group;
+        try
+        {
+            group = store.getProjectGroupByGroupId( Continuum.DEFAULT_PROJECT_GROUP_GROUP_ID
);
+        }
+        catch ( ContinuumObjectNotFoundException e )
+        {
+            group = new ProjectGroup();
 
-        group.setName( "Default Project Group" );
+            group.setName( "Default Project Group" );
 
-        group.setGroupId( Continuum.DEFAULT_PROJECT_GROUP_GROUP_ID );
+            group.setGroupId( Continuum.DEFAULT_PROJECT_GROUP_GROUP_ID );
 
-        group.setDescription( "Contains all projects that do not have a group of their own"
);
+            group.setDescription( "Contains all projects that do not have a group of their
own" );
 
-        group = store.addProjectGroup( group );
+            group = store.addProjectGroup( group );
+        }
     }
 }

Modified: maven/continuum/branches/continuum-acegi/continuum-core/src/test/java/org/apache/maven/continuum/DefaultContinuumTest.java
URL: http://svn.apache.org/viewvc/maven/continuum/branches/continuum-acegi/continuum-core/src/test/java/org/apache/maven/continuum/DefaultContinuumTest.java?view=diff&rev=442733&r1=442732&r2=442733
==============================================================================
--- maven/continuum/branches/continuum-acegi/continuum-core/src/test/java/org/apache/maven/continuum/DefaultContinuumTest.java
(original)
+++ maven/continuum/branches/continuum-acegi/continuum-core/src/test/java/org/apache/maven/continuum/DefaultContinuumTest.java
Tue Sep 12 15:10:20 2006
@@ -219,21 +219,28 @@
     {
         Continuum continuum = (Continuum) lookup( Continuum.ROLE );
 
+        Collection projectGroupList = continuum.getAllProjectGroupsWithProjects();
+
+        int projectGroupsBefore = projectGroupList.size();
+
+        assertEquals( 1, projectGroupsBefore );
+
         String url = getTestFile( "src/test-projects/project1/pom.xml" ).toURL().toExternalForm();
 
         ContinuumProjectBuildingResult result = continuum.addMavenTwoProject( url );
 
         assertNotNull( result );
-        
+
         assertEquals( 1, result.getProjectGroups().size() );
-        
+
         ProjectGroup projectGroup = (ProjectGroup) result.getProjectGroups().get( 0 );
 
-        assertEquals( 1, projectGroup.getId() );
+        assertEquals( "plexus", projectGroup.getGroupId() );
 
-        Collection projectGroupList = continuum.getAllProjectGroupsWithProjects();
+        projectGroupList = continuum.getAllProjectGroupsWithProjects();
 
-        assertEquals( "Project group missing, should have two project groups", 1, projectGroupList.size()
);
+        assertEquals( "Project group missing, should have " + ( projectGroupsBefore + 1 )
+ " project groups",
+                      projectGroupsBefore + 1, projectGroupList.size() );
 
         projectGroup = (ProjectGroup) projectGroupList.iterator().next();
 
@@ -243,6 +250,6 @@
 
         projectGroupList = continuum.getAllProjectGroupsWithProjects();
 
-        assertEquals ( "Remove project group failed", 0, projectGroupList.size() );
+        assertEquals( "Remove project group failed", projectGroupsBefore, projectGroupList.size()
);
     }
 }

Modified: maven/continuum/branches/continuum-acegi/continuum-security/continuum-security-acegi/src/main/java/org/apache/maven/continuum/security/acegi/acl/AclInitializer.java
URL: http://svn.apache.org/viewvc/maven/continuum/branches/continuum-acegi/continuum-security/continuum-security-acegi/src/main/java/org/apache/maven/continuum/security/acegi/acl/AclInitializer.java?view=diff&rev=442733&r1=442732&r2=442733
==============================================================================
--- maven/continuum/branches/continuum-acegi/continuum-security/continuum-security-acegi/src/main/java/org/apache/maven/continuum/security/acegi/acl/AclInitializer.java
(original)
+++ maven/continuum/branches/continuum-acegi/continuum-security/continuum-security-acegi/src/main/java/org/apache/maven/continuum/security/acegi/acl/AclInitializer.java
Tue Sep 12 15:10:20 2006
@@ -39,6 +39,16 @@
      */
     private ContinuumStore store;
 
+    public void setStore( ContinuumStore store )
+    {
+        this.store = store;
+    }
+
+    public ContinuumStore getStore()
+    {
+        return store;
+    }
+
     protected void insertDefaultData()
     {
         /* 
@@ -57,7 +67,7 @@
         ProjectGroup defaultProjectGroup;
         try
         {
-            defaultProjectGroup = store.getProjectGroupByGroupId( Continuum.DEFAULT_PROJECT_GROUP_GROUP_ID
);
+            defaultProjectGroup = getStore().getProjectGroupByGroupId( Continuum.DEFAULT_PROJECT_GROUP_GROUP_ID
);
         }
         catch ( ContinuumStoreException e )
         {

Modified: maven/continuum/branches/continuum-acegi/continuum-security/continuum-security-acegi/src/test/java/org/apache/maven/continuum/security/acegi/acl/AclInitializerPlexusTest.java
URL: http://svn.apache.org/viewvc/maven/continuum/branches/continuum-acegi/continuum-security/continuum-security-acegi/src/test/java/org/apache/maven/continuum/security/acegi/acl/AclInitializerPlexusTest.java?view=diff&rev=442733&r1=442732&r2=442733
==============================================================================
--- maven/continuum/branches/continuum-acegi/continuum-security/continuum-security-acegi/src/test/java/org/apache/maven/continuum/security/acegi/acl/AclInitializerPlexusTest.java
(original)
+++ maven/continuum/branches/continuum-acegi/continuum-security/continuum-security-acegi/src/test/java/org/apache/maven/continuum/security/acegi/acl/AclInitializerPlexusTest.java
Tue Sep 12 15:10:20 2006
@@ -16,6 +16,9 @@
  * limitations under the License.
  */
 
+import org.apache.maven.continuum.Continuum;
+import org.apache.maven.continuum.model.project.ProjectGroup;
+import org.apache.maven.continuum.store.ContinuumStore;
 import org.codehaus.plexus.PlexusTestCase;
 
 /**
@@ -34,7 +37,14 @@
         throws Exception
     {
         super.setUp();
+        ContinuumStore store = (ContinuumStore) super.lookup( ContinuumStore.ROLE );
+
+        ProjectGroup projectGroup = new ProjectGroup();
+        projectGroup.setGroupId( Continuum.DEFAULT_PROJECT_GROUP_GROUP_ID );
+        store.addProjectGroup( projectGroup );
+
         initializer = (AclInitializer) super.lookup( AclInitializer.ROLE );
+
     }
 
     public void testInitialize()

Modified: maven/continuum/branches/continuum-acegi/continuum-security/continuum-security-acegi/src/test/java/org/apache/maven/continuum/security/acegi/acl/AclInitializerTest.java
URL: http://svn.apache.org/viewvc/maven/continuum/branches/continuum-acegi/continuum-security/continuum-security-acegi/src/test/java/org/apache/maven/continuum/security/acegi/acl/AclInitializerTest.java?view=diff&rev=442733&r1=442732&r2=442733
==============================================================================
--- maven/continuum/branches/continuum-acegi/continuum-security/continuum-security-acegi/src/test/java/org/apache/maven/continuum/security/acegi/acl/AclInitializerTest.java
(original)
+++ maven/continuum/branches/continuum-acegi/continuum-security/continuum-security-acegi/src/test/java/org/apache/maven/continuum/security/acegi/acl/AclInitializerTest.java
Tue Sep 12 15:10:20 2006
@@ -18,13 +18,15 @@
 
 import javax.sql.DataSource;
 
-import junit.framework.TestCase;
-
 import org.acegisecurity.acl.basic.jdbc.JdbcExtendedDaoImpl;
 import org.apache.commons.dbcp.BasicDataSource;
+import org.apache.maven.continuum.model.project.ProjectGroup;
+import org.apache.maven.continuum.store.ContinuumStore;
 import org.codehaus.mojo.sql.SqlExecMojo;
 import org.codehaus.plexus.logging.Logger;
 import org.codehaus.plexus.logging.console.ConsoleLogger;
+import org.jmock.Mock;
+import org.jmock.MockObjectTestCase;
 
 /**
  * Test for {@link AclInitializer}
@@ -33,13 +35,15 @@
  * @version $Id$
  */
 public class AclInitializerTest
-    extends TestCase
+    extends MockObjectTestCase
 {
 
     private AclInitializer initializer;
-    
+
     private SqlExecMojo sqlMojo;
 
+    private Mock store;
+
     protected void setUp()
         throws Exception
     {
@@ -59,11 +63,17 @@
         JdbcExtendedDaoImpl dao = new JdbcExtendedDaoImpl();
         dao.setDataSource( getDataSource() );
         initializer.setDao( dao );
+
+        store = mock( ContinuumStore.class );
+        initializer.setStore( (ContinuumStore) store.proxy() );
     }
 
     public void testInitialize()
         throws Exception
     {
+        ProjectGroup parentGroup = new ProjectGroup();
+        parentGroup.setId( 1 );
+        store.expects( once() ).method( "getProjectGroupByGroupId" ).will( returnValue( parentGroup
) );
         initializer.initialize();
         initializer.initialize();
     }

Modified: maven/continuum/branches/continuum-acegi/continuum-security/continuum-security-acegi/src/test/resources/org/apache/maven/continuum/security/acegi/acl/AclInitializerPlexusTest.xml
URL: http://svn.apache.org/viewvc/maven/continuum/branches/continuum-acegi/continuum-security/continuum-security-acegi/src/test/resources/org/apache/maven/continuum/security/acegi/acl/AclInitializerPlexusTest.xml?view=diff&rev=442733&r1=442732&r2=442733
==============================================================================
--- maven/continuum/branches/continuum-acegi/continuum-security/continuum-security-acegi/src/test/resources/org/apache/maven/continuum/security/acegi/acl/AclInitializerPlexusTest.xml
(original)
+++ maven/continuum/branches/continuum-acegi/continuum-security/continuum-security-acegi/src/test/resources/org/apache/maven/continuum/security/acegi/acl/AclInitializerPlexusTest.xml
Tue Sep 12 15:10:20 2006
@@ -14,6 +14,10 @@
           <role>org.acegisecurity.acl.basic.BasicAclExtendedDao</role>
           <field-name>dao</field-name>
         </requirement>
+        <requirement>
+          <role>org.apache.maven.continuum.store.ContinuumStore</role>
+          <field-name>store</field-name>
+        </requirement>
       </requirements>
       <configuration>
         <sqlClasspathResource>org/apache/maven/user/acegi/acl/acegi-acl-derby.sql</sqlClasspathResource>
@@ -51,6 +55,50 @@
         <driver>org.apache.derby.jdbc.EmbeddedDriver</driver>
         <url>jdbc:derby:${plexus.home}/database;create=true</url>
         <onError>continue</onError>
+      </configuration>
+    </component>
+
+    <component>
+      <role>org.codehaus.plexus.jdo.JdoFactory</role>
+      <implementation>org.codehaus.plexus.jdo.DefaultConfigurableJdoFactory</implementation>
+      <configuration>
+        <driverName>org.apache.derby.jdbc.EmbeddedDriver</driverName>
+        <url>jdbc:derby:${plexus.home}/database;create=true</url>
+        <userName>sa</userName>
+        <password></password>
+
+        <!-- JPOX and JDO configuration -->
+        <persistenceManagerFactoryClass>org.jpox.PersistenceManagerFactoryImpl</persistenceManagerFactoryClass>
+        <otherProperties>
+          <property>
+            <name>org.jpox.autoCreateSchema</name>
+            <value>true</value>
+          </property>
+          <property>
+            <name>org.jpox.autoStartMechanism</name>
+            <value>SchemaTable</value>
+          </property>
+          <property>
+            <name>org.jpox.autoStartMechanismMode</name>
+            <value>Ignored</value>
+          </property>
+          <property>
+            <name>org.jpox.validateTables</name>
+            <value>false</value>
+          </property>
+          <property>
+            <name>org.jpox.validateConstraints</name>
+            <value>false</value>
+          </property>
+          <property>
+            <name>org.jpox.transactionIsolation</name>
+            <value>READ_UNCOMMITTED</value>
+          </property>
+          <property>
+            <name>org.jpox.poid.transactionIsolation</name>
+            <value>READ_UNCOMMITTED</value>
+          </property>
+        </otherProperties>
       </configuration>
     </component>
 

Modified: maven/continuum/branches/continuum-acegi/continuum-test/src/main/java/org/apache/maven/continuum/AbstractContinuumTest.java
URL: http://svn.apache.org/viewvc/maven/continuum/branches/continuum-acegi/continuum-test/src/main/java/org/apache/maven/continuum/AbstractContinuumTest.java?view=diff&rev=442733&r1=442732&r2=442733
==============================================================================
--- maven/continuum/branches/continuum-acegi/continuum-test/src/main/java/org/apache/maven/continuum/AbstractContinuumTest.java
(original)
+++ maven/continuum/branches/continuum-acegi/continuum-test/src/main/java/org/apache/maven/continuum/AbstractContinuumTest.java
Tue Sep 12 15:10:20 2006
@@ -23,6 +23,7 @@
 import org.apache.maven.continuum.model.project.ProjectGroup;
 import org.apache.maven.continuum.model.project.ProjectNotifier;
 import org.apache.maven.continuum.model.scm.ScmResult;
+import org.apache.maven.continuum.store.ContinuumObjectNotFoundException;
 import org.apache.maven.continuum.store.ContinuumStore;
 import org.apache.maven.continuum.store.ContinuumStoreException;
 import org.codehaus.plexus.PlexusTestCase;
@@ -36,6 +37,7 @@
 
 import java.net.URL;
 import java.util.ArrayList;
+import java.util.Collection;
 import java.util.Iterator;
 import java.util.List;
 import java.util.Map;
@@ -62,6 +64,38 @@
         getStore();
 
         setUpConfigurationService( (ConfigurationService) lookup( ConfigurationService.ROLE
) );
+        
+        Collection projectGroups = store.getAllProjectGroupsWithProjects();
+
+        assertEquals( 0, projectGroups.size() );
+
+        createDefaultProjectGroup();
+        
+        projectGroups = store.getAllProjectGroupsWithProjects();
+        
+        assertEquals( 1, projectGroups.size() );
+    }
+
+    protected void createDefaultProjectGroup()
+        throws Exception
+    {
+        ProjectGroup group;
+        try
+        {
+            group = getDefaultProjectGroup();
+        }
+        catch ( ContinuumObjectNotFoundException e )
+        {
+            group = new ProjectGroup();
+
+            group.setName( "Default Project Group" );
+
+            group.setGroupId( Continuum.DEFAULT_PROJECT_GROUP_GROUP_ID );
+
+            group.setDescription( "Contains all projects that do not have a group of their
own" );
+
+            group = store.addProjectGroup( group );
+        }
     }
 
     public static void setUpConfigurationService( ConfigurationService configurationService
)
@@ -79,7 +113,7 @@
     protected ProjectGroup getDefaultProjectGroup()
         throws ContinuumStoreException
     {
-        return store.getProjectGroupByGroupId( Continuum.DEFAULT_PROJECT_GROUP_GROUP_ID );
+        return store.getProjectGroupByGroupIdWithProjects( Continuum.DEFAULT_PROJECT_GROUP_GROUP_ID
);
     }
 
     // ----------------------------------------------------------------------



Mime
View raw message