From 8742ae6f863c36964d67f5b013e7dbfac781043a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Herv=C3=A9=20Boutemy?= Date: Thu, 30 May 2013 03:07:13 +0200 Subject: [PATCH] [MNG-5482] added IT to check that missing Sonatype Aether classes are detected and give a hint to AetherClassNotFound Wiki article --- .../apache/maven/it/IntegrationTestSuite.java | 1 + .../it/MavenITmng5482AetherNotFoundTest.java | 113 ++++++++++++++++++ .../mng-5482/plugin-dependency/pom.xml | 26 ++++ .../resources/mng-5482/plugin-site/pom.xml | 26 ++++ .../resources/mng-5482/report-mpir/pom.xml | 42 +++++++ its/pom.xml | 28 +++++ 6 files changed, 236 insertions(+) create mode 100644 its/core-it-suite/src/test/java/org/apache/maven/it/MavenITmng5482AetherNotFoundTest.java create mode 100644 its/core-it-suite/src/test/resources/mng-5482/plugin-dependency/pom.xml create mode 100644 its/core-it-suite/src/test/resources/mng-5482/plugin-site/pom.xml create mode 100644 its/core-it-suite/src/test/resources/mng-5482/report-mpir/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 a06066b21b..bacc532902 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 @@ -109,6 +109,7 @@ public class IntegrationTestSuite //suite.addTestSuite( MavenITmng5208EventSpyParallelTest.class ); + suite.addTestSuite( MavenITmng5482AetherNotFoundTest.class ); suite.addTestSuite( MavenITmng5445LegacyStringSearchModelInterpolatorTest.class ); suite.addTestSuite( MavenITmng5387ArtifactReplacementPlugin.class ); suite.addTestSuite( MavenITmng5382Jsr330Plugin.class ); diff --git a/its/core-it-suite/src/test/java/org/apache/maven/it/MavenITmng5482AetherNotFoundTest.java b/its/core-it-suite/src/test/java/org/apache/maven/it/MavenITmng5482AetherNotFoundTest.java new file mode 100644 index 0000000000..e1f15fe955 --- /dev/null +++ b/its/core-it-suite/src/test/java/org/apache/maven/it/MavenITmng5482AetherNotFoundTest.java @@ -0,0 +1,113 @@ +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.io.IOException; +import java.util.List; +import java.util.regex.Pattern; + +/** + * This is a test set for MNG-5482. + * + * It checks that plugins and reports causing errors because of Aether change from Sonatype to Eclipse + * get a dedicated message to explain solution to end-users + * + * @author hboutemy + */ +public class MavenITmng5482AetherNotFoundTest + extends AbstractMavenIntegrationTestCase +{ + + public MavenITmng5482AetherNotFoundTest() + { + super( "[3.1-A,)" ); + } + + public void testPluginDependency() + throws IOException, VerificationException + { + check( "plugin-dependency" ); + } + + public void testPluginSite() + throws IOException, VerificationException + { + check( "plugin-site" ); + } + + /*public void testReportMpir() + throws IOException, VerificationException + { + check( "report-mpir" ); + }*/ + + public void check( String dir ) + throws IOException, VerificationException + { + File testDir = ResourceExtractor.simpleExtractResources( getClass(), "/mng-5482/" + dir ); + + Verifier verifier = newVerifier( testDir.getAbsolutePath() ); + verifier.setAutoclean( false ); + + try + { + verifier.executeGoal( "validate" ); + + fail( "should throw an error during execution." ); + } + catch ( VerificationException e ) + { + // expected...it'd be nice if we could get the specifics of the exception right here... + } + finally + { + verifier.resetStreams(); + } + + List lines = verifier.loadFile( new File( testDir, "log.txt" ), false ); + + int msg = indexOf( lines, "Caused by: java.lang.ClassNotFoundException: org.sonatype.aether.+" ); + assertTrue( "ClassNotFoundException message was not found in output.", msg >= 0 ); + + int url = indexOf( lines, ".*http://cwiki.apache.org/confluence/display/MAVEN/AetherClassNotFound.*" ); + assertTrue( "Url to ClassNotFoundAether was not found in output.", url >= 0 ); + } + + private int indexOf( List logLines, String regex ) + { + Pattern pattern = Pattern.compile( regex ); + + for ( int i = 0; i < logLines.size(); i++ ) + { + String logLine = logLines.get( i ); + + if ( pattern.matcher( logLine ).matches() ) + { + return i; + } + } + + return -1; + } + +} diff --git a/its/core-it-suite/src/test/resources/mng-5482/plugin-dependency/pom.xml b/its/core-it-suite/src/test/resources/mng-5482/plugin-dependency/pom.xml new file mode 100644 index 0000000000..405f507bac --- /dev/null +++ b/its/core-it-suite/src/test/resources/mng-5482/plugin-dependency/pom.xml @@ -0,0 +1,26 @@ + + + 4.0.0 + org.apache.maven.its.mng5482 + mng-5482-plugin-site + 1 + pom + + + + + maven-dependency-plugin + 2.7 + + + trigger-error + validate + + tree + + + + + + + diff --git a/its/core-it-suite/src/test/resources/mng-5482/plugin-site/pom.xml b/its/core-it-suite/src/test/resources/mng-5482/plugin-site/pom.xml new file mode 100644 index 0000000000..84485d1141 --- /dev/null +++ b/its/core-it-suite/src/test/resources/mng-5482/plugin-site/pom.xml @@ -0,0 +1,26 @@ + + + 4.0.0 + org.apache.maven.its.mng5482 + mng-5482-plugin-site + 1 + pom + + + + + maven-site-plugin + 3.2 + + + trigger-error + validate + + site + + + + + + + diff --git a/its/core-it-suite/src/test/resources/mng-5482/report-mpir/pom.xml b/its/core-it-suite/src/test/resources/mng-5482/report-mpir/pom.xml new file mode 100644 index 0000000000..f4a3a0c055 --- /dev/null +++ b/its/core-it-suite/src/test/resources/mng-5482/report-mpir/pom.xml @@ -0,0 +1,42 @@ + + + 4.0.0 + org.apache.maven.its.mng5482 + mng-5482-plugin-site + 1 + pom + + + + + maven-site-plugin + 3.3 + + + trigger-error + validate + + site + + + + + + + + + + + maven-project-info-reports-plugin + 2.6 + + + + dependencies + + + + + + + diff --git a/its/pom.xml b/its/pom.xml index 72c51382af..9df8f21be8 100644 --- a/its/pom.xml +++ b/its/pom.xml @@ -103,4 +103,32 @@ under the License. + + + + reporting + + + + org.apache.maven.plugins + maven-project-info-reports-plugin + 2.7 + + + org.apache.maven.plugins + maven-jxr-plugin + + + default + + jxr + test-jxr + + + + + + + +