continuum-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From c...@apache.org
Subject svn commit: r897084 - in /continuum/branches/continuum-1.3.x/continuum-webapp/src: main/java/org/apache/maven/continuum/web/action/ test/java/org/apache/maven/continuum/web/action/ test/java/org/apache/maven/continuum/web/action/stub/
Date Fri, 08 Jan 2010 03:42:37 GMT
Author: ctan
Date: Fri Jan  8 03:41:00 2010
New Revision: 897084

URL: http://svn.apache.org/viewvc?rev=897084&view=rev
Log:
[CONTINUUM-2394] fixed build result link of project currently building in a distributed build
mode

Added:
    continuum/branches/continuum-1.3.x/continuum-webapp/src/test/java/org/apache/maven/continuum/web/action/SummaryActionTest.java
    continuum/branches/continuum-1.3.x/continuum-webapp/src/test/java/org/apache/maven/continuum/web/action/stub/SummaryActionStub.java
Modified:
    continuum/branches/continuum-1.3.x/continuum-webapp/src/main/java/org/apache/maven/continuum/web/action/BuildResultAction.java
    continuum/branches/continuum-1.3.x/continuum-webapp/src/main/java/org/apache/maven/continuum/web/action/SummaryAction.java
    continuum/branches/continuum-1.3.x/continuum-webapp/src/test/java/org/apache/maven/continuum/web/action/BuildResultActionTest.java

Modified: continuum/branches/continuum-1.3.x/continuum-webapp/src/main/java/org/apache/maven/continuum/web/action/BuildResultAction.java
URL: http://svn.apache.org/viewvc/continuum/branches/continuum-1.3.x/continuum-webapp/src/main/java/org/apache/maven/continuum/web/action/BuildResultAction.java?rev=897084&r1=897083&r2=897084&view=diff
==============================================================================
--- continuum/branches/continuum-1.3.x/continuum-webapp/src/main/java/org/apache/maven/continuum/web/action/BuildResultAction.java
(original)
+++ continuum/branches/continuum-1.3.x/continuum-webapp/src/main/java/org/apache/maven/continuum/web/action/BuildResultAction.java
Fri Jan  8 03:41:00 2010
@@ -93,7 +93,14 @@
         // check if there are surefire results to display
         project = getContinuum().getProject( getProjectId() );
 
-        buildResult = getContinuum().getBuildResult( getBuildId() );
+        try
+        {
+            buildResult = getContinuum().getBuildResult( getBuildId() );
+        }
+        catch ( ContinuumException e )
+        {
+            buildResult = null;
+        }
 
         ConfigurationService configuration = getContinuum().getConfiguration();
 

Modified: continuum/branches/continuum-1.3.x/continuum-webapp/src/main/java/org/apache/maven/continuum/web/action/SummaryAction.java
URL: http://svn.apache.org/viewvc/continuum/branches/continuum-1.3.x/continuum-webapp/src/main/java/org/apache/maven/continuum/web/action/SummaryAction.java?rev=897084&r1=897083&r2=897084&view=diff
==============================================================================
--- continuum/branches/continuum-1.3.x/continuum-webapp/src/main/java/org/apache/maven/continuum/web/action/SummaryAction.java
(original)
+++ continuum/branches/continuum-1.3.x/continuum-webapp/src/main/java/org/apache/maven/continuum/web/action/SummaryAction.java
Fri Jan  8 03:41:00 2010
@@ -29,6 +29,7 @@
 import org.apache.continuum.buildmanager.BuildManagerException;
 import org.apache.continuum.buildmanager.BuildsManager;
 import org.apache.maven.continuum.ContinuumException;
+import org.apache.maven.continuum.configuration.ConfigurationService;
 import org.apache.maven.continuum.model.project.BuildResult;
 import org.apache.maven.continuum.model.project.Project;
 import org.apache.maven.continuum.project.ContinuumProjectState;
@@ -156,6 +157,14 @@
                     model.setLastBuildDateTime( latestBuild.getEndTime() );
                     model.setLastBuildDuration( latestBuild.getDurationTime() );
                 }
+
+                ConfigurationService configuration = getContinuum().getConfiguration();
+
+                if ( configuration.isDistributedBuildEnabled() && 
+                                project.getState() == ContinuumProjectState.BUILDING )
+                {
+                    model.setLatestBuildId( 0 );
+                }
             }
 
             summary.add( model );
@@ -230,4 +239,10 @@
     {
         this.groupSummary = groupSummary;
     }
+
+    // test
+    public void setParallelBuildsManager( BuildsManager parallelBuildsManager )
+    {
+        this.parallelBuildsManager = parallelBuildsManager;
+    }
 }

Modified: continuum/branches/continuum-1.3.x/continuum-webapp/src/test/java/org/apache/maven/continuum/web/action/BuildResultActionTest.java
URL: http://svn.apache.org/viewvc/continuum/branches/continuum-1.3.x/continuum-webapp/src/test/java/org/apache/maven/continuum/web/action/BuildResultActionTest.java?rev=897084&r1=897083&r2=897084&view=diff
==============================================================================
--- continuum/branches/continuum-1.3.x/continuum-webapp/src/test/java/org/apache/maven/continuum/web/action/BuildResultActionTest.java
(original)
+++ continuum/branches/continuum-1.3.x/continuum-webapp/src/test/java/org/apache/maven/continuum/web/action/BuildResultActionTest.java
Fri Jan  8 03:41:00 2010
@@ -57,6 +57,7 @@
         buildsManager.expects( once() ).method( "getCurrentBuilds" ).will( returnValue( new
HashMap<String, BuildProjectTask>() ) );
 
         action.execute();
+        continuum.verify();
     }
 
     public void testViewCurrentBuildInDistributedBuildAgent()
@@ -71,6 +72,7 @@
         distributedBuildManager.expects( once() ).method( "getBuildResult" ).will( returnValue(
new HashMap<String, Object>() ) );
 
         action.execute();
+        continuum.verify();
     }
 
     private Project createProject( String name )

Added: continuum/branches/continuum-1.3.x/continuum-webapp/src/test/java/org/apache/maven/continuum/web/action/SummaryActionTest.java
URL: http://svn.apache.org/viewvc/continuum/branches/continuum-1.3.x/continuum-webapp/src/test/java/org/apache/maven/continuum/web/action/SummaryActionTest.java?rev=897084&view=auto
==============================================================================
--- continuum/branches/continuum-1.3.x/continuum-webapp/src/test/java/org/apache/maven/continuum/web/action/SummaryActionTest.java
(added)
+++ continuum/branches/continuum-1.3.x/continuum-webapp/src/test/java/org/apache/maven/continuum/web/action/SummaryActionTest.java
Fri Jan  8 03:41:00 2010
@@ -0,0 +1,172 @@
+package org.apache.maven.continuum.web.action;
+
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import org.apache.continuum.buildmanager.BuildsManager;
+import org.apache.maven.continuum.Continuum;
+import org.apache.maven.continuum.configuration.ConfigurationService;
+import org.apache.maven.continuum.model.project.BuildResult;
+import org.apache.maven.continuum.model.project.Project;
+import org.apache.maven.continuum.model.project.ProjectGroup;
+import org.apache.maven.continuum.web.action.stub.SummaryActionStub;
+import org.apache.maven.continuum.web.model.ProjectSummary;
+import org.apache.maven.continuum.xmlrpc.project.ContinuumProjectState;
+import org.jmock.Mock;
+import org.jmock.MockObjectTestCase;
+
+public class SummaryActionTest
+    extends MockObjectTestCase
+{
+    private SummaryActionStub action;
+
+    private Mock continuum;
+
+    private Mock configurationService;
+
+    private Mock buildsManager;
+
+    protected void setUp()
+    {
+        action = new SummaryActionStub();
+
+        continuum = mock( Continuum.class );
+
+        configurationService = mock( ConfigurationService.class );
+
+        buildsManager = mock( BuildsManager.class );
+
+        action.setContinuum( (Continuum) continuum.proxy() );
+        action.setParallelBuildsManager( (BuildsManager ) buildsManager.proxy() );
+    }
+
+    public void testLatestBuildIdWhenCurrentlyBuildingInDistributedBuild()
+        throws Exception
+    {
+        Collection<Project> projectsInGroup = createProjectsInGroup( 1, ContinuumProjectState.BUILDING
);
+        Map<Integer, BuildResult> buildResults = createBuildResults( 0, ContinuumProjectState.OK
);
+        Map<Integer, BuildResult> buildResultsInSuccess = new HashMap<Integer, BuildResult>();
+
+        continuum.expects( once() ).method( "getProjectsInGroup" ).will( returnValue( projectsInGroup
) );
+        continuum.expects( once() ).method( "getLatestBuildResults" ).will( returnValue(
buildResults ) );
+        continuum.expects( once() ).method( "getBuildResultsInSuccess" ).will( returnValue(
buildResultsInSuccess ) );
+
+        buildsManager.expects( once() ).method( "isInAnyBuildQueue" ).will( returnValue(
false ) );
+        buildsManager.expects( once() ).method( "isInPrepareBuildQueue").will( returnValue(
false ) );
+        buildsManager.expects( once() ).method( "isInAnyCheckoutQueue" ).will( returnValue(
false ) );
+
+        continuum.expects( once() ).method( "getConfiguration" ).will( returnValue( (ConfigurationService)
configurationService.proxy()  ) );
+        configurationService.expects( once() ).method( "isDistributedBuildEnabled" ).will(
returnValue( true ) );
+
+        action.execute();
+        continuum.verify();
+
+        List<ProjectSummary> projects = action.getProjects();
+
+        assertNotNull( projects );
+        assertEquals( 1, projects.size() );
+
+        ProjectSummary summary = projects.get( 0 );
+        assertEquals( 0, summary.getLatestBuildId() );
+    }
+
+    public void testLatestBuildIdInDistributedBuild()
+        throws Exception
+    {
+        Collection<Project> projectsInGroup = createProjectsInGroup( 1, ContinuumProjectState.OK
);
+        Map<Integer, BuildResult> buildResults = createBuildResults( 1, ContinuumProjectState.OK
);
+        Map<Integer, BuildResult> buildResultsInSuccess = new HashMap<Integer, BuildResult>();
+
+        continuum.expects( once() ).method( "getProjectsInGroup" ).will( returnValue( projectsInGroup
) );
+        continuum.expects( once() ).method( "getLatestBuildResults" ).will( returnValue(
buildResults ) );
+        continuum.expects( once() ).method( "getBuildResultsInSuccess" ).will( returnValue(
buildResultsInSuccess ) );
+
+        buildsManager.expects( once() ).method( "isInAnyBuildQueue" ).will( returnValue(
false ) );
+        buildsManager.expects( once() ).method( "isInPrepareBuildQueue").will( returnValue(
false ) );
+        buildsManager.expects( once() ).method( "isInAnyCheckoutQueue" ).will( returnValue(
false ) );
+
+        continuum.expects( once() ).method( "getConfiguration" ).will( returnValue( (ConfigurationService)
configurationService.proxy()  ) );
+        configurationService.expects( once() ).method( "isDistributedBuildEnabled" ).will(
returnValue( true ) );
+
+        action.execute();
+        continuum.verify();
+
+        List<ProjectSummary> projects = action.getProjects();
+
+        assertNotNull( projects );
+        assertEquals( 1, projects.size() );
+
+        ProjectSummary summary = projects.get( 0 );
+        assertEquals( 1, summary.getLatestBuildId() );
+    }
+
+    public void testLatestBuildIdWhenCurrentlyBuilding()
+        throws Exception
+    {
+        Collection<Project> projectsInGroup = createProjectsInGroup( 1, ContinuumProjectState.BUILDING
);
+        Map<Integer, BuildResult> buildResults = createBuildResults( 1, ContinuumProjectState.BUILDING
);
+        Map<Integer, BuildResult> buildResultsInSuccess = new HashMap<Integer, BuildResult>();
+
+        continuum.expects( once() ).method( "getProjectsInGroup" ).will( returnValue( projectsInGroup
) );
+        continuum.expects( once() ).method( "getLatestBuildResults" ).will( returnValue(
buildResults ) );
+        continuum.expects( once() ).method( "getBuildResultsInSuccess" ).will( returnValue(
buildResultsInSuccess ) );
+
+        buildsManager.expects( once() ).method( "isInAnyBuildQueue" ).will( returnValue(
false ) );
+        buildsManager.expects( once() ).method( "isInPrepareBuildQueue").will( returnValue(
false ) );
+        buildsManager.expects( once() ).method( "isInAnyCheckoutQueue" ).will( returnValue(
false ) );
+
+        continuum.expects( once() ).method( "getConfiguration" ).will( returnValue( (ConfigurationService)
configurationService.proxy()  ) );
+        configurationService.expects( once() ).method( "isDistributedBuildEnabled" ).will(
returnValue( false ) );
+
+        action.execute();
+        continuum.verify();
+
+        List<ProjectSummary> projects = action.getProjects();
+
+        assertNotNull( projects );
+        assertEquals( 1, projects.size() );
+
+        ProjectSummary summary = projects.get( 0 );
+        assertEquals( 1, summary.getLatestBuildId() );
+    }
+
+    private Collection<Project> createProjectsInGroup( int projectId, int state )
+    {
+        Collection<Project> projectsInGroup = new ArrayList<Project>(); 
+        
+        ProjectGroup group = new ProjectGroup();
+        group.setId( 1 );
+        group.setName( "test-group" );
+
+        Project project = new Project();
+        project.setId( projectId );
+        project.setName( "test-project" );
+        project.setVersion( "1.0" );
+        project.setBuildNumber( 1 );
+        project.setState( state );
+        project.setExecutorId( "maven2" );
+        project.setProjectGroup( group );
+
+        projectsInGroup.add( project );
+
+        return projectsInGroup;
+    }
+
+    private Map<Integer, BuildResult> createBuildResults( int projectId, int state
)
+    {
+        Map<Integer, BuildResult> buildResults = new HashMap<Integer, BuildResult>();
+
+        BuildResult br = new BuildResult();
+        br.setId( 1 );
+        br.setStartTime( System.currentTimeMillis() );
+        br.setEndTime( System.currentTimeMillis() );
+        br.setState( state );
+        
+        buildResults.put( projectId, br );
+
+        return buildResults;
+    }
+}

Added: continuum/branches/continuum-1.3.x/continuum-webapp/src/test/java/org/apache/maven/continuum/web/action/stub/SummaryActionStub.java
URL: http://svn.apache.org/viewvc/continuum/branches/continuum-1.3.x/continuum-webapp/src/test/java/org/apache/maven/continuum/web/action/stub/SummaryActionStub.java?rev=897084&view=auto
==============================================================================
--- continuum/branches/continuum-1.3.x/continuum-webapp/src/test/java/org/apache/maven/continuum/web/action/stub/SummaryActionStub.java
(added)
+++ continuum/branches/continuum-1.3.x/continuum-webapp/src/test/java/org/apache/maven/continuum/web/action/stub/SummaryActionStub.java
Fri Jan  8 03:41:00 2010
@@ -0,0 +1,17 @@
+package org.apache.maven.continuum.web.action.stub;
+
+import org.apache.maven.continuum.web.action.SummaryAction;
+
+public class SummaryActionStub
+    extends SummaryAction
+{
+    public String getProjectGroupName()
+    {
+        return "test-group";
+    }
+    
+    protected void checkViewProjectGroupAuthorization( String resource )
+    {
+        // skip authorization check
+    }
+}



Mime
View raw message