From 6921cebb9ce15553bfabc7159977a6910fd6c720 Mon Sep 17 00:00:00 2001 From: Brett Porter Date: Thu, 29 Jan 2009 04:15:02 +0000 Subject: [PATCH] [MNG-3920] add integration test for uses of plexus-component-api in plugins git-svn-id: https://svn.apache.org/repos/asf/maven/core-integration-testing/trunk@738752 13f79535-47bb-0310-9956-ffa450edef68 --- .../MavenITmng3920PlexusComponentApiTest.java | 55 ++++++++++++++++++ .../src/test/resources/bootstrap/pom.xml | 6 ++ .../src/test/resources/mng-3920/pom.xml | 24 ++++++++ .../pom.xml | 55 ++++++++++++++++++ .../maven/its/plugins/VelocityMojo.java | 56 +++++++++++++++++++ .../src/main/resources/template.vm | 1 + its/core-it-support/core-it-plugins/pom.xml | 1 + 7 files changed, 198 insertions(+) create mode 100644 its/core-it-suite/src/test/java/org/apache/maven/it/MavenITmng3920PlexusComponentApiTest.java create mode 100644 its/core-it-suite/src/test/resources/mng-3920/pom.xml create mode 100644 its/core-it-support/core-it-plugins/maven-it-plugin-plexus-component-api/pom.xml create mode 100644 its/core-it-support/core-it-plugins/maven-it-plugin-plexus-component-api/src/main/java/org/apache/maven/its/plugins/VelocityMojo.java create mode 100644 its/core-it-support/core-it-plugins/maven-it-plugin-plexus-component-api/src/main/resources/template.vm diff --git a/its/core-it-suite/src/test/java/org/apache/maven/it/MavenITmng3920PlexusComponentApiTest.java b/its/core-it-suite/src/test/java/org/apache/maven/it/MavenITmng3920PlexusComponentApiTest.java new file mode 100644 index 0000000000..30289d4c07 --- /dev/null +++ b/its/core-it-suite/src/test/java/org/apache/maven/it/MavenITmng3920PlexusComponentApiTest.java @@ -0,0 +1,55 @@ +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 java.io.File; + +import org.apache.maven.it.util.FileUtils; +import org.apache.maven.it.util.ResourceExtractor; + +/** + * This is a test set for MNG-3920. The first test verifies that + * a plugin using plexus-component-api in a Plexus component does not cause linkage errors. + */ +public class MavenITmng3920PlexusComponentApiTest + extends AbstractMavenIntegrationTestCase +{ + public MavenITmng3920PlexusComponentApiTest() + { + super( "(2.0.10,2.1.0-M1),(2.1.0-M1,)" ); // only test in 2.0.11+, and not in 2.1.0-M1 + } + + public void testitMNG3920() + throws Exception + { + File dir = + ResourceExtractor.simpleExtractResources( getClass(), "/mng-3920" ); + + Verifier verifier; + + verifier = new Verifier( dir.getAbsolutePath() ); + + verifier.executeGoal( "validate" ); + + verifier.verifyErrorFreeLog(); + + verifier.resetStreams(); + } +} diff --git a/its/core-it-suite/src/test/resources/bootstrap/pom.xml b/its/core-it-suite/src/test/resources/bootstrap/pom.xml index 1558b576c8..f9e8cb6e32 100644 --- a/its/core-it-suite/src/test/resources/bootstrap/pom.xml +++ b/its/core-it-suite/src/test/resources/bootstrap/pom.xml @@ -183,6 +183,12 @@ under the License. ${itPluginVersion} runtime + + org.apache.maven.its.plugins + maven-it-plugin-plexus-component-api + ${itPluginVersion} + runtime + org.apache.maven.its.plugins maven-it-plugin-project-interpolation diff --git a/its/core-it-suite/src/test/resources/mng-3920/pom.xml b/its/core-it-suite/src/test/resources/mng-3920/pom.xml new file mode 100644 index 0000000000..f963d7c439 --- /dev/null +++ b/its/core-it-suite/src/test/resources/mng-3920/pom.xml @@ -0,0 +1,24 @@ + + 4.0.0 + org.apache.maven.its.mng3920 + child + jar + 1.0-SNAPSHOT + + + + org.apache.maven.its.plugins + maven-it-plugin-plexus-component-api + 2.1-SNAPSHOT + + + + velocity + + + + + + + diff --git a/its/core-it-support/core-it-plugins/maven-it-plugin-plexus-component-api/pom.xml b/its/core-it-support/core-it-plugins/maven-it-plugin-plexus-component-api/pom.xml new file mode 100644 index 0000000000..76d1c5e9de --- /dev/null +++ b/its/core-it-support/core-it-plugins/maven-it-plugin-plexus-component-api/pom.xml @@ -0,0 +1,55 @@ + + + + + + 4.0.0 + + + maven-it-plugins + org.apache.maven.its.plugins + 2.1-SNAPSHOT + + + maven-it-plugin-plexus-component-api + maven-plugin + + Maven Integration Test Plugin :: Plexus Component API + + + + + org.codehaus.plexus + plexus-velocity + 1.1.7 + + + org.apache.maven + maven-plugin-api + 2.0 + + + junit + junit + 3.8.1 + test + + + diff --git a/its/core-it-support/core-it-plugins/maven-it-plugin-plexus-component-api/src/main/java/org/apache/maven/its/plugins/VelocityMojo.java b/its/core-it-support/core-it-plugins/maven-it-plugin-plexus-component-api/src/main/java/org/apache/maven/its/plugins/VelocityMojo.java new file mode 100644 index 0000000000..a0f10c2597 --- /dev/null +++ b/its/core-it-support/core-it-plugins/maven-it-plugin-plexus-component-api/src/main/java/org/apache/maven/its/plugins/VelocityMojo.java @@ -0,0 +1,56 @@ +package org.apache.maven.its.plugins; + +/* + * 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.plugin.AbstractMojo; +import org.apache.maven.plugin.MojoExecutionException; +import org.apache.maven.plugin.MojoFailureException; +import org.codehaus.plexus.velocity.VelocityComponent; + +/** + * @goal velocity + * @phase validate + */ +public class VelocityMojo + extends AbstractMojo +{ + /** + * @component + */ + protected VelocityComponent velocityComponent; + + public void execute() + throws MojoExecutionException, MojoFailureException + { + // velocityComponent should not be null + velocityComponent.getEngine(); + + try + { + // velocityComponent engine should not be null + // this is the real test to check that we got the right Initializable interface in both Plexus and the component + velocityComponent.getEngine().getTemplate( "/template.vm" ); + } + catch ( Exception e ) + { + throw new MojoExecutionException( e.getMessage(), e ); + } + } +} diff --git a/its/core-it-support/core-it-plugins/maven-it-plugin-plexus-component-api/src/main/resources/template.vm b/its/core-it-support/core-it-plugins/maven-it-plugin-plexus-component-api/src/main/resources/template.vm new file mode 100644 index 0000000000..8ab686eafe --- /dev/null +++ b/its/core-it-support/core-it-plugins/maven-it-plugin-plexus-component-api/src/main/resources/template.vm @@ -0,0 +1 @@ +Hello, World! diff --git a/its/core-it-support/core-it-plugins/pom.xml b/its/core-it-support/core-it-plugins/pom.xml index a3cc167522..e69b83b7dc 100644 --- a/its/core-it-support/core-it-plugins/pom.xml +++ b/its/core-it-support/core-it-plugins/pom.xml @@ -57,6 +57,7 @@ under the License. maven-it-plugin-all maven-it-plugin-plexus-utils-11 maven-it-plugin-plexus-utils-new + maven-it-plugin-plexus-component-api