continuum-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From c...@apache.org
Subject svn commit: r1036488 - in /continuum/trunk: continuum-core/src/main/java/org/apache/continuum/release/distributed/manager/ continuum-xmlrpc/continuum-xmlrpc-server/ continuum-xmlrpc/continuum-xmlrpc-server/src/main/java/org/apache/maven/continuum/xmlrp...
Date Thu, 18 Nov 2010 15:22:14 GMT
Author: ctan
Date: Thu Nov 18 15:22:13 2010
New Revision: 1036488

URL: http://svn.apache.org/viewvc?rev=1036488&view=rev
Log:
[CONTINUUM-2581]
- fixed NPE in rewrite-pom-phase
- fixed ClassCastException when invoking getListener()
- throw an exception when agent is unreachable while doing a release perform

Added:
    continuum/trunk/continuum-xmlrpc/continuum-xmlrpc-server/src/test/
    continuum/trunk/continuum-xmlrpc/continuum-xmlrpc-server/src/test/java/
    continuum/trunk/continuum-xmlrpc/continuum-xmlrpc-server/src/test/java/org/
    continuum/trunk/continuum-xmlrpc/continuum-xmlrpc-server/src/test/java/org/apache/
    continuum/trunk/continuum-xmlrpc/continuum-xmlrpc-server/src/test/java/org/apache/continuum/
    continuum/trunk/continuum-xmlrpc/continuum-xmlrpc-server/src/test/java/org/apache/continuum/xmlrpc/
    continuum/trunk/continuum-xmlrpc/continuum-xmlrpc-server/src/test/java/org/apache/continuum/xmlrpc/server/
    continuum/trunk/continuum-xmlrpc/continuum-xmlrpc-server/src/test/java/org/apache/continuum/xmlrpc/server/ContinuumServiceImplStub.java
  (with props)
    continuum/trunk/continuum-xmlrpc/continuum-xmlrpc-server/src/test/java/org/apache/continuum/xmlrpc/server/ContinuumServiceImplTest.java
  (with props)
Modified:
    continuum/trunk/continuum-core/src/main/java/org/apache/continuum/release/distributed/manager/DefaultDistributedReleaseManager.java
    continuum/trunk/continuum-xmlrpc/continuum-xmlrpc-server/pom.xml
    continuum/trunk/continuum-xmlrpc/continuum-xmlrpc-server/src/main/java/org/apache/maven/continuum/xmlrpc/server/ContinuumServiceImpl.java

Modified: continuum/trunk/continuum-core/src/main/java/org/apache/continuum/release/distributed/manager/DefaultDistributedReleaseManager.java
URL: http://svn.apache.org/viewvc/continuum/trunk/continuum-core/src/main/java/org/apache/continuum/release/distributed/manager/DefaultDistributedReleaseManager.java?rev=1036488&r1=1036487&r2=1036488&view=diff
==============================================================================
--- continuum/trunk/continuum-core/src/main/java/org/apache/continuum/release/distributed/manager/DefaultDistributedReleaseManager.java
(original)
+++ continuum/trunk/continuum-core/src/main/java/org/apache/continuum/release/distributed/manager/DefaultDistributedReleaseManager.java
Thu Nov 18 15:22:13 2010
@@ -409,12 +409,14 @@ public class DefaultDistributedReleaseMa
     
                 addReleaseInProgress( releaseId, "perform", projectId, username );
             }
+            else
+            {
+                // call reload in case we disable the build agent
+                distributedBuildManager.reload();
 
-            // call reload in case we disable the build agent
-            distributedBuildManager.reload();
-
-            throw new ContinuumReleaseException( "Failed to perform release of " + releaseId
+ 
-                                                 " because the build agent " + buildAgentUrl
+ " is not available" );
+                throw new ContinuumReleaseException( "Failed to perform release of " + releaseId
+ 
+                                                     " because the build agent " + buildAgentUrl
+ " is not available" );
+            }
         }
         catch ( MalformedURLException e )
         {

Modified: continuum/trunk/continuum-xmlrpc/continuum-xmlrpc-server/pom.xml
URL: http://svn.apache.org/viewvc/continuum/trunk/continuum-xmlrpc/continuum-xmlrpc-server/pom.xml?rev=1036488&r1=1036487&r2=1036488&view=diff
==============================================================================
--- continuum/trunk/continuum-xmlrpc/continuum-xmlrpc-server/pom.xml (original)
+++ continuum/trunk/continuum-xmlrpc/continuum-xmlrpc-server/pom.xml Thu Nov 18 15:22:13 2010
@@ -122,6 +122,31 @@ under the License.
       <version>2.4</version>
       <scope>provided</scope>
     </dependency>
+    <dependency>
+      <groupId>org.jmock</groupId>
+      <artifactId>jmock</artifactId>
+      <scope>test</scope>
+    </dependency>
+    <dependency>
+      <groupId>org.jmock</groupId>
+      <artifactId>jmock-junit3</artifactId>
+      <scope>test</scope>
+    </dependency>
+    <dependency>
+      <groupId>cglib</groupId>
+      <artifactId>cglib-nodep</artifactId>
+      <scope>test</scope>
+    </dependency>
+    <dependency>
+      <groupId>org.objenesis</groupId>
+      <artifactId>objenesis</artifactId>  
+      <scope>test</scope>
+    </dependency>
+    <dependency>
+      <groupId>org.slf4j</groupId>
+      <artifactId>slf4j-simple</artifactId>
+      <scope>test</scope>
+    </dependency>
   </dependencies>
 
   <build>

Modified: continuum/trunk/continuum-xmlrpc/continuum-xmlrpc-server/src/main/java/org/apache/maven/continuum/xmlrpc/server/ContinuumServiceImpl.java
URL: http://svn.apache.org/viewvc/continuum/trunk/continuum-xmlrpc/continuum-xmlrpc-server/src/main/java/org/apache/maven/continuum/xmlrpc/server/ContinuumServiceImpl.java?rev=1036488&r1=1036487&r2=1036488&view=diff
==============================================================================
--- continuum/trunk/continuum-xmlrpc/continuum-xmlrpc-server/src/main/java/org/apache/maven/continuum/xmlrpc/server/ContinuumServiceImpl.java
(original)
+++ continuum/trunk/continuum-xmlrpc/continuum-xmlrpc-server/src/main/java/org/apache/maven/continuum/xmlrpc/server/ContinuumServiceImpl.java
Thu Nov 18 15:22:13 2010
@@ -73,7 +73,6 @@ import org.apache.maven.continuum.xmlrpc
 import org.apache.maven.continuum.xmlrpc.system.Profile;
 import org.apache.maven.continuum.xmlrpc.system.SystemConfiguration;
 import org.apache.maven.scm.provider.svn.repository.SvnScmProviderRepository;
-import org.apache.maven.shared.release.ReleaseResult;
 import org.codehaus.plexus.redback.authorization.AuthorizationException;
 import org.codehaus.plexus.redback.role.RoleManager;
 import org.codehaus.plexus.redback.role.RoleManagerException;
@@ -3009,7 +3008,7 @@ public class ContinuumServiceImpl
 
             // set scm tag and scm tag base if no values yet
             // scm tag
-            if ( params.get( "scm-tag") == null )
+            if ( StringUtils.isBlank( (String) params.get( "scm-tag" ) ) )
             {
                 String scmTag;
                 if ( project.getScmTag() != null )
@@ -3037,7 +3036,7 @@ public class ContinuumServiceImpl
             }
 
             // scm tagbase
-            if ( params.get( "scm-tagbase") == null )
+            if ( StringUtils.isBlank( (String) params.get( "scm-tagbase") ) )
             {
                 if ( project.getScmUrl().startsWith( "scm:svn" ) )
                 {
@@ -3090,13 +3089,13 @@ public class ContinuumServiceImpl
         value = context.get( "release-phases" );
         if ( value != null )
         {
-            listenerSummary.setPhases( (List<String>) value );
+            listenerSummary.setPhases( getList( value ) );
         }
 
         value = context.get( "completed-release-phases" );
         if ( value != null )
         {
-            listenerSummary.setPhases( (List<String>) value );
+            listenerSummary.setCompletedPhases( getList( value ) );
         }
 
         return listenerSummary;
@@ -3107,4 +3106,28 @@ public class ContinuumServiceImpl
     {
         return (ReleaseListenerSummary) mapper.map( listener, ReleaseListenerSummary.class
);
     }
+
+    private List getList( Object obj )
+    {
+        List<Object> list = new ArrayList<Object>();
+
+        if ( obj instanceof Object[] )
+        {
+            Object[] objA = (Object[]) obj;
+
+            list.addAll( Arrays.asList( objA ) );
+        }
+        else
+        {
+            list = (List<Object>) obj;
+        }
+
+        return list;
+    }
+
+    // testing
+    public void setContinuum( Continuum continuum )
+    {
+        this.continuum = continuum;
+    }
 }

Added: continuum/trunk/continuum-xmlrpc/continuum-xmlrpc-server/src/test/java/org/apache/continuum/xmlrpc/server/ContinuumServiceImplStub.java
URL: http://svn.apache.org/viewvc/continuum/trunk/continuum-xmlrpc/continuum-xmlrpc-server/src/test/java/org/apache/continuum/xmlrpc/server/ContinuumServiceImplStub.java?rev=1036488&view=auto
==============================================================================
--- continuum/trunk/continuum-xmlrpc/continuum-xmlrpc-server/src/test/java/org/apache/continuum/xmlrpc/server/ContinuumServiceImplStub.java
(added)
+++ continuum/trunk/continuum-xmlrpc/continuum-xmlrpc-server/src/test/java/org/apache/continuum/xmlrpc/server/ContinuumServiceImplStub.java
Thu Nov 18 15:22:13 2010
@@ -0,0 +1,14 @@
+package org.apache.continuum.xmlrpc.server;
+
+import org.apache.maven.continuum.ContinuumException;
+import org.apache.maven.continuum.xmlrpc.server.ContinuumServiceImpl;
+
+public class ContinuumServiceImplStub
+    extends ContinuumServiceImpl
+{
+    protected void checkBuildProjectInGroupAuthorization( String resource )
+        throws ContinuumException
+    {
+        // do nothing
+    }
+}

Propchange: continuum/trunk/continuum-xmlrpc/continuum-xmlrpc-server/src/test/java/org/apache/continuum/xmlrpc/server/ContinuumServiceImplStub.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: continuum/trunk/continuum-xmlrpc/continuum-xmlrpc-server/src/test/java/org/apache/continuum/xmlrpc/server/ContinuumServiceImplStub.java
------------------------------------------------------------------------------
    svn:keywords = Author Date Id Revision

Added: continuum/trunk/continuum-xmlrpc/continuum-xmlrpc-server/src/test/java/org/apache/continuum/xmlrpc/server/ContinuumServiceImplTest.java
URL: http://svn.apache.org/viewvc/continuum/trunk/continuum-xmlrpc/continuum-xmlrpc-server/src/test/java/org/apache/continuum/xmlrpc/server/ContinuumServiceImplTest.java?rev=1036488&view=auto
==============================================================================
--- continuum/trunk/continuum-xmlrpc/continuum-xmlrpc-server/src/test/java/org/apache/continuum/xmlrpc/server/ContinuumServiceImplTest.java
(added)
+++ continuum/trunk/continuum-xmlrpc/continuum-xmlrpc-server/src/test/java/org/apache/continuum/xmlrpc/server/ContinuumServiceImplTest.java
Thu Nov 18 15:22:13 2010
@@ -0,0 +1,149 @@
+package org.apache.continuum.xmlrpc.server;
+
+import java.util.Arrays;
+import java.util.HashMap;
+import java.util.Map;
+
+import org.apache.continuum.release.distributed.manager.DistributedReleaseManager;
+import org.apache.maven.continuum.Continuum;
+import org.apache.maven.continuum.configuration.ConfigurationService;
+import org.apache.maven.continuum.model.project.Project;
+import org.apache.maven.continuum.model.project.ProjectGroup;
+import org.apache.maven.continuum.release.ContinuumReleaseManager;
+import org.apache.maven.continuum.xmlrpc.project.ReleaseListenerSummary;
+import org.apache.maven.continuum.xmlrpc.server.ContinuumServiceImpl;
+import org.codehaus.plexus.spring.PlexusInSpringTestCase;
+import org.jmock.Expectations;
+import org.jmock.Mockery;
+import org.jmock.integration.junit3.JUnit3Mockery;
+import org.jmock.lib.legacy.ClassImposteriser;
+
+import com.sun.tools.javac.code.Attribute.Array;
+
+public class ContinuumServiceImplTest
+    extends PlexusInSpringTestCase
+{
+    private ContinuumServiceImpl continuumService;
+
+    private Mockery context;
+
+    private Continuum continuum;
+
+    private DistributedReleaseManager distributedReleaseManager;
+
+    private ContinuumReleaseManager releaseManager;
+
+    private ConfigurationService configurationService;
+
+    private Project project;
+
+    private Map<String, Object> params;
+
+    @Override
+    public void setUp()
+        throws Exception
+    {
+        super.setUp();
+
+        context = new JUnit3Mockery();
+        context.setImposteriser( ClassImposteriser.INSTANCE );
+
+        continuumService = new ContinuumServiceImplStub();
+        continuum = context.mock( Continuum.class );
+        continuumService.setContinuum( continuum );
+
+        distributedReleaseManager = context.mock( DistributedReleaseManager.class );
+        releaseManager = context.mock( ContinuumReleaseManager.class );
+        configurationService = context.mock( ConfigurationService.class );
+
+        ProjectGroup projectGroup = new ProjectGroup();
+        projectGroup.setName( "test-group" );
+
+        project = new Project();
+        project.setId( 1 );
+        project.setProjectGroup( projectGroup );
+        project.setVersion( "1.0-SNAPSHOT" );
+        project.setArtifactId( "continuum-test" );
+        project.setScmUrl( "scm:svn:http://svn.test.org/repository/project" );
+    }
+
+    public void testGetReleasePluginParameters()
+        throws Exception
+    {
+        params = new HashMap<String, Object>();
+        params.put( "scm-tag", "" );
+        params.put( "scm-tagbase", "" );    
+
+        context.checking( new Expectations()
+        {
+            {
+                one( continuum ).getProject( 1 );
+                will( returnValue( project ) );
+
+                one( continuum ).getConfiguration();
+                will( returnValue( configurationService ) );
+
+                one( configurationService ).isDistributedBuildEnabled();
+                will( returnValue( true ) );
+
+                one( continuum ).getDistributedReleaseManager();
+                will( returnValue( distributedReleaseManager ) );
+
+                one( distributedReleaseManager ).getReleasePluginParameters( 1, "pom.xml"
);
+                will( returnValue( params ) );
+
+                one( continuum ).getReleaseManager();
+                will( returnValue( releaseManager ) );
+
+                one( releaseManager ).sanitizeTagName( "scm:svn:http://svn.test.org/repository/project",
+                                                       "continuum-test-1.0" );
+            }
+        } );
+
+        Map<String, Object> releaseParams = continuumService.getReleasePluginParameters(
1 );
+        assertEquals( "continuum-test-1.0", releaseParams.get( "scm-tag" ) );
+        assertEquals( "http://svn.test.org/repository/project/tags", releaseParams.get( "scm-tagbase"
) );
+
+        context.assertIsSatisfied();
+    }
+
+    public void testGetListenerWithDistributedBuilds()
+        throws Exception
+    {
+        final Map map = getListenerMap();
+
+        context.checking( new Expectations()
+        {
+            {
+                one( continuum ).getProject( 1 );
+                will( returnValue( project ) );
+
+                one( continuum ).getConfiguration();
+                will( returnValue( configurationService ) );
+
+                one( configurationService ).isDistributedBuildEnabled();
+                will( returnValue( true ) );
+
+                one( continuum ).getDistributedReleaseManager();
+                will( returnValue( distributedReleaseManager ) );
+
+                one( distributedReleaseManager ).getListener( "releaseId-1" );
+                will( returnValue( map ) );
+            }
+        } );
+
+        ReleaseListenerSummary summary = continuumService.getListener( 1, "releaseId-1" );
+        assertNotNull( summary );
+        assertEquals( "incomplete-phase", summary.getPhases().get( 0 ) );
+        assertEquals( "completed-phase", summary.getCompletedPhases().get( 0 ) );
+    }
+
+    private Map<String, Object> getListenerMap()
+    {
+        Map<String, Object> map = new HashMap<String, Object>();
+ 
+        map.put( "release-phases", Arrays.asList( "incomplete-phase" ) );
+        map.put( "completed-release-phases", Arrays.asList( "completed-phase" ) );
+        return map;
+    }
+}

Propchange: continuum/trunk/continuum-xmlrpc/continuum-xmlrpc-server/src/test/java/org/apache/continuum/xmlrpc/server/ContinuumServiceImplTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: continuum/trunk/continuum-xmlrpc/continuum-xmlrpc-server/src/test/java/org/apache/continuum/xmlrpc/server/ContinuumServiceImplTest.java
------------------------------------------------------------------------------
    svn:keywords = Author Date Id Revision



Mime
View raw message