continuum-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From och...@apache.org
Subject svn commit: r769671 [2/2] - in /continuum/branches/continuum-flat-multi-module: continuum-api/src/main/java/org/apache/continuum/buildmanager/ continuum-api/src/main/java/org/apache/continuum/taskqueue/ continuum-api/src/main/java/org/apache/maven/cont...
Date Wed, 29 Apr 2009 06:08:22 GMT
Modified: continuum/branches/continuum-flat-multi-module/continuum-core/src/test/java/org/apache/maven/continuum/core/action/CreateProjectsFromMetadataTest.java
URL: http://svn.apache.org/viewvc/continuum/branches/continuum-flat-multi-module/continuum-core/src/test/java/org/apache/maven/continuum/core/action/CreateProjectsFromMetadataTest.java?rev=769671&r1=769670&r2=769671&view=diff
==============================================================================
--- continuum/branches/continuum-flat-multi-module/continuum-core/src/test/java/org/apache/maven/continuum/core/action/CreateProjectsFromMetadataTest.java
(original)
+++ continuum/branches/continuum-flat-multi-module/continuum-core/src/test/java/org/apache/maven/continuum/core/action/CreateProjectsFromMetadataTest.java
Wed Apr 29 06:08:15 2009
@@ -25,6 +25,7 @@
 import org.apache.maven.continuum.execution.ContinuumBuildExecutorConstants;
 import org.apache.maven.continuum.model.project.BuildDefinition;
 import org.apache.maven.continuum.model.project.BuildDefinitionTemplate;
+import org.apache.maven.continuum.model.project.Project;
 import org.apache.maven.continuum.project.builder.ContinuumProjectBuilder;
 import org.apache.maven.continuum.project.builder.ContinuumProjectBuildingResult;
 import org.apache.maven.continuum.project.builder.manager.ContinuumProjectBuilderManager;
@@ -33,37 +34,52 @@
 import org.apache.maven.settings.Settings;
 import org.codehaus.plexus.logging.Logger;
 import org.codehaus.plexus.logging.console.ConsoleLogger;
+import org.codehaus.plexus.spring.PlexusInSpringTestCase;
 import org.jmock.Mock;
 import org.jmock.MockObjectTestCase;
 
 public class CreateProjectsFromMetadataTest
     extends MockObjectTestCase
 {
-
     private CreateProjectsFromMetadataAction action;
+    
+    private ContinuumProjectBuildingResult result;
 
     protected void setUp()
         throws Exception
     {
         action = new CreateProjectsFromMetadataAction();
         action.enableLogging( new ConsoleLogger( Logger.LEVEL_DEBUG, "" ) );
+        
+        recordBuildProjectFromHttp();
+    }
+
+    private void recordBuildProjectFromHttp()
+        throws Exception
+    {
+        result = new ContinuumProjectBuildingResult();
+        
         Mock projectBuilderManagerMock = mock( ContinuumProjectBuilderManager.class );
-        Mock mavenSettingsBuilderMock = mock( MavenSettingsBuilder.class );
+        
         action.setProjectBuilderManager( (ContinuumProjectBuilderManager) projectBuilderManagerMock.proxy()
);
-        action.setMavenSettingsBuilder( (MavenSettingsBuilder) mavenSettingsBuilderMock.proxy()
);
+        
         action.setUrlValidator( new ContinuumUrlValidator() );
         Mock projectBuilder = mock( ContinuumProjectBuilder.class );
 
         projectBuilderManagerMock.expects( once() ).method( "getProjectBuilder" ).will(
             returnValue( projectBuilder.proxy() ) );
         projectBuilder.expects( once() ).method( "buildProjectsFromMetadata" ).will(
-            returnValue( new ContinuumProjectBuildingResult() ) );
+            returnValue( result ) );
 
         projectBuilder.expects( once() ).method( "getDefaultBuildDefinitionTemplate" ).will(
             returnValue( getDefaultBuildDefinitionTemplate() ) );
+    }
 
+    private void invokeBuildSettings()
+    {
+        Mock mavenSettingsBuilderMock = mock( MavenSettingsBuilder.class );
+        action.setMavenSettingsBuilder( (MavenSettingsBuilder) mavenSettingsBuilderMock.proxy()
);
         mavenSettingsBuilderMock.expects( once() ).method( "buildSettings" ).will( returnValue(
new Settings() ) );
-
     }
 
     private BuildDefinitionTemplate getDefaultBuildDefinitionTemplate()
@@ -90,11 +106,14 @@
     public void testExecuteWithNonRecursiveMode()
         throws Exception
     {
+        invokeBuildSettings();
+        
         Map<String, Object> context = new HashMap<String, Object>();
-        context.put( CreateProjectsFromMetadataAction.KEY_URL,
+        context.put( AbstractContinuumAction.KEY_URL,
                      "http://svn.apache.org/repos/asf/maven/continuum/trunk/pom.xml" );
         context.put( CreateProjectsFromMetadataAction.KEY_PROJECT_BUILDER_ID, "id" );
         context.put( CreateProjectsFromMetadataAction.KEY_LOAD_RECURSIVE_PROJECTS, true );
+        context.put( CreateProjectsFromMetadataAction.KEY_CHECKOUT_PROJECTS_IN_SINGLE_DIRECTORY,
false );
 
         action.execute( context );
 
@@ -109,12 +128,15 @@
 
     public void testExecuteWithRecursiveMode()
         throws Exception
-    {
+    {        
+        invokeBuildSettings();
+        
         Map<String, Object> context = new HashMap<String, Object>();
-        context.put( CreateProjectsFromMetadataAction.KEY_URL,
+        context.put( AbstractContinuumAction.KEY_URL,
                      "http://svn.apache.org/repos/asf/maven/archiva/trunk/pom.xml" );
         context.put( CreateProjectsFromMetadataAction.KEY_PROJECT_BUILDER_ID, "id" );
         context.put( CreateProjectsFromMetadataAction.KEY_LOAD_RECURSIVE_PROJECTS, false
);
+        context.put( CreateProjectsFromMetadataAction.KEY_CHECKOUT_PROJECTS_IN_SINGLE_DIRECTORY,
false );
 
         action.execute( context );
 
@@ -126,5 +148,59 @@
             "Should not have errors but had " + result.getErrorsAsString() + " (this test
requires internet access)",
             result.hasErrors() );
     }
+    
+    // TODO: deng --> should this work with non-recursive mode?    
+    public void testExecuteWithCheckoutProjectsInSingleDirectory()
+        throws Exception
+    {   
+        Project project = new Project();
+        project.setGroupId( "org.apache.continuum" );
+        project.setArtifactId( "parent-project" );
+        project.setVersion( "1.0-SNAPSHOT" );
+        project.setId( 6 );
+        project.setName( "parent-project" );
+        project.setScmUrl( "scm:local:src/test-projects:flat-multi-module/parent-project"
);
+        
+        this.result.addProject( project );
+        
+        project = new Project();
+        project.setGroupId( "org.apache.continuum" );
+        project.setArtifactId( "module-a" );
+        project.setVersion( "1.0-SNAPSHOT" );
+        project.setId( 7 );
+        project.setName( "module-a" );
+        project.setScmUrl( "scm:local:src/test-projects:flat-multi-module/module-a" );
+        
+        this.result.addProject( project );
+        
+        project = new Project();
+        project.setGroupId( "org.apache.continuum" );
+        project.setArtifactId( "module-b" );
+        project.setVersion( "1.0-SNAPSHOT" );
+        project.setId( 8 );
+        project.setName( "module-b" );
+        project.setScmUrl( "scm:local:src/test-projects:flat-multi-module/module-b" );
+        
+        this.result.addProject( project );
+                        
+        // assert using scm url set in root!
+        Map<String, Object> context = new HashMap<String, Object>();
+        context.put( AbstractContinuumAction.KEY_URL,
+                     "file://" + PlexusInSpringTestCase.getBasedir() + "/src/test-projects/flat-multi-module/parent-project/pom.xml"
);
+        context.put( CreateProjectsFromMetadataAction.KEY_PROJECT_BUILDER_ID, "id" );
+        context.put( CreateProjectsFromMetadataAction.KEY_LOAD_RECURSIVE_PROJECTS, true );
+        context.put( CreateProjectsFromMetadataAction.KEY_CHECKOUT_PROJECTS_IN_SINGLE_DIRECTORY,
true );
 
+        action.execute( context );
+
+        ContinuumProjectBuildingResult result =
+            (ContinuumProjectBuildingResult) context.get( CreateProjectsFromMetadataAction.KEY_PROJECT_BUILDING_RESULT
)
+            ;
+
+        assertFalse(
+            "Should not have errors but had " + result.getErrorsAsString() + " (this test
requires internet access)",
+            result.hasErrors() );
+        assertEquals( "Incorrect SCM Root Url for flat multi-module project.",
+                      "scm:local:src/test-projects:flat-multi-module/", context.get( AbstractContinuumAction.KEY_URL
) );
+    }
 }

Modified: continuum/branches/continuum-flat-multi-module/continuum-core/src/test/java/org/apache/maven/continuum/project/builder/AbstractContinuumProjectBuilderTest.java
URL: http://svn.apache.org/viewvc/continuum/branches/continuum-flat-multi-module/continuum-core/src/test/java/org/apache/maven/continuum/project/builder/AbstractContinuumProjectBuilderTest.java?rev=769671&r1=769670&r2=769671&view=diff
==============================================================================
--- continuum/branches/continuum-flat-multi-module/continuum-core/src/test/java/org/apache/maven/continuum/project/builder/AbstractContinuumProjectBuilderTest.java
(original)
+++ continuum/branches/continuum-flat-multi-module/continuum-core/src/test/java/org/apache/maven/continuum/project/builder/AbstractContinuumProjectBuilderTest.java
Wed Apr 29 06:08:15 2009
@@ -69,7 +69,7 @@
         }
 
         public ContinuumProjectBuildingResult buildProjectsFromMetadata( URL url, String
username, String password,
-                                                                         boolean recursiveProjects
)
+                                                                         boolean recursiveProjects,
boolean checkoutInSingleDirectory )
             throws ContinuumProjectBuilderException
         {
             return null;
@@ -77,7 +77,7 @@
 
         public ContinuumProjectBuildingResult buildProjectsFromMetadata( URL url, String
username, String password,
                                                                          boolean recursiveProjects,
-                                                                         BuildDefinitionTemplate
buildDefinitionTemplate )
+                                                                         BuildDefinitionTemplate
buildDefinitionTemplate, boolean checkoutInSingleDirectory )
             throws ContinuumProjectBuilderException
         {
             return null;

Modified: continuum/branches/continuum-flat-multi-module/continuum-core/src/test/java/org/apache/maven/continuum/project/builder/maven/MavenOneContinuumProjectBuilderTest.java
URL: http://svn.apache.org/viewvc/continuum/branches/continuum-flat-multi-module/continuum-core/src/test/java/org/apache/maven/continuum/project/builder/maven/MavenOneContinuumProjectBuilderTest.java?rev=769671&r1=769670&r2=769671&view=diff
==============================================================================
--- continuum/branches/continuum-flat-multi-module/continuum-core/src/test/java/org/apache/maven/continuum/project/builder/maven/MavenOneContinuumProjectBuilderTest.java
(original)
+++ continuum/branches/continuum-flat-multi-module/continuum-core/src/test/java/org/apache/maven/continuum/project/builder/maven/MavenOneContinuumProjectBuilderTest.java
Wed Apr 29 06:08:15 2009
@@ -63,7 +63,7 @@
         bdt = service.addBuildDefinitionInTemplate( bdt, bd, false );
 
         ContinuumProjectBuildingResult result = projectBuilder.buildProjectsFromMetadata(
-            getTestFile( "src/test/resources/projects/maven-1.pom.xml" ).toURL(), null, null,
false, bdt );
+            getTestFile( "src/test/resources/projects/maven-1.pom.xml" ).toURL(), null, null,
false, bdt, false );
 
         assertOnResult( result );
 
@@ -79,7 +79,7 @@
 
         ContinuumProjectBuildingResult result = projectBuilder.buildProjectsFromMetadata(
             getTestFile( "src/test/resources/projects/maven-1.pom.xml" ).toURL(), null, null,
false,
-            service.getDefaultMavenOneBuildDefinitionTemplate() );
+            service.getDefaultMavenOneBuildDefinitionTemplate(), false );
 
         assertOnResult( result );
 

Modified: continuum/branches/continuum-flat-multi-module/continuum-core/src/test/java/org/apache/maven/continuum/project/builder/maven/MavenTwoContinuumProjectBuilderTest.java
URL: http://svn.apache.org/viewvc/continuum/branches/continuum-flat-multi-module/continuum-core/src/test/java/org/apache/maven/continuum/project/builder/maven/MavenTwoContinuumProjectBuilderTest.java?rev=769671&r1=769670&r2=769671&view=diff
==============================================================================
--- continuum/branches/continuum-flat-multi-module/continuum-core/src/test/java/org/apache/maven/continuum/project/builder/maven/MavenTwoContinuumProjectBuilderTest.java
(original)
+++ continuum/branches/continuum-flat-multi-module/continuum-core/src/test/java/org/apache/maven/continuum/project/builder/maven/MavenTwoContinuumProjectBuilderTest.java
Wed Apr 29 06:08:15 2009
@@ -21,6 +21,7 @@
 
 import java.io.File;
 import java.net.URL;
+import java.util.ArrayList;
 import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
@@ -36,6 +37,7 @@
 import org.apache.maven.continuum.model.project.ProjectNotifier;
 import org.apache.maven.continuum.project.builder.ContinuumProjectBuilder;
 import org.apache.maven.continuum.project.builder.ContinuumProjectBuildingResult;
+import org.codehaus.plexus.spring.PlexusInSpringTestCase;
 import org.codehaus.plexus.util.StringUtils;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
@@ -359,7 +361,7 @@
 
         ContinuumProjectBuildingResult result;
 
-        result = projectBuilder.buildProjectsFromMetadata( url, null, null, false, bdt );
+        result = projectBuilder.buildProjectsFromMetadata( url, null, null, false, bdt, false
);
         assertFalse( result.hasErrors() );
 
         assertEquals( 5, service.getAllBuildDefinitionTemplate().size() );
@@ -390,7 +392,43 @@
 
         assertEquals( 0, projectGroup.getProjects().size() );
     }
+    
+    public void testCreateProjectWithFlatStructure()
+        throws Exception
+    {
+        ContinuumProjectBuilder projectBuilder =
+            (ContinuumProjectBuilder) lookup( ContinuumProjectBuilder.ROLE, MavenTwoContinuumProjectBuilder.ID
);
 
+        URL url =
+            new URL( "file://" + PlexusInSpringTestCase.getBasedir() +
+                "/src/test-projects/flat-multi-module/parent-project/pom.xml" );
+
+        ContinuumProjectBuildingResult result = projectBuilder.buildProjectsFromMetadata(
url, null, null, true, true );
+        
+        Project rootProject = result.getRootProject();
+        assertEquals( "Incorrect root project", "parent-project", rootProject.getArtifactId()
);
+        
+        List<Project> projects = result.getProjects();
+        for( Project project : projects )
+        {
+            if( project.getName().equals( "parent-project" ) )
+            {
+                assertEquals( "Incorrect scm url for parent-project",
+                              "scm:local:src/test-projects:flat-multi-module/parent-project",
project.getScmUrl() );
+            }
+            else if( project.getName().equals( "module-a" ) )
+            {
+                assertEquals( "Incorrect scm url for parent-project",
+                              "scm:local:src/test-projects:flat-multi-module/module-a", project.getScmUrl()
);
+            }
+            else
+            {
+                assertEquals( "Incorrect scm url for parent-project",
+                              "scm:local:src/test-projects:flat-multi-module/module-b", project.getScmUrl()
);
+            }   
+        }
+    }
+    
     private void assertDependency( String dep, String proj, Map<String, Project> projects
)
     {
         Project p = projects.get( proj );

Modified: continuum/branches/continuum-flat-multi-module/continuum-webapp/src/main/java/org/apache/maven/continuum/web/action/AddMavenTwoProjectAction.java
URL: http://svn.apache.org/viewvc/continuum/branches/continuum-flat-multi-module/continuum-webapp/src/main/java/org/apache/maven/continuum/web/action/AddMavenTwoProjectAction.java?rev=769671&r1=769670&r2=769671&view=diff
==============================================================================
--- continuum/branches/continuum-flat-multi-module/continuum-webapp/src/main/java/org/apache/maven/continuum/web/action/AddMavenTwoProjectAction.java
(original)
+++ continuum/branches/continuum-flat-multi-module/continuum-webapp/src/main/java/org/apache/maven/continuum/web/action/AddMavenTwoProjectAction.java
Wed Apr 29 06:08:15 2009
@@ -28,7 +28,6 @@
 import org.apache.continuum.web.util.AuditLog;
 import org.apache.continuum.web.util.AuditLogConstants;
 import org.apache.maven.continuum.ContinuumException;
-import org.apache.maven.continuum.builddefinition.BuildDefinitionServiceException;
 import org.apache.maven.continuum.project.builder.ContinuumProjectBuildingResult;
 import org.apache.maven.model.Model;
 import org.apache.maven.model.io.xpp3.MavenXpp3Reader;
@@ -54,6 +53,8 @@
     public static final String FILE_SCHEME = "file:/";
 
     private boolean nonRecursiveProject;
+    
+    private boolean checkoutInSingleDirectory;
 
     protected ContinuumProjectBuildingResult doExecute( String pomUrl, int selectedProjectGroup,
boolean checkProtocol,
                                                         boolean scmUseCache )
@@ -109,7 +110,7 @@
         {
             result = getContinuum().addMavenTwoProject( pomUrl, selectedProjectGroup, checkProtocol,
scmUseCache,
                                                         !this.isNonRecursiveProject(),
-                                                        this.getBuildDefinitionTemplateId()
);
+                                                        this.getBuildDefinitionTemplateId(),
this.isCheckoutInSingleDirectory() );
         }
         
         String projectUrl = hidePasswordInUrl( pomUrl );
@@ -163,6 +164,16 @@
     {
         this.nonRecursiveProject = nonRecursiveProject;
     }
+
+    public boolean isCheckoutInSingleDirectory()
+    {
+        return checkoutInSingleDirectory;
+    }
+
+    public void setCheckoutInSingleDirectory( boolean checkoutInSingleDirectory )
+    {
+        this.checkoutInSingleDirectory = checkoutInSingleDirectory;
+    }
     
     private String hidePasswordInUrl( String pomUrl )
     {

Modified: continuum/branches/continuum-flat-multi-module/continuum-webapp/src/main/resources/localization/Continuum.properties
URL: http://svn.apache.org/viewvc/continuum/branches/continuum-flat-multi-module/continuum-webapp/src/main/resources/localization/Continuum.properties?rev=769671&r1=769670&r2=769671&view=diff
==============================================================================
--- continuum/branches/continuum-flat-multi-module/continuum-webapp/src/main/resources/localization/Continuum.properties
(original)
+++ continuum/branches/continuum-flat-multi-module/continuum-webapp/src/main/resources/localization/Continuum.properties
Wed Apr 29 06:08:15 2009
@@ -330,6 +330,7 @@
 add.m2.project.nonRecursiveProject = For multi-module project, load only root as recursive
build
 add.m2.project.buildDefinitionTemplate = Build Definition Template
 add.m2.project.defaultBuildDefinition = Default
+add.m2.project.checkoutInSingleDirectory = Checkout multi-module project in single directory
 
 # ----------------------------------------------------------------------
 # Page: AddProject (ant or shell)

Modified: continuum/branches/continuum-flat-multi-module/continuum-webapp/src/main/webapp/WEB-INF/jsp/addMavenTwoProject.jsp
URL: http://svn.apache.org/viewvc/continuum/branches/continuum-flat-multi-module/continuum-webapp/src/main/webapp/WEB-INF/jsp/addMavenTwoProject.jsp?rev=769671&r1=769670&r2=769671&view=diff
==============================================================================
--- continuum/branches/continuum-flat-multi-module/continuum-webapp/src/main/webapp/WEB-INF/jsp/addMavenTwoProject.jsp
(original)
+++ continuum/branches/continuum-flat-multi-module/continuum-webapp/src/main/webapp/WEB-INF/jsp/addMavenTwoProject.jsp
Wed Apr 29 06:08:15 2009
@@ -82,6 +82,7 @@
                             </c:otherwise>
                             </c:choose>
                             <s:checkbox label="%{getText('add.m2.project.nonRecursiveProject')}"
name="nonRecursiveProject" />
+                            <s:checkbox label="%{getText('add.m2.project.checkoutInSingleDirectory')}"
name="checkoutInSingleDirectory" />
                             <s:select label="%{getText('add.m2.project.buildDefinitionTemplate')}"
name="buildDefinitionTemplateId"
                                        list="buildDefinitionTemplates" listKey="id" listValue="name"
headerKey="-1" 
                                        headerValue="%{getText('add.m2.project.defaultBuildDefinition')}"/>




Mime
View raw message