From 40aa2f7a337f96bdb4f73932d9854c0aba942abd Mon Sep 17 00:00:00 2001 From: John Dennis Casey Date: Wed, 17 Jun 2009 20:48:24 +0000 Subject: [PATCH] [MNG-4207] Adding IT plugin that depends on log4j, and integration test to verify non-lightweight http wagon can shade commons-logging and log4j properly git-svn-id: https://svn.apache.org/repos/asf/maven/core-integration-testing/trunk@785790 13f79535-47bb-0310-9956-ffa450edef68 --- .../it/MavenITmng4207PluginWithLog4JTest.java | 54 +++++++++ .../src/test/resources/mng-4207/pom.xml | 64 ++++++++++ .../maven-it-plugin-log4j/pom.xml | 85 ++++++++++++++ .../apache/maven/plugin/coreit/ItMojo.java | 109 ++++++++++++++++++ its/core-it-support/core-it-plugins/pom.xml | 1 + 5 files changed, 313 insertions(+) create mode 100644 its/core-it-suite/src/test/java/org/apache/maven/it/MavenITmng4207PluginWithLog4JTest.java create mode 100644 its/core-it-suite/src/test/resources/mng-4207/pom.xml create mode 100644 its/core-it-support/core-it-plugins/maven-it-plugin-log4j/pom.xml create mode 100644 its/core-it-support/core-it-plugins/maven-it-plugin-log4j/src/main/java/org/apache/maven/plugin/coreit/ItMojo.java diff --git a/its/core-it-suite/src/test/java/org/apache/maven/it/MavenITmng4207PluginWithLog4JTest.java b/its/core-it-suite/src/test/java/org/apache/maven/it/MavenITmng4207PluginWithLog4JTest.java new file mode 100644 index 0000000000..9efd9cb358 --- /dev/null +++ b/its/core-it-suite/src/test/java/org/apache/maven/it/MavenITmng4207PluginWithLog4JTest.java @@ -0,0 +1,54 @@ +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; + +/** + * This is a test set for MNG-4207. + * + * @author John Casey + */ +public class MavenITmng4207PluginWithLog4JTest + extends AbstractMavenIntegrationTestCase +{ + + public MavenITmng4207PluginWithLog4JTest() + { + super( ALL_MAVEN_VERSIONS ); + } + + /** + * Test that exclusions defined on a dependency apply to its transitive dependencies as well. + */ + public void testit() + throws Exception + { + File testDir = ResourceExtractor.simpleExtractResources( getClass(), "/mng-4207" ); + + Verifier verifier = new Verifier( testDir.getAbsolutePath() ); + verifier.executeGoal( "initialize" ); + verifier.verifyErrorFreeLog(); + verifier.resetStreams(); + } + +} diff --git a/its/core-it-suite/src/test/resources/mng-4207/pom.xml b/its/core-it-suite/src/test/resources/mng-4207/pom.xml new file mode 100644 index 0000000000..7c4afb06d7 --- /dev/null +++ b/its/core-it-suite/src/test/resources/mng-4207/pom.xml @@ -0,0 +1,64 @@ + + + + + + 4.0.0 + + org.apache.maven.its.mngXXXX + test + 0.1 + jar + + + + + org.apache.maven.wagon + wagon-webdav-jackrabbit + 1.0-beta-5 + + + + + + org.apache.maven.its.plugins + maven-it-plugin-log4j + + test + test + 1.0 + + + + test + initialize + + it + + + + + + + diff --git a/its/core-it-support/core-it-plugins/maven-it-plugin-log4j/pom.xml b/its/core-it-support/core-it-plugins/maven-it-plugin-log4j/pom.xml new file mode 100644 index 0000000000..4e167b4896 --- /dev/null +++ b/its/core-it-support/core-it-plugins/maven-it-plugin-log4j/pom.xml @@ -0,0 +1,85 @@ + + + + + + 4.0.0 + + + maven-it-plugin-core-stubs + org.apache.maven.its.plugins + 2.1-SNAPSHOT + + + org.apache.maven.its.plugins + maven-it-plugin-log4j + maven-plugin + + Maven Integration Test Plugin :: Log4J Client + + A test plugin that uses log4j. + + 2008 + + + true + + + + + org.apache.maven + maven-plugin-api + 2.0 + + + org.apache.maven + maven-artifact + 2.0 + + + log4j + log4j + 1.2.14 + + + + + + + maven-assembly-plugin + 2.2-beta-4 + + + jar-with-deps + package + + single + + + + jar-with-dependencies + + + + + + + + diff --git a/its/core-it-support/core-it-plugins/maven-it-plugin-log4j/src/main/java/org/apache/maven/plugin/coreit/ItMojo.java b/its/core-it-support/core-it-plugins/maven-it-plugin-log4j/src/main/java/org/apache/maven/plugin/coreit/ItMojo.java new file mode 100644 index 0000000000..40791ec4f9 --- /dev/null +++ b/its/core-it-support/core-it-plugins/maven-it-plugin-log4j/src/main/java/org/apache/maven/plugin/coreit/ItMojo.java @@ -0,0 +1,109 @@ +package org.apache.maven.plugin.coreit; + +/* + * 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 java.util.*; + +import org.apache.maven.artifact.*; +import org.apache.maven.artifact.factory.*; +import org.apache.maven.artifact.resolver.*; +import org.apache.maven.artifact.repository.*; +import org.apache.maven.plugin.AbstractMojo; +import org.apache.maven.plugin.MojoExecutionException; + +/** + * Resolves an artifact and has an (unused) dependency on log4j. + * + * @goal it + * + * @author Benjamin Bentmann + * @version $Id: CleanMojo.java 698220 2008-09-23 16:18:19Z bentmann $ + */ +public class ItMojo + extends AbstractMojo +{ + + /** + * @component + */ + private ArtifactFactory artifactFactory; + + /** + * @component + */ + private ArtifactResolver artifactResolver; + + /** + * @parameter default-value="${localRepository}" + * @required + * @readonly + */ + private ArtifactRepository localRepository; + + /** + * @parameter default-value="${project.remoteArtifactRepositories}" + * @required + * @readonly + */ + private List remoteRepositories; + + /** + * @parameter default-value="test" + */ + private String groupId; + + /** + * @parameter default-value="test" + */ + private String artifactId; + + /** + * @parameter default-value="1.0" + */ + private String version; + + /** + * Runs this mojo. + * + * @throws MojoExecutionException If the output file could not be created. + * @throws MojoFailureException If the output file has not been set. + */ + public void execute() + throws MojoExecutionException + { + getLog().info( "[MAVEN-CORE-IT-LOG4J]" ); + + Artifact artifact = artifactFactory.createProjectArtifact( groupId, artifactId, version ); + + try + { + artifactResolver.resolve( artifact, remoteRepositories, localRepository ); + } + catch ( ArtifactNotFoundException e ) + { + getLog().info( "SUCCESS" ); + } + catch ( ArtifactResolutionException e ) + { + throw new MojoExecutionException( "Should have responded with ArtifactNotFoundException.", e ); + } + } + +} diff --git a/its/core-it-support/core-it-plugins/pom.xml b/its/core-it-support/core-it-plugins/pom.xml index 48c6e178b6..f93619dd76 100644 --- a/its/core-it-support/core-it-plugins/pom.xml +++ b/its/core-it-support/core-it-plugins/pom.xml @@ -59,6 +59,7 @@ under the License. maven-it-plugin-plexus-utils-11 maven-it-plugin-plexus-utils-new maven-it-plugin-plexus-component-api + maven-it-plugin-log4j