continuum-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From eveni...@apache.org
Subject svn commit: r548732 [2/3] - in /maven/continuum/trunk: ./ continuum-api/src/main/java/org/apache/maven/continuum/ continuum-api/src/main/java/org/apache/maven/continuum/installation/ continuum-api/src/main/java/org/apache/maven/continuum/profile/ conti...
Date Tue, 19 Jun 2007 14:04:17 GMT
Added: maven/continuum/trunk/continuum-core/src/test/java/org/apache/maven/continuum/initialization/DefaultContinuumInitializerTest.java
URL: http://svn.apache.org/viewvc/maven/continuum/trunk/continuum-core/src/test/java/org/apache/maven/continuum/initialization/DefaultContinuumInitializerTest.java?view=auto&rev=548732
==============================================================================
--- maven/continuum/trunk/continuum-core/src/test/java/org/apache/maven/continuum/initialization/DefaultContinuumInitializerTest.java (added)
+++ maven/continuum/trunk/continuum-core/src/test/java/org/apache/maven/continuum/initialization/DefaultContinuumInitializerTest.java Tue Jun 19 07:04:13 2007
@@ -0,0 +1,56 @@
+package org.apache.maven.continuum.initialization;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+import org.apache.maven.continuum.AbstractContinuumTest;
+import org.apache.maven.continuum.model.project.Schedule;
+import org.apache.maven.continuum.store.ContinuumStore;
+
+/**
+ * @author <a href="mailto:olamy@codehaus.org">olamy</a>
+ * @since 4 juin 07
+ * @version $Id$
+ */
+public class DefaultContinuumInitializerTest
+    extends AbstractContinuumTest
+{
+
+    protected void setUp()
+        throws Exception
+    {
+        super.setUp();
+        ContinuumInitializer continuumInitializer = (ContinuumInitializer) lookup( ContinuumInitializer.ROLE, "default" );
+        continuumInitializer.initialize();
+    }
+
+    public ContinuumStore getContinuumStore()
+        throws Exception
+    {
+        return (ContinuumStore) lookup( ContinuumStore.ROLE, "jdo" );
+    }
+
+    public void testDefaultSchedule()
+        throws Exception
+    {
+        Schedule schedule = getContinuumStore().getScheduleByName( DefaultContinuumInitializer.DEFAULT_SCHEDULE_NAME );
+        assertNotNull( schedule );
+    }
+
+}

Propchange: maven/continuum/trunk/continuum-core/src/test/java/org/apache/maven/continuum/initialization/DefaultContinuumInitializerTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: maven/continuum/trunk/continuum-core/src/test/java/org/apache/maven/continuum/initialization/DefaultContinuumInitializerTest.java
------------------------------------------------------------------------------
    svn:keywords = "Author Date Id Revision"

Added: maven/continuum/trunk/continuum-core/src/test/java/org/apache/maven/continuum/installation/DefaultInstallationServiceTest.java
URL: http://svn.apache.org/viewvc/maven/continuum/trunk/continuum-core/src/test/java/org/apache/maven/continuum/installation/DefaultInstallationServiceTest.java?view=auto&rev=548732
==============================================================================
--- maven/continuum/trunk/continuum-core/src/test/java/org/apache/maven/continuum/installation/DefaultInstallationServiceTest.java (added)
+++ maven/continuum/trunk/continuum-core/src/test/java/org/apache/maven/continuum/installation/DefaultInstallationServiceTest.java Tue Jun 19 07:04:13 2007
@@ -0,0 +1,158 @@
+package org.apache.maven.continuum.installation;
+
+import java.util.List;
+
+import org.apache.maven.continuum.AbstractContinuumTest;
+import org.apache.maven.continuum.model.system.Installation;
+import org.apache.maven.continuum.store.ContinuumStore;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+/**
+ * @author <a href="mailto:olamy@codehaus.org">olamy</a>
+ * @since 13 juin 07
+ * @version $Id$
+ */
+public class DefaultInstallationServiceTest
+    extends AbstractContinuumTest
+{
+    private static final String DEFAULT_INSTALLATION_NAME = "defaultInstallation";
+
+    private static final String NEW_INSTALLATION_NAME = "newInstallation";
+
+    public Installation defaultInstallation;
+
+    protected void setUp()
+        throws Exception
+    {
+        super.setUp();
+        getStore().eraseDatabase();
+        if ( getInstallationService().getInstallation( DEFAULT_INSTALLATION_NAME ) == null )
+        {
+            defaultInstallation = createDefault();
+            ContinuumStore store = getStore();
+            defaultInstallation = store.addInstallation( defaultInstallation );
+        }
+    }
+
+    private Installation createDefault()
+    {
+        Installation installation = new Installation();
+        installation.setType( "description" );
+        installation.setName( DEFAULT_INSTALLATION_NAME );
+        installation.setVarName( "varName" );
+        installation.setVarValue( "varValue" );
+        return installation;
+    }
+
+    private InstallationService getInstallationService()
+        throws Exception
+    {
+        //Continuum continuum = (Continuum) lookup( Continuum.ROLE );
+        //return continuum.getInstallationService();
+        return (InstallationService) lookup( InstallationService.ROLE );
+    }
+
+    private Installation addInstallation( String name, String varName, String varValue, String type )
+        throws Exception
+    {
+
+        Installation installation = new Installation();
+        installation.setType( InstallationService.JDK_TYPE );
+        installation.setName( name );
+        installation.setVarName( varName );
+        installation.setVarValue( varValue );
+        return getInstallationService().add( installation );
+    }
+
+    public void testAddInstallation()
+        throws Exception
+    {
+        this.addInstallation( NEW_INSTALLATION_NAME, null, "bar", InstallationService.JDK_TYPE );
+        Installation getted = getInstallationService().getInstallation( NEW_INSTALLATION_NAME );
+        assertNotNull( getted );
+        assertEquals( getInstallationService().getEnvVar( InstallationService.JDK_TYPE ), getted.getVarName() );
+        assertEquals( "bar", getted.getVarValue() );
+    }
+
+    public void testgetOne()
+        throws Exception
+    {
+        Installation getted = getInstallationService().getInstallation( DEFAULT_INSTALLATION_NAME );
+        assertNotNull( getted );
+        assertEquals( defaultInstallation.getType(), getted.getType() );
+        assertEquals( defaultInstallation.getName(), getted.getName() );
+        assertEquals( defaultInstallation.getVarName(), getted.getVarName() );
+        assertEquals( defaultInstallation.getVarValue(), getted.getVarValue() );
+    }
+
+    public void testRemove()
+        throws Exception
+    {
+        String name = "toremove";
+        this.addInstallation( name, "foo", "bar", InstallationService.JDK_TYPE );
+        Installation getted = getInstallationService().getInstallation( name );
+        assertNotNull( getted );
+        getInstallationService().delete( getted );
+        getted = getInstallationService().getInstallation( name );
+        assertNull( getted );
+
+    }
+
+    public void testUpdate()
+        throws Exception
+    {
+        String name = "toupdate";
+        this.addInstallation( name, "foo", "bar", InstallationService.JDK_TYPE );
+        Installation getted = getInstallationService().getInstallation( name );
+        assertNotNull( getted );
+        assertEquals( getInstallationService().getEnvVar( InstallationService.JDK_TYPE ), getted.getVarName() );
+        assertEquals( "bar", getted.getVarValue() );
+        getted.setVarName( "updatefoo" );
+        getted.setVarValue( "updatedbar" );
+        getInstallationService().update( getted );
+        getted = getInstallationService().getInstallation( name );
+        assertNotNull( getted );
+        assertEquals( getInstallationService().getEnvVar( InstallationService.JDK_TYPE ), getted.getVarName() );
+        assertEquals( "updatedbar", getted.getVarValue() );
+    }
+
+    public void testgetDefaultJdkInformations()
+        throws Exception
+    {
+        InstallationService installationService = (InstallationService) lookup( InstallationService.ROLE, "default" );
+        List<String> infos = installationService.getDefaultJdkInformations();
+        assertNotNull( infos );
+    }
+
+    public void testgetJdkInformations()
+        throws Exception
+    {
+        InstallationService installationService = (InstallationService) lookup( InstallationService.ROLE, "default" );
+        String javaHome = System.getProperty( "JAVA_HOME" );
+        Installation installation = new Installation();
+        installation.setName( "test" );
+        installation.setType( InstallationService.JDK_TYPE );
+        installation.setVarValue( javaHome );
+
+        List<String> infos = installationService.getJdkInformations( installation );
+        assertNotNull( infos );
+    }
+}

Propchange: maven/continuum/trunk/continuum-core/src/test/java/org/apache/maven/continuum/installation/DefaultInstallationServiceTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: maven/continuum/trunk/continuum-core/src/test/java/org/apache/maven/continuum/installation/DefaultInstallationServiceTest.java
------------------------------------------------------------------------------
    svn:keywords = "Author Date Id Revision"

Added: maven/continuum/trunk/continuum-core/src/test/java/org/apache/maven/continuum/profile/DefaultProfileServiceTest.java
URL: http://svn.apache.org/viewvc/maven/continuum/trunk/continuum-core/src/test/java/org/apache/maven/continuum/profile/DefaultProfileServiceTest.java?view=auto&rev=548732
==============================================================================
--- maven/continuum/trunk/continuum-core/src/test/java/org/apache/maven/continuum/profile/DefaultProfileServiceTest.java (added)
+++ maven/continuum/trunk/continuum-core/src/test/java/org/apache/maven/continuum/profile/DefaultProfileServiceTest.java Tue Jun 19 07:04:13 2007
@@ -0,0 +1,227 @@
+package org.apache.maven.continuum.profile;
+
+import java.util.List;
+
+import org.apache.maven.continuum.AbstractContinuumTest;
+import org.apache.maven.continuum.installation.InstallationService;
+import org.apache.maven.continuum.model.system.Installation;
+import org.apache.maven.continuum.model.system.Profile;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+/**
+ * @author <a href="mailto:olamy@codehaus.org">olamy</a>
+ * @since 15 juin 07
+ * @version $Id$
+ */
+public class DefaultProfileServiceTest
+    extends AbstractContinuumTest
+{
+    Installation jdk1;
+
+    String jdk1Name = "jdk1";
+
+    Installation jdk2;
+
+    String jdk2Name = "jdk2";
+
+    Installation mvn205;
+
+    String mvn205Name = "mvn 2.0.5";
+
+    Installation mvn206;
+
+    String mvn206Name = "mvn 2.0.6";
+
+    Profile jdk1mvn205;
+
+    String jdk1mvn205Name = "jdk1 mvn 2.0.5";
+
+    Profile jdk2mvn206;
+
+    String jdk2mvn206Name = "jdk2 mvn 2.0.6";
+
+    Installation mvnOpts1;
+
+    String mvnOpts1Name = "mvnOpts1";
+
+    Installation mvnOpts2;
+
+    String mvnOpts2Name = "mvnOpts2";
+
+    protected void setUp()
+        throws Exception
+    {
+        super.setUp();
+        getStore().eraseDatabase();
+
+        jdk1 = new Installation();
+        jdk1.setType( InstallationService.JDK_TYPE );
+        jdk1.setVarValue( "/foo/bar" );
+        jdk1.setName( jdk1Name );
+        jdk1 = getInstallationService().add( jdk1 );
+
+        jdk2 = new Installation();
+        jdk2.setType( InstallationService.JDK_TYPE );
+        jdk2.setVarValue( "/foo/bar/zloug" );
+        jdk2.setName( jdk2Name );
+        jdk2 = getInstallationService().add( jdk2 );
+
+        mvn205 = new Installation();
+        mvn205.setType( InstallationService.MAVEN2_TYPE );
+        mvn205.setVarValue( "/users/maven-2.0.5" );
+        mvn205.setName( mvn205Name );
+        mvn205 = getInstallationService().add( mvn205 );
+
+        mvn206 = new Installation();
+        mvn206.setType( InstallationService.MAVEN2_TYPE );
+        mvn206.setVarValue( "/users/maven-2.0.6" );
+        mvn206.setName( mvn206Name );
+        mvn206 = getInstallationService().add( mvn206 );
+
+        jdk1mvn205 = new Profile();
+        jdk1mvn205.setJdk( jdk1 );
+        jdk1mvn205.setBuilder( mvn205 );
+        jdk1mvn205.setName( jdk1mvn205Name );
+        getProfileService().addProfile( jdk1mvn205 );
+
+        jdk2mvn206 = new Profile();
+        jdk2mvn206.setJdk( jdk2 );
+        jdk2mvn206.setBuilder( mvn206 );
+        jdk2mvn206.setName( jdk2mvn206Name );
+        getProfileService().addProfile( jdk2mvn206 );
+
+        mvnOpts1 = new Installation();
+        mvnOpts1.setType( InstallationService.ENVVAR_TYPE );
+        mvnOpts1.setVarName( "MAVEN_OPTS" );
+        mvnOpts1.setVarValue( "-Xmx256m -Djava.awt.headless=true" );
+        mvnOpts1.setName( mvnOpts1Name );
+        mvnOpts1 = getInstallationService().add( mvnOpts1 );
+
+        mvnOpts2 = new Installation();
+        mvnOpts2.setType( InstallationService.ENVVAR_TYPE );
+        mvnOpts2.setVarName( "MAVEN_OPTS" );
+        mvnOpts2.setVarValue( "-Xmx1024m -Xms1024m" );
+        mvnOpts2.setName( mvnOpts2Name );
+        mvnOpts2 = getInstallationService().add( mvnOpts2 );
+
+    }
+
+    public InstallationService getInstallationService()
+        throws Exception
+    {
+        return (InstallationService) lookup( InstallationService.ROLE, "default" );
+    }
+
+    public ProfileService getProfileService()
+        throws Exception
+    {
+        return (ProfileService) lookup( ProfileService.ROLE, "default" );
+    }
+
+    public void testAddProfile()
+        throws Exception
+    {
+        Profile defaultProfile = new Profile();
+        defaultProfile.setName( "default profile" );
+        Profile getted = getProfileService().addProfile( defaultProfile );
+        assertNotNull( getProfileService().getProfile( getted.getId() ) );
+    }
+
+    public void testDeleteProfile()
+        throws Exception
+    {
+        Profile defaultProfile = new Profile();
+        defaultProfile.setName( "default profile" );
+        Profile getted = getProfileService().addProfile( defaultProfile );
+        int id = getted.getId();
+        assertNotNull( getProfileService().getProfile( id ) );
+        getProfileService().deleteProfile( id );
+        assertNull( getProfileService().getProfile( id ) );
+    }
+
+    public void testgetAllProfile()
+        throws Exception
+    {
+        List<Profile> all = getProfileService().getAllProfiles();
+        assertNotNull( all );
+        assertFalse( all.isEmpty() );
+        assertEquals( 2, all.size() );
+    }
+
+    public void updateProfile()
+        throws Exception
+    {
+        Profile profile = getProfileService().getProfile( jdk1mvn205.getId() );
+        assertEquals( jdk1mvn205Name, profile.getName() );
+        String newName = "new name";
+        profile.setName( newName );
+        getProfileService().updateProfile( profile );
+
+        Profile getted = getProfileService().getProfile( jdk1mvn205.getId() );
+        assertNotNull( getted );
+        assertEquals( newName, getted.getName() );
+    }
+
+    public void testsetJdkInProfile()
+        throws Exception
+    {
+        Profile profile = getProfileService().getProfile( jdk1mvn205.getId() );
+        getProfileService().setJdkInProfile( profile, jdk2 );
+
+        profile = getProfileService().getProfile( jdk1mvn205.getId() );
+        assertEquals( jdk2.getName(), profile.getJdk().getName() );
+        assertEquals( jdk2.getVarValue(), profile.getJdk().getVarValue() );
+    }
+
+    public void testsetBuilderInProfile()
+        throws Exception
+    {
+        Profile profile = getProfileService().getProfile( jdk1mvn205.getId() );
+        getProfileService().setBuilderInProfile( profile, mvn206 );
+        profile = getProfileService().getProfile( jdk1mvn205.getId() );
+        assertEquals( mvn206.getName(), profile.getBuilder().getName() );
+        assertEquals( mvn206.getVarValue(), profile.getBuilder().getVarValue() );
+
+    }
+
+    public void testaddEnvVarInProfile()
+        throws Exception
+    {
+        Profile profile = getProfileService().getProfile( jdk1mvn205.getId() );
+        getProfileService().setBuilderInProfile( profile, mvn206 );
+        getProfileService().addEnvVarInProfile( profile, mvnOpts1 );
+        profile = getProfileService().getProfile( jdk1mvn205.getId() );
+        assertFalse( profile.getEnvironmentVariables().isEmpty() );
+        assertEquals( 1, profile.getEnvironmentVariables().size() );
+    }
+
+    public void testRemoveInstallationLinkedToAProfile()
+        throws Exception
+    {
+        Profile profile = getProfileService().getProfile( jdk1mvn205.getId() );
+        getProfileService().setJdkInProfile( profile, jdk2 );
+
+        profile = getProfileService().getProfile( jdk1mvn205.getId() );
+        InstallationService installationService = (InstallationService) lookup( InstallationService.ROLE, "default" );
+        installationService.delete( jdk2 );
+    }
+
+}

Propchange: maven/continuum/trunk/continuum-core/src/test/java/org/apache/maven/continuum/profile/DefaultProfileServiceTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: maven/continuum/trunk/continuum-core/src/test/java/org/apache/maven/continuum/profile/DefaultProfileServiceTest.java
------------------------------------------------------------------------------
    svn:keywords = "Author Date Id Revision"

Modified: maven/continuum/trunk/continuum-data-management/data-management-jdo/pom.xml
URL: http://svn.apache.org/viewvc/maven/continuum/trunk/continuum-data-management/data-management-jdo/pom.xml?view=diff&rev=548732&r1=548731&r2=548732
==============================================================================
--- maven/continuum/trunk/continuum-data-management/data-management-jdo/pom.xml (original)
+++ maven/continuum/trunk/continuum-data-management/data-management-jdo/pom.xml Tue Jun 19 07:04:13 2007
@@ -88,5 +88,17 @@
         </exclusion>
       </exclusions>
     </dependency>
+    <dependency>
+      <groupId>xmlunit</groupId>
+      <artifactId>xmlunit</artifactId>
+      <version>1.0</version>
+      <scope>test</scope>
+    </dependency>
+    <dependency>
+      <groupId>jdom</groupId>
+      <artifactId>jdom</artifactId>
+      <version>1.0</version>
+      <scope>test</scope>
+    </dependency>      
   </dependencies>
 </project>

Modified: maven/continuum/trunk/continuum-data-management/data-management-jdo/src/main/java/org/apache/maven/continuum/management/JdoDataManagementTool.java
URL: http://svn.apache.org/viewvc/maven/continuum/trunk/continuum-data-management/data-management-jdo/src/main/java/org/apache/maven/continuum/management/JdoDataManagementTool.java?view=diff&rev=548732&r1=548731&r2=548732
==============================================================================
--- maven/continuum/trunk/continuum-data-management/data-management-jdo/src/main/java/org/apache/maven/continuum/management/JdoDataManagementTool.java (original)
+++ maven/continuum/trunk/continuum-data-management/data-management-jdo/src/main/java/org/apache/maven/continuum/management/JdoDataManagementTool.java Tue Jun 19 07:04:13 2007
@@ -19,24 +19,6 @@
  * under the License.
  */
 
-import org.apache.maven.continuum.model.project.BuildDefinition;
-import org.apache.maven.continuum.model.project.ContinuumDatabase;
-import org.apache.maven.continuum.model.project.Profile;
-import org.apache.maven.continuum.model.project.Project;
-import org.apache.maven.continuum.model.project.ProjectGroup;
-import org.apache.maven.continuum.model.project.Schedule;
-import org.apache.maven.continuum.model.project.io.stax.ContinuumStaxReader;
-import org.apache.maven.continuum.model.project.io.stax.ContinuumStaxWriter;
-import org.apache.maven.continuum.model.system.Installation;
-import org.apache.maven.continuum.store.ContinuumStore;
-import org.apache.maven.continuum.store.ContinuumStoreException;
-import org.codehaus.plexus.jdo.DefaultConfigurableJdoFactory;
-import org.codehaus.plexus.jdo.PlexusJdoUtils;
-import org.codehaus.plexus.util.IOUtil;
-
-import javax.jdo.JDOHelper;
-import javax.jdo.PersistenceManagerFactory;
-import javax.xml.stream.XMLStreamException;
 import java.io.File;
 import java.io.FileOutputStream;
 import java.io.FileReader;
@@ -53,6 +35,25 @@
 import java.util.Map;
 import java.util.Properties;
 
+import javax.jdo.JDOHelper;
+import javax.jdo.PersistenceManagerFactory;
+import javax.xml.stream.XMLStreamException;
+
+import org.apache.maven.continuum.model.project.BuildDefinition;
+import org.apache.maven.continuum.model.project.ContinuumDatabase;
+import org.apache.maven.continuum.model.project.Project;
+import org.apache.maven.continuum.model.project.ProjectGroup;
+import org.apache.maven.continuum.model.project.Schedule;
+import org.apache.maven.continuum.model.project.io.stax.ContinuumStaxReader;
+import org.apache.maven.continuum.model.project.io.stax.ContinuumStaxWriter;
+import org.apache.maven.continuum.model.system.Installation;
+import org.apache.maven.continuum.model.system.Profile;
+import org.apache.maven.continuum.store.ContinuumStore;
+import org.apache.maven.continuum.store.ContinuumStoreException;
+import org.codehaus.plexus.jdo.DefaultConfigurableJdoFactory;
+import org.codehaus.plexus.jdo.PlexusJdoUtils;
+import org.codehaus.plexus.util.IOUtil;
+
 /**
  * JDO implementation the database management tool API.
  *
@@ -89,8 +90,14 @@
         // TODO: need these to lazy load to conserve memory while we stream out the model
         Collection projectGroups = store.getAllProjectGroupsWithTheLot();
         database.setProjectGroups( new ArrayList( projectGroups ) );
-
-        database.setInstallations( store.getAllInstallations() );
+        try
+        {
+            database.setInstallations( store.getAllInstallations() );
+        }
+        catch ( ContinuumStoreException e )
+        {
+            throw new DataManagementException( e );
+        }
         database.setSchedules( store.getAllSchedulesByName() );
         database.setProfiles( store.getAllProfilesByName() );
 

Modified: maven/continuum/trunk/continuum-data-management/data-management-jdo/src/test/java/org/apache/maven/continuum/management/DataManagementToolTest.java
URL: http://svn.apache.org/viewvc/maven/continuum/trunk/continuum-data-management/data-management-jdo/src/test/java/org/apache/maven/continuum/management/DataManagementToolTest.java?view=diff&rev=548732&r1=548731&r2=548732
==============================================================================
--- maven/continuum/trunk/continuum-data-management/data-management-jdo/src/test/java/org/apache/maven/continuum/management/DataManagementToolTest.java (original)
+++ maven/continuum/trunk/continuum-data-management/data-management-jdo/src/test/java/org/apache/maven/continuum/management/DataManagementToolTest.java Tue Jun 19 07:04:13 2007
@@ -1,38 +1,41 @@
 package org.apache.maven.continuum.management;
 
 /*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *   http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied.  See the License for the
- * specific language governing permissions and limitations
- * under the License.
+ * Licensed to the Apache Software Foundation (ASF) under one or more contributor license
+ * agreements. See the NOTICE file distributed with this work for additional information regarding
+ * copyright ownership. The ASF licenses this file to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance with the License. You may obtain a
+ * copy of the License at
+ * 
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software distributed under the License
+ * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
+ * or implied. See the License for the specific language governing permissions and limitations under
+ * the License.
  */
 
-import org.apache.maven.continuum.store.AbstractContinuumStoreTestCase;
-import org.apache.maven.continuum.store.ContinuumStoreException;
-import org.codehaus.plexus.util.FileUtils;
-import org.codehaus.plexus.util.IOUtil;
-
-import javax.xml.stream.XMLStreamException;
 import java.io.File;
 import java.io.FileWriter;
 import java.io.IOException;
+import java.io.StringReader;
 import java.io.StringWriter;
 import java.text.SimpleDateFormat;
 import java.util.Date;
 import java.util.Locale;
 
+import javax.xml.stream.XMLStreamException;
+
+import org.apache.maven.continuum.store.AbstractContinuumStoreTestCase;
+import org.apache.maven.continuum.store.ContinuumStoreException;
+import org.codehaus.plexus.util.FileUtils;
+import org.codehaus.plexus.util.IOUtil;
+import org.custommonkey.xmlunit.Diff;
+import org.jdom.Document;
+import org.jdom.input.SAXBuilder;
+import org.jdom.output.Format;
+import org.jdom.output.XMLOutputter;
+
 /**
  * Test the database management tool.
  */
@@ -72,7 +75,7 @@
 */
 
     public void testBackupBuilds()
-        throws IOException, ContinuumStoreException, XMLStreamException
+        throws IOException, ContinuumStoreException, XMLStreamException, Exception
     {
         createBuildDatabase();
 
@@ -89,8 +92,10 @@
 
         IOUtil.copy( getClass().getResourceAsStream( "/expected.xml" ), sw );
 
-        assertEquals( "Check database content", removeTimestampVariance( sw.toString() ),
-                      removeTimestampVariance( FileUtils.fileRead( backupFile ) ) );
+        //assertEquals( "Check database content", removeTimestampVariance( sw.toString() ),
+        //              removeTimestampVariance( FileUtils.fileRead( backupFile ) ) );
+        assertXmlIdentical( removeTimestampVariance( sw.toString() ), removeTimestampVariance( FileUtils
+            .fileRead( backupFile ) ) );
     }
 
     public void testEraseBuilds()
@@ -126,8 +131,10 @@
 
         IOUtil.copy( getClass().getResourceAsStream( "/expected.xml" ), sw );
 
-        assertEquals( "Check database content", removeTimestampVariance( sw.toString() ),
-                      removeTimestampVariance( FileUtils.fileRead( backupFile ) ) );
+        //assertEquals( "Check database content", removeTimestampVariance( sw.toString() ),
+        //              removeTimestampVariance( FileUtils.fileRead( backupFile ) ) );
+        assertXmlIdentical( removeTimestampVariance( sw.toString() ), removeTimestampVariance( FileUtils
+            .fileRead( backupFile ) ) );
     }
 
     private static File createBackupDirectory()
@@ -142,24 +149,49 @@
 
     private static String removeTimestampVariance( String content )
     {
-        return fixXmlQuotes( removeTagContent(
-            removeTagContent( removeTagContent( removeTagContent( content, "startTime" ), "endTime" ), "date" ),
-            "id" ) );
+        /*return fixXmlQuotes( removeTagContent( removeTagContent( removeTagContent( removeTagContent( content,
+                                                                                                     "startTime" ),
+                                                                                   "endTime" ), "date" ), "id" ) );*/
+
+        return removeTagContent( removeTagContent( removeTagContent( removeTagContent( content, "startTime" ),
+                                                                     "endTime" ), "date" ), "id" );
     }
 
-    private static String fixXmlQuotes( String s )
+    public void assertXmlIdentical( String expected, String test )
+        throws Exception
     {
-        if ( s.startsWith( "<?xml version='1.0' encoding='UTF-8'?>" ) )
-        {
-            return "<?xml version=\"1.0\" encoding=\"UTF-8\"?>" +
-                s.substring( "<?xml version='1.0' encoding='UTF-8'?>".length() );
-        }
-        return cleanLineEndings( s );
+        String expectedXml = prettyXmlPrint( expected );
+        String testXml = prettyXmlPrint( test );
+        Diff diff = new Diff( expectedXml, testXml );
+        StringBuffer diffMessage = new StringBuffer();
+        assertTrue( " xml diff not identical " + diff.appendMessage( diffMessage ).toString(), diff.identical() );
     }
 
-    private static String cleanLineEndings( String s )
+/*
+    public void assertXmlSimilar( String expected, String test )
+        throws Exception
     {
-        return s.replaceAll( "\r\n", "\n" );
+        String expectedXml = XMLOutputHelper.prettyXmlPrint( expected );
+        String testXml = XMLOutputHelper.prettyXmlPrint( test );
+        Diff diff = new Diff( expectedXml, testXml );
+        StringBuffer diffMessage = new StringBuffer();
+        assertTrue( " xml diff not similar " + diff.appendMessage( diffMessage ).toString(), diff.similar() );
+    }
+*/
+    public String prettyXmlPrint( String xml )
+        throws Exception
+    {
+        SAXBuilder saxBuilder = new SAXBuilder();
+        Document document = saxBuilder.build( new StringReader( xml ) );
+        XMLOutputter outp = new XMLOutputter();
+
+        outp.setFormat( Format.getPrettyFormat() );
+
+        StringWriter sw = new StringWriter();
+
+        outp.output( document, sw );
+        return sw.getBuffer().toString();
+
     }
 
     private static String removeTagContent( String content, String field )

Modified: maven/continuum/trunk/continuum-data-management/data-management-jdo/src/test/resources/expected.xml
URL: http://svn.apache.org/viewvc/maven/continuum/trunk/continuum-data-management/data-management-jdo/src/test/resources/expected.xml?view=diff&rev=548732&r1=548731&r2=548732
==============================================================================
--- maven/continuum/trunk/continuum-data-management/data-management-jdo/src/test/resources/expected.xml (original)
+++ maven/continuum/trunk/continuum-data-management/data-management-jdo/src/test/resources/expected.xml Tue Jun 19 07:04:13 2007
@@ -404,18 +404,18 @@
   </systemConfiguration>
   <installations>
     <installation>
-      <version>1.3</version>
-      <path>/usr/local/java-1.3</path>
+      <varValue>/usr/local/java-1.3</varValue>
+      <varName>JAVA_HOME</varName>
       <name>JDK 1.3</name>
     </installation>
     <installation>
-      <version>1.4</version>
-      <path>/usr/local/java-1.4</path>
+      <varValue>/usr/local/java-1.4</varValue>
+      <varName>JAVA_HOME</varName>
       <name>JDK 1.4</name>
     </installation>
     <installation>
-      <version>2.0-alpha-3</version>
-      <path>/usr/local/maven-2.0-alpha-3</path>
+      <varValue>/usr/local/maven-2.0-alpha-3</varValue>    
+      <varName>M2_HOME</varName>
       <name>Maven 2.0 alpha 3</name>
     </installation>
   </installations>

Modified: maven/continuum/trunk/continuum-model/pom.xml
URL: http://svn.apache.org/viewvc/maven/continuum/trunk/continuum-model/pom.xml?view=diff&rev=548732&r1=548731&r2=548732
==============================================================================
--- maven/continuum/trunk/continuum-model/pom.xml (original)
+++ maven/continuum/trunk/continuum-model/pom.xml Tue Jun 19 07:04:13 2007
@@ -43,7 +43,7 @@
           </execution>
         </executions>
         <configuration>
-          <version>1.1.0</version>
+          <version>1.1.1</version>
           <packageWithVersion>false</packageWithVersion>
           <model>src/main/mdo/continuum.xml</model>
         </configuration>

Modified: maven/continuum/trunk/continuum-model/src/main/mdo/continuum.xml
URL: http://svn.apache.org/viewvc/maven/continuum/trunk/continuum-model/src/main/mdo/continuum.xml?view=diff&rev=548732&r1=548731&r2=548732
==============================================================================
--- maven/continuum/trunk/continuum-model/src/main/mdo/continuum.xml (original)
+++ maven/continuum/trunk/continuum-model/src/main/mdo/continuum.xml Tue Jun 19 07:04:13 2007
@@ -959,6 +959,7 @@
 
     <class jpox.table="profiles">
       <name>Profile</name>
+      <packageName>org.apache.maven.continuum.model.system</packageName>
       <version>1.1.0+</version>
       <fields>
         <field>
@@ -1006,6 +1007,15 @@
             <type>Installation</type>
           </association>
         </field>
+        <field>
+          <name>environmentVariables</name>
+          <version>1.1.1+</version>
+          <association xml.reference="true" stash.part="true" jpox.dependent="false">
+            <type>Installation</type>
+            <!-- org.apache.maven.continuum.model.system. -->
+            <multiplicity>*</multiplicity>
+          </association>
+        </field>          
       </fields>
     </class>
 
@@ -1014,16 +1024,21 @@
       <packageName>org.apache.maven.continuum.model.system</packageName>
       <version>1.1.0+</version>
       <fields>
-        <field>
-          <name>version</name>
-          <version>1.1.0+</version>
+        <field jpox.column="installationtype">
+          <name>type</name>
+          <version>1.1.1+</version>
           <type>String</type>
         </field>
-        <field jpox.column="installpath">
-          <name>path</name>
-          <version>1.1.0+</version>
+        <field jpox.column="varvalue">
+          <name>varValue</name>
+          <version>1.1.1+</version>
           <type>String</type>
         </field>
+        <field jpox.column="varname">
+          <name>varName</name>
+          <version>1.1.1+</version>
+          <type>String</type>
+        </field>          
         <field jpox.primary-key="true" jpox.value-strategy="off">
           <name>name</name>
           <version>1.1.0+</version>

Modified: maven/continuum/trunk/continuum-store/src/main/java/org/apache/maven/continuum/store/JdoContinuumStore.java
URL: http://svn.apache.org/viewvc/maven/continuum/trunk/continuum-store/src/main/java/org/apache/maven/continuum/store/JdoContinuumStore.java?view=diff&rev=548732&r1=548731&r2=548732
==============================================================================
--- maven/continuum/trunk/continuum-store/src/main/java/org/apache/maven/continuum/store/JdoContinuumStore.java (original)
+++ maven/continuum/trunk/continuum-store/src/main/java/org/apache/maven/continuum/store/JdoContinuumStore.java Tue Jun 19 07:04:13 2007
@@ -19,9 +19,25 @@
  * under the License.
  */
 
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Collection;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+
+import javax.jdo.Extent;
+import javax.jdo.FetchPlan;
+import javax.jdo.JDOHelper;
+import javax.jdo.JDOUserException;
+import javax.jdo.PersistenceManager;
+import javax.jdo.PersistenceManagerFactory;
+import javax.jdo.Query;
+import javax.jdo.Transaction;
+
 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;
@@ -35,6 +51,7 @@
 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.Profile;
 import org.apache.maven.continuum.model.system.SystemConfiguration;
 import org.apache.maven.continuum.project.ContinuumProjectState;
 import org.codehaus.plexus.jdo.JdoFactory;
@@ -43,28 +60,14 @@
 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.Extent;
-import javax.jdo.FetchPlan;
-import javax.jdo.JDOHelper;
-import javax.jdo.JDOUserException;
-import javax.jdo.PersistenceManager;
-import javax.jdo.PersistenceManagerFactory;
-import javax.jdo.Query;
-import javax.jdo.Transaction;
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.Collection;
-import java.util.HashMap;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Map;
+import org.codehaus.plexus.util.StringUtils;
 
 /**
  * @author <a href="mailto:trygvis@inamo.no">Trygve Laugst&oslash;l</a>
  * @author <a href="mailto:brett@apache.org">Brett Porter</a>
  * @version $Id$
- * @plexus.component role="org.apache.maven.continuum.store.ContinuumStore" role-hint="jdo"
+ * @plexus.component role="org.apache.maven.continuum.store.ContinuumStore"
+ *                   role-hint="jdo"
  */
 public class JdoContinuumStore
     extends AbstractContinuumStore
@@ -203,9 +206,9 @@
     }
 
     /**
-     * get the combined list of projectId and build definitions, including the ones
-     * inherited by their project group
-     *
+     * get the combined list of projectId and build definitions, including the
+     * ones inherited by their project group
+     * 
      * @param scheduleId
      * @return
      * @throws ContinuumStoreException
@@ -224,7 +227,8 @@
             aggregate.putAll( projectSource );
         }
 
-        // iterate through the project groups and make sure we are not walking over projects that
+        // iterate through the project groups and make sure we are not walking
+        // over projects that
         // might define their own build definitions
         if ( projectGroupSource != null )
         {
@@ -432,7 +436,8 @@
 
             build = (BuildResult) makePersistent( pm, build, false );
 
-            // TODO: these are in the wrong spot - set them on success (though currently some depend on latest build being the one in progress)
+            // TODO: these are in the wrong spot - set them on success (though
+            // currently some depend on latest build being the one in progress)
             project.setLatestBuildId( build.getId() );
 
             project.setState( build.getState() );
@@ -577,7 +582,7 @@
             getLogger().debug( "no default build definition on project, trying project group" );
         }
 
-        //project group should have default build definition defined
+        // project group should have default build definition defined
         if ( bd == null )
         {
             ProjectGroup projectGroup = getProjectGroupByProjectId( projectId );
@@ -619,7 +624,6 @@
         throw new ContinuumObjectNotFoundException( "no default build definition declared for project " + projectId );
     }
 
-
     public BuildDefinition getDefaultBuildDefinitionForProjectGroup( int projectGroupId )
         throws ContinuumStoreException, ContinuumObjectNotFoundException
     {
@@ -663,7 +667,7 @@
 
             List result = (List) query.execute();
 
-            //result = (List) pm.detachCopyAll( result );
+            // result = (List) pm.detachCopyAll( result );
 
             Map builds = new HashMap();
 
@@ -903,16 +907,66 @@
         return schedule;
     }
 
+    // ----------------------------------------------------------------
+    // Profile
+    // ----------------------------------------------------------------    
+
     public List getAllProfilesByName()
     {
         return getAllObjectsDetached( Profile.class, "name ascending", null );
     }
 
+    public Profile getProfileByName( String profileName )
+        throws ContinuumStoreException
+    {
+        PersistenceManager pm = getPersistenceManager();
+
+        Transaction tx = pm.currentTransaction();
+
+        try
+        {
+            tx.begin();
+
+            Extent extent = pm.getExtent( Profile.class, true );
+
+            Query query = pm.newQuery( extent );
+
+            query.declareImports( "import java.lang.String" );
+
+            query.declareParameters( "String name" );
+
+            query.setFilter( "this.name == name" );
+
+            Collection result = (Collection) query.execute( profileName );
+
+            if ( result.size() == 0 )
+            {
+                tx.commit();
+
+                return null;
+            }
+
+            Object object = pm.detachCopy( result.iterator().next() );
+
+            tx.commit();
+
+            return (Profile) object;
+        }
+        finally
+        {
+            rollback( tx );
+        }
+    }
+
     public Profile addProfile( Profile profile )
     {
         return (Profile) addObject( profile );
     }
 
+    // ----------------------------------------------------------------
+    // Installation
+    // ----------------------------------------------------------------
+
     public Installation addInstallation( Installation installation )
     {
         return (Installation) addObject( installation );
@@ -920,7 +974,161 @@
 
     public List getAllInstallations()
     {
-        return getAllObjectsDetached( Installation.class, "name ascending, version ascending", null );
+        return getAllObjectsDetached( Installation.class, "name ascending", null );
+    }
+
+    public void removeInstallation( Installation installation )
+        throws ContinuumStoreException, ContinuumObjectNotFoundException
+    {
+        // first delete link beetwen profile and this installation
+        // then removing this
+        //attachAndDelete( installation );
+        PersistenceManager pm = getPersistenceManager();
+
+        Transaction tx = pm.currentTransaction();
+
+        try
+        {
+            // this must be done in the same transaction
+            tx.begin();
+
+            // first removing linked jdk
+
+            Extent extent = pm.getExtent( Profile.class, true );
+
+            Query query = pm.newQuery( extent );
+
+            query.declareImports( "import java.lang.String" );
+
+            query.declareParameters( "String name" );
+
+            query.setFilter( "this.jdk.name == name" );
+
+            Collection<Profile> result = (Collection) query.execute( installation.getName() );
+
+            if ( result.size() != 0 )
+            {
+                for ( Iterator<Profile> iterator = result.iterator(); iterator.hasNext(); )
+                {
+                    Profile profile = iterator.next();
+                    profile.setJdk( null );
+                    pm.makePersistent( profile );
+                }
+            }
+
+            // removing linked builder
+            query = pm.newQuery( extent );
+
+            query.declareImports( "import java.lang.String" );
+
+            query.declareParameters( "String name" );
+
+            query.setFilter( "this.builder.name == name" );
+
+            result = (Collection) query.execute( installation.getName() );
+
+            if ( result.size() != 0 )
+            {
+                for ( Iterator<Profile> iterator = result.iterator(); iterator.hasNext(); )
+                {
+                    Profile profile = iterator.next();
+                    profile.setBuilder( null );
+                    pm.makePersistent( profile );
+                }
+            }
+
+            // removing linked env Var
+            query = pm.newQuery( extent );
+
+            query.declareImports( "import java.lang.String" );
+            query.declareImports( "import " + Installation.class.getName() );
+
+            query.declareParameters( "Installation installation" );
+
+            query.setFilter( "environmentVariables.contains(installation)" );
+
+            //query = pm
+            //    .newQuery( "SELECT FROM profile WHERE environmentVariables.contains(installation) && installation.name == name" );
+
+            result = (Collection) query.execute( installation );
+
+            if ( result.size() != 0 )
+            {
+                for ( Iterator<Profile> iterator = result.iterator(); iterator.hasNext(); )
+                {
+                    Profile profile = iterator.next();
+                    List newEnvironmentVariables = new ArrayList<Installation>();
+                    for ( Iterator<Installation> iteInstallation = profile.getEnvironmentVariables().iterator(); iteInstallation
+                        .hasNext(); )
+                    {
+                        Installation current = iteInstallation.next();
+                        if ( !StringUtils.equals( current.getName(), installation.getName() ) )
+                        {
+                            newEnvironmentVariables.add( current );
+                        }
+                    }
+                    profile.setEnvironmentVariables( newEnvironmentVariables );
+                    pm.makePersistent( profile );
+                }
+            }
+
+            pm.deletePersistent( installation );
+
+            tx.commit();
+
+        }
+        finally
+        {
+            rollback( tx );
+        }
+    }
+
+    public void updateInstallation( Installation installation )
+        throws ContinuumStoreException, ContinuumObjectNotFoundException
+    {
+        updateObject( installation );
+    }
+
+    public Installation getInstallationByName( String name )
+        throws ContinuumStoreException, ContinuumObjectNotFoundException
+    {
+        PersistenceManager pm = getPersistenceManager();
+
+        Transaction tx = pm.currentTransaction();
+
+        try
+        {
+            tx.begin();
+
+            Extent extent = pm.getExtent( Installation.class, true );
+
+            Query query = pm.newQuery( extent );
+
+            query.declareImports( "import java.lang.String" );
+
+            query.declareParameters( "String name" );
+
+            query.setFilter( "this.name == name" );
+
+            Collection result = (Collection) query.execute( name );
+
+            if ( result.size() == 0 )
+            {
+                tx.commit();
+
+                return null;
+            }
+
+            Object object = pm.detachCopy( result.iterator().next() );
+
+            tx.commit();
+
+            return (Installation) object;
+        }
+        finally
+        {
+            rollback( tx );
+        }
     }
 
     public List getAllBuildsForAProjectByDate( int projectId )
@@ -933,8 +1141,8 @@
         {
             tx.begin();
 
-            Query query = pm.newQuery( "SELECT FROM " + BuildResult.class.getName() +
-                " WHERE project.id == projectId PARAMETERS int projectId ORDER BY endTime DESC" );
+            Query query = pm.newQuery( "SELECT FROM " + BuildResult.class.getName()
+                + " WHERE project.id == projectId PARAMETERS int projectId ORDER BY endTime DESC" );
 
             query.declareImports( "import java.lang.Integer" );
 
@@ -1172,12 +1380,14 @@
         }
         catch ( Exception e )
         {
-            //Do nothing
+            // Do nothing
         }
 
         if ( pg != null )
         {
-            // TODO: why do we need to do this? if not - build results are not removed and a integrity constraint is violated. I assume its because of the fetch groups
+            // TODO: why do we need to do this? if not - build results are not
+            // removed and a integrity constraint is violated. I assume its
+            // because of the fetch groups
             for ( Iterator i = pg.getProjects().iterator(); i.hasNext(); )
             {
                 removeProject( (Project) i.next() );
@@ -1352,8 +1562,8 @@
         }
         catch ( ContinuumStoreException e )
         {
-            throw new ContinuumObjectNotFoundException(
-                "unable to find project group containing project with id: " + projectId );
+            throw new ContinuumObjectNotFoundException( "unable to find project group containing project with id: "
+                + projectId );
 
         }
     }
@@ -1381,7 +1591,7 @@
         else if ( systemConfs.size() > 1 )
         {
             throw new ContinuumStoreException(
-                "Database is corrupted. There are more than one systemConfiguration object." );
+                                               "Database is corrupted. There are more than one systemConfiguration object." );
         }
         else
         {
@@ -1411,10 +1621,13 @@
 
     public Collection getAllProjectGroupsWithTheLot()
     {
-        List fetchGroups = Arrays.asList( new String[]{PROJECT_WITH_BUILDS_FETCH_GROUP,
-            PROJECTGROUP_PROJECTS_FETCH_GROUP, BUILD_RESULT_WITH_DETAILS_FETCH_GROUP,
-            PROJECT_WITH_CHECKOUT_RESULT_FETCH_GROUP, PROJECT_ALL_DETAILS_FETCH_GROUP,
-            PROJECT_BUILD_DETAILS_FETCH_GROUP} );
+        List fetchGroups = Arrays.asList( new String[] {
+            PROJECT_WITH_BUILDS_FETCH_GROUP,
+            PROJECTGROUP_PROJECTS_FETCH_GROUP,
+            BUILD_RESULT_WITH_DETAILS_FETCH_GROUP,
+            PROJECT_WITH_CHECKOUT_RESULT_FETCH_GROUP,
+            PROJECT_ALL_DETAILS_FETCH_GROUP,
+            PROJECT_BUILD_DETAILS_FETCH_GROUP } );
         return PlexusJdoUtils.getAllObjectsDetached( getPersistenceManager(), ProjectGroup.class, "name ascending",
                                                      fetchGroups );
     }
@@ -1442,8 +1655,9 @@
 
     /**
      * Close the PersistenceManagerFactory.
-     *
-     * @param numTry The number of try. The maximum try is 5.
+     * 
+     * @param numTry
+     *            The number of try. The maximum try is 5.
      */
     private void closePersistenceManagerFactory( PersistenceManagerFactory pmf, int numTry )
     {
@@ -1469,7 +1683,7 @@
                         }
                         catch ( InterruptedException ie )
                         {
-                            //nothing to do
+                            // nothing to do
                         }
 
                         closePersistenceManagerFactory( pmf, numTry + 1 );

Modified: maven/continuum/trunk/continuum-store/src/test/java/org/apache/maven/continuum/store/AbstractContinuumStoreTestCase.java
URL: http://svn.apache.org/viewvc/maven/continuum/trunk/continuum-store/src/test/java/org/apache/maven/continuum/store/AbstractContinuumStoreTestCase.java?view=diff&rev=548732&r1=548731&r2=548732
==============================================================================
--- maven/continuum/trunk/continuum-store/src/test/java/org/apache/maven/continuum/store/AbstractContinuumStoreTestCase.java (original)
+++ maven/continuum/trunk/continuum-store/src/test/java/org/apache/maven/continuum/store/AbstractContinuumStoreTestCase.java Tue Jun 19 07:04:13 2007
@@ -19,9 +19,15 @@
  * under the License.
  */
 
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+
+import org.apache.maven.continuum.installation.InstallationService;
 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;
@@ -32,17 +38,12 @@
 import org.apache.maven.continuum.model.scm.ChangeSet;
 import org.apache.maven.continuum.model.scm.ScmResult;
 import org.apache.maven.continuum.model.system.Installation;
+import org.apache.maven.continuum.model.system.Profile;
 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 java.util.ArrayList;
-import java.util.HashMap;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Map;
-
 /**
  * Base class for tests using the continuum store.
  */
@@ -120,15 +121,17 @@
     }
 
     protected void createBuildDatabase()
+        throws Exception
     {
         createBuildDatabase( true );
     }
 
     protected void createBuildDatabase( boolean addToStore )
+        throws Exception
     {
         // Setting up test data
-        defaultProjectGroup =
-            createTestProjectGroup( "Default Group", "The Default Group", "org.apache.maven.test.default" );
+        defaultProjectGroup = createTestProjectGroup( "Default Group", "The Default Group",
+                                                      "org.apache.maven.test.default" );
 
         testProjectGroup2 = createTestProjectGroup( "test group 2", "test group 2 desc", "test group 2 groupId" );
 
@@ -143,10 +146,12 @@
         testSchedule2 = createTestSchedule( "name2", "description2", 2, "cronExpression2", true );
         testSchedule3 = createTestSchedule( "name3", "description3", 3, "cronExpression3", true );
 
-        testInstallationJava13 = createTestInstallation( "JDK 1.3", "/usr/local/java-1.3", "1.3" );
-        testInstallationJava14 = createTestInstallation( "JDK 1.4", "/usr/local/java-1.4", "1.4" );
-        testInstallationMaven20a3 =
-            createTestInstallation( "Maven 2.0 alpha 3", "/usr/local/maven-2.0-alpha-3", "2.0-alpha-3" );
+        testInstallationJava13 = createTestInstallation( "JDK 1.3", InstallationService.JDK_TYPE, "JAVA_HOME",
+                                                         "/usr/local/java-1.3" );
+        testInstallationJava14 = createTestInstallation( "JDK 1.4", InstallationService.JDK_TYPE, "JAVA_HOME",
+                                                         "/usr/local/java-1.4" );
+        testInstallationMaven20a3 = createTestInstallation( "Maven 2.0 alpha 3", InstallationService.MAVEN2_TYPE,
+                                                            "M2_HOME", "/usr/local/maven-2.0-alpha-3" );
 
         testGroupNotifier1 = createTestNotifier( 1, true, false, true, "type1" );
         testGroupNotifier2 = createTestNotifier( 2, false, true, false, "type2" );
@@ -243,12 +248,12 @@
             installationJava13 = store.addInstallation( installationJava13 );
         }
 
-        testProfile1 =
-            createTestProfile( "name1", "description1", 1, true, true, installationJava13, installationMaven20a3 );
-        testProfile2 =
-            createTestProfile( "name2", "description2", 2, false, true, installationJava14, installationMaven20a3 );
-        testProfile3 =
-            createTestProfile( "name3", "description3", 3, true, false, installationJava14, installationMaven20a3 );
+        testProfile1 = createTestProfile( "name1", "description1", 1, true, true, installationJava13,
+                                          installationMaven20a3 );
+        testProfile2 = createTestProfile( "name2", "description2", 2, false, true, installationJava14,
+                                          installationMaven20a3 );
+        testProfile3 = createTestProfile( "name3", "description3", 3, true, false, installationJava14,
+                                          installationMaven20a3 );
 
         Profile profile1 = createTestProfile( testProfile1 );
         if ( addToStore )
@@ -271,23 +276,23 @@
         }
         testProfile3.setId( profile3.getId() );
 
-        BuildDefinition testGroupBuildDefinition1 =
-            createTestBuildDefinition( "arguments1", "buildFile1", "goals1", profile1, schedule2, false, false );
-        BuildDefinition testGroupBuildDefinition2 =
-            createTestBuildDefinition( "arguments2", "buildFile2", "goals2", profile1, schedule1, false, false );
-        BuildDefinition testGroupBuildDefinition3 =
-            createTestBuildDefinition( "arguments3", "buildFile3", "goals3", profile2, schedule1, false, false );
-        BuildDefinition testGroupBuildDefinition4 =
-            createTestBuildDefinition( null, null, "deploy", null, null, false, false );
-
-        BuildDefinition testBuildDefinition1 =
-            createTestBuildDefinition( "arguments11", "buildFile11", "goals11", profile2, schedule1, false, false );
-        BuildDefinition testBuildDefinition2 =
-            createTestBuildDefinition( "arguments12", "buildFile12", "goals12", profile2, schedule2, false, false );
-        BuildDefinition testBuildDefinition3 =
-            createTestBuildDefinition( "arguments13", "buildFile13", "goals13", profile1, schedule2, false, false );
-        BuildDefinition testBuildDefinition4 =
-            createTestBuildDefinition( null, null, "deploy", null, null, false, false );
+        BuildDefinition testGroupBuildDefinition1 = createTestBuildDefinition( "arguments1", "buildFile1", "goals1",
+                                                                               profile1, schedule2, false, false );
+        BuildDefinition testGroupBuildDefinition2 = createTestBuildDefinition( "arguments2", "buildFile2", "goals2",
+                                                                               profile1, schedule1, false, false );
+        BuildDefinition testGroupBuildDefinition3 = createTestBuildDefinition( "arguments3", "buildFile3", "goals3",
+                                                                               profile2, schedule1, false, false );
+        BuildDefinition testGroupBuildDefinition4 = createTestBuildDefinition( null, null, "deploy", null, null, false,
+                                                                               false );
+
+        BuildDefinition testBuildDefinition1 = createTestBuildDefinition( "arguments11", "buildFile11", "goals11",
+                                                                          profile2, schedule1, false, false );
+        BuildDefinition testBuildDefinition2 = createTestBuildDefinition( "arguments12", "buildFile12", "goals12",
+                                                                          profile2, schedule2, false, false );
+        BuildDefinition testBuildDefinition3 = createTestBuildDefinition( "arguments13", "buildFile13", "goals13",
+                                                                          profile1, schedule2, false, false );
+        BuildDefinition testBuildDefinition4 = createTestBuildDefinition( null, null, "deploy", null, null, false,
+                                                                          false );
 
         ProjectGroup group = createTestProjectGroup( defaultProjectGroup );
 
@@ -634,9 +639,9 @@
     protected static BuildDefinition createTestBuildDefinition( BuildDefinition buildDefinition )
     {
         return createTestBuildDefinition( buildDefinition.getArguments(), buildDefinition.getBuildFile(),
-                                          buildDefinition.getGoals(), buildDefinition.getProfile(),
-                                          buildDefinition.getSchedule(), buildDefinition.isDefaultForProject(),
-                                          buildDefinition.isBuildFresh() );
+                                          buildDefinition.getGoals(), buildDefinition.getProfile(), buildDefinition
+                                              .getSchedule(), buildDefinition.isDefaultForProject(), buildDefinition
+                                              .isBuildFresh() );
     }
 
     protected static BuildDefinition createTestBuildDefinition( String arguments, String buildFile, String goals,
@@ -680,8 +685,8 @@
 
     private static ScmResult createTestScmResult( ScmResult scmResult, String base )
     {
-        return createTestScmResult( scmResult.getCommandOutput(), scmResult.getProviderMessage(), scmResult.isSuccess(),
-                                    base );
+        return createTestScmResult( scmResult.getCommandOutput(), scmResult.getProviderMessage(),
+                                    scmResult.isSuccess(), base );
     }
 
     private static ScmResult createTestScmResult( String commandOutput, String providerMessage, boolean success,
@@ -743,24 +748,25 @@
         return result;
     }
 
-    private static Installation createTestInstallation( String name, String path, String version )
+    protected static Installation createTestInstallation( String name, String type, String varName, String varValue )
     {
         Installation installation = new Installation();
         installation.setName( name );
-        installation.setPath( path );
-        installation.setVersion( version );
+        installation.setVarName( varName );
+        installation.setVarValue( varValue );
         return installation;
     }
 
     protected static Installation createTestInstallation( Installation installation )
     {
-        return createTestInstallation( installation.getName(), installation.getPath(), installation.getVersion() );
+        return createTestInstallation( installation.getName(), installation.getType(), installation.getVarName(),
+                                       installation.getVarValue() );
     }
 
     protected static Schedule createTestSchedule( Schedule schedule )
     {
-        return createTestSchedule( schedule.getName(), schedule.getDescription(), schedule.getDelay(),
-                                   schedule.getCronExpression(), schedule.isActive() );
+        return createTestSchedule( schedule.getName(), schedule.getDescription(), schedule.getDelay(), schedule
+            .getCronExpression(), schedule.isActive() );
     }
 
     protected static Schedule createTestSchedule( String name, String description, int delay, String cronExpression,
@@ -777,9 +783,8 @@
 
     protected static Profile createTestProfile( Profile profile )
     {
-        return createTestProfile( profile.getName(), profile.getDescription(), profile.getScmMode(),
-                                  profile.isBuildWithoutChanges(), profile.isActive(), profile.getJdk(),
-                                  profile.getBuilder() );
+        return createTestProfile( profile.getName(), profile.getDescription(), profile.getScmMode(), profile
+            .isBuildWithoutChanges(), profile.isActive(), profile.getJdk(), profile.getBuilder() );
 //                                  createTestInstallation( profile.getJdk() ),
 //                                  createTestInstallation( profile.getBuilder() ) );
     }
@@ -798,6 +803,22 @@
         profile.setJdk( jdk );
         return profile;
     }
+    
+    protected static Profile createTestProfile( String name, String description, int scmMode,
+                                                boolean buildWithoutChanges, boolean active, Installation jdk,
+                                                Installation builder, List envVars )
+    {
+        Profile profile = new Profile();
+        profile.setActive( active );
+        profile.setBuildWithoutChanges( buildWithoutChanges );
+        profile.setScmMode( scmMode );
+        profile.setDescription( description );
+        profile.setName( name );
+        profile.setBuilder( builder );
+        profile.setJdk( jdk );
+        profile.setEnvironmentVariables( envVars );
+        return profile;
+    }
 
     protected static ProjectGroup createTestProjectGroup( ProjectGroup group )
     {
@@ -815,9 +836,9 @@
 
     protected static Project createTestProject( Project project )
     {
-        return createTestProject( project.getArtifactId(), project.getBuildNumber(), project.getDescription(),
-                                  project.getGroupId(), project.getName(), project.getScmUrl(), project.getState(),
-                                  project.getUrl(), project.getVersion(), project.getWorkingDirectory() );
+        return createTestProject( project.getArtifactId(), project.getBuildNumber(), project.getDescription(), project
+            .getGroupId(), project.getName(), project.getScmUrl(), project.getState(), project.getUrl(), project
+            .getVersion(), project.getWorkingDirectory() );
     }
 
     private static Project createTestProject( String artifactId, int buildNumber, String description, String groupId,
@@ -846,16 +867,15 @@
         assertEquals( "compare expectedProject - name", expectedProject.getName(), project.getName() );
         assertEquals( "compare expectedProject - desc", expectedProject.getDescription(), project.getDescription() );
         assertEquals( "compare expectedProject - groupId", expectedProject.getGroupId(), project.getGroupId() );
-        assertEquals( "compare expectedProject - artifactId", expectedProject.getArtifactId(),
-                      project.getArtifactId() );
-        assertEquals( "compare expectedProject - buildNumber", expectedProject.getBuildNumber(),
-                      project.getBuildNumber() );
+        assertEquals( "compare expectedProject - artifactId", expectedProject.getArtifactId(), project.getArtifactId() );
+        assertEquals( "compare expectedProject - buildNumber", expectedProject.getBuildNumber(), project
+            .getBuildNumber() );
         assertEquals( "compare expectedProject - scmUrl", expectedProject.getScmUrl(), project.getScmUrl() );
         assertEquals( "compare expectedProject - state", expectedProject.getState(), project.getState() );
         assertEquals( "compare expectedProject - url", expectedProject.getUrl(), project.getUrl() );
         assertEquals( "compare expectedProject - version", expectedProject.getVersion(), project.getVersion() );
-        assertEquals( "compare expectedProject - workingDirectory", expectedProject.getWorkingDirectory(),
-                      project.getWorkingDirectory() );
+        assertEquals( "compare expectedProject - workingDirectory", expectedProject.getWorkingDirectory(), project
+            .getWorkingDirectory() );
     }
 
     protected static void assertProjectGroupEquals( ProjectGroup expectedGroup, ProjectGroup actualGroup )
@@ -876,11 +896,10 @@
             assertNotSame( expectedSchedule, actualSchedule );
             assertEquals( "compare schedule - id", expectedSchedule.getId(), actualSchedule.getId() );
             assertEquals( "compare schedule - name", expectedSchedule.getName(), actualSchedule.getName() );
-            assertEquals( "compare schedule - desc", expectedSchedule.getDescription(),
-                          actualSchedule.getDescription() );
+            assertEquals( "compare schedule - desc", expectedSchedule.getDescription(), actualSchedule.getDescription() );
             assertEquals( "compare schedule - delay", expectedSchedule.getDelay(), actualSchedule.getDelay() );
-            assertEquals( "compare schedule - cron", expectedSchedule.getCronExpression(),
-                          actualSchedule.getCronExpression() );
+            assertEquals( "compare schedule - cron", expectedSchedule.getCronExpression(), actualSchedule
+                .getCronExpression() );
             assertEquals( "compare schedule - active", expectedSchedule.isActive(), actualSchedule.isActive() );
         }
     }
@@ -894,17 +913,18 @@
             assertEquals( "compare profile - name", expectedProfile.getName(), actualProfile.getName() );
             assertEquals( "compare profile - desc", expectedProfile.getDescription(), actualProfile.getDescription() );
             assertEquals( "compare profile - scmMode", expectedProfile.getScmMode(), actualProfile.getScmMode() );
-            assertEquals( "compare profile - build w/o changes", expectedProfile.isBuildWithoutChanges(),
-                          actualProfile.isBuildWithoutChanges() );
+            assertEquals( "compare profile - build w/o changes", expectedProfile.isBuildWithoutChanges(), actualProfile
+                .isBuildWithoutChanges() );
             assertEquals( "compare profile - active", expectedProfile.isActive(), actualProfile.isActive() );
         }
     }
 
     protected static void assertInstallationEquals( Installation expected, Installation actual )
     {
+        assertNotNull( actual );
         assertEquals( "compare installation - name", expected.getName(), actual.getName() );
-        assertEquals( "compare installation - path", expected.getPath(), actual.getPath() );
-        assertEquals( "compare installation - version", expected.getVersion(), actual.getVersion() );
+        assertEquals( "compare installation - varName", expected.getVarName(), actual.getVarName() );
+        assertEquals( "compare installation - varValue", expected.getVarValue(), actual.getVarValue() );
     }
 
     protected static void assertBuildResultEquals( BuildResult expected, BuildResult actual )
@@ -926,8 +946,7 @@
         assertEquals( "compare SCM result - changes size", actual.getChanges().size(), expected.getChanges().size() );
         for ( int i = 0; i < actual.getChanges().size(); i++ )
         {
-            assertChangeSetEquals( (ChangeSet) expected.getChanges().get( i ),
-                                   (ChangeSet) actual.getChanges().get( i ) );
+            assertChangeSetEquals( (ChangeSet) expected.getChanges().get( i ), (ChangeSet) actual.getChanges().get( i ) );
         }
     }
 
@@ -940,8 +959,7 @@
         assertEquals( "compare change set result - files size", expected.getFiles().size(), actual.getFiles().size() );
         for ( int i = 0; i < actual.getFiles().size(); i++ )
         {
-            assertChangeFileEquals( (ChangeFile) expected.getFiles().get( i ),
-                                    (ChangeFile) actual.getFiles().get( i ) );
+            assertChangeFileEquals( (ChangeFile) expected.getFiles().get( i ), (ChangeFile) actual.getFiles().get( i ) );
         }
     }
 
@@ -988,8 +1006,8 @@
                       actualBuildDefinition.getArguments() );
         assertEquals( "compare build definition - build file", expectedBuildDefinition.getBuildFile(),
                       actualBuildDefinition.getBuildFile() );
-        assertEquals( "compare build definition - goals", expectedBuildDefinition.getGoals(),
-                      actualBuildDefinition.getGoals() );
+        assertEquals( "compare build definition - goals", expectedBuildDefinition.getGoals(), actualBuildDefinition
+            .getGoals() );
         assertEquals( "compare build definition - build fresh", expectedBuildDefinition.isBuildFresh(),
                       actualBuildDefinition.isBuildFresh() );
         assertEquals( "compare build definition - defaultForProject", expectedBuildDefinition.isDefaultForProject(),
@@ -1000,8 +1018,8 @@
     {
         for ( int i = 0; i < actualDevelopers.size(); i++ )
         {
-            assertDeveloperEquals( (ProjectDeveloper) expectedDevelopers.get( i ),
-                                   (ProjectDeveloper) actualDevelopers.get( i ) );
+            assertDeveloperEquals( (ProjectDeveloper) expectedDevelopers.get( i ), (ProjectDeveloper) actualDevelopers
+                .get( i ) );
         }
     }
 
@@ -1010,8 +1028,8 @@
         assertEquals( "compare developer - name", expectedDeveloper.getName(), actualDeveloper.getName() );
         assertEquals( "compare developer - email", expectedDeveloper.getEmail(), actualDeveloper.getEmail() );
         assertEquals( "compare developer - scmId", expectedDeveloper.getScmId(), actualDeveloper.getScmId() );
-        assertEquals( "compare developer - continuumId", expectedDeveloper.getContinuumId(),
-                      actualDeveloper.getContinuumId() );
+        assertEquals( "compare developer - continuumId", expectedDeveloper.getContinuumId(), actualDeveloper
+            .getContinuumId() );
     }
 
     protected static void assertDependenciesEqual( List expectedDependencies, List actualDependencies )
@@ -1027,8 +1045,8 @@
                                                   ProjectDependency actualDependency )
     {
         assertEquals( "compare dependency - groupId", expectedDependency.getGroupId(), actualDependency.getGroupId() );
-        assertEquals( "compare dependency - artifactId", expectedDependency.getArtifactId(),
-                      actualDependency.getArtifactId() );
+        assertEquals( "compare dependency - artifactId", expectedDependency.getArtifactId(), actualDependency
+            .getArtifactId() );
         assertEquals( "compare dependency - version", expectedDependency.getVersion(), actualDependency.getVersion() );
     }
 
@@ -1039,8 +1057,8 @@
 
     protected static ProjectDeveloper createTestDeveloper( ProjectDeveloper developer )
     {
-        return createTestDeveloper( developer.getContinuumId(), developer.getEmail(), developer.getName(),
-                                    developer.getScmId() );
+        return createTestDeveloper( developer.getContinuumId(), developer.getEmail(), developer.getName(), developer
+            .getScmId() );
     }
 
     protected static ProjectDependency createTestDependency( String groupId, String artifactId, String version )
@@ -1070,8 +1088,7 @@
     protected ContinuumStore createStore()
         throws Exception
     {
-        DefaultConfigurableJdoFactory jdoFactory = (DefaultConfigurableJdoFactory) lookup( JdoFactory.ROLE,
-                                                                                           "continuum" );
+        DefaultConfigurableJdoFactory jdoFactory = (DefaultConfigurableJdoFactory) lookup( JdoFactory.ROLE, "continuum" );
 
         jdoFactory.setUrl( "jdbc:hsqldb:mem:" + getName() );
 

Modified: maven/continuum/trunk/continuum-store/src/test/java/org/apache/maven/continuum/store/ContinuumStoreTest.java
URL: http://svn.apache.org/viewvc/maven/continuum/trunk/continuum-store/src/test/java/org/apache/maven/continuum/store/ContinuumStoreTest.java?view=diff&rev=548732&r1=548731&r2=548732
==============================================================================
--- maven/continuum/trunk/continuum-store/src/test/java/org/apache/maven/continuum/store/ContinuumStoreTest.java (original)
+++ maven/continuum/trunk/continuum-store/src/test/java/org/apache/maven/continuum/store/ContinuumStoreTest.java Tue Jun 19 07:04:13 2007
@@ -19,9 +19,17 @@
  * under the License.
  */
 
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Collection;
+import java.util.Iterator;
+import java.util.List;
+
+import javax.jdo.JDODetachedFieldAccessException;
+
+import org.apache.maven.continuum.installation.InstallationService;
 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;
@@ -29,12 +37,8 @@
 import org.apache.maven.continuum.model.project.ProjectNotifier;
 import org.apache.maven.continuum.model.project.Schedule;
 import org.apache.maven.continuum.model.system.Installation;
-
-import javax.jdo.JDODetachedFieldAccessException;
-import java.util.Arrays;
-import java.util.Collection;
-import java.util.Iterator;
-import java.util.List;
+import org.apache.maven.continuum.model.system.Profile;
+import org.codehaus.plexus.logging.LoggerManager;
 
 /**
  * @author <a href="mailto:brett@apache.org">Brett Porter</a>
@@ -270,7 +274,7 @@
     public void testGetAllProjects()
     {
         List projects = store.getAllProjectsByName();
-        assertEquals( "check items", Arrays.asList( new Project[]{testProject1, testProject2} ), projects );
+        assertEquals( "check items", Arrays.asList( new Project[] { testProject1, testProject2 } ), projects );
 
         Project project = (Project) projects.get( 1 );
         assertProjectEquals( testProject2, project );
@@ -334,11 +338,12 @@
     }
 
     public void testAddProfile()
+        throws Exception
     {
         List installations = store.getAllInstallations();
         Profile newProfile = createTestProfile( "testAddProfile", "testAddProfile desc", 5, false, false,
-                                                (Installation) installations.get( 1 ),
-                                                (Installation) installations.get( 2 ) );
+                                                (Installation) installations.get( 1 ), (Installation) installations
+                                                    .get( 2 ) );
         Profile copy = createTestProfile( newProfile );
         store.addProfile( newProfile );
         copy.setId( newProfile.getId() );
@@ -402,7 +407,16 @@
         assertInstallationEquals( testProfile3.getJdk(), profile.getJdk() );
     }
 
+/*
+    public void testGetgetProfileByName()
+        throws ContinuumStoreException
+    {
+        Profile profile = store.getProfileByName( "name1" );
+        assertNotNull( profile );
+    }
+*/
     public void testGetAllInstallations()
+        throws Exception
     {
         List installations = store.getAllInstallations();
 
@@ -417,6 +431,158 @@
         assertInstallationEquals( testInstallationMaven20a3, installation );
     }
 
+    public void testUpdateInstallation()
+        throws Exception
+    {
+        String name = "installationTest";
+        Installation testOne = createTestInstallation( name, InstallationService.JDK_TYPE, "varName", "varValue" );
+        testOne = store.addInstallation( testOne );
+
+        Installation fromStore = store.getInstallationByName( name );
+        assertInstallationEquals( testOne, fromStore );
+
+        fromStore.setVarName( "JAVA_HOME" );
+        fromStore.setVarValue( "/usr/local/jdk1.5.0_08" );
+        store.updateInstallation( fromStore );
+
+        Installation updatedFromStore = store.getInstallationByName( name );
+
+        assertInstallationEquals( fromStore, updatedFromStore );
+    }
+
+    public void testRemoveInstallation()
+        throws Exception
+    {
+        String name = "installationTestRemove";
+        Installation testOne = createTestInstallation( name, InstallationService.JDK_TYPE, "varName", "varValue" );
+        testOne = store.addInstallation( testOne );
+
+        store.removeInstallation( testOne );
+        Installation fromStore = store.getInstallationByName( name );
+        assertNull( fromStore );
+    }
+
+    public void testRemoveLinkedInstallations()
+        throws Exception
+    {
+        String nameFirstInst = "linkedFirstInstallationTestRemove";
+        String nameSecondInst = "linkedSecondInstallationTestRemove";
+        String nameFirstEnvVar = "firstEnvVar";
+        String nameSecondEnvVar = "secondEnvVar";
+
+        Installation testOne = createTestInstallation( nameFirstInst, InstallationService.JDK_TYPE, "varName",
+                                                       "varValue" );
+
+        Installation testTwo = createTestInstallation( nameSecondInst, InstallationService.MAVEN2_TYPE, "varName",
+                                                       "varValue" );
+
+        Installation firstEnvVar = createTestInstallation( nameFirstEnvVar, InstallationService.MAVEN2_TYPE, "varName",
+                                                           "varValue" );
+
+        Installation secondEnvVar = createTestInstallation( nameSecondEnvVar, InstallationService.MAVEN2_TYPE,
+                                                            "varName", "varValue" );
+
+        testOne = store.addInstallation( testOne );
+        testTwo = store.addInstallation( testTwo );
+
+        firstEnvVar = store.addInstallation( firstEnvVar );
+        secondEnvVar = store.addInstallation( secondEnvVar );
+
+        List envVars = new ArrayList<Installation>( 2 );
+        envVars.add( firstEnvVar );
+        envVars.add( secondEnvVar );
+
+        Profile firstProfile = createTestProfile( "first", "", 1, true, true, testOne, testTwo, envVars );
+
+        Profile secondProfile = createTestProfile( "first", "", 1, true, true, testOne, testTwo, envVars );
+
+        firstProfile = store.addProfile( firstProfile );
+        secondProfile = store.addProfile( secondProfile );
+
+        Profile firstGetted = store.getProfile( firstProfile.getId() );
+        Profile secondGetted = store.getProfile( secondProfile.getId() );
+
+        assertNotNull( firstGetted );
+        assertNotNull( firstGetted.getJdk() );
+        assertEquals( nameFirstInst, firstGetted.getJdk().getName() );
+
+        assertNotNull( secondGetted );
+        assertNotNull( secondGetted.getJdk() );
+        assertEquals( nameFirstInst, secondGetted.getJdk().getName() );
+
+        assertNotNull( firstGetted.getBuilder() );
+        assertEquals( nameSecondInst, firstGetted.getBuilder().getName() );
+        assertEquals( 2, firstGetted.getEnvironmentVariables().size() );
+
+        assertNotNull( secondGetted.getBuilder() );
+        assertEquals( nameSecondInst, secondGetted.getBuilder().getName() );
+        assertEquals( 2, secondGetted.getEnvironmentVariables().size() );
+
+        store.removeInstallation( testOne );
+
+        Installation fromStore = store.getInstallationByName( nameFirstInst );
+        assertNull( fromStore );
+
+        firstGetted = store.getProfile( firstProfile.getId() );
+        secondGetted = store.getProfile( secondProfile.getId() );
+        assertNotNull( firstGetted );
+        assertNull( firstGetted.getJdk() );
+        assertNotNull( firstGetted.getBuilder() );
+        assertEquals( 2, firstGetted.getEnvironmentVariables().size() );
+        assertNotNull( secondGetted );
+        assertNull( secondGetted.getJdk() );
+        assertNotNull( secondGetted.getBuilder() );
+        assertEquals( 2, secondGetted.getEnvironmentVariables().size() );
+        // removing builder
+        store.removeInstallation( testTwo );
+
+        firstGetted = store.getProfile( firstProfile.getId() );
+        secondGetted = store.getProfile( secondProfile.getId() );
+
+        assertNotNull( firstGetted );
+        assertNull( firstGetted.getJdk() );
+        assertNull( firstGetted.getBuilder() );
+        assertEquals( 2, firstGetted.getEnvironmentVariables().size() );
+
+        assertNotNull( secondGetted );
+        assertNull( secondGetted.getJdk() );
+        assertNull( secondGetted.getBuilder() );
+        assertEquals( 2, secondGetted.getEnvironmentVariables().size() );
+
+        // removing firstEnvVar
+        store.removeInstallation( firstEnvVar );
+        firstGetted = store.getProfile( firstProfile.getId() );
+        secondGetted = store.getProfile( secondProfile.getId() );
+        assertNotNull( firstGetted );
+        assertNull( firstGetted.getJdk() );
+        assertNull( firstGetted.getBuilder() );
+        assertEquals( 1, firstGetted.getEnvironmentVariables().size() );
+        Installation env = (Installation) firstGetted.getEnvironmentVariables().get( 0 );
+        assertEquals( nameSecondEnvVar, env.getName() );
+        
+        assertNotNull( secondGetted );
+        assertNull( secondGetted.getJdk() );
+        assertNull( secondGetted.getBuilder() );
+        assertEquals( 1, secondGetted.getEnvironmentVariables().size() );
+        env = (Installation) secondGetted.getEnvironmentVariables().get( 0 );
+        assertEquals( nameSecondEnvVar, env.getName() );
+        
+        // removing secondEnvVar
+        store.removeInstallation( secondEnvVar );
+        firstGetted = store.getProfile( firstProfile.getId() );
+        secondGetted = store.getProfile( secondProfile.getId() );
+        assertNotNull( firstGetted );
+        assertNull( firstGetted.getJdk() );
+        assertNull( firstGetted.getBuilder() );
+        assertEquals( 0, firstGetted.getEnvironmentVariables().size() );
+
+        
+        assertNotNull( secondGetted );
+        assertNull( secondGetted.getJdk() );
+        assertNull( secondGetted.getBuilder() );
+        assertEquals( 0, secondGetted.getEnvironmentVariables().size() );
+    }
+
     public void testDeleteProject()
         throws ContinuumStoreException
     {
@@ -525,7 +691,8 @@
     public void testGetProjectGroupWithDetails()
         throws ContinuumStoreException
     {
-        ProjectGroup retrievedGroup = store.getProjectGroupWithBuildDetailsByProjectGroupId( defaultProjectGroup.getId() );
+        ProjectGroup retrievedGroup = store.getProjectGroupWithBuildDetailsByProjectGroupId( defaultProjectGroup
+            .getId() );
         assertProjectGroupEquals( defaultProjectGroup, retrievedGroup );
         assertNotifiersEqual( defaultProjectGroup.getNotifiers(), retrievedGroup.getNotifiers() );
         assertBuildDefinitionsEqual( retrievedGroup.getBuildDefinitions(), defaultProjectGroup.getBuildDefinitions() );

Modified: maven/continuum/trunk/continuum-webapp/src/main/java/org/apache/maven/continuum/web/action/AddProjectAction.java
URL: http://svn.apache.org/viewvc/maven/continuum/trunk/continuum-webapp/src/main/java/org/apache/maven/continuum/web/action/AddProjectAction.java?view=diff&rev=548732&r1=548731&r2=548732
==============================================================================
--- maven/continuum/trunk/continuum-webapp/src/main/java/org/apache/maven/continuum/web/action/AddProjectAction.java (original)
+++ maven/continuum/trunk/continuum-webapp/src/main/java/org/apache/maven/continuum/web/action/AddProjectAction.java Tue Jun 19 07:04:13 2007
@@ -24,12 +24,16 @@
 import org.apache.maven.continuum.ContinuumException;
 import org.apache.maven.continuum.model.project.Project;
 import org.apache.maven.continuum.model.project.ProjectGroup;
+import org.apache.maven.continuum.model.system.Profile;
+import org.apache.maven.continuum.profile.ProfileException;
+import org.apache.maven.continuum.profile.ProfileService;
 import org.apache.maven.continuum.web.exception.AuthorizationRequiredException;
 import org.codehaus.plexus.util.StringUtils;
 
 import java.util.ArrayList;
 import java.util.Collection;
 import java.util.Iterator;
+import java.util.List;
 
 /**
  * @author Nick Gonzalez
@@ -65,6 +69,13 @@
 
     private boolean projectScmUseCache;
 
+    private List<Profile> profiles;
+
+    /**
+     * @plexus.requirement role-hint="default"
+     */
+    private ProfileService profileService;
+
     public void validate()
     {
         boolean projectNameAlreadyExist = false;
@@ -138,7 +149,7 @@
     }
 
     public String input()
-        throws ContinuumException
+        throws ContinuumException, ProfileException
     {
         try
         {
@@ -171,10 +182,10 @@
 
         if ( !disableGroupSelection )
         {
-            selectedProjectGroup =
-                getContinuum().getProjectGroupByGroupId( Continuum.DEFAULT_PROJECT_GROUP_GROUP_ID ).getId();
+            selectedProjectGroup = getContinuum().getProjectGroupByGroupId( Continuum.DEFAULT_PROJECT_GROUP_GROUP_ID )
+                .getId();
         }
-
+        this.profiles = profileService.getAllProfiles();
         return SUCCESS;
     }
 
@@ -296,5 +307,15 @@
     public void setProjectScmUseCache( boolean projectScmUseCache )
     {
         this.projectScmUseCache = projectScmUseCache;
+    }
+
+    public List<Profile> getProfiles()
+    {
+        return profiles;
+    }
+
+    public void setProfiles( List<Profile> profiles )
+    {
+        this.profiles = profiles;
     }
 }



Mime
View raw message