continuum-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From c...@apache.org
Subject svn commit: r1156970 - in /continuum/trunk/continuum-xmlrpc: continuum-xmlrpc-api/src/main/java/org/apache/maven/continuum/xmlrpc/ continuum-xmlrpc-client/src/main/java/org/apache/maven/continuum/xmlrpc/client/ continuum-xmlrpc-server/src/main/java/org...
Date Fri, 12 Aug 2011 05:41:18 GMT
Author: ctan
Date: Fri Aug 12 05:41:17 2011
New Revision: 1156970

URL: http://svn.apache.org/viewvc?rev=1156970&view=rev
Log:
[CONTINUUM-2644] expose getBuildAgentUrl() method via XMLRPC

Submitted By: Greg Michael Meneses

Modified:
    continuum/trunk/continuum-xmlrpc/continuum-xmlrpc-api/src/main/java/org/apache/maven/continuum/xmlrpc/ContinuumService.java
    continuum/trunk/continuum-xmlrpc/continuum-xmlrpc-client/src/main/java/org/apache/maven/continuum/xmlrpc/client/ContinuumXmlRpcClient.java
    continuum/trunk/continuum-xmlrpc/continuum-xmlrpc-server/src/main/java/org/apache/maven/continuum/xmlrpc/server/ContinuumServiceImpl.java
    continuum/trunk/continuum-xmlrpc/continuum-xmlrpc-server/src/test/java/org/apache/continuum/xmlrpc/server/ContinuumServiceImplTest.java

Modified: continuum/trunk/continuum-xmlrpc/continuum-xmlrpc-api/src/main/java/org/apache/maven/continuum/xmlrpc/ContinuumService.java
URL: http://svn.apache.org/viewvc/continuum/trunk/continuum-xmlrpc/continuum-xmlrpc-api/src/main/java/org/apache/maven/continuum/xmlrpc/ContinuumService.java?rev=1156970&r1=1156969&r2=1156970&view=diff
==============================================================================
--- continuum/trunk/continuum-xmlrpc/continuum-xmlrpc-api/src/main/java/org/apache/maven/continuum/xmlrpc/ContinuumService.java
(original)
+++ continuum/trunk/continuum-xmlrpc/continuum-xmlrpc-api/src/main/java/org/apache/maven/continuum/xmlrpc/ContinuumService.java
Fri Aug 12 05:41:17 2011
@@ -1702,6 +1702,15 @@ public interface ContinuumService
      * @return
      */
     BuildAgentConfiguration getBuildAgent( String url );
+    
+    /**
+     * Get the url of the build agent that is processing the project
+     * 
+     * @param projectId project Id
+     * 
+     * @return build agent url
+     */
+    String getBuildAgentUrl( int projectId ) throws Exception;
 
     /**
      * Same method but compatible with standard XMLRPC

Modified: continuum/trunk/continuum-xmlrpc/continuum-xmlrpc-client/src/main/java/org/apache/maven/continuum/xmlrpc/client/ContinuumXmlRpcClient.java
URL: http://svn.apache.org/viewvc/continuum/trunk/continuum-xmlrpc/continuum-xmlrpc-client/src/main/java/org/apache/maven/continuum/xmlrpc/client/ContinuumXmlRpcClient.java?rev=1156970&r1=1156969&r2=1156970&view=diff
==============================================================================
--- continuum/trunk/continuum-xmlrpc/continuum-xmlrpc-client/src/main/java/org/apache/maven/continuum/xmlrpc/client/ContinuumXmlRpcClient.java
(original)
+++ continuum/trunk/continuum-xmlrpc/continuum-xmlrpc-client/src/main/java/org/apache/maven/continuum/xmlrpc/client/ContinuumXmlRpcClient.java
Fri Aug 12 05:41:17 2011
@@ -1347,4 +1347,10 @@ public class ContinuumXmlRpcClient
     {
         return continuum.pingBuildAgent( buildAgentUrl );
     }
+    
+    public String getBuildAgentUrl( int projectId )
+        throws Exception
+    {
+        return continuum.getBuildAgentUrl( projectId );
+    }
 }

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=1156970&r1=1156969&r2=1156970&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
Fri Aug 12 05:41:17 2011
@@ -1966,6 +1966,23 @@ public class ContinuumServiceImpl
         BuildAgentConfiguration buildAgentConfiguration = buildAgent != null ? populateBuildAgent(
buildAgent ) : null;
         return buildAgentConfiguration;
     }
+    
+    /**
+     * {@inheritDoc}
+     * 
+     * @throws ContinuumException distributed build is not enabled or error during retrieval
of build agent url
+     * 
+     *  @see DistributedBuildManager#getBuildAgentUrl(int)
+     */
+    public String getBuildAgentUrl( int projectId ) throws ContinuumException
+    {
+        if ( !continuum.getConfiguration().isDistributedBuildEnabled() )
+        {
+            throw new ContinuumException( "Method available only in distributed build mode."
);
+        }
+        
+        return distributedBuildManager.getBuildAgentUrl( projectId );
+    }
 
     public BuildAgentConfiguration updateBuildAgent( BuildAgentConfiguration buildAgentConfiguration
)
         throws ConfigurationStoringException, ContinuumConfigurationException
@@ -3890,4 +3907,9 @@ public class ContinuumServiceImpl
     {
         this.continuum = continuum;
     }
+    
+    public void setDistributedBuildManager( DistributedBuildManager distributedBuildManager
)
+    {
+        this.distributedBuildManager = distributedBuildManager;
+    }
 }

Modified: 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=1156970&r1=1156969&r2=1156970&view=diff
==============================================================================
--- continuum/trunk/continuum-xmlrpc/continuum-xmlrpc-server/src/test/java/org/apache/continuum/xmlrpc/server/ContinuumServiceImplTest.java
(original)
+++ continuum/trunk/continuum-xmlrpc/continuum-xmlrpc-server/src/test/java/org/apache/continuum/xmlrpc/server/ContinuumServiceImplTest.java
Fri Aug 12 05:41:17 2011
@@ -6,10 +6,12 @@ import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
 
+import org.apache.continuum.builder.distributed.manager.DistributedBuildManager;
 import org.apache.continuum.model.project.ProjectScmRoot;
 import org.apache.continuum.release.distributed.manager.DistributedReleaseManager;
 import org.apache.continuum.xmlrpc.utils.BuildTrigger;
 import org.apache.maven.continuum.Continuum;
+import org.apache.maven.continuum.ContinuumException;
 import org.apache.maven.continuum.configuration.ConfigurationService;
 import org.apache.maven.continuum.model.project.Project;
 import org.apache.maven.continuum.model.project.ProjectGroup;
@@ -36,6 +38,8 @@ public class ContinuumServiceImplTest
     private DistributedReleaseManager distributedReleaseManager;
 
     private ContinuumReleaseManager releaseManager;
+    
+    private DistributedBuildManager distributedBuildManager;
 
     private ConfigurationService configurationService;
 
@@ -52,13 +56,15 @@ public class ContinuumServiceImplTest
         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 );
+        distributedBuildManager = context.mock( DistributedBuildManager.class );
+
+        continuumService = new ContinuumServiceImplStub();
+        continuum = context.mock( Continuum.class );
+        continuumService.setContinuum( continuum );
+        continuumService.setDistributedBuildManager( distributedBuildManager );
 
         ProjectGroup projectGroup = new ProjectGroup();
         projectGroup.setName( "test-group" );
@@ -262,6 +268,52 @@ public class ContinuumServiceImplTest
         assertEquals( 3, projectScmRoot.getOldState() );
         assertEquals( "address1", projectScmRoot.getScmRootAddress() );
     }
+    
+    public void testGetBuildAgentUrl() throws Exception
+    {
+        context.checking( new Expectations() 
+        {
+            {
+                one( continuum ).getConfiguration();
+                will( returnValue( configurationService ) );
+                
+                one( configurationService ).isDistributedBuildEnabled();
+                will( returnValue ( true ) );
+                
+                one( distributedBuildManager ).getBuildAgentUrl( 1 );
+                will( returnValue( "http://localhost:8181/continuum-buildagent/xmlrpc" )
);
+            }
+        });
+        String buildAgentUrl = continuumService.getBuildAgentUrl( 1 );
+        assertEquals( "http://localhost:8181/continuum-buildagent/xmlrpc", buildAgentUrl
);
+
+        context.assertIsSatisfied();
+    }
+    
+    public void testGetBuildAgentUrlNotSupported() throws Exception
+    {
+        context.checking( new Expectations()
+        {
+            {
+                one( continuum ).getConfiguration();
+                will( returnValue( configurationService ) );
+
+                one( configurationService ).isDistributedBuildEnabled();
+                will( returnValue( false ) );
+            }
+        } );
+
+        try 
+        {
+            String buildAgentUrl = continuumService.getBuildAgentUrl( 1 );
+            fail ( "ContinuumException is expected to occur here." ); 
+        } 
+        catch ( ContinuumException e )
+        {
+            ; //pass
+        }
+        context.assertIsSatisfied();
+    }
 
     private BuildDefinition createBuildDefinition()
     {



Mime
View raw message