continuum-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jzurb...@apache.org
Subject svn commit: r928598 - in /continuum/trunk: continuum-api/src/main/java/org/apache/continuum/release/distributed/manager/ continuum-core/src/main/java/org/apache/continuum/release/distributed/manager/ continuum-core/src/test/java/org/apache/continuum/re...
Date Mon, 29 Mar 2010 05:41:34 GMT
Author: jzurbano
Date: Mon Mar 29 05:41:34 2010
New Revision: 928598

URL: http://svn.apache.org/viewvc?rev=928598&view=rev
Log:
[CONTINUUM-2386] Build environment selection is ignored when releasing with distributed build
enabled
* added check if last used build agent in building is in group to be used for release
* added method to get the last build agent used in building
* added unit tests
* updated documentation



Added:
    continuum/trunk/continuum-core/src/test/java/org/apache/continuum/release/
    continuum/trunk/continuum-core/src/test/java/org/apache/continuum/release/distributed/
    continuum/trunk/continuum-core/src/test/java/org/apache/continuum/release/distributed/manager/
    continuum/trunk/continuum-core/src/test/java/org/apache/continuum/release/distributed/manager/DefaultDistributedReleaseManagerTest.java
  (with props)
    continuum/trunk/continuum-webapp/src/test/java/org/apache/continuum/
    continuum/trunk/continuum-webapp/src/test/java/org/apache/continuum/web/
    continuum/trunk/continuum-webapp/src/test/java/org/apache/continuum/web/action/
    continuum/trunk/continuum-webapp/src/test/java/org/apache/continuum/web/action/AbstractReleaseActionTest.java
  (with props)
    continuum/trunk/continuum-webapp/src/test/java/org/apache/continuum/web/action/stub/
    continuum/trunk/continuum-webapp/src/test/java/org/apache/continuum/web/action/stub/ReleaseActionStub.java
  (with props)
Modified:
    continuum/trunk/continuum-api/src/main/java/org/apache/continuum/release/distributed/manager/DistributedReleaseManager.java
    continuum/trunk/continuum-core/src/main/java/org/apache/continuum/release/distributed/manager/DefaultDistributedReleaseManager.java
    continuum/trunk/continuum-docs/src/site/apt/user_guides/release/prepare.apt
    continuum/trunk/continuum-webapp/src/main/java/org/apache/continuum/web/action/AbstractReleaseAction.java
    continuum/trunk/continuum-webapp/src/main/java/org/apache/maven/continuum/web/action/ReleasePerformAction.java
    continuum/trunk/continuum-webapp/src/main/java/org/apache/maven/continuum/web/action/ReleasePrepareAction.java

Modified: continuum/trunk/continuum-api/src/main/java/org/apache/continuum/release/distributed/manager/DistributedReleaseManager.java
URL: http://svn.apache.org/viewvc/continuum/trunk/continuum-api/src/main/java/org/apache/continuum/release/distributed/manager/DistributedReleaseManager.java?rev=928598&r1=928597&r2=928598&view=diff
==============================================================================
--- continuum/trunk/continuum-api/src/main/java/org/apache/continuum/release/distributed/manager/DistributedReleaseManager.java
(original)
+++ continuum/trunk/continuum-api/src/main/java/org/apache/continuum/release/distributed/manager/DistributedReleaseManager.java
Mon Mar 29 05:41:34 2010
@@ -68,4 +68,6 @@ public interface DistributedReleaseManag
 
     List<Map<String, Object>> getAllReleasesInProgress()
         throws ContinuumReleaseException, BuildAgentConfigurationException;
+    
+    String getDefaultBuildagent( int projectId );
 }
\ No newline at end of file

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=928598&r1=928597&r2=928598&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
Mon Mar 29 05:41:34 2010
@@ -90,9 +90,7 @@ public class DefaultDistributedReleaseMa
     public Map getReleasePluginParameters( int projectId, String pomFilename )
         throws ContinuumReleaseException, BuildAgentConfigurationException
     {
-        BuildResult buildResult = buildResultDao.getLatestBuildResultForProject( projectId
);
-
-        String buildAgentUrl = buildResult.getBuildUrl();
+        String buildAgentUrl = getDefaultBuildagent( projectId );
 
         if ( !checkBuildAgent( buildAgentUrl ) )
         {
@@ -159,9 +157,7 @@ public class DefaultDistributedReleaseMa
                                   Map<String, String> developmentVersion, Map<String,
String> environments, String username )
         throws ContinuumReleaseException, BuildAgentConfigurationException
     {
-        BuildResult buildResult = buildResultDao.getLatestBuildResultForProject( project.getId()
);
-
-        String buildAgentUrl = buildResult.getBuildUrl();
+        String buildAgentUrl = environments.get( DistributedReleaseUtil.KEY_BUILD_AGENT_URL
);
 
         if ( !checkBuildAgent( buildAgentUrl ) )
         {
@@ -411,9 +407,7 @@ public class DefaultDistributedReleaseMa
                                          String scmPassword, String scmTag, String scmTagBase,
Map environments, String username )
         throws ContinuumReleaseException, BuildAgentConfigurationException
     {
-        BuildResult buildResult = buildResultDao.getLatestBuildResultForProject( projectId
);
-
-        String buildAgentUrl = buildResult.getBuildUrl();
+        String buildAgentUrl = (String) environments.get( DistributedReleaseUtil.KEY_BUILD_AGENT_URL
);
 
         if ( !checkBuildAgent( buildAgentUrl ) )
         {
@@ -595,6 +589,13 @@ public class DefaultDistributedReleaseMa
 
         return releases;
     }
+    
+    public String getDefaultBuildagent( int projectId )
+    {
+        BuildResult buildResult = buildResultDao.getLatestBuildResultForProject( projectId
);
+        
+        return buildResult != null ? buildResult.getBuildUrl() : null;
+    }
 
     private Map createProjectMap( Project project )
     {
@@ -860,4 +861,11 @@ public class DefaultDistributedReleaseMa
             throw new ContinuumReleaseException( "Failed to write prepared releases in file",
e );
         }
     }
+    
+    // for unit test
+    
+    public void setBuildResultDao( BuildResultDao buildResultDao )
+    {
+        this.buildResultDao = buildResultDao;
+    }
 }
\ No newline at end of file

Added: continuum/trunk/continuum-core/src/test/java/org/apache/continuum/release/distributed/manager/DefaultDistributedReleaseManagerTest.java
URL: http://svn.apache.org/viewvc/continuum/trunk/continuum-core/src/test/java/org/apache/continuum/release/distributed/manager/DefaultDistributedReleaseManagerTest.java?rev=928598&view=auto
==============================================================================
--- continuum/trunk/continuum-core/src/test/java/org/apache/continuum/release/distributed/manager/DefaultDistributedReleaseManagerTest.java
(added)
+++ continuum/trunk/continuum-core/src/test/java/org/apache/continuum/release/distributed/manager/DefaultDistributedReleaseManagerTest.java
Mon Mar 29 05:41:34 2010
@@ -0,0 +1,102 @@
+package org.apache.continuum.release.distributed.manager;
+
+/*
+ * 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.continuum.dao.BuildResultDao;
+import org.apache.maven.continuum.model.project.BuildResult;
+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;
+
+/**
+ * DefaultDistributedReleaseManagerTest
+ */
+public class DefaultDistributedReleaseManagerTest
+    extends PlexusInSpringTestCase
+{
+    private DefaultDistributedReleaseManager distributedReleaseManager;
+
+    private BuildResultDao buildResultDao;
+    
+    private BuildResult buildResult;
+    
+    private Mockery context;
+    
+    @Override
+    protected void setUp()
+        throws Exception
+    {
+        super.setUp();
+
+        context = new JUnit3Mockery();
+        context.setImposteriser( ClassImposteriser.INSTANCE );
+        
+        distributedReleaseManager = new DefaultDistributedReleaseManager();
+        
+        buildResultDao = context.mock( BuildResultDao.class );
+        distributedReleaseManager.setBuildResultDao( buildResultDao );
+    }
+    
+    public void testGetDefaultBuildagent()
+        throws Exception
+    {
+        String defaultBuildagentUrl = "http://localhost:8181/continuum-buildagent/xmlrpc";
+        
+        buildResult = new BuildResult();
+        buildResult.setBuildUrl( defaultBuildagentUrl );
+        
+        contextBuildResultDaoExpectations();
+        
+        String returnedBuildagent = distributedReleaseManager.getDefaultBuildagent( 0 );
+        
+        assertNotNull( returnedBuildagent );
+        assertEquals( returnedBuildagent, defaultBuildagentUrl );
+
+        context.assertIsSatisfied();
+    }
+    
+    public void testGetDefaultBuildagentNullBuildResult()
+        throws Exception
+    {
+        buildResult = null;
+        
+        contextBuildResultDaoExpectations();
+        
+        String returnedBuildagent = distributedReleaseManager.getDefaultBuildagent( 0 );
+        
+        assertNull( returnedBuildagent );
+
+        context.assertIsSatisfied();
+    }
+
+    private void contextBuildResultDaoExpectations()
+        throws Exception
+    {
+        context.checking( new Expectations()
+        {
+            {
+                one( buildResultDao ).getLatestBuildResultForProject( 0 );
+                will( returnValue( buildResult )  );
+            }
+        } );
+    }
+}

Propchange: continuum/trunk/continuum-core/src/test/java/org/apache/continuum/release/distributed/manager/DefaultDistributedReleaseManagerTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: continuum/trunk/continuum-docs/src/site/apt/user_guides/release/prepare.apt
URL: http://svn.apache.org/viewvc/continuum/trunk/continuum-docs/src/site/apt/user_guides/release/prepare.apt?rev=928598&r1=928597&r2=928598&view=diff
==============================================================================
--- continuum/trunk/continuum-docs/src/site/apt/user_guides/release/prepare.apt (original)
+++ continuum/trunk/continuum-docs/src/site/apt/user_guides/release/prepare.apt Mon Mar 29
05:41:34 2010
@@ -20,6 +20,17 @@ Prepare for Release
  Check the <<Use edit mode>> checkbox if you are using an SCM system that requires
you to obtain a lock before editing.
 
  Click <<Submit>>.
+ 
+ <<Note:>> When releasing in a {{{../../administrator_guides/distributed-builds.html}
distributed builds}} setup, a <<Build environment>>
+ should be selected containing at least one enabled build agent. Furthermore, the release
will not happen in the following cases:
+ 
+   * no build environment selected
+   
+   * no build agent found in the build agent group attached to the build environment
+   
+   * all build agents configured in the selected build environment are disabled
+ 
+ []
 
 [../../images/release-prepare-parameters.png] Release Prepare parameters
 

Modified: continuum/trunk/continuum-webapp/src/main/java/org/apache/continuum/web/action/AbstractReleaseAction.java
URL: http://svn.apache.org/viewvc/continuum/trunk/continuum-webapp/src/main/java/org/apache/continuum/web/action/AbstractReleaseAction.java?rev=928598&r1=928597&r2=928598&view=diff
==============================================================================
--- continuum/trunk/continuum-webapp/src/main/java/org/apache/continuum/web/action/AbstractReleaseAction.java
(original)
+++ continuum/trunk/continuum-webapp/src/main/java/org/apache/continuum/web/action/AbstractReleaseAction.java
Mon Mar 29 05:41:34 2010
@@ -24,6 +24,9 @@ import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
 
+import org.apache.continuum.configuration.BuildAgentGroupConfiguration;
+import org.apache.continuum.configuration.BuildAgentConfiguration;
+import org.apache.continuum.release.distributed.DistributedReleaseUtil;
 import org.apache.maven.continuum.installation.InstallationService;
 import org.apache.maven.continuum.model.system.Installation;
 import org.apache.maven.continuum.model.system.Profile;
@@ -33,7 +36,7 @@ import org.codehaus.plexus.util.StringUt
 public class AbstractReleaseAction
     extends ContinuumActionSupport
 {
-    protected Map<String, String> getEnvironments( Profile profile )
+    protected Map<String, String> getEnvironments( Profile profile, String defaultBuildagent
)
     {
         if ( profile == null )
         {
@@ -41,6 +44,35 @@ public class AbstractReleaseAction
         }
 
         Map<String, String> envVars = new HashMap<String, String>();
+        
+        if ( defaultBuildagent != null && defaultBuildagent.length() > 0 )
+        {
+            // get buildagent to be used from the buildagent group for distributed builds
setup
+            BuildAgentGroupConfiguration group = getContinuum().getConfiguration().getBuildAgentGroup(
profile.getBuildAgentGroup() );
+            
+            if ( group != null )
+            {
+                List<BuildAgentConfiguration> agents = group.getBuildAgents();
+                if ( agents != null )
+                {
+                    if ( isDefaultBuildAgentEnabledInGroup( defaultBuildagent, agents ) )
+                    {
+                        envVars.put( DistributedReleaseUtil.KEY_BUILD_AGENT_URL, defaultBuildagent
);
+                    }
+                    else
+                    {
+                        for ( BuildAgentConfiguration agent : agents )
+                        {
+                            if ( agent.isEnabled() == true )
+                            {
+                                envVars.put( DistributedReleaseUtil.KEY_BUILD_AGENT_URL,
agent.getUrl() );
+                                break;
+                            }
+                        }
+                    }
+                }
+            }
+        }
 
         String javaHome = getJavaHomeValue( profile );
         if ( !StringUtils.isEmpty( javaHome ) )
@@ -61,6 +93,25 @@ public class AbstractReleaseAction
         }
         return envVars;
     }
+    
+    private boolean isDefaultBuildAgentEnabledInGroup( String defaultBuildagent, List<BuildAgentConfiguration>
agents )
+    {
+        boolean isInGroup = false;
+        
+        for ( BuildAgentConfiguration agent : agents )
+        {
+            if ( agent.isEnabled() == true )
+            {
+                if ( defaultBuildagent.equals( agent.getUrl() ) )
+                {
+                    isInGroup = true;
+                    break;
+                }
+            }
+        }
+        
+        return isInGroup;
+    }
 
     private String getJavaHomeValue( Profile profile )
     {

Modified: continuum/trunk/continuum-webapp/src/main/java/org/apache/maven/continuum/web/action/ReleasePerformAction.java
URL: http://svn.apache.org/viewvc/continuum/trunk/continuum-webapp/src/main/java/org/apache/maven/continuum/web/action/ReleasePerformAction.java?rev=928598&r1=928597&r2=928598&view=diff
==============================================================================
--- continuum/trunk/continuum-webapp/src/main/java/org/apache/maven/continuum/web/action/ReleasePerformAction.java
(original)
+++ continuum/trunk/continuum-webapp/src/main/java/org/apache/maven/continuum/web/action/ReleasePerformAction.java
Mon Mar 29 05:41:34 2010
@@ -294,7 +294,7 @@ public class ReleasePerformAction
             if ( profileId != -1 )
             {
                 Profile profile = getContinuum().getProfileService().getProfile( profileId
);
-                environments = getEnvironments( profile );
+                environments = getEnvironments( profile, releaseManager.getDefaultBuildagent(
projectId ) );
             }
 
             try
@@ -327,7 +327,7 @@ public class ReleasePerformAction
             if ( profileId != -1 )
             {
                 Profile profile = getContinuum().getProfileService().getProfile( profileId
);
-                descriptor.setEnvironments( getEnvironments( profile ) );
+                descriptor.setEnvironments( getEnvironments( profile, null ) );
             }
     
             do

Modified: continuum/trunk/continuum-webapp/src/main/java/org/apache/maven/continuum/web/action/ReleasePrepareAction.java
URL: http://svn.apache.org/viewvc/continuum/trunk/continuum-webapp/src/main/java/org/apache/maven/continuum/web/action/ReleasePrepareAction.java?rev=928598&r1=928597&r2=928598&view=diff
==============================================================================
--- continuum/trunk/continuum-webapp/src/main/java/org/apache/maven/continuum/web/action/ReleasePrepareAction.java
(original)
+++ continuum/trunk/continuum-webapp/src/main/java/org/apache/maven/continuum/web/action/ReleasePrepareAction.java
Mon Mar 29 05:41:34 2010
@@ -307,11 +307,13 @@ public class ReleasePrepareAction
         
         String username = getPrincipal();
 
-        Map<String, String> environments = getEnvironments( profile );
+        Map<String, String> environments = new HashMap<String, String>();
 
         if ( getContinuum().getConfiguration().isDistributedBuildEnabled() )
         {
             DistributedReleaseManager distributedReleaseManager = getContinuum().getDistributedReleaseManager();
+            
+            environments = getEnvironments( profile, distributedReleaseManager.getDefaultBuildagent(
projectId ) );
 
             try
             {
@@ -335,6 +337,8 @@ public class ReleasePrepareAction
         }
         else
         {
+            environments = getEnvironments( profile, null );
+            
             listener = new DefaultReleaseManagerListener();
             
             listener.setUsername( username );

Added: continuum/trunk/continuum-webapp/src/test/java/org/apache/continuum/web/action/AbstractReleaseActionTest.java
URL: http://svn.apache.org/viewvc/continuum/trunk/continuum-webapp/src/test/java/org/apache/continuum/web/action/AbstractReleaseActionTest.java?rev=928598&view=auto
==============================================================================
--- continuum/trunk/continuum-webapp/src/test/java/org/apache/continuum/web/action/AbstractReleaseActionTest.java
(added)
+++ continuum/trunk/continuum-webapp/src/test/java/org/apache/continuum/web/action/AbstractReleaseActionTest.java
Mon Mar 29 05:41:34 2010
@@ -0,0 +1,145 @@
+package org.apache.maven.continuum.web.action;
+
+/*
+ * 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 java.util.ArrayList;
+import java.util.List;
+import java.util.Map;
+
+import org.apache.continuum.configuration.BuildAgentConfiguration;
+import org.apache.continuum.configuration.BuildAgentGroupConfiguration;
+import org.apache.continuum.release.distributed.DistributedReleaseUtil;
+import org.apache.continuum.web.action.stub.ReleaseActionStub;
+import org.apache.maven.continuum.Continuum;
+import org.apache.maven.continuum.configuration.ConfigurationService;
+import org.apache.maven.continuum.model.system.Profile;
+import org.jmock.Mock;
+import org.jmock.MockObjectTestCase;
+
+public class AbstractReleaseActionTest
+    extends MockObjectTestCase
+{
+    private ReleaseActionStub action;
+
+    private Mock continuumMock;
+
+    private Mock configurationServiceMock;
+    
+    private String defaultBuildagentUrl = "http://localhost:8181/continuum-buildagent/xmlrpc";
+
+    protected void setUp()
+        throws Exception
+    {
+        continuumMock = mock( Continuum.class );
+        configurationServiceMock = mock( ConfigurationService.class );
+
+        Profile profile = new Profile();
+        profile.setBuildAgentGroup( "BUILDAGENT_GROUP" );
+        
+        action = new ReleaseActionStub();
+        action.setProfile( profile );
+        action.setDefaultBuildagent( defaultBuildagentUrl );
+        action.setContinuum( (Continuum) continuumMock.proxy() );
+    }
+    
+    public void testGetEnvironmentsDefaultAgentInGroup()
+        throws Exception
+    {
+        BuildAgentGroupConfiguration buildAgentGroup = createBuildAgentGroupConfiguration(
true );
+        buildAgentGroup.addBuildAgent( new BuildAgentConfiguration( defaultBuildagentUrl,
"Default Build Agent", true ) );
+        
+        continuumMock.expects( atLeastOnce() ).method( "getConfiguration" ).will( returnValue(
configurationServiceMock.proxy() ) );
+        configurationServiceMock.expects( atLeastOnce() ).method( "getBuildAgentGroup" ).will(
returnValue( buildAgentGroup ) );
+        
+        action.getEnvironments();
+        Map<String, String> envVars = action.getEnvironmentVariables();
+        String buildagent = envVars.get( DistributedReleaseUtil.KEY_BUILD_AGENT_URL );
+        
+        assertNotNull( envVars );
+        assertTrue( "Default build agent is expected to be used.", defaultBuildagentUrl.equals(
buildagent ) );
+    }
+    
+    public void testGetEnvironmentsDefaultAgentNotInGroup()
+        throws Exception
+    {
+        BuildAgentGroupConfiguration buildAgentGroup = createBuildAgentGroupConfiguration(
true );
+        
+        continuumMock.expects( atLeastOnce() ).method( "getConfiguration" ).will( returnValue(
configurationServiceMock.proxy() ) );
+        configurationServiceMock.expects( atLeastOnce() ).method( "getBuildAgentGroup" ).will(
returnValue( buildAgentGroup ) );
+        
+        action.getEnvironments();
+        Map<String, String> envVars = action.getEnvironmentVariables();
+        String buildagent = envVars.get( DistributedReleaseUtil.KEY_BUILD_AGENT_URL );
+        
+        assertNotNull( envVars );
+        assertFalse( "Default build agent is not expected to be used.", defaultBuildagentUrl.equals(
buildagent ) );
+    }
+    
+    public void testGetEnvironmentsNoEnabledAgentInGroup()
+        throws Exception
+    {
+        BuildAgentGroupConfiguration buildAgentGroup = createBuildAgentGroupConfiguration(
false );
+        buildAgentGroup.addBuildAgent( new BuildAgentConfiguration( defaultBuildagentUrl,
"Default Build Agent", false ) );
+        
+        continuumMock.expects( atLeastOnce() ).method( "getConfiguration" ).will( returnValue(
configurationServiceMock.proxy() ) );
+        configurationServiceMock.expects( atLeastOnce() ).method( "getBuildAgentGroup" ).will(
returnValue( buildAgentGroup ) );
+        
+        action.getEnvironments();
+        Map<String, String> envVars = action.getEnvironmentVariables();
+        String buildagent = envVars.get( DistributedReleaseUtil.KEY_BUILD_AGENT_URL );
+        
+        assertNotNull( envVars );
+        assertFalse( "Default build agent is not expected to be used.", defaultBuildagentUrl.equals(
buildagent ) );
+        assertNull( "Build agent should be empty.", buildagent );
+    }
+    
+    public void testGetEnvironmentsNoAgentInGroup()
+        throws Exception
+    {
+        BuildAgentGroupConfiguration buildAgentGroup = new BuildAgentGroupConfiguration();
+        
+        continuumMock.expects( atLeastOnce() ).method( "getConfiguration" ).will( returnValue(
configurationServiceMock.proxy() ) );
+        configurationServiceMock.expects( atLeastOnce() ).method( "getBuildAgentGroup" ).will(
returnValue( buildAgentGroup ) );
+        
+        action.getEnvironments();
+        Map<String, String> envVars = action.getEnvironmentVariables();
+        String buildagent = envVars.get( DistributedReleaseUtil.KEY_BUILD_AGENT_URL );
+        
+        assertNotNull( envVars );
+        assertFalse( "Default build agent is not expected to be used.", defaultBuildagentUrl.equals(
buildagent ) );
+        assertNull( "Build agent should be empty.", buildagent );
+    }
+    
+    private BuildAgentGroupConfiguration createBuildAgentGroupConfiguration( boolean isAgentEnabled
)
+    {
+        BuildAgentConfiguration buildagent1 = new BuildAgentConfiguration( "http://localhost:9191/continuum-buildagent/xmlrpc",
+                                                                               "Other Build
Agent", isAgentEnabled );
+        BuildAgentConfiguration buildagent2 = new BuildAgentConfiguration( "http://localhost:9292/continuum-buildagent/xmlrpc",
+                                                                               "Other Build
Agent", isAgentEnabled );
+        
+        List<BuildAgentConfiguration> buildAgents = new ArrayList<BuildAgentConfiguration>();
+        buildAgents.add( buildagent1 );
+        buildAgents.add( buildagent2 );
+        
+        BuildAgentGroupConfiguration buildAgentGroup = new BuildAgentGroupConfiguration(
"BUILDAGENT_GROUP", buildAgents );
+        
+        return buildAgentGroup;
+    }
+}

Propchange: continuum/trunk/continuum-webapp/src/test/java/org/apache/continuum/web/action/AbstractReleaseActionTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: continuum/trunk/continuum-webapp/src/test/java/org/apache/continuum/web/action/stub/ReleaseActionStub.java
URL: http://svn.apache.org/viewvc/continuum/trunk/continuum-webapp/src/test/java/org/apache/continuum/web/action/stub/ReleaseActionStub.java?rev=928598&view=auto
==============================================================================
--- continuum/trunk/continuum-webapp/src/test/java/org/apache/continuum/web/action/stub/ReleaseActionStub.java
(added)
+++ continuum/trunk/continuum-webapp/src/test/java/org/apache/continuum/web/action/stub/ReleaseActionStub.java
Mon Mar 29 05:41:34 2010
@@ -0,0 +1,61 @@
+package org.apache.continuum.web.action.stub;
+
+/*
+ * 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 java.util.HashMap;
+import java.util.Map;
+
+import org.apache.continuum.web.action.AbstractReleaseAction;
+import org.apache.maven.continuum.model.system.Profile;
+
+public class ReleaseActionStub
+    extends AbstractReleaseAction
+{
+    private Map<String, String> environmentVariables;
+    
+    private Profile profile;
+    
+    private String defaultBuildagent;
+    
+    public ReleaseActionStub()
+    {
+        this.environmentVariables = new HashMap<String, String>();
+    }
+    
+    public void getEnvironments()
+    {
+        this.environmentVariables = getEnvironments( profile, defaultBuildagent );
+    }
+    
+    public Map<String, String> getEnvironmentVariables()
+    {
+        return this.environmentVariables;
+    }
+    
+    public void setProfile( Profile profile )
+    {
+        this.profile = profile;
+    }
+    
+    public void setDefaultBuildagent( String defaultBuildagent )
+    {
+        this.defaultBuildagent = defaultBuildagent;
+    }
+}

Propchange: continuum/trunk/continuum-webapp/src/test/java/org/apache/continuum/web/action/stub/ReleaseActionStub.java
------------------------------------------------------------------------------
    svn:eol-style = native



Mime
View raw message