maven-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bentm...@apache.org
Subject svn commit: r812908 - in /maven/core-integration-testing/trunk/core-it-suite/src/test: java/org/apache/maven/it/ resources/mng-4348/
Date Wed, 09 Sep 2009 11:53:22 GMT
Author: bentmann
Date: Wed Sep  9 11:53:21 2009
New Revision: 812908

URL: http://svn.apache.org/viewvc?rev=812908&view=rev
Log:
[MNG-4348] [regression] Unnecessary remote repo access for POMs while execution plugin that
does not require dependency resolution

o Added IT

Added:
    maven/core-integration-testing/trunk/core-it-suite/src/test/java/org/apache/maven/it/MavenITmng4348NoUnnecessaryRepositoryAccessTest.java
  (with props)
    maven/core-integration-testing/trunk/core-it-suite/src/test/resources/mng-4348/
    maven/core-integration-testing/trunk/core-it-suite/src/test/resources/mng-4348/pom.xml
  (with props)
    maven/core-integration-testing/trunk/core-it-suite/src/test/resources/mng-4348/settings-template.xml
  (with props)
Modified:
    maven/core-integration-testing/trunk/core-it-suite/src/test/java/org/apache/maven/it/IntegrationTestSuite.java

Modified: maven/core-integration-testing/trunk/core-it-suite/src/test/java/org/apache/maven/it/IntegrationTestSuite.java
URL: http://svn.apache.org/viewvc/maven/core-integration-testing/trunk/core-it-suite/src/test/java/org/apache/maven/it/IntegrationTestSuite.java?rev=812908&r1=812907&r2=812908&view=diff
==============================================================================
--- maven/core-integration-testing/trunk/core-it-suite/src/test/java/org/apache/maven/it/IntegrationTestSuite.java
(original)
+++ maven/core-integration-testing/trunk/core-it-suite/src/test/java/org/apache/maven/it/IntegrationTestSuite.java
Wed Sep  9 11:53:21 2009
@@ -85,6 +85,7 @@
         // suite.addTestSuite( MavenIT0109ReleaseUpdateTest.class );
         // suite.addTestSuite( MavenIT0108SnapshotUpdateTest.class ); -- MNG-3137
 
+        suite.addTestSuite( MavenITmng4348NoUnnecessaryRepositoryAccessTest.class );
         suite.addTestSuite( MavenITmng4345DefaultPluginExecutionOrderTest.class );
         suite.addTestSuite( MavenITmng4344ManagedPluginExecutionOrderTest.class );
         suite.addTestSuite( MavenITmng4342IndependentMojoParameterDefaultValuesTest.class
);

Added: maven/core-integration-testing/trunk/core-it-suite/src/test/java/org/apache/maven/it/MavenITmng4348NoUnnecessaryRepositoryAccessTest.java
URL: http://svn.apache.org/viewvc/maven/core-integration-testing/trunk/core-it-suite/src/test/java/org/apache/maven/it/MavenITmng4348NoUnnecessaryRepositoryAccessTest.java?rev=812908&view=auto
==============================================================================
--- maven/core-integration-testing/trunk/core-it-suite/src/test/java/org/apache/maven/it/MavenITmng4348NoUnnecessaryRepositoryAccessTest.java
(added)
+++ maven/core-integration-testing/trunk/core-it-suite/src/test/java/org/apache/maven/it/MavenITmng4348NoUnnecessaryRepositoryAccessTest.java
Wed Sep  9 11:53:21 2009
@@ -0,0 +1,116 @@
+package org.apache.maven.it;
+
+/*
+ * 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.maven.it.Verifier;
+import org.apache.maven.it.util.ResourceExtractor;
+
+import java.io.File;
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Properties;
+
+import javax.servlet.ServletException;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+
+import org.mortbay.jetty.Handler;
+import org.mortbay.jetty.Request;
+import org.mortbay.jetty.Server;
+import org.mortbay.jetty.handler.AbstractHandler;
+
+/**
+ * This is a test set for <a href="http://jira.codehaus.org/browse/MNG-4348">MNG-4348</a>.
+ * 
+ * @author Benjamin Bentmann
+ * @version $Id$
+ */
+public class MavenITmng4348NoUnnecessaryRepositoryAccessTest
+    extends AbstractMavenIntegrationTestCase
+{
+
+    public MavenITmng4348NoUnnecessaryRepositoryAccessTest()
+    {
+        super( ALL_MAVEN_VERSIONS );
+    }
+
+    /**
+     * Test that the (remote) repos are not accessed during execution of a mojo that does
not require dependency
+     * resolution. In detail, Maven should neither touch POMs, JARs nor metadata.
+     */
+    public void testit()
+        throws Exception
+    {
+        File testDir = ResourceExtractor.simpleExtractResources( getClass(), "/mng-4348"
);
+
+        Verifier verifier = new Verifier( testDir.getAbsolutePath() );
+
+        final List requestedUris = new ArrayList();
+
+        Handler repoHandler = new AbstractHandler()
+        {
+            public void handle( String target, HttpServletRequest request, HttpServletResponse
response, int dispatch )
+                throws IOException, ServletException
+            {
+                System.out.println( "Handling " + request.getMethod() + " " + request.getRequestURL()
);
+
+                // NOTE: Old Maven versions use the test repo also to check for plugin updates
so we need to filter
+                if ( request.getRequestURI().startsWith( "/org/apache/maven/its/mng4348"
) )
+                {
+                    requestedUris.add( request.getRequestURI() );
+                }
+
+                response.setStatus( HttpServletResponse.SC_NOT_FOUND );
+
+                ( (Request) request ).setHandled( true );
+            }
+        };
+
+        Server server = new Server( 0 );
+        server.setHandler( repoHandler );
+        server.start();
+
+        try
+        {
+            int port = server.getConnectors()[0].getLocalPort();
+
+            verifier.setAutoclean( false );
+            verifier.deleteArtifacts( "org.apache.maven.its.mng4348" );
+            verifier.deleteDirectory( "target" );
+            Properties filterProps = verifier.newDefaultFilterProperties();
+            filterProps.setProperty( "@port@", Integer.toString( port ) );
+            verifier.filterFile( "settings-template.xml", "settings.xml", "UTF-8", filterProps
);
+            verifier.getCliOptions().add( "--settings" );
+            verifier.getCliOptions().add( "settings.xml" );
+            verifier.executeGoal( "validate" );
+            verifier.verifyErrorFreeLog();
+            verifier.resetStreams();
+        }
+        finally
+        {
+            server.stop();
+        }
+
+        verifier.assertFilePresent( "target/touch.txt" );
+        assertEquals( new ArrayList(), requestedUris );
+    }
+
+}

Propchange: maven/core-integration-testing/trunk/core-it-suite/src/test/java/org/apache/maven/it/MavenITmng4348NoUnnecessaryRepositoryAccessTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: maven/core-integration-testing/trunk/core-it-suite/src/test/java/org/apache/maven/it/MavenITmng4348NoUnnecessaryRepositoryAccessTest.java
------------------------------------------------------------------------------
    svn:keywords = Author Date Id Revision

Added: maven/core-integration-testing/trunk/core-it-suite/src/test/resources/mng-4348/pom.xml
URL: http://svn.apache.org/viewvc/maven/core-integration-testing/trunk/core-it-suite/src/test/resources/mng-4348/pom.xml?rev=812908&view=auto
==============================================================================
--- maven/core-integration-testing/trunk/core-it-suite/src/test/resources/mng-4348/pom.xml
(added)
+++ maven/core-integration-testing/trunk/core-it-suite/src/test/resources/mng-4348/pom.xml
Wed Sep  9 11:53:21 2009
@@ -0,0 +1,68 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<!--
+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.
+-->
+
+<project>
+  <modelVersion>4.0.0</modelVersion>
+
+  <groupId>org.apache.maven.its.mng4348</groupId>
+  <artifactId>test</artifactId>
+  <version>0.1</version>
+  <packaging>jar</packaging>
+
+  <name>Maven Integration Test :: MNG-4348</name> 
+  <description>
+    Test that the (remote) repos are not accessed during execution of a mojo that does not
require dependency
+    resolution. In detail, Maven should neither touch POMs, JARs nor metadata.
+  </description>
+
+  <dependencies>
+    <dependency>
+      <!-- no files related to this dependency should be touched during the test -->
+      <groupId>org.apache.maven.its.mng4348</groupId>
+      <artifactId>failed</artifactId>
+      <version>0.1-SNAPSHOT</version>
+      <scope>compile</scope>
+    </dependency>
+  </dependencies>
+
+  <build>
+    <plugins>
+      <plugin>
+        <!-- NOTE: This plugin does not require any kind of dependency resolution/collection
-->
+        <groupId>org.apache.maven.its.plugins</groupId>
+        <artifactId>maven-it-plugin-log-file</artifactId>
+        <version>2.1-SNAPSHOT</version>
+        <configuration>
+          <logFile>target/touch.txt</logFile>
+        </configuration>
+        <executions>
+          <execution>
+            <id>test</id>
+            <phase>validate</phase>
+            <goals>
+              <goal>reset</goal>
+            </goals>
+          </execution>
+        </executions>
+      </plugin>
+    </plugins>
+  </build>
+</project>

Propchange: maven/core-integration-testing/trunk/core-it-suite/src/test/resources/mng-4348/pom.xml
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: maven/core-integration-testing/trunk/core-it-suite/src/test/resources/mng-4348/pom.xml
------------------------------------------------------------------------------
    svn:keywords = Author Date Id Revision

Added: maven/core-integration-testing/trunk/core-it-suite/src/test/resources/mng-4348/settings-template.xml
URL: http://svn.apache.org/viewvc/maven/core-integration-testing/trunk/core-it-suite/src/test/resources/mng-4348/settings-template.xml?rev=812908&view=auto
==============================================================================
--- maven/core-integration-testing/trunk/core-it-suite/src/test/resources/mng-4348/settings-template.xml
(added)
+++ maven/core-integration-testing/trunk/core-it-suite/src/test/resources/mng-4348/settings-template.xml
Wed Sep  9 11:53:21 2009
@@ -0,0 +1,43 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<!--
+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.
+-->
+
+<settings>
+  <profiles>
+    <profile>
+      <id>maven-core-it-repo</id>
+      <repositories>
+        <repository>
+          <id>maven-core-it</id>
+          <url>http://localhost:@port@/</url>
+          <releases>
+            <enabled>false</enabled>
+          </releases>
+          <snapshots>
+            <checksumPolicy>ignore</checksumPolicy>
+          </snapshots>
+        </repository>
+      </repositories>
+    </profile>
+  </profiles>
+  <activeProfiles>
+    <activeProfile>maven-core-it-repo</activeProfile>
+  </activeProfiles>
+</settings>

Propchange: maven/core-integration-testing/trunk/core-it-suite/src/test/resources/mng-4348/settings-template.xml
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: maven/core-integration-testing/trunk/core-it-suite/src/test/resources/mng-4348/settings-template.xml
------------------------------------------------------------------------------
    svn:keywords = Author Date Id Revision



Mime
View raw message