continuum-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From c...@apache.org
Subject svn commit: r802678 - in /continuum/branches/continuum-1.3.x/continuum-core/src: test-projects/multi-module/ test-projects/multi-module/module-A/ test-projects/multi-module/module-A/src/ test-projects/multi-module/module-A/src/main/ test-projects/multi...
Date Mon, 10 Aug 2009 07:43:32 GMT
Author: ctan
Date: Mon Aug 10 07:43:31 2009
New Revision: 802678

URL: http://svn.apache.org/viewvc?rev=802678&view=rev
Log:
added unit test for PrepareBuildProjectsTaskExecutor

Added:
    continuum/branches/continuum-1.3.x/continuum-core/src/test-projects/multi-module/
    continuum/branches/continuum-1.3.x/continuum-core/src/test-projects/multi-module/module-A/
    continuum/branches/continuum-1.3.x/continuum-core/src/test-projects/multi-module/module-A/pom.xml
    continuum/branches/continuum-1.3.x/continuum-core/src/test-projects/multi-module/module-A/src/
    continuum/branches/continuum-1.3.x/continuum-core/src/test-projects/multi-module/module-A/src/main/
    continuum/branches/continuum-1.3.x/continuum-core/src/test-projects/multi-module/module-A/src/main/java/
    continuum/branches/continuum-1.3.x/continuum-core/src/test-projects/multi-module/module-A/src/main/java/org/
    continuum/branches/continuum-1.3.x/continuum-core/src/test-projects/multi-module/module-A/src/main/java/org/apache/
    continuum/branches/continuum-1.3.x/continuum-core/src/test-projects/multi-module/module-A/src/main/java/org/apache/continuum/
    continuum/branches/continuum-1.3.x/continuum-core/src/test-projects/multi-module/module-A/src/main/java/org/apache/continuum/module/
    continuum/branches/continuum-1.3.x/continuum-core/src/test-projects/multi-module/module-A/src/main/java/org/apache/continuum/module/a/
    continuum/branches/continuum-1.3.x/continuum-core/src/test-projects/multi-module/module-A/src/main/java/org/apache/continuum/module/a/App.java
    continuum/branches/continuum-1.3.x/continuum-core/src/test-projects/multi-module/module-A/test/
    continuum/branches/continuum-1.3.x/continuum-core/src/test-projects/multi-module/module-A/test/java/
    continuum/branches/continuum-1.3.x/continuum-core/src/test-projects/multi-module/module-A/test/java/org/
    continuum/branches/continuum-1.3.x/continuum-core/src/test-projects/multi-module/module-A/test/java/org/apache/
    continuum/branches/continuum-1.3.x/continuum-core/src/test-projects/multi-module/module-A/test/java/org/apache/continuum/
    continuum/branches/continuum-1.3.x/continuum-core/src/test-projects/multi-module/module-A/test/java/org/apache/continuum/module/
    continuum/branches/continuum-1.3.x/continuum-core/src/test-projects/multi-module/module-A/test/java/org/apache/continuum/module/a/
    continuum/branches/continuum-1.3.x/continuum-core/src/test-projects/multi-module/module-A/test/java/org/apache/continuum/module/a/AppTest.java
    continuum/branches/continuum-1.3.x/continuum-core/src/test-projects/multi-module/module-B/
    continuum/branches/continuum-1.3.x/continuum-core/src/test-projects/multi-module/module-B/pom.xml
    continuum/branches/continuum-1.3.x/continuum-core/src/test-projects/multi-module/module-B/src/
    continuum/branches/continuum-1.3.x/continuum-core/src/test-projects/multi-module/module-B/src/main/
    continuum/branches/continuum-1.3.x/continuum-core/src/test-projects/multi-module/module-B/src/main/java/
    continuum/branches/continuum-1.3.x/continuum-core/src/test-projects/multi-module/module-B/src/main/java/org/
    continuum/branches/continuum-1.3.x/continuum-core/src/test-projects/multi-module/module-B/src/main/java/org/apache/
    continuum/branches/continuum-1.3.x/continuum-core/src/test-projects/multi-module/module-B/src/main/java/org/apache/continuum/
    continuum/branches/continuum-1.3.x/continuum-core/src/test-projects/multi-module/module-B/src/main/java/org/apache/continuum/module/
    continuum/branches/continuum-1.3.x/continuum-core/src/test-projects/multi-module/module-B/src/main/java/org/apache/continuum/module/b/
    continuum/branches/continuum-1.3.x/continuum-core/src/test-projects/multi-module/module-B/src/main/java/org/apache/continuum/module/b/App.java
    continuum/branches/continuum-1.3.x/continuum-core/src/test-projects/multi-module/module-B/src/test/
    continuum/branches/continuum-1.3.x/continuum-core/src/test-projects/multi-module/module-B/src/test/java/
    continuum/branches/continuum-1.3.x/continuum-core/src/test-projects/multi-module/module-B/src/test/java/org/
    continuum/branches/continuum-1.3.x/continuum-core/src/test-projects/multi-module/module-B/src/test/java/org/apache/
    continuum/branches/continuum-1.3.x/continuum-core/src/test-projects/multi-module/module-B/src/test/java/org/apache/continuum/
    continuum/branches/continuum-1.3.x/continuum-core/src/test-projects/multi-module/module-B/src/test/java/org/apache/continuum/module/
    continuum/branches/continuum-1.3.x/continuum-core/src/test-projects/multi-module/module-B/src/test/java/org/apache/continuum/module/b/
    continuum/branches/continuum-1.3.x/continuum-core/src/test-projects/multi-module/module-B/src/test/java/org/apache/continuum/module/b/AppTest.java
    continuum/branches/continuum-1.3.x/continuum-core/src/test-projects/multi-module/pom.xml
    continuum/branches/continuum-1.3.x/continuum-core/src/test/java/org/apache/maven/continuum/scm/
    continuum/branches/continuum-1.3.x/continuum-core/src/test/java/org/apache/maven/continuum/scm/queue/
    continuum/branches/continuum-1.3.x/continuum-core/src/test/java/org/apache/maven/continuum/scm/queue/PrepareBuildProjectsTaskExecutorTest.java

Added: continuum/branches/continuum-1.3.x/continuum-core/src/test-projects/multi-module/module-A/pom.xml
URL: http://svn.apache.org/viewvc/continuum/branches/continuum-1.3.x/continuum-core/src/test-projects/multi-module/module-A/pom.xml?rev=802678&view=auto
==============================================================================
--- continuum/branches/continuum-1.3.x/continuum-core/src/test-projects/multi-module/module-A/pom.xml
(added)
+++ continuum/branches/continuum-1.3.x/continuum-core/src/test-projects/multi-module/module-A/pom.xml
Mon Aug 10 07:43:31 2009
@@ -0,0 +1,39 @@
+<?xml version="1.0"?><project>
+<!--
+
+    Copyright 2005 Exist Global
+    
+     Licensed 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.
+
+-->
+
+  <parent>
+    <artifactId>multi-module-parent</artifactId>
+    <groupId>org.apache.continuum</groupId>
+    <version>1.0-SNAPSHOT</version>
+  </parent>
+  <modelVersion>4.0.0</modelVersion>
+  <groupId>org.apache.continuum</groupId>
+  <artifactId>module-A</artifactId>
+  <name>module-A</name>
+  <version>1.0-SNAPSHOT</version>
+  <url>http://maven.apache.org</url>
+  <dependencies>
+    <dependency>
+      <groupId>junit</groupId>
+      <artifactId>junit</artifactId>
+      <version>3.8.1</version>
+      <scope>test</scope>
+    </dependency>
+  </dependencies>
+</project>

Added: continuum/branches/continuum-1.3.x/continuum-core/src/test-projects/multi-module/module-A/src/main/java/org/apache/continuum/module/a/App.java
URL: http://svn.apache.org/viewvc/continuum/branches/continuum-1.3.x/continuum-core/src/test-projects/multi-module/module-A/src/main/java/org/apache/continuum/module/a/App.java?rev=802678&view=auto
==============================================================================
--- continuum/branches/continuum-1.3.x/continuum-core/src/test-projects/multi-module/module-A/src/main/java/org/apache/continuum/module/a/App.java
(added)
+++ continuum/branches/continuum-1.3.x/continuum-core/src/test-projects/multi-module/module-A/src/main/java/org/apache/continuum/module/a/App.java
Mon Aug 10 07:43:31 2009
@@ -0,0 +1,29 @@
+/**
+ * Copyright 2005 Exist Global
+ * 
+ *  Licensed 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.
+ */
+
+package org.apache.continuum.module.a;
+
+/**
+ * Hello world!
+ *
+ */
+public class App 
+{
+    public static void main( String[] args )
+    {
+        System.out.println( "Hello World!" );
+    }
+}

Added: continuum/branches/continuum-1.3.x/continuum-core/src/test-projects/multi-module/module-A/test/java/org/apache/continuum/module/a/AppTest.java
URL: http://svn.apache.org/viewvc/continuum/branches/continuum-1.3.x/continuum-core/src/test-projects/multi-module/module-A/test/java/org/apache/continuum/module/a/AppTest.java?rev=802678&view=auto
==============================================================================
--- continuum/branches/continuum-1.3.x/continuum-core/src/test-projects/multi-module/module-A/test/java/org/apache/continuum/module/a/AppTest.java
(added)
+++ continuum/branches/continuum-1.3.x/continuum-core/src/test-projects/multi-module/module-A/test/java/org/apache/continuum/module/a/AppTest.java
Mon Aug 10 07:43:31 2009
@@ -0,0 +1,54 @@
+/**
+ * Copyright 2005 Exist Global
+ * 
+ *  Licensed 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.
+ */
+
+package org.apache.continuum.module.a;
+
+import junit.framework.Test;
+import junit.framework.TestCase;
+import junit.framework.TestSuite;
+
+/**
+ * Unit test for simple App.
+ */
+public class AppTest 
+    extends TestCase
+{
+    /**
+     * Create the test case
+     *
+     * @param testName name of the test case
+     */
+    public AppTest( String testName )
+    {
+        super( testName );
+    }
+
+    /**
+     * @return the suite of tests being tested
+     */
+    public static Test suite()
+    {
+        return new TestSuite( AppTest.class );
+    }
+
+    /**
+     * Rigourous Test :-)
+     */
+    public void testApp()
+    {
+        assertTrue( true );
+    }
+}

Added: continuum/branches/continuum-1.3.x/continuum-core/src/test-projects/multi-module/module-B/pom.xml
URL: http://svn.apache.org/viewvc/continuum/branches/continuum-1.3.x/continuum-core/src/test-projects/multi-module/module-B/pom.xml?rev=802678&view=auto
==============================================================================
--- continuum/branches/continuum-1.3.x/continuum-core/src/test-projects/multi-module/module-B/pom.xml
(added)
+++ continuum/branches/continuum-1.3.x/continuum-core/src/test-projects/multi-module/module-B/pom.xml
Mon Aug 10 07:43:31 2009
@@ -0,0 +1,39 @@
+<?xml version="1.0"?><project>
+<!--
+
+    Copyright 2005 Exist Global
+    
+     Licensed 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.
+
+-->
+
+  <parent>
+    <artifactId>multi-module-parent</artifactId>
+    <groupId>org.apache.continuum</groupId>
+    <version>1.0-SNAPSHOT</version>
+  </parent>
+  <modelVersion>4.0.0</modelVersion>
+  <groupId>org.apache.continuum</groupId>
+  <artifactId>module-B</artifactId>
+  <name>module-B</name>
+  <version>1.0-SNAPSHOT</version>
+  <url>http://maven.apache.org</url>
+  <dependencies>
+    <dependency>
+      <groupId>junit</groupId>
+      <artifactId>junit</artifactId>
+      <version>3.8.1</version>
+      <scope>test</scope>
+    </dependency>
+  </dependencies>
+</project>

Added: continuum/branches/continuum-1.3.x/continuum-core/src/test-projects/multi-module/module-B/src/main/java/org/apache/continuum/module/b/App.java
URL: http://svn.apache.org/viewvc/continuum/branches/continuum-1.3.x/continuum-core/src/test-projects/multi-module/module-B/src/main/java/org/apache/continuum/module/b/App.java?rev=802678&view=auto
==============================================================================
--- continuum/branches/continuum-1.3.x/continuum-core/src/test-projects/multi-module/module-B/src/main/java/org/apache/continuum/module/b/App.java
(added)
+++ continuum/branches/continuum-1.3.x/continuum-core/src/test-projects/multi-module/module-B/src/main/java/org/apache/continuum/module/b/App.java
Mon Aug 10 07:43:31 2009
@@ -0,0 +1,29 @@
+/**
+ * Copyright 2005 Exist Global
+ * 
+ *  Licensed 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.
+ */
+
+package org.apache.continuum.module.b;
+
+/**
+ * Hello world!
+ *
+ */
+public class App 
+{
+    public static void main( String[] args )
+    {
+        System.out.println( "Hello World!" );
+    }
+}

Added: continuum/branches/continuum-1.3.x/continuum-core/src/test-projects/multi-module/module-B/src/test/java/org/apache/continuum/module/b/AppTest.java
URL: http://svn.apache.org/viewvc/continuum/branches/continuum-1.3.x/continuum-core/src/test-projects/multi-module/module-B/src/test/java/org/apache/continuum/module/b/AppTest.java?rev=802678&view=auto
==============================================================================
--- continuum/branches/continuum-1.3.x/continuum-core/src/test-projects/multi-module/module-B/src/test/java/org/apache/continuum/module/b/AppTest.java
(added)
+++ continuum/branches/continuum-1.3.x/continuum-core/src/test-projects/multi-module/module-B/src/test/java/org/apache/continuum/module/b/AppTest.java
Mon Aug 10 07:43:31 2009
@@ -0,0 +1,54 @@
+/**
+ * Copyright 2005 Exist Global
+ * 
+ *  Licensed 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.
+ */
+
+package org.apache.continuum.module.b;
+
+import junit.framework.Test;
+import junit.framework.TestCase;
+import junit.framework.TestSuite;
+
+/**
+ * Unit test for simple App.
+ */
+public class AppTest 
+    extends TestCase
+{
+    /**
+     * Create the test case
+     *
+     * @param testName name of the test case
+     */
+    public AppTest( String testName )
+    {
+        super( testName );
+    }
+
+    /**
+     * @return the suite of tests being tested
+     */
+    public static Test suite()
+    {
+        return new TestSuite( AppTest.class );
+    }
+
+    /**
+     * Rigourous Test :-)
+     */
+    public void testApp()
+    {
+        assertTrue( true );
+    }
+}

Added: continuum/branches/continuum-1.3.x/continuum-core/src/test-projects/multi-module/pom.xml
URL: http://svn.apache.org/viewvc/continuum/branches/continuum-1.3.x/continuum-core/src/test-projects/multi-module/pom.xml?rev=802678&view=auto
==============================================================================
--- continuum/branches/continuum-1.3.x/continuum-core/src/test-projects/multi-module/pom.xml
(added)
+++ continuum/branches/continuum-1.3.x/continuum-core/src/test-projects/multi-module/pom.xml
Mon Aug 10 07:43:31 2009
@@ -0,0 +1,44 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+
+    Copyright 2005 Exist Global
+    
+     Licensed 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.
+
+-->
+
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+  <modelVersion>4.0.0</modelVersion>
+  <groupId>org.apache.continuum</groupId>
+  <artifactId>multi-module-parent</artifactId>
+  <packaging>pom</packaging>
+  <version>1.0-SNAPSHOT</version>
+  <name>multi-module-parent</name>
+  <url>http://maven.apache.org</url>
+  <scm>
+    <connection>scm:local:src/test-projects:multi-module</connection>
+    <url>http://cvs.plexus.codehaus.org/plexus-components/native/continuum/src/test-projects/multi-module</url>
+  </scm>
+  <dependencies>
+    <dependency>
+      <groupId>junit</groupId>
+      <artifactId>junit</artifactId>
+      <version>3.8.1</version>
+      <scope>test</scope>
+    </dependency>
+  </dependencies>
+  <modules>
+    <module>module-A</module>
+    <module>module-B</module>
+  </modules>
+</project>

Added: continuum/branches/continuum-1.3.x/continuum-core/src/test/java/org/apache/maven/continuum/scm/queue/PrepareBuildProjectsTaskExecutorTest.java
URL: http://svn.apache.org/viewvc/continuum/branches/continuum-1.3.x/continuum-core/src/test/java/org/apache/maven/continuum/scm/queue/PrepareBuildProjectsTaskExecutorTest.java?rev=802678&view=auto
==============================================================================
--- continuum/branches/continuum-1.3.x/continuum-core/src/test/java/org/apache/maven/continuum/scm/queue/PrepareBuildProjectsTaskExecutorTest.java
(added)
+++ continuum/branches/continuum-1.3.x/continuum-core/src/test/java/org/apache/maven/continuum/scm/queue/PrepareBuildProjectsTaskExecutorTest.java
Mon Aug 10 07:43:31 2009
@@ -0,0 +1,423 @@
+/**
+ * Copyright 2005 Exist Global
+ * 
+ *  Licensed 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.
+ */
+
+package org.apache.maven.continuum.scm.queue;
+
+import java.io.File;
+import java.io.IOException;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import org.apache.continuum.dao.ProjectScmRootDao;
+import org.apache.continuum.model.project.ProjectScmRoot;
+import org.apache.continuum.taskqueue.PrepareBuildProjectsTask;
+import org.apache.maven.continuum.AbstractContinuumTest;
+import org.apache.maven.continuum.configuration.ConfigurationService;
+import org.apache.maven.continuum.core.action.AbstractContinuumAction;
+import org.apache.maven.continuum.model.project.BuildDefinition;
+import org.apache.maven.continuum.model.project.Project;
+import org.apache.maven.continuum.model.project.ProjectGroup;
+import org.apache.maven.continuum.project.ContinuumProjectState;
+import org.apache.maven.continuum.project.builder.ContinuumProjectBuilder;
+import org.apache.maven.continuum.project.builder.ContinuumProjectBuilderException;
+import org.apache.maven.continuum.project.builder.ContinuumProjectBuildingResult;
+import org.apache.maven.continuum.project.builder.maven.MavenTwoContinuumProjectBuilder;
+import org.codehaus.plexus.action.ActionManager;
+import org.codehaus.plexus.taskqueue.TaskQueue;
+import org.codehaus.plexus.taskqueue.execution.TaskQueueExecutor;
+import org.codehaus.plexus.util.StringUtils;
+
+public class PrepareBuildProjectsTaskExecutorTest
+    extends AbstractContinuumTest
+{
+    private ContinuumProjectBuilder projectBuilder;
+
+    private TaskQueue prepareBuildQueue;
+
+    private TaskQueueExecutor prepareBuildTaskQueueExecutor;
+
+    private ActionManager actionManager;
+
+    private ProjectScmRootDao projectScmRootDao;
+
+    private ConfigurationService configurationService;
+
+    @Override
+    protected void setUp()
+        throws Exception
+    {
+        super.setUp();
+
+        projectBuilder =
+            (ContinuumProjectBuilder) lookup( ContinuumProjectBuilder.ROLE, MavenTwoContinuumProjectBuilder.ID
);
+
+        prepareBuildQueue = (TaskQueue) lookup( TaskQueue.ROLE, "prepare-build-project" );
+
+        prepareBuildTaskQueueExecutor = (TaskQueueExecutor) lookup( TaskQueueExecutor.ROLE,
"prepare-build-project" );
+
+        projectScmRootDao = (ProjectScmRootDao) lookup( ProjectScmRootDao.class.getName()
);
+
+        actionManager = (ActionManager) lookup( ActionManager.ROLE );
+
+        configurationService =  (ConfigurationService ) lookup( "configurationService" );
+    }
+
+    public void testCheckoutPrepareBuildMultiModuleProject()
+        throws Exception
+    {
+        PrepareBuildProjectsTask task = createTask( "src/test-projects/multi-module/pom.xml",
false, false );
+
+        this.prepareBuildQueue.put( task );
+
+        List<Project> projects = getProjectDao().getProjectsInGroup( task.getProjectGroupId()
);
+
+        assertEquals( "failed to add all projects", 3, projects.size() );
+
+        Project rootProject = getProjectDao().getProjectByName( "multi-module-parent" );
+        Project moduleA = getProjectDao().getProjectByName( "module-A" );
+        Project moduleB = getProjectDao().getProjectByName( "module-B" );
+
+        // wait while task finishes prepare build
+        while( !prepareBuildQueue.getQueueSnapshot().isEmpty() || 
+                        prepareBuildTaskQueueExecutor.getCurrentTask() != null )
+        {
+            Thread.sleep( 10 );
+        }
+
+        ProjectScmRoot scmRoot = projectScmRootDao.getProjectScmRoot( task.getProjectScmRootId()
);
+        assertEquals( "Failed to update multi-module project", ContinuumProjectState.UPDATED,
scmRoot.getState() );
+
+        File workingDir = configurationService.getWorkingDirectory();
+
+        assertTrue( "checkout directory of project 'multi-module-parent' does not exist.",
new File( workingDir, Integer.toString( rootProject.getId() ) ).exists() );
+
+        assertTrue( "checkout directory of project 'module-A' does not exist.", new File(
workingDir, Integer.toString( moduleA.getId() ) ).exists() );
+
+        assertTrue( "checkout directory of project 'module-B' does not exist.", new File(
workingDir, Integer.toString( moduleB.getId() ) ).exists() );
+    }
+
+    public void testCheckoutPrepareBuildMultiModuleProjectFreshBuild()
+        throws Exception
+    {
+        PrepareBuildProjectsTask task = createTask( "src/test-projects/multi-module/pom.xml",
false, true );
+
+        this.prepareBuildQueue.put( task );
+
+        List<Project> projects = getProjectDao().getProjectsInGroup( task.getProjectGroupId()
);
+
+        assertEquals( "failed to add all projects", 3, projects.size() );
+
+        Project rootProject = getProjectDao().getProjectByName( "multi-module-parent" );
+        Project moduleA = getProjectDao().getProjectByName( "module-A" );
+        Project moduleB = getProjectDao().getProjectByName( "module-B" );
+
+        // wait while task finishes prepare build
+        while( !prepareBuildQueue.getQueueSnapshot().isEmpty() || 
+                        prepareBuildTaskQueueExecutor.getCurrentTask() != null )
+        {
+            Thread.sleep( 10 );
+        }
+
+        ProjectScmRoot scmRoot = projectScmRootDao.getProjectScmRoot( task.getProjectScmRootId()
);
+        assertEquals( "Failed to update multi-module project", ContinuumProjectState.UPDATED,
scmRoot.getState() );
+
+        File workingDir = configurationService.getWorkingDirectory();
+
+        assertTrue( "checkout directory of project 'multi-module-parent' does not exist.",
new File( workingDir, Integer.toString( rootProject.getId() ) ).exists() );
+
+        assertTrue( "checkout directory of project 'module-A' does not exist.", new File(
workingDir, Integer.toString( moduleA.getId() ) ).exists() );
+
+        assertTrue( "checkout directory of project 'module-B' does not exist.", new File(
workingDir, Integer.toString( moduleB.getId() ) ).exists() );
+    }
+/*
+    public void testCheckoutPrepareBuildSingleCheckedoutMultiModuleProject()
+        throws Exception
+    {
+        PrepareBuildProjectsTask task = createTask( "src/test-projects/multi-module/pom.xml",
true, false );
+
+        this.prepareBuildQueue.put( task );
+
+        List<Project> projects = getProjectDao().getProjectsInGroup( task.getProjectGroupId()
);
+
+        assertEquals( "failed to add all projects", 3, projects.size() );
+
+        Project rootProject = getProjectDao().getProjectByName( "multi-module-parent" );
+
+        // wait while task finishes prepare build
+        while( !prepareBuildQueue.getQueueSnapshot().isEmpty() || 
+                        prepareBuildTaskQueueExecutor.getCurrentTask() != null )
+        {
+            Thread.sleep( 10 );
+        }
+
+        ProjectScmRoot scmRoot = projectScmRootDao.getProjectScmRoot( task.getProjectScmRootId()
);
+        assertEquals( "Failed to update multi-module project", ContinuumProjectState.UPDATED,
scmRoot.getState() );
+
+        File checkedOutDir = new File( configurationService.getWorkingDirectory(), Integer.toString(
rootProject.getId() ) );
+
+        assertTrue( "checkout directory of project 'multi-module-parent' does not exist.",
checkedOutDir.exists() );
+
+        assertTrue( "module-A was not checked out in the same directory as it's parent.",
new File( checkedOutDir, "module-A" ).exists() );
+
+        assertTrue( "module-B was not checked out in the same directory as it's parent.",
new File( checkedOutDir, "module-B" ).exists() );
+    }
+
+    public void testCheckoutPrepareBuildSingleCheckedoutMultiModuleProjectFreshBuild()
+        throws Exception
+    {
+        PrepareBuildProjectsTask task = createTask( "src/test-projects/multi-module/pom.xml",
true, true );
+
+        this.prepareBuildQueue.put( task );
+
+        List<Project> projects = getProjectDao().getProjectsInGroup( task.getProjectGroupId()
);
+
+        assertEquals( "failed to add all projects", 3, projects.size() );
+
+        Project rootProject = getProjectDao().getProjectByName( "multi-module-parent" );
+
+        // wait while task finishes prepare build
+        while( !prepareBuildQueue.getQueueSnapshot().isEmpty() || 
+                        prepareBuildTaskQueueExecutor.getCurrentTask() != null )
+        {
+            Thread.sleep( 10 );
+        }
+
+        ProjectScmRoot scmRoot = projectScmRootDao.getProjectScmRoot( task.getProjectScmRootId()
);
+        assertEquals( "Failed to update multi-module project", ContinuumProjectState.UPDATED,
scmRoot.getState() );
+
+        File checkedOutDir = new File( configurationService.getWorkingDirectory(), Integer.toString(
rootProject.getId() ) );
+
+        assertTrue( "checkout directory of project 'multi-module-parent' does not exist.",
checkedOutDir.exists() );
+
+        assertTrue( "module-A was not checked out in the same directory as it's parent.",
new File( checkedOutDir, "module-A" ).exists() );
+
+        assertTrue( "module-B was not checked out in the same directory as it's parent.",
new File( checkedOutDir, "module-B" ).exists() );
+    }
+
+    public void testCheckoutPrepareBuildSingleCheckoutFlatMultiModuleProject()
+        throws Exception
+    {
+        PrepareBuildProjectsTask task = createTask( "src/test-projects/flat-multi-module/parent-project/pom.xml",
true, false );
+
+        this.prepareBuildQueue.put( task );
+
+        List<Project> projects = getProjectDao().getProjectsInGroup( task.getProjectGroupId()
);
+
+        assertEquals( "failed to add all projects", 3, projects.size() );
+
+        Project rootProject = getProjectDao().getProjectByName( "parent-project" );
+
+        // wait while task finishes prepare build
+        while( !prepareBuildQueue.getQueueSnapshot().isEmpty() || 
+                        prepareBuildTaskQueueExecutor.getCurrentTask() != null )
+        {
+            Thread.sleep( 10 );
+        }
+
+        ProjectScmRoot scmRoot = projectScmRootDao.getProjectScmRoot( task.getProjectScmRootId()
);
+        assertEquals( "Failed to update multi-module project", ContinuumProjectState.UPDATED,
scmRoot.getState() );
+
+        File checkedOutDir = new File( configurationService.getWorkingDirectory(), Integer.toString(
rootProject.getId() ) );
+
+        assertTrue( "checkout directory of project 'parent-project' does not exist.", new
File( checkedOutDir, "parent-project" ).exists() );
+
+        assertTrue( "module-a was not checked out in the same directory as it's parent.",
new File( checkedOutDir, "module-a" ).exists() );
+
+        assertTrue( "module-b was not checked out in the same directory as it's parent.",
new File( checkedOutDir, "module-b" ).exists() );
+    }
+
+    public void testCheckoutPrepareBuildSingleCheckoutFlatMultiModuleProjectBuildFresh()
+        throws Exception
+    {
+        PrepareBuildProjectsTask task = createTask( "src/test-projects/flat-multi-module/parent-project/pom.xml",
true, true );
+
+        this.prepareBuildQueue.put( task );
+
+        List<Project> projects = getProjectDao().getProjectsInGroup( task.getProjectGroupId()
);
+
+        assertEquals( "failed to add all projects", 3, projects.size() );
+
+        Project rootProject = getProjectDao().getProjectByName( "parent-project" );
+
+        ProjectScmRoot scmRoot = projectScmRootDao.getProjectScmRoot( task.getProjectScmRootId()
);
+        // wait while task finishes prepare build
+        while( !prepareBuildQueue.getQueueSnapshot().isEmpty() || 
+                        prepareBuildTaskQueueExecutor.getCurrentTask() != null || scmRoot.getState()
== ContinuumProjectState.UPDATING )
+        {
+            Thread.sleep( 10 );
+
+            scmRoot = projectScmRootDao.getProjectScmRoot( task.getProjectScmRootId() );
+        }
+
+        scmRoot = projectScmRootDao.getProjectScmRoot( task.getProjectScmRootId() );
+        assertEquals( "Failed to update multi-module project", ContinuumProjectState.UPDATED,
scmRoot.getState() );
+
+        File checkedOutDir = new File( configurationService.getWorkingDirectory(), Integer.toString(
rootProject.getId() ) );
+
+        assertTrue( "checkout directory of project 'parent-project' does not exist.", new
File( checkedOutDir, "parent-project" ).exists() );
+
+        assertTrue( "module-a was not checked out in the same directory as it's parent.",
new File( checkedOutDir, "module-a" ).exists() );
+
+        assertTrue( "module-b was not checked out in the same directory as it's parent.",
new File( checkedOutDir, "module-b" ).exists() );
+    }
+*/
+    private PrepareBuildProjectsTask createTask( String pomResource, boolean singleCheckout,
boolean buildFresh )
+        throws Exception
+    {
+        ProjectGroup projectGroup = getProjectGroup( pomResource, singleCheckout );
+
+        BuildDefinition buildDefinition = new BuildDefinition();
+        buildDefinition.setId( 0 );
+        buildDefinition.setGoals( "clean" );
+        buildDefinition.setBuildFresh( buildFresh );
+        
+        projectGroup.addBuildDefinition( buildDefinition );
+
+        Map<String, Object> pgContext = new HashMap<String, Object>();
+
+        AbstractContinuumAction.setWorkingDirectory( pgContext, configurationService.getWorkingDirectory().getAbsolutePath()
);
+
+        AbstractContinuumAction.setUnvalidatedProjectGroup( pgContext, projectGroup );
+
+        actionManager.lookup( "validate-project-group" ).execute( pgContext );
+
+        actionManager.lookup( "store-project-group" ).execute( pgContext );
+
+        int projectGroupId = AbstractContinuumAction.getProjectGroupId( pgContext );
+
+        projectGroup = getProjectGroupDao().getProjectGroupWithBuildDetailsByProjectGroupId(
projectGroupId );
+
+        String scmRootUrl = getScmRootUrl( projectGroup );
+
+        assertNotNull( scmRootUrl );
+
+        ProjectScmRoot scmRoot = getProjectScmRoot( projectGroup, scmRootUrl );
+
+        assertNotNull( scmRoot );
+
+        buildDefinition = (BuildDefinition) projectGroup.getBuildDefinitions().get( 0 );
+
+        Map<Integer, Integer> map = new HashMap<Integer, Integer>();
+
+        Project rootProject = null;
+
+        List<Project> projects = (List<Project>) projectGroup.getProjects();
+
+        for ( Project project : projects )
+        {
+            assertFalse( project.getId() == 0 );
+            
+            map.put( project.getId(), buildDefinition.getId() );
+
+            if ( rootProject == null || rootProject.getId() > project.getId() )
+            {
+                rootProject = project;
+            }
+        }
+
+        assertEquals( 3, map.size() );
+        PrepareBuildProjectsTask task = new PrepareBuildProjectsTask( map, 1, 
+                                                                      projectGroupId, projectGroup.getName(),

+                                                                      scmRoot.getScmRootAddress(),
scmRoot.getId() );
+
+        return task;
+    }
+
+    private ProjectGroup getProjectGroup( String pomResource, boolean singleCheckout )
+        throws ContinuumProjectBuilderException, IOException
+    {
+        File pom = getTestFile( pomResource );
+    
+        assertNotNull( "Can't find project " + pomResource, pom );
+
+        //ContinuumProjectBuildingResult result = projectBuilder.buildProjectsFromMetadata(
pom.toURL(), null, null, true, singleCheckout );
+        ContinuumProjectBuildingResult result = projectBuilder.buildProjectsFromMetadata(
pom.toURL(), null, null, true );
+
+        // some assertions to make sure our expectations match. This is NOT
+        // meant as a unit test for the projectbuilder!
+    
+        assertNotNull( "Project list not null", result.getProjects() );
+    
+        assertEquals( "#Projectgroups", 1, result.getProjectGroups().size() );
+    
+        ProjectGroup pg = result.getProjectGroups().get( 0 );
+    
+        if ( !result.getProjects().isEmpty() )
+        {
+            for ( Project p : result.getProjects() )
+            {
+                pg.addProject( p );
+            }
+        }
+
+        return pg;
+    }
+
+    private ProjectScmRoot getProjectScmRoot ( ProjectGroup pg, String url )
+        throws Exception
+    {
+        if ( StringUtils.isEmpty( url ) )
+        {
+            return null;
+        }
+
+        ProjectScmRoot scmRoot =
+            projectScmRootDao.getProjectScmRootByProjectGroupAndScmRootAddress( pg.getId(),
url );
+
+        if ( scmRoot != null )
+        {
+            return scmRoot;
+        }
+
+        ProjectScmRoot projectScmRoot = new ProjectScmRoot();
+
+        projectScmRoot.setProjectGroup( pg );
+
+        projectScmRoot.setScmRootAddress( url );
+
+        projectScmRoot.setState( ContinuumProjectState.ERROR );
+
+        return projectScmRootDao.addProjectScmRoot( projectScmRoot );
+    }
+
+    private String getScmRootUrl( ProjectGroup pg )
+    {
+        String scmRootUrl = null;
+
+        for ( Project project : (List<Project>) pg.getProjects() )
+        {
+            String scmUrl = project.getScmUrl();
+
+            scmRootUrl = getCommonPath( scmUrl, scmRootUrl );
+        }
+
+        return scmRootUrl;
+    }
+
+    private String getCommonPath( String path1, String path2 )
+    {
+        if ( path2 == null || path2.equals( "" ) )
+        {
+            return path1;
+        }
+        else
+        {
+            int indexDiff = StringUtils.differenceAt( path1, path2 );
+            return path1.substring( 0, indexDiff );
+        }
+    }
+}



Mime
View raw message