continuum-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From br...@apache.org
Subject svn commit: r1370678 - in /continuum/trunk/continuum-core: ./ src/test/java/org/apache/continuum/ src/test/java/org/apache/maven/continuum/
Date Wed, 08 Aug 2012 07:18:31 GMT
Author: brett
Date: Wed Aug  8 07:18:30 2012
New Revision: 1370678

URL: http://svn.apache.org/viewvc?rev=1370678&view=rev
Log:
make tests work offline

Added:
    continuum/trunk/continuum-core/src/test/java/org/apache/continuum/AbstractAddProjectTest.java
Modified:
    continuum/trunk/continuum-core/pom.xml
    continuum/trunk/continuum-core/src/test/java/org/apache/maven/continuum/AddMaven2ProjectTest.java
    continuum/trunk/continuum-core/src/test/java/org/apache/maven/continuum/AddProjectTest.java

Modified: continuum/trunk/continuum-core/pom.xml
URL: http://svn.apache.org/viewvc/continuum/trunk/continuum-core/pom.xml?rev=1370678&r1=1370677&r2=1370678&view=diff
==============================================================================
--- continuum/trunk/continuum-core/pom.xml (original)
+++ continuum/trunk/continuum-core/pom.xml Wed Aug  8 07:18:30 2012
@@ -273,6 +273,12 @@ under the License.
       <artifactId>jmock</artifactId>
       <scope>test</scope>
     </dependency>
+    <dependency>
+      <groupId>org.mortbay.jetty</groupId>
+      <artifactId>jetty</artifactId>
+      <version>${jetty.version}</version>
+      <scope>test</scope>
+    </dependency>
   </dependencies>
   <build>
     <plugins>

Added: continuum/trunk/continuum-core/src/test/java/org/apache/continuum/AbstractAddProjectTest.java
URL: http://svn.apache.org/viewvc/continuum/trunk/continuum-core/src/test/java/org/apache/continuum/AbstractAddProjectTest.java?rev=1370678&view=auto
==============================================================================
--- continuum/trunk/continuum-core/src/test/java/org/apache/continuum/AbstractAddProjectTest.java
(added)
+++ continuum/trunk/continuum-core/src/test/java/org/apache/continuum/AbstractAddProjectTest.java
Wed Aug  8 07:18:30 2012
@@ -0,0 +1,51 @@
+/*
+ * 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.
+ */
+package org.apache.continuum;
+
+import org.apache.maven.continuum.AbstractContinuumTest;
+import org.codehaus.plexus.util.FileUtils;
+
+import java.io.File;
+import java.io.IOException;
+
+public abstract class AbstractAddProjectTest
+    extends AbstractContinuumTest
+{
+    private static void mkdirs( File directory )
+        throws IOException
+    {
+        if ( !directory.exists() && !directory.mkdirs() )
+        {
+            throw new IOException( "Unable to create repository " + directory );
+        }
+    }
+
+    protected void createLocalRepository()
+        throws IOException
+    {
+        File localRepo = getTestFile( "target/test-classes/.m2/repository" );
+        mkdirs( localRepo );
+
+        File artifact =
+            new File( localRepo, "org/apache/maven/continuum/continuum-parent/1.0.3/continuum-parent-1.0.3.pom"
);
+        mkdirs( artifact.getParentFile() );
+
+        FileUtils.copyFile( getTestFile( "src/test/resources/projects/continuum/pom.xml"
), artifact );
+    }
+}

Modified: continuum/trunk/continuum-core/src/test/java/org/apache/maven/continuum/AddMaven2ProjectTest.java
URL: http://svn.apache.org/viewvc/continuum/trunk/continuum-core/src/test/java/org/apache/maven/continuum/AddMaven2ProjectTest.java?rev=1370678&r1=1370677&r2=1370678&view=diff
==============================================================================
--- continuum/trunk/continuum-core/src/test/java/org/apache/maven/continuum/AddMaven2ProjectTest.java
(original)
+++ continuum/trunk/continuum-core/src/test/java/org/apache/maven/continuum/AddMaven2ProjectTest.java
Wed Aug  8 07:18:30 2012
@@ -3,6 +3,7 @@ package org.apache.maven.continuum;
 import java.io.File;
 import java.util.Collections;
 
+import org.apache.continuum.AbstractAddProjectTest;
 import org.apache.maven.continuum.builddefinition.BuildDefinitionService;
 import org.apache.maven.continuum.model.project.BuildDefinition;
 import org.apache.maven.continuum.model.project.BuildDefinitionTemplate;
@@ -36,7 +37,7 @@ import org.slf4j.LoggerFactory;
  * @version $Id$
  */
 public class AddMaven2ProjectTest
-    extends AbstractContinuumTest
+    extends AbstractAddProjectTest
 {
     protected final Logger log = LoggerFactory.getLogger( getClass() );
 
@@ -65,11 +66,11 @@ public class AddMaven2ProjectTest
         
         bdt = bds.addBuildDefinitionTemplate( bdt );
         
-        bdt = bds.addBuildDefinitionInTemplate( bdt, bd, false );        
-    }    
-    
-    
-    
+        bdt = bds.addBuildDefinitionInTemplate( bdt, bd, false );
+
+        createLocalRepository();
+    }
+
     public void testAddProjectToExistingGroupWithBuildDefTemplate()
         throws Exception
     {
@@ -226,7 +227,7 @@ public class AddMaven2ProjectTest
 
         pg = getContinuum().getProjectGroupWithBuildDetails( pg.getId() );
         
-        assertEquals( "clean install", ( (BuildDefinition) pg.getBuildDefinitions().get(
0 ) ).getGoals() );
+        assertEquals( "clean install", pg.getBuildDefinitions().get( 0 ).getGoals() );
     }
     
     

Modified: continuum/trunk/continuum-core/src/test/java/org/apache/maven/continuum/AddProjectTest.java
URL: http://svn.apache.org/viewvc/continuum/trunk/continuum-core/src/test/java/org/apache/maven/continuum/AddProjectTest.java?rev=1370678&r1=1370677&r2=1370678&view=diff
==============================================================================
--- continuum/trunk/continuum-core/src/test/java/org/apache/maven/continuum/AddProjectTest.java
(original)
+++ continuum/trunk/continuum-core/src/test/java/org/apache/maven/continuum/AddProjectTest.java
Wed Aug  8 07:18:30 2012
@@ -18,11 +18,17 @@
  */
 package org.apache.maven.continuum;
 
+import org.apache.continuum.AbstractAddProjectTest;
 import org.apache.maven.continuum.builddefinition.BuildDefinitionService;
 import org.apache.maven.continuum.execution.ContinuumBuildExecutorConstants;
 import org.apache.maven.continuum.model.project.Project;
 import org.apache.maven.continuum.project.builder.ContinuumProjectBuildingResult;
 import org.apache.maven.continuum.project.builder.maven.MavenTwoContinuumProjectBuilder;
+import org.mortbay.jetty.Handler;
+import org.mortbay.jetty.Server;
+import org.mortbay.jetty.handler.DefaultHandler;
+import org.mortbay.jetty.handler.ResourceHandler;
+import org.mortbay.jetty.nio.SelectChannelConnector;
 
 import java.util.Collections;
 
@@ -32,21 +38,56 @@ import java.util.Collections;
  * @version $Id$
  */
 public class AddProjectTest
-    extends AbstractContinuumTest
-{
+        extends AbstractAddProjectTest {
     static final String SCM_USERNAME = "test";
     
     static final String SCM_PASSWORD = ";password";
-    
+
+    private Server server;
+
+    private String scmUrl;
+
+    @Override
+    protected void setUp()
+        throws Exception
+    {
+        super.setUp();
+
+        createLocalRepository();
+
+        server = startJettyServer();
+        int port = server.getConnectors()[0].getLocalPort();
+        scmUrl = "http://test:;password@localhost:" + port + "/projects/continuum/continuum-core/pom.xml";
+    }
+
+    @Override
+    protected void tearDown()
+        throws Exception
+    {
+        super.tearDown();
+        server.stop();
+    }
+
+    private Server startJettyServer()
+        throws Exception
+    {
+        Server server = new Server( 0 );
+        ResourceHandler handler = new ResourceHandler();
+        handler.setResourceBase( getTestFile( "src/test/resources" ).getAbsolutePath() );
+        server.setHandlers( new Handler[]{ handler, new DefaultHandler() } );
+        server.start();
+        return server;
+    }
+
     public void testScmUserNamePasswordNotStoring()
         throws Exception
     {
-        String metadataUrl = "http://test:;password@svn.apache.org/repos/asf/continuum/tags/continuum-1.1/continuum-api/pom.xml";
         DefaultContinuum continuum = (DefaultContinuum) lookup( Continuum.ROLE );
-        
+
         ContinuumProjectBuildingResult result = continuum
-            .executeAddProjectsFromMetadataActivity( metadataUrl, MavenTwoContinuumProjectBuilder.ID,
-            						getDefaultProjectGroup().getId(), false, true, false, -1, false, false
);
+            .executeAddProjectsFromMetadataActivity( scmUrl, MavenTwoContinuumProjectBuilder.ID,
+                                                     getDefaultProjectGroup().getId(), false,
true, false, -1, false,
+                                                     false );
         assertEquals( Collections.emptyList(), result.getErrors() );
 
         assertEquals( 1, result.getProjects().size() );
@@ -61,12 +102,12 @@ public class AddProjectTest
     public void testScmUserNamePasswordStoring()
         throws Exception
     {
-        String metadataUrl = "http://test:;password@svn.apache.org/repos/asf/continuum/tags/continuum-1.1/continuum-api/pom.xml";
         DefaultContinuum continuum = (DefaultContinuum) lookup( Continuum.ROLE );
 
         ContinuumProjectBuildingResult result = continuum
-            .executeAddProjectsFromMetadataActivity( metadataUrl, MavenTwoContinuumProjectBuilder.ID,
-            						getDefaultProjectGroup().getId(), false, false, false, -1, false, false
);
+            .executeAddProjectsFromMetadataActivity( scmUrl, MavenTwoContinuumProjectBuilder.ID,
+                                                     getDefaultProjectGroup().getId(), false,
false, false, -1, false,
+                                                     false );
         assertEquals( Collections.emptyList(), result.getErrors() );
 
         assertEquals( 1, result.getProjects().size() );
@@ -81,8 +122,6 @@ public class AddProjectTest
     public void testAntProjectScmUserNamePasswordNotStoring()
         throws Exception
     {
-        // use same url since we're just going to add the project, not build it
-        String scmUrl = "http://test:;password@svn.apache.org/repos/asf/continuum/tags/continuum-1.1/continuum-api/pom.xml";
         DefaultContinuum continuum = (DefaultContinuum) lookup( Continuum.ROLE );
         
         Project project = new Project();
@@ -90,7 +129,7 @@ public class AddProjectTest
         project.setVersion( "1.0" );
         project.setScmUsername( SCM_USERNAME );
         project.setScmPassword( SCM_PASSWORD );
-        project.setScmUrl( scmUrl );        
+        project.setScmUrl( this.scmUrl );
         project.setScmUseCache( true );
         
         BuildDefinitionService bdService = ( BuildDefinitionService )lookup( BuildDefinitionService.class.getName()
);
@@ -110,8 +149,6 @@ public class AddProjectTest
     public void testAntProjectScmUserNamePasswordStoring()
         throws Exception
     {
-        // use same url since we're just going to add the project, not build it
-        String scmUrl = "http://test:;password@svn.apache.org/repos/asf/continuum/tags/continuum-1.1/continuum-api/pom.xml";
         DefaultContinuum continuum = (DefaultContinuum) lookup( Continuum.ROLE );
         
         Project project = new Project();



Mime
View raw message