From 8bb7612e0d6268db51370c178892b140737eaec2 Mon Sep 17 00:00:00 2001 From: Benjamin Bentmann Date: Sun, 28 Mar 2010 15:03:41 +0000 Subject: [PATCH] [MNG-1701] Validate that a plugin is not configured twice in the pom o Added IT git-svn-id: https://svn.apache.org/repos/asf/maven/core-integration-testing/trunk@928424 13f79535-47bb-0310-9956-ffa450edef68 --- .../apache/maven/it/IntegrationTestSuite.java | 1 + .../it/MavenITmng1701DuplicatePluginTest.java | 72 +++++++++++++++++++ .../src/test/resources/mng-1701/pom.xml | 49 +++++++++++++ .../apache/maven/its/mng4403/b/0.1/b-0.1.pom | 16 +++++ 4 files changed, 138 insertions(+) create mode 100644 its/core-it-suite/src/test/java/org/apache/maven/it/MavenITmng1701DuplicatePluginTest.java create mode 100644 its/core-it-suite/src/test/resources/mng-1701/pom.xml 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 30b9e5c083..8fe8d5b4eb 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 @@ -436,6 +436,7 @@ public static Test suite() suite.addTestSuite( MavenITmng1908LegacySnapshotUpdateTest.class ); suite.addTestSuite( MavenITmng1830ShowVersionTest.class ); suite.addTestSuite( MavenITmng1703PluginMgmtDepInheritanceTest.class ); + suite.addTestSuite( MavenITmng1701DuplicatePluginTest.class ); suite.addTestSuite( MavenITmng1493NonStandardModulePomNamesTest.class ); suite.addTestSuite( MavenITmng1491ReactorArtifactIdCollisionTest.class ); suite.addTestSuite( MavenITmng1415QuotedSystemPropertiesTest.class ); diff --git a/its/core-it-suite/src/test/java/org/apache/maven/it/MavenITmng1701DuplicatePluginTest.java b/its/core-it-suite/src/test/java/org/apache/maven/it/MavenITmng1701DuplicatePluginTest.java new file mode 100644 index 0000000000..71f9994d92 --- /dev/null +++ b/its/core-it-suite/src/test/java/org/apache/maven/it/MavenITmng1701DuplicatePluginTest.java @@ -0,0 +1,72 @@ +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-1701. + * + * @author Benjamin Bentmann + */ +public class MavenITmng1701DuplicatePluginTest + extends AbstractMavenIntegrationTestCase +{ + + public MavenITmng1701DuplicatePluginTest() + { + super( "[3.0-alpha-8,)" ); + } + + /** + * Verify that duplicate plugin declarations cause a warning. + */ + public void testit() + throws Exception + { + File testDir = ResourceExtractor.simpleExtractResources( getClass(), "/mng-1701" ); + + Verifier verifier = new Verifier( testDir.getAbsolutePath() ); + verifier.setAutoclean( false ); + verifier.executeGoal( "validate" ); + verifier.verifyErrorFreeLog(); + verifier.resetStreams(); + + List lines = verifier.loadLines( verifier.getLogFileName(), "UTF-8" ); + boolean foundWarning = false; + for ( Iterator it = lines.iterator(); it.hasNext(); ) + { + String line = (String) it.next(); + + if ( line.startsWith( "[WARNING]" ) && + line.indexOf( "duplicate declaration of plugin org.apache.maven.its.plugins:maven-it-plugin-expression" ) > 0 ) + { + foundWarning = true; + } + } + + assertTrue( "Duplicate plugin warning wasn't generated.", foundWarning ); + } + +} diff --git a/its/core-it-suite/src/test/resources/mng-1701/pom.xml b/its/core-it-suite/src/test/resources/mng-1701/pom.xml new file mode 100644 index 0000000000..409e669aee --- /dev/null +++ b/its/core-it-suite/src/test/resources/mng-1701/pom.xml @@ -0,0 +1,49 @@ + + + + + + 4.0.0 + + org.apache.maven.its.mng1701 + test + 1.0 + pom + + Maven Integration Test :: MNG-1701 + + Verify that duplicate plugin declarations cause a warning/error. + + + + + + org.apache.maven.its.plugins + maven-it-plugin-expression + 2.1-SNAPSHOT + + + org.apache.maven.its.plugins + maven-it-plugin-expression + 2.1-SNAPSHOT + + + + diff --git a/its/core-it-suite/src/test/resources/mng-4403/repo/org/apache/maven/its/mng4403/b/0.1/b-0.1.pom b/its/core-it-suite/src/test/resources/mng-4403/repo/org/apache/maven/its/mng4403/b/0.1/b-0.1.pom index 5446930657..b5bca9b8b7 100644 --- a/its/core-it-suite/src/test/resources/mng-4403/repo/org/apache/maven/its/mng4403/b/0.1/b-0.1.pom +++ b/its/core-it-suite/src/test/resources/mng-4403/repo/org/apache/maven/its/mng4403/b/0.1/b-0.1.pom @@ -137,6 +137,22 @@ under the License. ${missing.property} + + org.apache.maven.its.mng4405 + a + + + + org.apache.maven.its.mng1701 + b + 1.0 + + + + org.apache.maven.its.mng1701 + b + 1.0 +