You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@maven.apache.org by be...@apache.org on 2009/08/11 15:57:53 UTC

svn commit: r803127 - in /maven/core-integration-testing/trunk/core-it-suite/src/test: java/org/apache/maven/it/ resources/bootstrap/ resources/mng-4291/

Author: bentmann
Date: Tue Aug 11 13:57:53 2009
New Revision: 803127

URL: http://svn.apache.org/viewvc?rev=803127&view=rev
Log:
[MNG-4291] [regression] @requiresOnline mojo annotation is ignored

o Added IT

Added:
    maven/core-integration-testing/trunk/core-it-suite/src/test/java/org/apache/maven/it/MavenITmng4291MojoRequiresOnlineModeTest.java   (with props)
    maven/core-integration-testing/trunk/core-it-suite/src/test/resources/mng-4291/
    maven/core-integration-testing/trunk/core-it-suite/src/test/resources/mng-4291/pom.xml   (with props)
Modified:
    maven/core-integration-testing/trunk/core-it-suite/src/test/java/org/apache/maven/it/IntegrationTestSuite.java
    maven/core-integration-testing/trunk/core-it-suite/src/test/resources/bootstrap/pom.xml

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=803127&r1=803126&r2=803127&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 Tue Aug 11 13:57:53 2009
@@ -86,6 +86,7 @@
         // suite.addTestSuite( MavenIT0109ReleaseUpdateTest.class );
         // suite.addTestSuite( MavenIT0108SnapshotUpdateTest.class ); -- MNG-3137
 
+        suite.addTestSuite( MavenITmng4291MojoRequiresOnlineModeTest.class );
         suite.addTestSuite( MavenITmng4283ParentPomPackagingTest.class );
         suite.addTestSuite( MavenITmng4281PreferLocalSnapshotTest.class );
         suite.addTestSuite( MavenITmng4279WagonProviderFailoverTest.class );

Added: maven/core-integration-testing/trunk/core-it-suite/src/test/java/org/apache/maven/it/MavenITmng4291MojoRequiresOnlineModeTest.java
URL: http://svn.apache.org/viewvc/maven/core-integration-testing/trunk/core-it-suite/src/test/java/org/apache/maven/it/MavenITmng4291MojoRequiresOnlineModeTest.java?rev=803127&view=auto
==============================================================================
--- maven/core-integration-testing/trunk/core-it-suite/src/test/java/org/apache/maven/it/MavenITmng4291MojoRequiresOnlineModeTest.java (added)
+++ maven/core-integration-testing/trunk/core-it-suite/src/test/java/org/apache/maven/it/MavenITmng4291MojoRequiresOnlineModeTest.java Tue Aug 11 13:57:53 2009
@@ -0,0 +1,93 @@
+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.util.Properties;
+
+/**
+ * This is a test set for <a href="http://jira.codehaus.org/browse/MNG-4291">MNG-4291</a>.
+ * 
+ * @author Benjamin Bentmann
+ */
+public class MavenITmng4291MojoRequiresOnlineModeTest
+    extends AbstractMavenIntegrationTestCase
+{
+
+    public MavenITmng4291MojoRequiresOnlineModeTest()
+    {
+        super( ALL_MAVEN_VERSIONS );
+    }
+
+    /**
+     * Test that the mojo annotation @requiresOnline is recognized. For a direct mojo invocation, this means to fail
+     * when Maven is in offline mode but the mojo requires online model.
+     */
+    public void testitDirectInvocation()
+        throws Exception
+    {
+        File testDir = ResourceExtractor.simpleExtractResources( getClass(), "/mng-4291" );
+
+        Verifier verifier = new Verifier( testDir.getAbsolutePath() );
+        verifier.setAutoclean( false );
+        verifier.deleteDirectory( "target" );
+        verifier.setLogFileName( "log-direct.txt" );
+        verifier.getCliOptions().add( "--offline" );
+        try
+        {
+            verifier.executeGoal( "org.apache.maven.its.plugins:maven-it-plugin-online:2.1-SNAPSHOT:touch" );
+            verifier.verifyErrorFreeLog();
+            fail( "Invalid packaging of parent POM did not fail the build." );
+        }
+        catch ( VerificationException e )
+        {
+            // expected
+        }
+        finally
+        {
+            verifier.resetStreams();
+        }
+    }
+
+    /**
+     * Test that the mojo annotation @requiresOnline is recognized. For a mojo invocation bound to a lifecycle phase,
+     * this means to skip the mojo when Maven is in offline mode but the mojo requires online model.
+     */
+    public void testitLifecycleInvocation()
+        throws Exception
+    {
+        File testDir = ResourceExtractor.simpleExtractResources( getClass(), "/mng-4291" );
+
+        Verifier verifier = new Verifier( testDir.getAbsolutePath() );
+        verifier.setAutoclean( false );
+        verifier.deleteDirectory( "target" );
+        verifier.setLogFileName( "log-lifecycle.txt" );
+        verifier.getCliOptions().add( "--offline" );
+        verifier.executeGoal( "validate" );
+        verifier.verifyErrorFreeLog();
+        verifier.resetStreams();
+
+        verifier.assertFileNotPresent( "target/touch.txt" );
+    }
+
+}

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

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

Modified: maven/core-integration-testing/trunk/core-it-suite/src/test/resources/bootstrap/pom.xml
URL: http://svn.apache.org/viewvc/maven/core-integration-testing/trunk/core-it-suite/src/test/resources/bootstrap/pom.xml?rev=803127&r1=803126&r2=803127&view=diff
==============================================================================
--- maven/core-integration-testing/trunk/core-it-suite/src/test/resources/bootstrap/pom.xml (original)
+++ maven/core-integration-testing/trunk/core-it-suite/src/test/resources/bootstrap/pom.xml Tue Aug 11 13:57:53 2009
@@ -153,6 +153,12 @@
     </dependency>
     <dependency>
       <groupId>org.apache.maven.its.plugins</groupId>
+      <artifactId>maven-it-plugin-online</artifactId>
+      <version>${itPluginVersion}</version>
+      <scope>runtime</scope>
+    </dependency>
+    <dependency>
+      <groupId>org.apache.maven.its.plugins</groupId>
       <artifactId>maven-it-plugin-packaging</artifactId>
       <version>${itPluginVersion}</version>
       <scope>runtime</scope>

Added: maven/core-integration-testing/trunk/core-it-suite/src/test/resources/mng-4291/pom.xml
URL: http://svn.apache.org/viewvc/maven/core-integration-testing/trunk/core-it-suite/src/test/resources/mng-4291/pom.xml?rev=803127&view=auto
==============================================================================
--- maven/core-integration-testing/trunk/core-it-suite/src/test/resources/mng-4291/pom.xml (added)
+++ maven/core-integration-testing/trunk/core-it-suite/src/test/resources/mng-4291/pom.xml Tue Aug 11 13:57:53 2009
@@ -0,0 +1,53 @@
+<?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.mng4291</groupId>
+  <artifactId>test</artifactId>
+  <version>0.1</version>
+  <packaging>jar</packaging>
+
+  <name>Maven Integration Test :: MNG-4291</name>
+  <description>
+    Test that the mojo annotation @requiresOnline is recognized.
+  </description>
+
+  <build>
+    <plugins>
+      <plugin>
+        <groupId>org.apache.maven.its.plugins</groupId>
+        <artifactId>maven-it-plugin-online</artifactId>
+        <version>2.1-SNAPSHOT</version>
+        <executions>
+          <execution>
+            <id>test</id>
+            <phase>validate</phase>
+            <goals>
+              <goal>touch</goal>
+            </goals>
+          </execution>
+        </executions>
+      </plugin>
+    </plugins>
+  </build>
+</project>

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

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