continuum-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From tryg...@apache.org
Subject svn commit: r164064 - /maven/continuum/trunk/continuum-core-it /maven/continuum/trunk/continuum-core/src/main/java/org/apache/maven/continuum/buildcontroller /maven/continuum/trunk/continuum-core/src/main/java/org/apache/maven/continuum/store /maven/continuum/trunk/continuum-core/src/test/java/org/apache/maven/continuum/store /maven/continuum/trunk/continuum-model/src/main/resources
Date Thu, 21 Apr 2005 14:10:09 GMT
Author: trygvis
Date: Thu Apr 21 07:10:08 2005
New Revision: 164064

URL: http://svn.apache.org/viewcvs?rev=164064&view=rev
Log:
Fixing a issue with removing projects.
o When persisting the changed file list the object has to be JDO persistable so
  the list now contains ScmFile objects instead of Strings.
o Changed the build controller to add ScmFile objects instead of Strings.
o Added removeProject() to the continuum Python module.
o After the integration test has executed the tests on a project it removed them.

o Ignoring compiled Python files.

Modified:
    maven/continuum/trunk/continuum-core-it/   (props changed)
    maven/continuum/trunk/continuum-core-it/continuum.py
    maven/continuum/trunk/continuum-core-it/it.py
    maven/continuum/trunk/continuum-core/src/main/java/org/apache/maven/continuum/buildcontroller/DefaultBuildController.java
    maven/continuum/trunk/continuum-core/src/main/java/org/apache/maven/continuum/store/ModelloJPoxContinuumStore.java
    maven/continuum/trunk/continuum-core/src/test/java/org/apache/maven/continuum/store/ModelloJPoxContinuumStoreTest.java
    maven/continuum/trunk/continuum-model/src/main/resources/continuum.mdo

Propchange: maven/continuum/trunk/continuum-core-it/
------------------------------------------------------------------------------
--- svn:ignore (original)
+++ svn:ignore Thu Apr 21 07:10:08 2005
@@ -6,3 +6,4 @@
 *.ipr
 *.iws
 *.iml
+*.pyc

Modified: maven/continuum/trunk/continuum-core-it/continuum.py
URL: http://svn.apache.org/viewcvs/maven/continuum/trunk/continuum-core-it/continuum.py?rev=164064&r1=164063&r2=164064&view=diff
==============================================================================
--- maven/continuum/trunk/continuum-core-it/continuum.py (original)
+++ maven/continuum/trunk/continuum-core-it/continuum.py Thu Apr 21 07:10:08 2005
@@ -74,6 +74,9 @@
 
     return result[ "projects" ]
 
+def removeProject( projectId ):
+    checkResult( server.continuum.removeProject( projectId ) )
+
 def buildProject( projectId ):
     result = checkResult( server.continuum.buildProject( projectId ) )
 

Modified: maven/continuum/trunk/continuum-core-it/it.py
URL: http://svn.apache.org/viewcvs/maven/continuum/trunk/continuum-core-it/it.py?rev=164064&r1=164063&r2=164064&view=diff
==============================================================================
--- maven/continuum/trunk/continuum-core-it/it.py (original)
+++ maven/continuum/trunk/continuum-core-it/it.py Thu Apr 21 07:10:08 2005
@@ -23,7 +23,7 @@
 
     if( expected == actual ):
         return
-    
+
     print
     print "##############################################"
     print "ASSERTION FAILURE!"
@@ -110,6 +110,15 @@
     assertEquals( "Standard output didn't contain the expected output.", expectedStandardOutput,
buildResult.standardOutput )
     assertEquals( "Standard error wasn't empty.", 0, len( buildResult.standardError ) )
 
+def removeProject( projectId ):
+    continuum.removeProject( projectId )
+
+    map = continuum.server.continuum.getProject( projectId )
+
+    if ( map[ "result" ] != "failure" ):
+        print map
+        fail( "Expected a failure when removing project." )
+
 def execute( workingDirectory, command ):
     cwd = os.getcwd()
     os.chdir( workingDirectory )
@@ -187,10 +196,10 @@
     <nagEmailAddress>%(email)s</nagEmailAddress>
   </build>
 </project>
-""" % { 
-        "artifactId" : artifactId, 
-        "scm" : scm, 
-        "scmUrl" : makeScmUrl( scm, scmroot, artifactId ), 
+""" % {
+        "artifactId" : artifactId,
+        "scm" : scm,
+        "scmUrl" : makeScmUrl( scm, scmroot, artifactId ),
         "email" : email
       } )
     pom.close()
@@ -270,9 +279,14 @@
     script.close()
     os.system( "chmod +x " + basedir + "/script.sh" )
 
-############################################################
-# Start
-############################################################
+print "############################################################"
+print "Running integration tests"
+print ""
+print "NOTE:"
+print "When running these integration tests you will get some"
+print "stacktraces related."
+print "############################################################"
+print ""
 
 # This is the email that will be used as the nag email address
 email = "trygvis@codehaus.org"
@@ -329,6 +343,8 @@
     assertEquals( "The project name wasn't changed.", "Maven 1 Project - Changed", maven1.name
)
     assertEquals( "The project version wasn't changed.", "1.1", maven1.version )
 
+    removeProject( maven1.id );
+
 if 1:
     progress( "Initializing Maven 2 CVS project" )
     initMaven2Project( maven2Project, cvsroot, "maven-2" )
@@ -345,16 +361,18 @@
     build = continuum.buildProject( maven2.id )
     assertSuccessfulNoBuildPerformed( build )
 
+    removeProject( maven2Id )
+
 if 1:
     progress( "Initializing Ant SVN project" )
     initAntProject( antProject )
     svnImport( antProject, svnroot, "ant-svn" )
 
     progress( "Adding Ant SVN project" )
-    antSvnId = continuum.addProjectFromScm( "scm:svn:file://" + svnroot + "/ant-svn", "ant",
"Ant SVN Project", email, "3.0", 
-                                            { 
-                                                "executable": "ant", 
-                                                "targets" : "clean, build" 
+    antSvnId = continuum.addProjectFromScm( "scm:svn:file://" + svnroot + "/ant-svn", "ant",
"Ant SVN Project", email, "3.0",
+                                            {
+                                                "executable": "ant",
+                                                "targets" : "clean, build"
                                             } )
     antSvn = continuum.getProject( antSvnId )
     assertProject( antSvnId, "Ant SVN Project", email, continuum.STATE_NEW, "3.0", "ant",
antSvn )
@@ -362,17 +380,20 @@
     build = continuum.buildProject( antSvn.id )
     assertSuccessfulAntBuild( build )
 
+    removeProject( antSvnId )
+
 if 1:
     progress( "Initializing Ant CVS project" )
     initAntProject( antProject )
     cvsImport( antProject, cvsroot, "ant-cvs" )
-    antCvsId = continuum.addProjectFromScm( "scm:cvs:local:" + basedir + "/cvsroot:ant-cvs",
"ant", "Ant CVS Project", email, "3.0", 
+    antCvsId = continuum.addProjectFromScm( "scm:cvs:local:" + basedir + "/cvsroot:ant-cvs",
"ant", "Ant CVS Project", email, "3.0",
                                          { "executable": "ant", "targets" : "clean, build"}
)
     antCvs = continuum.getProject( antCvsId )
     assertProject( antCvsId, "Ant CVS Project", email, continuum.STATE_NEW, "3.0", "ant",
antCvs )
     progress( "Building CVS Ant project" )
     build = continuum.buildProject( antCvs.id )
     assertSuccessfulAntBuild( build )
+    removeProject( antCvsId )
 
 if 1:
     progress( "Initializing Shell CVS project" )
@@ -380,7 +401,7 @@
     cvsImport( shellProject, cvsroot, "shell" )
 
     progress( "Adding CVS Shell project" )
-    shellId = continuum.addProjectFromScm( "scm:cvs:local:" + basedir + "/cvsroot:shell",
"shell", "Shell Project", email, "3.0", 
+    shellId = continuum.addProjectFromScm( "scm:cvs:local:" + basedir + "/cvsroot:shell",
"shell", "Shell Project", email, "3.0",
                                            { "executable": "script.sh", "arguments" : ""}
)
 
     shell = continuum.getProject( shellId )
@@ -414,6 +435,7 @@
     assertSuccessfulShellBuild( build, """a
 b
 """ )
+    removeProject( shellId )
 
 # TODO: Add project failure tests
 

Modified: maven/continuum/trunk/continuum-core/src/main/java/org/apache/maven/continuum/buildcontroller/DefaultBuildController.java
URL: http://svn.apache.org/viewcvs/maven/continuum/trunk/continuum-core/src/main/java/org/apache/maven/continuum/buildcontroller/DefaultBuildController.java?rev=164064&r1=164063&r2=164064&view=diff
==============================================================================
--- maven/continuum/trunk/continuum-core/src/main/java/org/apache/maven/continuum/buildcontroller/DefaultBuildController.java
(original)
+++ maven/continuum/trunk/continuum-core/src/main/java/org/apache/maven/continuum/buildcontroller/DefaultBuildController.java
Thu Apr 21 07:10:08 2005
@@ -29,10 +29,10 @@
 import org.apache.maven.continuum.project.ContinuumBuildResult;
 import org.apache.maven.continuum.project.ContinuumProject;
 import org.apache.maven.continuum.project.ContinuumProjectState;
+import org.apache.maven.continuum.project.ScmFile;
 import org.apache.maven.continuum.scm.ContinuumScm;
 import org.apache.maven.continuum.store.ContinuumStore;
 import org.apache.maven.continuum.store.ContinuumStoreException;
-import org.apache.maven.scm.ScmFile;
 import org.apache.maven.scm.command.update.UpdateScmResult;
 
 import org.codehaus.plexus.logging.AbstractLogEnabled;
@@ -266,9 +266,11 @@
 
         for ( Iterator it = scmFiles.iterator(); it.hasNext(); )
         {
-            ScmFile file = (ScmFile) it.next();
+            org.apache.maven.scm.ScmFile scmFile = (org.apache.maven.scm.ScmFile) it.next();
 
-            files.add( file.getPath() );
+            ScmFile file = new ScmFile( scmFile.getPath() );
+
+            files.add( file );
         }
 
         result.setChangedFiles( files );

Modified: maven/continuum/trunk/continuum-core/src/main/java/org/apache/maven/continuum/store/ModelloJPoxContinuumStore.java
URL: http://svn.apache.org/viewcvs/maven/continuum/trunk/continuum-core/src/main/java/org/apache/maven/continuum/store/ModelloJPoxContinuumStore.java?rev=164064&r1=164063&r2=164064&view=diff
==============================================================================
--- maven/continuum/trunk/continuum-core/src/main/java/org/apache/maven/continuum/store/ModelloJPoxContinuumStore.java
(original)
+++ maven/continuum/trunk/continuum-core/src/main/java/org/apache/maven/continuum/store/ModelloJPoxContinuumStore.java
Thu Apr 21 07:10:08 2005
@@ -24,12 +24,14 @@
 import java.util.Properties;
 
 import javax.jdo.JDOHelper;
+import javax.jdo.PersistenceManager;
 
 import org.apache.maven.continuum.project.ContinuumBuild;
 import org.apache.maven.continuum.project.ContinuumBuildResult;
 import org.apache.maven.continuum.project.ContinuumJPoxStore;
 import org.apache.maven.continuum.project.ContinuumProject;
 import org.apache.maven.continuum.project.ContinuumProjectState;
+import org.apache.maven.continuum.project.ScmFile;
 
 import org.codehaus.plexus.jdo.JdoFactory;
 import org.codehaus.plexus.personality.plexus.lifecycle.phase.Initializable;
@@ -112,10 +114,65 @@
     {
         try
         {
+            store.begin();
+
+//            System.err.println( "**********************************" );
+//            System.err.println( "**********************************" );
+//            System.err.println( "**********************************" );
+
+//            System.err.println( "getProject()" );
+            ContinuumProject project = store.getContinuumProject( projectId, false );
+
+            // TODO: This is dumb.
+            PersistenceManager pm = store.getThreadState().getPersistenceManager();
+
+//            System.err.println( "getBuilds()" );
+            for ( Iterator it = project.getBuilds().iterator(); it.hasNext(); )
+            {
+                ContinuumBuild build = (ContinuumBuild) it.next();
+
+//                System.err.println( "getBuildResult()" );
+                ContinuumBuildResult result = build.getBuildResult();
+
+//                System.err.println( "result.getChangedFiles()" );
+                List changedFiles = result.getChangedFiles();
+
+//                System.err.println( "changedFiles.clear()" );
+                changedFiles.clear();
+
+//                System.err.println( "pm.deletePersistentAll( changedFiles )" );
+                pm.deletePersistentAll( changedFiles );
+
+//                System.err.println( "result.setBuild( null )" );
+                result.setBuild( null );
+
+//                System.err.println( "pm.deletePersistent( result )" );
+                pm.deletePersistent( result );
+            }
+
+//            System.err.println( "project.getBuilds()" );
+            List builds = new ArrayList( project.getBuilds() );
+
+            for ( Iterator it = builds.iterator(); it.hasNext(); )
+            {
+                ContinuumBuild build = (ContinuumBuild) it.next();
+
+//                System.err.println( "build.setProject( null )" );
+                build.setProject( null );
+            }
+
+//            System.err.println( "pm.deletePersistentAll( builds )" );
+            pm.deletePersistentAll( project.getBuilds() );
+
+//            System.err.println( "store.deleteContinuumProject( projectId )" );
             store.deleteContinuumProject( projectId );
+
+            store.commit();
         }
         catch ( Exception e )
         {
+            rollback( store );
+
             throw new ContinuumStoreException( "Error while removing project with id '" +
projectId + "'.", e );
         }
     }

Modified: maven/continuum/trunk/continuum-core/src/test/java/org/apache/maven/continuum/store/ModelloJPoxContinuumStoreTest.java
URL: http://svn.apache.org/viewcvs/maven/continuum/trunk/continuum-core/src/test/java/org/apache/maven/continuum/store/ModelloJPoxContinuumStoreTest.java?rev=164064&r1=164063&r2=164064&view=diff
==============================================================================
--- maven/continuum/trunk/continuum-core/src/test/java/org/apache/maven/continuum/store/ModelloJPoxContinuumStoreTest.java
(original)
+++ maven/continuum/trunk/continuum-core/src/test/java/org/apache/maven/continuum/store/ModelloJPoxContinuumStoreTest.java
Thu Apr 21 07:10:08 2005
@@ -29,6 +29,7 @@
 import org.apache.maven.continuum.project.ContinuumJPoxStore;
 import org.apache.maven.continuum.project.ContinuumProject;
 import org.apache.maven.continuum.project.ContinuumProjectState;
+import org.apache.maven.continuum.project.ScmFile;
 
 import org.codehaus.plexus.PlexusTestCase;
 import org.codehaus.plexus.jdo.JdoFactory;
@@ -342,6 +343,24 @@
         assertTrue( actual.containsKey( "key" ) );
 
         assertEquals( "value", actual.getProperty( "key" ) );
+    }
+
+    public void testRemoveProject()
+        throws Exception
+    {
+        ContinuumStore store = (ContinuumStore) lookup( ContinuumStore.ROLE );
+
+        String projectId = addProject( "Test Project" );
+
+        String buildId = store.createBuild( projectId );
+
+        ContinuumBuildResult result = new ShellBuildResult();
+
+        result.addChangedFile( new ScmFile( "foo" ) );
+
+        store.setBuildResult( buildId, ContinuumProjectState.OK, result, null );
+
+        store.removeProject( projectId );
     }
 
     // ----------------------------------------------------------------------

Modified: maven/continuum/trunk/continuum-model/src/main/resources/continuum.mdo
URL: http://svn.apache.org/viewcvs/maven/continuum/trunk/continuum-model/src/main/resources/continuum.mdo?rev=164064&r1=164063&r2=164064&view=diff
==============================================================================
--- maven/continuum/trunk/continuum-model/src/main/resources/continuum.mdo (original)
+++ maven/continuum/trunk/continuum-model/src/main/resources/continuum.mdo Thu Apr 21 07:10:08
2005
@@ -346,11 +346,42 @@
           <name>changedFiles</name>
           <version>1.0.0</version>
           <association>
-            <type>String</type>
+            <type>ScmFile</type>
             <multiplicity>*</multiplicity>
           </association>
         </field>
       </fields>
+    </class>
+
+    <class>
+      <name>ScmFile</name>
+      <version>1.0.0</version>
+      <fields>
+        <field>
+          <name>path</name>
+          <version>1.0.0</version>
+          <type>String</type>
+        </field>
+      </fields>
+      <codeSegments>
+        <codeSegment>
+          <code>
+            public ScmFile()
+            {
+            }
+
+            public ScmFile( String path )
+            {
+              this.path = path;
+            }
+
+            public String toString()
+            {
+              return path;
+            }
+          </code>
+        </codeSegment>
+      </codeSegments>
     </class>
 
     <class>



Mime
View raw message