more unit tests for error reporting on plugins-as-extensions.

git-svn-id: https://svn.apache.org/repos/asf/maven/components/trunk@612895 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
John Dennis Casey 2008-01-17 18:01:29 +00:00
parent e5c11f67c1
commit 4bcfd7c5a5
14 changed files with 256 additions and 49 deletions

View File

@ -123,7 +123,7 @@ public privileged aspect ExtensionErrorReporterAspect
&& call( ExtensionManagerException.new( .., ArtifactNotFoundException ) )
&& args( .., cause )
{
getReporter().reportMissingArtifactWhileAddingExtensionPlugin( plugin, originModel, remoteRepos, request, cause );
getReporter().reportExtensionPluginArtifactNotFound( plugin, originModel, remoteRepos, request, cause );
}
before( Plugin plugin, Model originModel, List remoteRepos, MavenExecutionRequest request, ArtifactResolutionException cause ):

View File

@ -4,6 +4,7 @@ import org.apache.maven.NoGoalsSpecifiedException;
import org.apache.maven.ProjectCycleException;
import org.apache.maven.artifact.Artifact;
import org.apache.maven.artifact.metadata.ArtifactMetadataRetrievalException;
import org.apache.maven.artifact.resolver.AbstractArtifactResolutionException;
import org.apache.maven.artifact.resolver.ArtifactNotFoundException;
import org.apache.maven.artifact.resolver.ArtifactResolutionException;
import org.apache.maven.artifact.resolver.ArtifactResolutionResult;
@ -26,7 +27,6 @@ import org.apache.maven.plugin.MojoFailureException;
import org.apache.maven.plugin.PluginConfigurationException;
import org.apache.maven.plugin.PluginExecutionException;
import org.apache.maven.plugin.PluginManagerException;
import org.apache.maven.plugin.PluginNotFoundException;
import org.apache.maven.plugin.PluginParameterException;
import org.apache.maven.plugin.descriptor.Parameter;
import org.apache.maven.plugin.loader.PluginLoaderException;
@ -81,7 +81,7 @@ public interface CoreErrorReporter
void reportErrorSearchingforCompatibleExtensionPluginVersion( Plugin plugin, Model originModel, List remoteRepos, MavenExecutionRequest request, String requiredMavenVersion, String currentMavenVersion, ArtifactMetadataRetrievalException cause );
void reportExtensionPluginArtifactNotFound( Plugin plugin, Model originModel, List remoteRepos, MavenExecutionRequest request, PluginNotFoundException cause );
void reportExtensionPluginArtifactNotFound( Plugin plugin, Model originModel, List remoteRepos, MavenExecutionRequest request, AbstractArtifactResolutionException cause );
void reportExtensionPluginVersionNotFound( Plugin plugin, Model originModel, List remoteRepos, MavenExecutionRequest request, PluginVersionNotFoundException cause );
@ -97,8 +97,6 @@ public interface CoreErrorReporter
void reportLifecycleSpecErrorWhileValidatingTask( String task, MavenSession session, MavenProject rootProject, LifecycleSpecificationException cause );
void reportMissingArtifactWhileAddingExtensionPlugin( Plugin plugin, Model originModel, List remoteRepos, MavenExecutionRequest request, ArtifactNotFoundException cause );
void reportMissingPluginDescriptor( MojoBinding binding, MavenProject project, LifecycleExecutionException err );
void reportMissingRequiredMojoParameter( MojoBinding binding, MavenProject project, List invalidParameters, PluginParameterException err );

View File

@ -31,7 +31,6 @@ import org.apache.maven.plugin.MojoFailureException;
import org.apache.maven.plugin.PluginConfigurationException;
import org.apache.maven.plugin.PluginExecutionException;
import org.apache.maven.plugin.PluginManagerException;
import org.apache.maven.plugin.PluginNotFoundException;
import org.apache.maven.plugin.PluginParameterException;
import org.apache.maven.plugin.PluginParameterExpressionEvaluator;
import org.apache.maven.plugin.descriptor.Parameter;
@ -1170,34 +1169,6 @@ public class DefaultCoreErrorReporter
writer.write( NEWLINE );
}
public void reportMissingArtifactWhileAddingExtensionPlugin( Plugin plugin,
Model originModel,
List remoteRepos,
MavenExecutionRequest request,
ArtifactNotFoundException cause )
{
StringWriter writer = new StringWriter();
writer.write( NEWLINE );
writer.write( "One or more dependency artifacts are missing for a plugin used by your project as a build extension." );
writer.write( NEWLINE );
writer.write( NEWLINE );
writer.write( "Project:" );
writeProjectCoordinate( originModel, null, writer );
writer.write( NEWLINE );
writer.write( NEWLINE );
writer.write( "Plugin (used as an extension):" );
writePluginInfo( plugin, writer );
writer.write( NEWLINE );
writer.write( NEWLINE );
writeArtifactError( cause, writer );
addTips( CoreErrorTips.getErrorResolvingExtensionPluginArtifactsTips( plugin, originModel, cause ),
writer );
registerBuildError( cause, writer.toString(), cause.getCause() );
}
public void reportUnresolvableArtifactWhileAddingExtensionPlugin( Plugin plugin,
Model originModel,
List remoteRepos,
@ -1230,7 +1201,7 @@ public class DefaultCoreErrorReporter
Model originModel,
List remoteRepos,
MavenExecutionRequest request,
PluginNotFoundException cause )
AbstractArtifactResolutionException cause )
{
StringWriter writer = new StringWriter();

View File

@ -276,6 +276,11 @@ public class DefaultPluginVersionManager
version = artifactVersion;
}
if ( version != null )
{
getLogger().info( "Using version: " + version + " of plugin: " + groupId + ":" + artifactId );
}
return version;
}

View File

@ -0,0 +1,55 @@
<?xml version='1.0' encoding='UTF-8'?>
<project>
<modelVersion>4.0.0</modelVersion>
<groupId>org.apache.maven.errortest</groupId>
<artifactId>testReportExtensionPluginArtifactNotFound-maven-plugin</artifactId>
<packaging>maven-plugin</packaging>
<version>1</version>
<dependencies>
<dependency>
<groupId>org.apache.maven</groupId>
<artifactId>maven-plugin-api</artifactId>
<version>2.0</version>
</dependency>
<dependency>
<groupId>nothing</groupId>
<artifactId>nothing</artifactId>
<version>1</version>
</dependency>
</dependencies>
<build>
<pluginManagement>
<plugins>
<plugin>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.3.1</version>
</plugin>
<plugin>
<artifactId>maven-deploy-plugin</artifactId>
<version>2.3</version>
</plugin>
<plugin>
<artifactId>maven-install-plugin</artifactId>
<version>2.2</version>
</plugin>
<plugin>
<artifactId>maven-resources-plugin</artifactId>
<version>2.2</version>
</plugin>
<plugin>
<artifactId>maven-jar-plugin</artifactId>
<version>2.1</version>
</plugin>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<version>2.0.2</version>
</plugin>
<plugin>
<artifactId>maven-plugin-plugin</artifactId>
<version>2.3</version>
</plugin>
</plugins>
</pluginManagement>
</build>
</project>

View File

@ -0,0 +1,37 @@
<!--
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.
-->
<project>
<modelVersion>4.0.0</modelVersion>
<groupId>org.apache.maven</groupId>
<artifactId>testReportExtensionPluginArtifactNotFound</artifactId>
<version>1</version>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.errortest</groupId>
<artifactId>testReportExtensionPluginArtifactNotFound-maven-plugin</artifactId>
<version>1</version>
<extensions>true</extensions>
</plugin>
</plugins>
</build>
</project>

View File

@ -1,4 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?><project>
<?xml version='1.0' encoding='UTF-8'?>
<project>
<modelVersion>4.0.0</modelVersion>
<groupId>org.apache.maven.errortest</groupId>
<artifactId>testReportExtensionPluginVersionNotFound-maven-plugin</artifactId>
@ -9,7 +10,7 @@
<dependency>
<groupId>org.apache.maven</groupId>
<artifactId>maven-plugin-api</artifactId>
<version>2.1-SNAPSHOT</version>
<version>2.0</version>
</dependency>
</dependencies>
<build>

View File

@ -1,4 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?><project>
<?xml version='1.0' encoding='UTF-8'?>
<project>
<modelVersion>4.0.0</modelVersion>
<groupId>org.apache.maven.errortest</groupId>
<artifactId>testReportIncompatibleMavenVersionForExtensionPlugin-maven-plugin</artifactId>
@ -13,7 +14,7 @@
<dependency>
<groupId>org.apache.maven</groupId>
<artifactId>maven-plugin-api</artifactId>
<version>2.1-SNAPSHOT</version>
<version>2.0</version>
</dependency>
</dependencies>
<build>

View File

@ -1,4 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?><project>
<?xml version='1.0' encoding='UTF-8'?>
<project>
<modelVersion>4.0.0</modelVersion>
<groupId>org.apache.maven.errortest</groupId>
<artifactId>testReportInvalidDependencyVersionInExtensionPluginPOM-maven-plugin</artifactId>
@ -9,7 +10,7 @@
<dependency>
<groupId>org.apache.maven</groupId>
<artifactId>maven-plugin-api</artifactId>
<version>2.1-SNAPSHOT</version>
<version>2.0</version>
</dependency>
<dependency>
<groupId>junit</groupId>

View File

@ -0,0 +1,16 @@
<?xml version="1.0"?>
<project>
<modelVersion>4.0.0</modelVersion>
<groupId>org.apache.maven.errortest</groupId>
<artifactId>dep</artifactId>
<version>1</version>
<packaging>pom</packaging>
<dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>[4.0,4.1]</version>
</dependency>
</dependencies>
</project>

View File

@ -0,0 +1,60 @@
<?xml version='1.0' encoding='UTF-8'?>
<project>
<modelVersion>4.0.0</modelVersion>
<groupId>org.apache.maven.errortest</groupId>
<artifactId>testReportUnresolvableArtifactWhileAddingExtensionPlugin-maven-plugin</artifactId>
<packaging>maven-plugin</packaging>
<version>1</version>
<dependencies>
<dependency>
<groupId>org.apache.maven</groupId>
<artifactId>maven-plugin-api</artifactId>
<version>2.0</version>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>[3.8.1,3.8.2]</version>
</dependency>
<dependency>
<groupId>org.apache.maven.errortest</groupId>
<artifactId>dep</artifactId>
<version>1</version>
</dependency>
</dependencies>
<build>
<pluginManagement>
<plugins>
<plugin>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.3.1</version>
</plugin>
<plugin>
<artifactId>maven-deploy-plugin</artifactId>
<version>2.3</version>
</plugin>
<plugin>
<artifactId>maven-install-plugin</artifactId>
<version>2.2</version>
</plugin>
<plugin>
<artifactId>maven-resources-plugin</artifactId>
<version>2.2</version>
</plugin>
<plugin>
<artifactId>maven-jar-plugin</artifactId>
<version>2.1</version>
</plugin>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<version>2.0.2</version>
</plugin>
<plugin>
<artifactId>maven-plugin-plugin</artifactId>
<version>2.3</version>
</plugin>
</plugins>
</pluginManagement>
</build>
</project>

View File

@ -0,0 +1,18 @@
<?xml version="1.0" encoding="UTF-8"?><project>
<modelVersion>4.0.0</modelVersion>
<groupId>org.apache.maven.errortest</groupId>
<artifactId>testReportUnresolvableArtifactWhileAddingExtensionPlugin</artifactId>
<version>1</version>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.errortest</groupId>
<artifactId>testReportUnresolvableArtifactWhileAddingExtensionPlugin-maven-plugin</artifactId>
<version>1</version>
<extensions>true</extensions>
</plugin>
</plugins>
</build>
</project>

View File

@ -472,9 +472,29 @@ public class ErrorReporterPointcutTest
}
public void testReportExtensionPluginArtifactNotFound()
throws IOException
{
// TODO Auto-generated method stub
File projectDir = prepareProjectDir();
File localRepo = new File( projectDir, "local-repo" );
File project = new File( projectDir, "project" );
reporter.reportExtensionPluginArtifactNotFound( null, null, null, null, null );
reporterCtl.setMatcher( MockControl.ALWAYS_MATCHER );
reporterCtl.setVoidCallable();
reporterCtl.replay();
MavenExecutionRequest request = new DefaultMavenExecutionRequest().setBaseDirectory( project )
.setShowErrors( true )
.setLocalRepositoryPath( localRepo )
.setErrorReporter( reporter )
.setGoals( Arrays.asList( new String[] {
"initialize"
} ) );
maven.execute( request );
reporterCtl.verify();
}
public void testReportExtensionPluginVersionNotFound()
@ -659,12 +679,6 @@ public class ErrorReporterPointcutTest
reporterCtl.verify();
}
public void testReportMissingArtifactWhileAddingExtensionPlugin()
{
// TODO Auto-generated method stub
}
public void testReportMissingPluginDescriptor()
{
// TODO Auto-generated method stub
@ -872,9 +886,39 @@ public class ErrorReporterPointcutTest
}
public void testReportUnresolvableArtifactWhileAddingExtensionPlugin()
throws IOException
{
// TODO Auto-generated method stub
File projectDir = prepareProjectDir();
File localRepo = new File( projectDir, "local-repo" );
File project = new File( projectDir, "project" );
Settings settings = new Settings();
settings.setOffline( true );
settings.setLocalRepository( localRepo.getAbsolutePath() );
reporter.reportUnresolvableArtifactWhileAddingExtensionPlugin( null, null, null, null, null );
reporterCtl.setMatcher( MockControl.ALWAYS_MATCHER );
reporterCtl.setVoidCallable();
reporterCtl.replay();
MavenExecutionRequest request = new DefaultMavenExecutionRequest().setBaseDirectory( project )
.setShowErrors( true )
.setSettings( settings )
.setErrorReporter( reporter )
// .setErrorReporter( new DummyCoreErrorReporter() )
.setGoals( Arrays.asList( new String[] {
"initialize"
} ) );
maven.execute( request );
// MavenExecutionResult result = maven.execute( request );
// if ( result.hasExceptions() )
// {
// reportExceptions( result, project );
// }
reporterCtl.verify();
}
public void testReportActivatorError()