You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@continuum.apache.org by ct...@apache.org on 2009/03/28 06:16:33 UTC

svn commit: r759430 - in /continuum/trunk: continuum-data-management/data-management-jdo/src/main/java/org/apache/maven/continuum/management/ continuum-data-management/data-management-jdo/src/test/resources/ continuum-store/src/test/java/org/apache/mav...

Author: ctan
Date: Sat Mar 28 05:16:31 2009
New Revision: 759430

URL: http://svn.apache.org/viewvc?rev=759430&view=rev
Log:
[CONTINUUM-2100] fixed restore when there's an installation of type envvar

Submitted By: Jose Morales Martinez (with slight modification)


Modified:
    continuum/trunk/continuum-data-management/data-management-jdo/src/main/java/org/apache/maven/continuum/management/JdoDataManagementTool.java
    continuum/trunk/continuum-data-management/data-management-jdo/src/test/resources/expected.xml
    continuum/trunk/continuum-store/src/test/java/org/apache/maven/continuum/store/AbstractContinuumStoreTestCase.java
    continuum/trunk/continuum-store/src/test/java/org/apache/maven/continuum/store/ContinuumStoreTest.java

Modified: continuum/trunk/continuum-data-management/data-management-jdo/src/main/java/org/apache/maven/continuum/management/JdoDataManagementTool.java
URL: http://svn.apache.org/viewvc/continuum/trunk/continuum-data-management/data-management-jdo/src/main/java/org/apache/maven/continuum/management/JdoDataManagementTool.java?rev=759430&r1=759429&r2=759430&view=diff
==============================================================================
--- continuum/trunk/continuum-data-management/data-management-jdo/src/main/java/org/apache/maven/continuum/management/JdoDataManagementTool.java (original)
+++ continuum/trunk/continuum-data-management/data-management-jdo/src/main/java/org/apache/maven/continuum/management/JdoDataManagementTool.java Sat Mar 28 05:16:31 2009
@@ -19,6 +19,27 @@
  * under the License.
  */
 
+import java.io.File;
+import java.io.FileOutputStream;
+import java.io.FileReader;
+import java.io.IOException;
+import java.io.OutputStream;
+import java.io.OutputStreamWriter;
+import java.io.Writer;
+import java.nio.charset.Charset;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+import java.util.Properties;
+import java.util.Set;
+
+import javax.jdo.JDOHelper;
+import javax.jdo.PersistenceManagerFactory;
+import javax.xml.stream.XMLStreamException;
+
 import org.apache.continuum.dao.BuildDefinitionTemplateDao;
 import org.apache.continuum.dao.BuildQueueDao;
 import org.apache.continuum.dao.ContinuumReleaseResultDao;
@@ -36,7 +57,6 @@
 import org.apache.continuum.model.release.ContinuumReleaseResult;
 import org.apache.continuum.model.repository.DirectoryPurgeConfiguration;
 import org.apache.continuum.model.repository.LocalRepository;
-import org.apache.continuum.model.repository.RepositoryPurgeConfiguration;
 import org.apache.continuum.utils.ProjectSorter;
 import org.apache.maven.continuum.model.project.BuildDefinition;
 import org.apache.maven.continuum.model.project.BuildDefinitionTemplate;
@@ -57,26 +77,6 @@
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
-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;
-import java.io.IOException;
-import java.io.OutputStream;
-import java.io.OutputStreamWriter;
-import java.io.Writer;
-import java.nio.charset.Charset;
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.HashMap;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Map;
-import java.util.Properties;
-import java.util.Set;
-
 /**
  * JDO implementation the database management tool API.
  * @version $Id$
@@ -86,7 +86,7 @@
     implements DataManagementTool
 {
     private Logger log = LoggerFactory.getLogger( JdoDataManagementTool.class );
-    
+
     /**
      * @plexus.requirement
      */
@@ -293,7 +293,13 @@
             {
                 profile.setBuilder( installations.get( profile.getBuilder().getInstallationId() ) );
             }
-
+            List environmentVariables = new ArrayList();
+            for (Iterator envIt = profile.getEnvironmentVariables().listIterator(); envIt.hasNext();){
+                Installation installation = (Installation) envIt.next();
+                environmentVariables.add(installations.get(installation.getInstallationId()));
+                envIt.remove();
+            }
+            profile.setEnvironmentVariables( environmentVariables );
             profile = (Profile) PlexusJdoUtils.addObject( pmf.getPersistenceManager(), profile );
             profiles.put( Integer.valueOf( profile.getId() ), profile );
         }
@@ -320,27 +326,27 @@
 
                 processBuildDefinitions( project.getBuildDefinitions(), schedules, profiles );
             }
-            
+
             if ( projectGroup.getLocalRepository() != null )
             {
-                projectGroup.setLocalRepository( localRepositories.get( 
+                projectGroup.setLocalRepository( localRepositories.get(
                                                  Integer.valueOf( projectGroup.getLocalRepository().getId() ) ) );
             }
-            
+
             projectGroup = (ProjectGroup) PlexusJdoUtils.addObject( pmf.getPersistenceManager(), projectGroup );
             projectGroups.put( Integer.valueOf( projectGroup.getId() ), projectGroup );
         }
-        
+
         // create project scm root data (CONTINUUM-2040)
         Map<Integer, ProjectScmRoot> projectScmRoots = new HashMap<Integer, ProjectScmRoot>();
         Set<Integer> keys = projectGroups.keySet();
         int id = 1;
         for( Integer key : keys )
         {
-            ProjectGroup projectGroup = projectGroups.get( key );            
+            ProjectGroup projectGroup = projectGroups.get( key );
             String url = " ";
             try
-            {                   
+            {
                 List<Project> projects =
                     ProjectSorter.getSortedProjects( getProjectsByGroupIdWithDependencies( pmf, projectGroup.getId() ),
                                                      log );
@@ -351,14 +357,14 @@
                     {
                         url = project.getScmUrl();
                         ProjectScmRoot projectScmRoot = new ProjectScmRoot();
-                        projectScmRoot.setId( id );                        
+                        projectScmRoot.setId( id );
                         projectScmRoot.setProjectGroup( projectGroup );
                         projectScmRoot.setScmRootAddress( url );
                         projectScmRoot.setState( project.getState() );
-                        
-                        projectScmRoot = (ProjectScmRoot) PlexusJdoUtils.addObject( pmf.getPersistenceManager(), projectScmRoot );                        
+
+                        projectScmRoot = (ProjectScmRoot) PlexusJdoUtils.addObject( pmf.getPersistenceManager(), projectScmRoot );
                         projectScmRoots.put( Integer.valueOf( projectScmRoot.getId() ), projectScmRoot );
-                        id++;                                                
+                        id++;
                     }
                 }
             }
@@ -374,12 +380,12 @@
         /*
         for ( RepositoryPurgeConfiguration repoPurge : (List<RepositoryPurgeConfiguration>) database.getRepositoryPurgeConfigurations() )
         {
-            repoPurge.setRepository( localRepositories.get( 
+            repoPurge.setRepository( localRepositories.get(
                                      Integer.valueOf( repoPurge.getRepository().getId() ) ) );
 
             if ( repoPurge.getSchedule() != null )
             {
-                repoPurge.setSchedule( schedules.get( 
+                repoPurge.setSchedule( schedules.get(
                                        Integer.valueOf( repoPurge.getSchedule().getId() ) ) );
             }
 
@@ -399,7 +405,7 @@
 
         for ( ContinuumReleaseResult releaseResult : (List<ContinuumReleaseResult>) database.getContinuumReleaseResults() )
         {
-            releaseResult.setProjectGroup( projectGroups.get( 
+            releaseResult.setProjectGroup( projectGroups.get(
                                            Integer.valueOf( releaseResult.getProjectGroup().getId() ) ) );
 
             releaseResult =
@@ -414,7 +420,7 @@
                 (BuildDefinitionTemplate) PlexusJdoUtils.addObject( pmf.getPersistenceManager(), template );
         }
     }
-    
+
     private List<Project> getProjectsByGroupIdWithDependencies( PersistenceManagerFactory pmf, int projectGroupId )
     {
         List<Project> allProjects =
@@ -429,10 +435,10 @@
                 groupProjects.add( project );
             }
         }
-        
+
         return groupProjects;
     }
-    
+
     private static void processBuildDefinitions( List buildDefinitions, Map<Integer, Schedule> schedules,
                                                  Map<Integer, Profile> profiles )
     {

Modified: continuum/trunk/continuum-data-management/data-management-jdo/src/test/resources/expected.xml
URL: http://svn.apache.org/viewvc/continuum/trunk/continuum-data-management/data-management-jdo/src/test/resources/expected.xml?rev=759430&r1=759429&r2=759430&view=diff
==============================================================================
--- continuum/trunk/continuum-data-management/data-management-jdo/src/test/resources/expected.xml (original)
+++ continuum/trunk/continuum-data-management/data-management-jdo/src/test/resources/expected.xml Sat Mar 28 05:16:31 2009
@@ -426,6 +426,13 @@
       <name>Maven 2.0 alpha 3</name>
       <installationId>2</installationId>
     </installation>
+    <installation>
+      <type>envvar</type>
+      <varValue>-Xms256m -Xmx256m</varValue>
+      <varName>MAVEN_OPTS</varName>
+      <name>Maven Heap Size</name>
+      <installationId>4</installationId>
+    </installation>
   </installations>
   <schedules>
     <schedule>
@@ -489,6 +496,17 @@
       <jdk installationId="1"></jdk>
       <builder installationId="2"></builder>
     </profile>
+    <profile>
+      <id>4</id>
+      <name>name4</name>
+      <description>description4</description>
+      <scmMode>4</scmMode>
+      <jdk installationId="1"></jdk>
+      <builder installationId="2"></builder>
+      <environmentVariables>
+        <environmentVariable installationId="4"></environmentVariable>
+      </environmentVariables>
+    </profile>
   </profiles>
   <localRepositories>
     <localRepository>

Modified: continuum/trunk/continuum-store/src/test/java/org/apache/maven/continuum/store/AbstractContinuumStoreTestCase.java
URL: http://svn.apache.org/viewvc/continuum/trunk/continuum-store/src/test/java/org/apache/maven/continuum/store/AbstractContinuumStoreTestCase.java?rev=759430&r1=759429&r2=759430&view=diff
==============================================================================
--- continuum/trunk/continuum-store/src/test/java/org/apache/maven/continuum/store/AbstractContinuumStoreTestCase.java (original)
+++ continuum/trunk/continuum-store/src/test/java/org/apache/maven/continuum/store/AbstractContinuumStoreTestCase.java Sat Mar 28 05:16:31 2009
@@ -119,12 +119,16 @@
 
     protected Profile testProfile3;
 
+    protected Profile testProfile4;
+
     protected Installation testInstallationJava13;
 
     protected Installation testInstallationJava14;
 
     protected Installation testInstallationMaven20a3;
 
+    protected Installation testInstallationEnvVar;
+
     protected BuildResult testBuildResult1;
 
     protected BuildResult testBuildResult2;
@@ -318,6 +322,8 @@
             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" );
+        testInstallationEnvVar =
+            createTestInstallation( "Maven Heap Size", InstallationService.ENVVAR_TYPE, "MAVEN_OPTS", "-Xms256m -Xmx256m" );
 
         ProjectNotifier testGroupNotifier1 = createTestNotifier( 1, true, false, true, "type1" );
         ProjectNotifier testGroupNotifier2 = createTestNotifier( 2, false, true, false, "type2" );
@@ -426,12 +432,25 @@
             installationJava13.setInstallationId( 3 );
         }
 
+        Installation installationEnvVar = createTestInstallation( testInstallationEnvVar );
+        if ( addToStore )
+        {
+            installationEnvVar = installationDao.addInstallation( installationEnvVar );
+        }
+        else
+        {
+            installationEnvVar.setInstallationId( 4 );
+        }
+
         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 );
+        testProfile4 =
+            createTestProfile( "name4", "description4", 4, false, false, installationJava14, installationMaven20a3 );
+        testProfile4.addEnvironmentVariable( installationEnvVar );
 
         Profile profile1 = createTestProfile( testProfile1 );
         if ( addToStore )
@@ -466,6 +485,17 @@
             profile3.setId( 3 );
         }
 
+        Profile profile4 = createTestProfile( testProfile4 );
+        if ( addToStore )
+        {
+            profile4 = profileDao.addProfile( profile4 );
+            testProfile4.setId( profile4.getId() );
+        }
+        else
+        {
+            profile4.setId( 4 );
+        }
+
         testRepoPurgeConfiguration1 =
             createTestRepositoryPurgeConfiguration( true, 5, 50, false, schedule2, true, localRepository1 );
         if ( addToStore )
@@ -1122,8 +1152,6 @@
         return createTestProfile( profile.getName(), profile.getDescription(), profile.getScmMode(), profile
             .isBuildWithoutChanges(), profile.isActive(), profile.getJdk(), profile.getBuilder(),
                                       profile.getEnvironmentVariables() );
-//                                  createTestInstallation( profile.getJdk() ),
-//                                  createTestInstallation( profile.getBuilder() ) );
     }
 
     protected static Profile createTestProfile( String name, String description, int scmMode,

Modified: continuum/trunk/continuum-store/src/test/java/org/apache/maven/continuum/store/ContinuumStoreTest.java
URL: http://svn.apache.org/viewvc/continuum/trunk/continuum-store/src/test/java/org/apache/maven/continuum/store/ContinuumStoreTest.java?rev=759430&r1=759429&r2=759430&view=diff
==============================================================================
--- continuum/trunk/continuum-store/src/test/java/org/apache/maven/continuum/store/ContinuumStoreTest.java (original)
+++ continuum/trunk/continuum-store/src/test/java/org/apache/maven/continuum/store/ContinuumStoreTest.java Sat Mar 28 05:16:31 2009
@@ -425,7 +425,7 @@
         profileDao.removeProfile( profile );
 
         List profiles = profileDao.getAllProfilesByName();
-        assertEquals( "check size", 2, profiles.size() );
+        assertEquals( "check size", 3, profiles.size() );
         assertFalse( "check not there", profiles.contains( profile ) );
     }
 
@@ -433,7 +433,7 @@
     {
         List profiles = profileDao.getAllProfilesByName();
 
-        assertEquals( "check item count", 3, profiles.size() );
+        assertEquals( "check item count", 4, profiles.size() );
 
         // check equality and order
         Profile profile = (Profile) profiles.get( 0 );
@@ -448,6 +448,13 @@
         assertProfileEquals( testProfile3, profile );
         assertInstallationEquals( testProfile3.getBuilder(), profile.getBuilder() );
         assertInstallationEquals( testProfile3.getJdk(), profile.getJdk() );
+        profile = (Profile) profiles.get( 3 );
+        assertProfileEquals( testProfile4, profile );
+        assertInstallationEquals( testProfile4.getBuilder(), profile.getBuilder() );
+        assertInstallationEquals( testProfile4.getJdk(), profile.getJdk() );
+        assertEquals( "check env var count", 1, profile.getEnvironmentVariables().size() );
+        assertInstallationEquals( (Installation) testProfile4.getEnvironmentVariables().get( 0 ), 
+                                  (Installation) profile.getEnvironmentVariables().get( 0 ) );
     }
 
     /*
@@ -463,7 +470,7 @@
     {
         List installations = installationDao.getAllInstallations();
 
-        assertEquals( "check item count", 3, installations.size() );
+        assertEquals( "check item count", 4, installations.size() );
 
         // check equality and order
         Installation installation = (Installation) installations.get( 0 );
@@ -472,6 +479,8 @@
         assertInstallationEquals( testInstallationJava14, installation );
         installation = (Installation) installations.get( 2 );
         assertInstallationEquals( testInstallationMaven20a3, installation );
+        installation = (Installation) installations.get( 3 );
+        assertInstallationEquals( testInstallationEnvVar, installation );
     }
 
     public void testUpdateInstallation()