diff --git a/its/core-it-suite/src/test/java/org/apache/maven/it/IntegrationTestSuite.java b/its/core-it-suite/src/test/java/org/apache/maven/it/IntegrationTestSuite.java index 56d443768a..d82ae24632 100644 --- a/its/core-it-suite/src/test/java/org/apache/maven/it/IntegrationTestSuite.java +++ b/its/core-it-suite/src/test/java/org/apache/maven/it/IntegrationTestSuite.java @@ -90,6 +90,7 @@ public class IntegrationTestSuite suite.addTestSuite( MavenITmng4281PreferLocalSnapshotTest.class ); suite.addTestSuite( MavenITmng4279WagonProviderFailoverTest.class ); suite.addTestSuite( MavenITmng4276WrongTransitivePlexusUtilsTest.class ); + suite.addTestSuite( MavenITmng4275RelocationWarningTest.class ); suite.addTestSuite( MavenITmng4274PluginRealmArtifactsTest.class ); suite.addTestSuite( MavenITmng4273RestrictedCoreRealmAccessForPluginTest.class ); suite.addTestSuite( MavenITmng4270ArtifactHandlersFromPluginDepsTest.class ); diff --git a/its/core-it-suite/src/test/java/org/apache/maven/it/MavenITmng4275RelocationWarningTest.java b/its/core-it-suite/src/test/java/org/apache/maven/it/MavenITmng4275RelocationWarningTest.java new file mode 100644 index 0000000000..c2a27d383f --- /dev/null +++ b/its/core-it-suite/src/test/java/org/apache/maven/it/MavenITmng4275RelocationWarningTest.java @@ -0,0 +1,88 @@ +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.util.ResourceExtractor; + +import java.io.File; +import java.util.Iterator; +import java.util.List; + +/** + * This is a test set for MNG-4275. + * + * @author John Casey + */ +public class MavenITmng4275RelocationWarningTest + extends AbstractMavenIntegrationTestCase +{ + + public MavenITmng4275RelocationWarningTest() + { + super( "[2.0,2.0.9)(2.2.0,2.99.99]" ); + } + + public void testit() + throws Exception + { + File testDir = ResourceExtractor.simpleExtractResources( getClass(), "/mng-4275" ); + File depsDir = new File( testDir, "dependencies" ); + File projectDir = new File( testDir, "project" ); + + Verifier verifier = new Verifier( depsDir.getAbsolutePath() ); + + verifier.deleteArtifacts( "org.apache.maven.it.mng4275" ); + + verifier.executeGoal( "install" ); + + verifier.verifyErrorFreeLog(); + verifier.resetStreams(); + + // now, build the project that depends on the above. + verifier = new Verifier( projectDir.getAbsolutePath() ); + + verifier.executeGoal( "install" ); + + verifier.verifyErrorFreeLog(); + verifier.resetStreams(); + + List lines = verifier.loadFile( new File( projectDir, verifier.getLogFileName() ), false ); + boolean foundWarning = false; + for ( Iterator it = lines.iterator(); it.hasNext(); ) + { + String line = (String) it.next(); + + if ( foundWarning ) + { + assertTrue( + "Relocation target should have been logged right after warning.", + line.indexOf( "This artifact has been relocated to org.apache.maven.it.mng4275:relocated:1" ) > -1 ); + break; + } + else if ( line.startsWith( "[WARNING] While downloading org.apache.maven.it.mng4275:relocation:1" ) ) + { + foundWarning = true; + } + } + + assertTrue( "Relocation warning should haven been logged.", foundWarning ); + } + +} diff --git a/its/core-it-suite/src/test/resources/mng-4275/dependencies/pom.xml b/its/core-it-suite/src/test/resources/mng-4275/dependencies/pom.xml new file mode 100644 index 0000000000..56f5f308d3 --- /dev/null +++ b/its/core-it-suite/src/test/resources/mng-4275/dependencies/pom.xml @@ -0,0 +1,12 @@ + + + 4.0.0 + org.apache.maven.it.mng4275 + dependencies + 1 + pom + + relocation + relocated + + \ No newline at end of file diff --git a/its/core-it-suite/src/test/resources/mng-4275/dependencies/relocated/pom.xml b/its/core-it-suite/src/test/resources/mng-4275/dependencies/relocated/pom.xml new file mode 100644 index 0000000000..323af4355c --- /dev/null +++ b/its/core-it-suite/src/test/resources/mng-4275/dependencies/relocated/pom.xml @@ -0,0 +1,19 @@ + + + 4.0.0 + relocated + org.apache.maven.it.mng4275 + 1 + + relocated + + + + junit + junit + 3.8.1 + test + + + diff --git a/its/core-it-suite/src/test/resources/mng-4275/dependencies/relocated/src/main/java/org/apache/maven/it/mng4275/relocated/App.java b/its/core-it-suite/src/test/resources/mng-4275/dependencies/relocated/src/main/java/org/apache/maven/it/mng4275/relocated/App.java new file mode 100644 index 0000000000..27de41ada7 --- /dev/null +++ b/its/core-it-suite/src/test/resources/mng-4275/dependencies/relocated/src/main/java/org/apache/maven/it/mng4275/relocated/App.java @@ -0,0 +1,13 @@ +package org.apache.maven.it.mng4275.relocated; + +/** + * Hello world! + * + */ +public class App +{ + public static void main( String[] args ) + { + System.out.println( "Hello World: Relocated." ); + } +} diff --git a/its/core-it-suite/src/test/resources/mng-4275/dependencies/relocated/src/test/java/org/apache/maven/it/mng4275/relocated/AppTest.java b/its/core-it-suite/src/test/resources/mng-4275/dependencies/relocated/src/test/java/org/apache/maven/it/mng4275/relocated/AppTest.java new file mode 100644 index 0000000000..26b8669bf3 --- /dev/null +++ b/its/core-it-suite/src/test/resources/mng-4275/dependencies/relocated/src/test/java/org/apache/maven/it/mng4275/relocated/AppTest.java @@ -0,0 +1,38 @@ +package org.apache.maven.it.mng4275.relocated; + +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 ); + } +} diff --git a/its/core-it-suite/src/test/resources/mng-4275/dependencies/relocation/pom.xml b/its/core-it-suite/src/test/resources/mng-4275/dependencies/relocation/pom.xml new file mode 100644 index 0000000000..40dd96ce81 --- /dev/null +++ b/its/core-it-suite/src/test/resources/mng-4275/dependencies/relocation/pom.xml @@ -0,0 +1,20 @@ + + + 4.0.0 + org.apache.maven.it.mng4275 + 1 + relocation + + + true + + + + + org.apache.maven.it.mng4275 + relocated + 1 + Relocation Test! + + + diff --git a/its/core-it-suite/src/test/resources/mng-4275/project/pom.xml b/its/core-it-suite/src/test/resources/mng-4275/project/pom.xml new file mode 100644 index 0000000000..3291e3fcfb --- /dev/null +++ b/its/core-it-suite/src/test/resources/mng-4275/project/pom.xml @@ -0,0 +1,22 @@ + + 4.0.0 + org.apache.maven.it.mng4275 + project + jar + 1 + project + + + org.apache.maven.it.mng4275 + relocation + 1 + + + junit + junit + 3.8.1 + test + + + diff --git a/its/core-it-suite/src/test/resources/mng-4275/project/src/main/java/org/apache/maven/it/mng4275/project/App.java b/its/core-it-suite/src/test/resources/mng-4275/project/src/main/java/org/apache/maven/it/mng4275/project/App.java new file mode 100644 index 0000000000..520f441d2b --- /dev/null +++ b/its/core-it-suite/src/test/resources/mng-4275/project/src/main/java/org/apache/maven/it/mng4275/project/App.java @@ -0,0 +1,15 @@ +package org.apache.maven.it.mng4275.project; + +/** + * Hello world! + * + */ +public class App +{ + public static void main( String[] args ) + { + System.out.println( "Hello World!" ); + + org.apache.maven.it.mng4275.relocated.App.main( args ); + } +} diff --git a/its/core-it-suite/src/test/resources/mng-4275/project/src/test/java/org/apache/maven/it/mng4275/project/AppTest.java b/its/core-it-suite/src/test/resources/mng-4275/project/src/test/java/org/apache/maven/it/mng4275/project/AppTest.java new file mode 100644 index 0000000000..a6e32d856f --- /dev/null +++ b/its/core-it-suite/src/test/resources/mng-4275/project/src/test/java/org/apache/maven/it/mng4275/project/AppTest.java @@ -0,0 +1,38 @@ +package org.apache.maven.it.mng4275.project; + +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() + { + App.main( new String[]{} ); + } +}