Modified: maven/components/trunk/maven-embedder/src/test/java/org/apache/maven/error/ErrorReporterPointcutTest.java URL: http://svn.apache.org/viewvc/maven/components/trunk/maven-embedder/src/test/java/org/apache/maven/error/ErrorReporterPointcutTest.java?rev=669222&r1=669221&r2=669222&view=diff ============================================================================== --- maven/components/trunk/maven-embedder/src/test/java/org/apache/maven/error/ErrorReporterPointcutTest.java (original) +++ maven/components/trunk/maven-embedder/src/test/java/org/apache/maven/error/ErrorReporterPointcutTest.java Wed Jun 18 09:56:56 2008 @@ -1,10 +1,34 @@ package org.apache.maven.error; -import org.apache.commons.httpclient.HttpClient; -import org.apache.commons.httpclient.HttpConnectionManager; -import org.apache.commons.httpclient.HttpException; -import org.apache.commons.httpclient.HttpStatus; -import org.apache.commons.httpclient.methods.GetMethod; +/* + * 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 java.io.IOException; +import java.io.PrintWriter; +import java.io.StringWriter; +import java.util.Arrays; +import java.util.Collection; +import java.util.Collections; + +import junit.framework.TestCase; + import org.apache.maven.artifact.resolver.MultipleArtifactsNotFoundException; import org.apache.maven.embedder.Configuration; import org.apache.maven.embedder.DefaultConfiguration; @@ -14,30 +38,15 @@ import org.apache.maven.execution.DefaultMavenExecutionRequest; import org.apache.maven.execution.MavenExecutionRequest; import org.apache.maven.execution.MavenExecutionResult; -import org.apache.maven.model.io.xpp3.MavenXpp3Reader; import org.apache.maven.plugin.PluginManagerException; import org.apache.maven.settings.Settings; import org.codehaus.plexus.util.FileUtils; import org.codehaus.plexus.util.xml.pull.XmlPullParserException; import org.easymock.MockControl; -import java.io.File; -import java.io.IOException; -import java.io.PrintWriter; -import java.io.StringReader; -import java.io.StringWriter; -import java.util.Arrays; -import java.util.Collections; -import java.util.Iterator; - -import junit.framework.TestCase; - public class ErrorReporterPointcutTest extends TestCase { - - private static final int ONE_SECOND = 1000; - private MockControl reporterCtl; private CoreErrorReporter reporter; @@ -46,10 +55,6 @@ private String basedir; - private static boolean isOffline; - - private static boolean offlineIsSet = false; - public void setUp() throws Exception { @@ -84,74 +89,6 @@ maven.stop(); } - private boolean checkOnline() - { - if ( !offlineIsSet ) - { - HttpClient client = new HttpClient(); - GetMethod get = new GetMethod( - "http://repo1.maven.org/maven2/org/apache/maven/maven-core/2.0/maven-core-2.0.pom" ); - - HttpConnectionManager mgr = client.getHttpConnectionManager(); - mgr.getParams().setConnectionTimeout( 3 * ONE_SECOND ); - - try - { - int result = client.executeMethod( get ); - if ( result == HttpStatus.SC_OK ) - { - String body = get.getResponseBodyAsString(); - new MavenXpp3Reader().read( new StringReader( body ) ); - isOffline = false; - } - else - { - System.out.println( "Got HTTP status of: " + result ); - System.out.println( "System is offline" ); - isOffline = true; - } - } - catch ( HttpException e ) - { - System.out.println( "Got error: " + e.getMessage() ); - System.out.println( "System is offline" ); - isOffline = true; - } - catch ( IOException e ) - { - System.out.println( "Got error: " + e.getMessage() ); - System.out.println( "System is offline" ); - isOffline = true; - } - catch ( XmlPullParserException e ) - { - System.out.println( "Got error: " + e.getMessage() ); - System.out.println( "System is offline" ); - isOffline = true; - } - finally - { - offlineIsSet = true; - } - } - - if ( isOffline ) - { - String method = getTestMethodName(); - System.out.println( "Test: " + method - + " requires an access to the Maven central repository. SKIPPING." ); - return false; - } - - return true; - } - - private String getTestMethodName() - { - String method = new Throwable().getStackTrace()[2].getMethodName(); - return method; - } - private File prepareProjectDir( String basename ) throws IOException { @@ -186,13 +123,8 @@ private void buildTestAccessory( File basedir ) { - MavenExecutionRequest request = new DefaultMavenExecutionRequest().setBaseDirectory( basedir ) - .setShowErrors( true ) - .setErrorReporter( new DummyCoreErrorReporter() ) - .setGoals( Arrays.asList( new String[] { - "clean", - "install" - } ) ); + MavenExecutionRequest request = + createRequest( basedir, new DummyCoreErrorReporter() ).setGoals( Arrays.asList( "clean", "install" ) ); MavenExecutionResult result = maven.execute( request ); @@ -202,6 +134,16 @@ } } + private MavenExecutionRequest createRequest( File basedir, CoreErrorReporter reporter ) + { + return createRequest( reporter ).setBaseDirectory( basedir ); + } + + private MavenExecutionRequest createRequest( CoreErrorReporter reporter ) + { + return new DefaultMavenExecutionRequest().setShowErrors( true ).setErrorReporter( reporter ); + } + private void reportExceptions( MavenExecutionResult result, File basedir ) { @@ -221,9 +163,8 @@ writer.write( basedir.getPath() ); writer.write( "\nEncountered the following errors:" ); - for ( Iterator it = result.getExceptions().iterator(); it.hasNext(); ) + for ( Throwable error : (Collection<Throwable>) result.getExceptions() ) { - Throwable error = (Throwable) it.next(); writer.write( "\n\n" ); error.printStackTrace( pWriter ); } @@ -256,13 +197,9 @@ reporterCtl.replay(); - MavenExecutionRequest request = new DefaultMavenExecutionRequest().setBaseDirectory( project ) - .setLocalRepositoryPath( localRepo ) - .setShowErrors( true ) - .setErrorReporter( reporter ) - .setGoals( Arrays.asList( new String[] { - "initialize" - } ) ); + MavenExecutionRequest request = + createRequest( project, reporter ).setLocalRepositoryPath( localRepo ).setGoals( + Arrays.asList( "initialize" ) ); maven.execute( request ); @@ -272,11 +209,6 @@ public void testReportAggregatedMojoFailureException() throws IOException { - if ( !checkOnline() ) - { - return; - } - File projectDir = prepareProjectDir( "aggregate-mojo-failure"); buildTestAccessory( new File( projectDir, "plugin" ) ); @@ -289,12 +221,9 @@ reporterCtl.replay(); - MavenExecutionRequest request = new DefaultMavenExecutionRequest().setBaseDirectory( basedir ) - .setShowErrors( true ) - .setErrorReporter( reporter ) - .setGoals( Arrays.asList( new String[] { - "org.apache.maven.errortest:aggregate-mojo-failure-maven-plugin:1:test" - } ) ); + MavenExecutionRequest request = + createRequest( basedir, reporter ).setGoals( + Arrays.asList( "org.apache.maven.errortest:aggregate-mojo-failure-maven-plugin:1:test" ) ); maven.execute( request ); @@ -304,11 +233,6 @@ public void testReportAttemptToOverrideUneditableMojoParameter() throws IOException { - if ( !checkOnline() ) - { - return; - } - File projectDir = prepareProjectDir( "config-rdonly-mojo-param"); buildTestAccessory( new File( projectDir, "plugin" ) ); @@ -328,12 +252,7 @@ reporterCtl.replay(); - MavenExecutionRequest request = new DefaultMavenExecutionRequest().setBaseDirectory( basedir ) - .setShowErrors( true ) - .setErrorReporter( reporter ) - .setGoals( Arrays.asList( new String[] { - "initialize" - } ) ); + MavenExecutionRequest request = createRequest( basedir, reporter ).setGoals( Arrays.asList( "initialize" ) ); maven.execute( request ); @@ -343,11 +262,6 @@ public void testReportErrorApplyingMojoConfiguration() throws IOException { - if ( !checkOnline() ) - { - return; - } - File projectDir = prepareProjectDir( "mojo-config-error"); File plugin = new File( projectDir, "plugin" ); File project = new File( projectDir, "project" ); @@ -360,12 +274,9 @@ reporterCtl.replay(); - MavenExecutionRequest request = new DefaultMavenExecutionRequest().setBaseDirectory( project ) - .setShowErrors( true ) - .setErrorReporter( reporter ) - .setGoals( Arrays.asList( new String[] { - "org.apache.maven.errortest:mojo-config-error-maven-plugin:1:test" - } ) ); + MavenExecutionRequest request = + createRequest( project, reporter ).setGoals( + Arrays.asList( "org.apache.maven.errortest:mojo-config-error-maven-plugin:1:test" ) ); maven.execute( request ); @@ -391,12 +302,7 @@ reporterCtl.replay(); - MavenExecutionRequest request = new DefaultMavenExecutionRequest().setBaseDirectory( project ) - .setShowErrors( true ) - .setErrorReporter( reporter ) - .setGoals( Arrays.asList( new String[] { - "initialize" - } ) ); + MavenExecutionRequest request = createRequest( project, reporter ).setGoals( Arrays.asList( "initialize" ) ); maven.execute( request ); @@ -406,11 +312,6 @@ public void testReportErrorFormulatingBuildPlan() throws IOException { - if ( !checkOnline() ) - { - return; - } - File projectDir = prepareProjectDir( "bad-build-plan" ); buildTestAccessory( new File( projectDir, "plugin" ) ); @@ -423,12 +324,9 @@ reporterCtl.replay(); - MavenExecutionRequest request = new DefaultMavenExecutionRequest().setBaseDirectory( basedir ) - .setShowErrors( true ) - .setErrorReporter( reporter ) - .setGoals( Arrays.asList( new String[] { - "org.apache.maven.errortest:bad-build-plan-maven-plugin:1:test" - } ) ); + MavenExecutionRequest request = + createRequest( basedir, reporter ).setGoals( + Arrays.asList( "org.apache.maven.errortest:bad-build-plan-maven-plugin:1:test" ) ); maven.execute( request ); @@ -438,13 +336,7 @@ public void testReportErrorInterpolatingModel_UsingProjectInstance() throws IOException { - if ( !checkOnline() ) - { - return; - } - File projectDir = prepareProjectDir( "interp-from-project"); - File localRepo = new File( projectDir, "local-repo" ); File project = new File( projectDir, "project" ); reporter.reportErrorInterpolatingModel( null, null, null ); @@ -453,13 +345,7 @@ reporterCtl.replay(); - MavenExecutionRequest request = new DefaultMavenExecutionRequest().setBaseDirectory( project ) - .setLocalRepositoryPath( localRepo ) - .setShowErrors( true ) - .setErrorReporter( reporter ) - .setGoals( Arrays.asList( new String[] { - "compile" - } ) ); + MavenExecutionRequest request = createRequest( project, reporter ).setGoals( Arrays.asList( "compile" ) ); maven.execute( request ); @@ -483,13 +369,9 @@ reporterCtl.replay(); - MavenExecutionRequest request = new DefaultMavenExecutionRequest().setBaseDirectory( project ) - .setSettings( settings ) - .setShowErrors( true ) - .setErrorReporter( reporter ) - .setGoals( Arrays.asList( new String[] { - "org.apache.maven.errortest:err-loading-plugin-maven-plugin:1:test" - } ) ); + MavenExecutionRequest request = + createRequest( project, reporter ).setSettings( settings ).setGoals( + Arrays.asList( "org.apache.maven.errortest:err-loading-plugin-maven-plugin:1:test" ) ); maven.execute( request ); @@ -499,11 +381,6 @@ public void testReportErrorManagingRealmForExtension() throws IOException { - if ( !checkOnline() ) - { - return; - } - File projectDir = prepareProjectDir( "ext-realm-error" ); buildTestAccessory( new File( projectDir, "ext" ) ); @@ -516,12 +393,7 @@ reporterCtl.replay(); - MavenExecutionRequest request = new DefaultMavenExecutionRequest().setBaseDirectory( project ) - .setShowErrors( true ) - .setErrorReporter( reporter ) - .setGoals( Arrays.asList( new String[] { - "initialize" - } ) ); + MavenExecutionRequest request = createRequest( project, reporter ).setGoals( Arrays.asList( "initialize" ) ); maven.execute( request ); @@ -541,13 +413,9 @@ reporterCtl.replay(); - MavenExecutionRequest request = new DefaultMavenExecutionRequest().setBaseDirectory( project ) - .setLocalRepositoryPath( localRepo ) - .setShowErrors( true ) - .setErrorReporter( reporter ) - .setGoals( Arrays.asList( new String[] { - "initialize" - } ) ); + MavenExecutionRequest request = + createRequest( project, reporter ).setLocalRepositoryPath( localRepo ).setGoals( + Arrays.asList( "initialize" ) ); maven.execute( request ); @@ -567,13 +435,9 @@ reporterCtl.replay(); - MavenExecutionRequest request = new DefaultMavenExecutionRequest().setBaseDirectory( project ) - .setShowErrors( true ) - .setLocalRepositoryPath( localRepo ) - .setErrorReporter( reporter ) - .setGoals( Arrays.asList( new String[] { - "initialize" - } ) ); + MavenExecutionRequest request = + createRequest( project, reporter ).setLocalRepositoryPath( localRepo ).setGoals( + Arrays.asList( "initialize" ) ); maven.execute( request ); @@ -597,13 +461,8 @@ reporterCtl.replay(); - MavenExecutionRequest request = new DefaultMavenExecutionRequest().setBaseDirectory( project ) - .setShowErrors( true ) - .setSettings( settings ) - .setErrorReporter( reporter ) - .setGoals( Arrays.asList( new String[] { - "initialize" - } ) ); + MavenExecutionRequest request = + createRequest( project, reporter ).setSettings( settings ).setGoals( Arrays.asList( "initialize" ) ); maven.execute( request ); @@ -629,13 +488,9 @@ reporterCtl.replay(); - MavenExecutionRequest request = new DefaultMavenExecutionRequest().setBaseDirectory( project ) - .setShowErrors( true ) - .setLocalRepositoryPath( localRepo ) - .setErrorReporter( reporter ) - .setGoals( Arrays.asList( new String[] { - "initialize" - } ) ); + MavenExecutionRequest request = + createRequest( project, reporter ).setLocalRepositoryPath( localRepo ).setGoals( + Arrays.asList( "initialize" ) ); maven.execute( request ); @@ -660,13 +515,9 @@ reporterCtl.replay(); - MavenExecutionRequest request = new DefaultMavenExecutionRequest().setBaseDirectory( project ) - .setShowErrors( true ) - .setLocalRepositoryPath( localRepo ) - .setErrorReporter( reporter ) - .setGoals( Arrays.asList( new String[] { - "initialize" - } ) ); + MavenExecutionRequest request = + createRequest( project, reporter ).setLocalRepositoryPath( localRepo ).setGoals( + Arrays.asList( "initialize" ) ); maven.execute( request ); @@ -684,12 +535,7 @@ reporterCtl.replay(); - MavenExecutionRequest request = new DefaultMavenExecutionRequest().setBaseDirectory( projectDir ) - .setShowErrors( true ) - .setErrorReporter( reporter ) - .setGoals( Arrays.asList( new String[] { - "initialize" - } ) ); + MavenExecutionRequest request = createRequest( projectDir, reporter ).setGoals( Arrays.asList( "initialize" ) ); maven.execute( request ); @@ -707,12 +553,9 @@ reporterCtl.replay(); - MavenExecutionRequest request = new DefaultMavenExecutionRequest().setBaseDirectory( projectDir ) - .setShowErrors( true ) - .setErrorReporter( reporter ) - .setGoals( Arrays.asList( new String[] { - "compiler:compile" - } ) ); + MavenExecutionRequest request = + createRequest( projectDir, reporter ).setGoals( + Arrays.asList( "org.apache.maven.plugins:maven-compiler-plugin:2.0.2:compile" ) ); maven.execute( request ); @@ -735,13 +578,8 @@ reporterCtl.replay(); - MavenExecutionRequest request = new DefaultMavenExecutionRequest().setBaseDirectory( projectDir ) - .setShowErrors( true ) - .setSettings( settings ) - .setErrorReporter( reporter ) - .setGoals( Arrays.asList( new String[] { - "invalid:test" - } ) ); + MavenExecutionRequest request = + createRequest( projectDir, reporter ).setSettings( settings ).setGoals( Arrays.asList( "invalid:test" ) ); maven.execute( request ); @@ -756,11 +594,8 @@ reporterCtl.replay(); - MavenExecutionRequest request = new DefaultMavenExecutionRequest().setShowErrors( true ) - .setErrorReporter( reporter ) - .setGoals( Arrays.asList( new String[] { - "name:of:invalid:direct:mojo:for:test" - } ) ); + MavenExecutionRequest request = + createRequest( reporter ).setGoals( Arrays.asList( "name:of:invalid:direct:mojo:for:test" ) ); maven.execute( request ); @@ -770,11 +605,6 @@ public void testReportMissingRequiredMojoParameter() throws IOException { - if ( !checkOnline() ) - { - return; - } - File projectDir = prepareProjectDir( "missing-req-mojo-param" ); buildTestAccessory( new File( projectDir, "plugin" ) ); @@ -787,12 +617,9 @@ reporterCtl.replay(); - MavenExecutionRequest request = new DefaultMavenExecutionRequest().setBaseDirectory( basedir ) - .setShowErrors( true ) - .setErrorReporter( reporter ) - .setGoals( Arrays.asList( new String[] { - "org.apache.maven.errortest:missing-req-mojo-param-maven-plugin:1:test" - } ) ); + MavenExecutionRequest request = + createRequest( basedir, reporter ).setGoals( + Arrays.asList( "org.apache.maven.errortest:missing-req-mojo-param-maven-plugin:1:test" ) ); maven.execute( request ); @@ -802,11 +629,6 @@ public void testReportMojoExecutionException() throws IOException { - if ( !checkOnline() ) - { - return; - } - File projectDir = prepareProjectDir( "mojo-exec-err" ); buildTestAccessory( new File( projectDir, "plugin" ) ); @@ -819,12 +641,9 @@ reporterCtl.replay(); - MavenExecutionRequest request = new DefaultMavenExecutionRequest().setBaseDirectory( basedir ) - .setShowErrors( true ) - .setErrorReporter( reporter ) - .setGoals( Arrays.asList( new String[] { - "org.apache.maven.errortest:mojo-exec-err-maven-plugin:1:test" - } ) ); + MavenExecutionRequest request = + createRequest( basedir, reporter ).setGoals( + Arrays.asList( "org.apache.maven.errortest:mojo-exec-err-maven-plugin:1:test" ) ); maven.execute( request ); @@ -834,11 +653,6 @@ public void testReportMojoLookupError() throws IOException { - if ( !checkOnline() ) - { - return; - } - File projectDir = prepareProjectDir( "mojo-lookup-err" ); buildTestAccessory( new File( projectDir, "plugin" ) ); @@ -849,12 +663,9 @@ reporterCtl.replay(); - MavenExecutionRequest request = new DefaultMavenExecutionRequest().setBaseDirectory( projectDir ) - .setShowErrors( true ) - .setErrorReporter( reporter ) - .setGoals( Arrays.asList( new String[] { - "org.apache.maven.errortest:mojo-lookup-err-maven-plugin:1:test" - } ) ); + MavenExecutionRequest request = + createRequest( projectDir, reporter ).setGoals( + Arrays.asList( "org.apache.maven.errortest:mojo-lookup-err-maven-plugin:1:test" ) ); maven.execute( request ); @@ -869,9 +680,7 @@ reporterCtl.replay(); - MavenExecutionRequest request = new DefaultMavenExecutionRequest().setShowErrors( true ) - .setErrorReporter( reporter ) - .setGoals( Collections.EMPTY_LIST ); + MavenExecutionRequest request = createRequest( reporter ).setGoals( Collections.EMPTY_LIST ); maven.execute( request ); @@ -889,12 +698,7 @@ reporterCtl.replay(); - MavenExecutionRequest request = new DefaultMavenExecutionRequest().setBaseDirectory( projectDir ) - .setShowErrors( true ) - .setErrorReporter( reporter ) - .setGoals( Arrays.asList( new String[] { - "initialize" - } ) ); + MavenExecutionRequest request = createRequest( projectDir, reporter ).setGoals( Arrays.asList( "initialize" ) ); maven.execute( request ); @@ -914,12 +718,7 @@ reporterCtl.replay(); - MavenExecutionRequest request = new DefaultMavenExecutionRequest().setBaseDirectory( projectDir ) - .setShowErrors( true ) - .setErrorReporter( reporter ) - .setGoals( Arrays.asList( new String[] { - "compile" - } ) ); + MavenExecutionRequest request = createRequest( projectDir, reporter ).setGoals( Arrays.asList( "compile" ) ); maven.execute( request ); @@ -929,13 +728,7 @@ public void testReportProjectDependenciesUnresolvable() throws IOException { - if ( !checkOnline() ) - { - return; - } - File projectDir = prepareProjectDir( "err-resolving-project-dep" ); - File localRepo = new File( projectDir, "local-repo" ); File project = new File( projectDir, "project" ); reporter.reportProjectDependenciesUnresolvable( null, null, null ); @@ -944,13 +737,7 @@ reporterCtl.replay(); - MavenExecutionRequest request = new DefaultMavenExecutionRequest().setBaseDirectory( project ) - .setShowErrors( true ) - .setLocalRepositoryPath( localRepo ) - .setErrorReporter( reporter ) - .setGoals( Arrays.asList( new String[] { - "compile" - } ) ); + MavenExecutionRequest request = createRequest( project, reporter ).setGoals( Arrays.asList( "compile" ) ); maven.execute( request ); @@ -968,13 +755,8 @@ reporterCtl.replay(); - MavenExecutionRequest request = new DefaultMavenExecutionRequest().setBaseDirectory( projectDir ) - .setShowErrors( true ) - .setErrorReporter( reporter ) - .setGoals( Arrays.asList( new String[] { - "clean", - "package" - } ) ); + MavenExecutionRequest request = + createRequest( projectDir, reporter ).setGoals( Arrays.asList( "clean", "package" ) ); maven.execute( request ); @@ -998,13 +780,8 @@ reporterCtl.replay(); - MavenExecutionRequest request = new DefaultMavenExecutionRequest().setBaseDirectory( project ) - .setShowErrors( true ) - .setSettings( settings ) - .setErrorReporter( reporter ) - .setGoals( Arrays.asList( new String[] { - "initialize" - } ) ); + MavenExecutionRequest request = + createRequest( project, reporter ).setSettings( settings ).setGoals( Arrays.asList( "initialize" ) ); maven.execute( request ); @@ -1022,12 +799,7 @@ reporterCtl.replay(); - MavenExecutionRequest request = new DefaultMavenExecutionRequest().setBaseDirectory( projectDir ) - .setShowErrors( true ) - .setErrorReporter( reporter ) - .setGoals( Arrays.asList( new String[] { - "initialize" - } ) ); + MavenExecutionRequest request = createRequest( projectDir, reporter ).setGoals( Arrays.asList( "initialize" ) ); maven.execute( request ); @@ -1037,11 +809,6 @@ public void testReportActivatorLookupError() throws IOException { - if ( !checkOnline() ) - { - return; - } - File projectDir = prepareProjectDir( "profile-activator-lookup-err" ); buildTestAccessory( new File( projectDir, "ext" ) ); @@ -1054,12 +821,7 @@ reporterCtl.replay(); - MavenExecutionRequest request = new DefaultMavenExecutionRequest().setBaseDirectory( project ) - .setShowErrors( true ) - .setErrorReporter( reporter ) - .setGoals( Arrays.asList( new String[] { - "initialize" - } ) ); + MavenExecutionRequest request = createRequest( project, reporter ).setGoals( Arrays.asList( "initialize" ) ); maven.execute( request ); @@ -1077,12 +839,7 @@ reporterCtl.replay(); - MavenExecutionRequest request = new DefaultMavenExecutionRequest().setBaseDirectory( projectDir ) - .setShowErrors( true ) - .setErrorReporter( reporter ) - .setGoals( Arrays.asList( new String[] { - "compile" - } ) ); + MavenExecutionRequest request = createRequest( projectDir, reporter ).setGoals( Arrays.asList( "compile" ) ); maven.execute( request ); @@ -1100,12 +857,7 @@ reporterCtl.replay(); - MavenExecutionRequest request = new DefaultMavenExecutionRequest().setBaseDirectory( projectDir ) - .setShowErrors( true ) - .setErrorReporter( reporter ) - .setGoals( Arrays.asList( new String[] { - "initialize" - } ) ); + MavenExecutionRequest request = createRequest( projectDir, reporter ).setGoals( Arrays.asList( "initialize" ) ); maven.execute( request ); @@ -1123,12 +875,7 @@ reporterCtl.replay(); - MavenExecutionRequest request = new DefaultMavenExecutionRequest().setBaseDirectory( projectDir ) - .setShowErrors( true ) - .setErrorReporter( reporter ) - .setGoals( Arrays.asList( new String[] { - "initialize" - } ) ); + MavenExecutionRequest request = createRequest( projectDir, reporter ).setGoals( Arrays.asList( "initialize" ) ); maven.execute( request ); @@ -1146,12 +893,7 @@ reporterCtl.replay(); - MavenExecutionRequest request = new DefaultMavenExecutionRequest().setBaseDirectory( projectDir ) - .setShowErrors( true ) - .setErrorReporter( reporter ) - .setGoals( Arrays.asList( new String[] { - "compile" - } ) ); + MavenExecutionRequest request = createRequest( projectDir, reporter ).setGoals( Arrays.asList( "compile" ) ); maven.execute( request ); @@ -1169,12 +911,7 @@ reporterCtl.replay(); - MavenExecutionRequest request = new DefaultMavenExecutionRequest().setBaseDirectory( projectDir ) - .setShowErrors( true ) - .setErrorReporter( reporter ) - .setGoals( Arrays.asList( new String[] { - "compile" - } ) ); + MavenExecutionRequest request = createRequest( projectDir, reporter ).setGoals( Arrays.asList( "compile" ) ); maven.execute( request ); @@ -1192,12 +929,7 @@ reporterCtl.replay(); - MavenExecutionRequest request = new DefaultMavenExecutionRequest().setBaseDirectory( projectDir ) - .setShowErrors( true ) - .setErrorReporter( reporter ) - .setGoals( Arrays.asList( new String[] { - "compile" - } ) ); + MavenExecutionRequest request = createRequest( projectDir, reporter ).setGoals( Arrays.asList( "compile" ) ); maven.execute( request ); @@ -1218,12 +950,7 @@ reporterCtl.replay(); - MavenExecutionRequest request = new DefaultMavenExecutionRequest().setBaseDirectory( projectDir ) - .setShowErrors( true ) - .setErrorReporter( reporter ) - .setGoals( Arrays.asList( new String[] { - "initialize" - } ) ); + MavenExecutionRequest request = createRequest( projectDir, reporter ).setGoals( Arrays.asList( "initialize" ) ); maven.execute( request ); @@ -1241,12 +968,7 @@ reporterCtl.replay(); - MavenExecutionRequest request = new DefaultMavenExecutionRequest().setBaseDirectory( projectDir ) - .setShowErrors( true ) - .setErrorReporter( reporter ) - .setGoals( Arrays.asList( new String[] { - "initialize" - } ) ); + MavenExecutionRequest request = createRequest( projectDir, reporter ).setGoals( Arrays.asList( "initialize" ) ); maven.execute( request ); @@ -1265,12 +987,7 @@ reporterCtl.replay(); - MavenExecutionRequest request = new DefaultMavenExecutionRequest().setBaseDirectory( childDir ) - .setShowErrors( true ) - .setErrorReporter( reporter ) - .setGoals( Arrays.asList( new String[] { - "initialize" - } ) ); + MavenExecutionRequest request = createRequest( childDir, reporter ).setGoals( Arrays.asList( "initialize" ) ); maven.execute( request ); @@ -1289,12 +1006,7 @@ reporterCtl.replay(); - MavenExecutionRequest request = new DefaultMavenExecutionRequest().setBaseDirectory( childDir ) - .setShowErrors( true ) - .setErrorReporter( reporter ) - .setGoals( Arrays.asList( new String[] { - "initialize" - } ) ); + MavenExecutionRequest request = createRequest( childDir, reporter ).setGoals( Arrays.asList( "initialize" ) ); maven.execute( request ); @@ -1312,12 +1024,7 @@ reporterCtl.replay(); - MavenExecutionRequest request = new DefaultMavenExecutionRequest().setBaseDirectory( projectDir ) - .setShowErrors( true ) - .setErrorReporter( reporter ) - .setGoals( Arrays.asList( new String[] { - "initialize" - } ) ); + MavenExecutionRequest request = createRequest( projectDir, reporter ).setGoals( Arrays.asList( "initialize" ) ); maven.execute( request ); @@ -1335,23 +1042,19 @@ reporterCtl.replay(); - MavenExecutionRequest request = new DefaultMavenExecutionRequest().setPom( new File( - projectDir, - "pom.xml" ) ) - .setShowErrors( true ) - .setErrorReporter( reporter ) - .setGoals( Arrays.asList( new String[] { - "initialize" - } ) ); + MavenExecutionRequest request = + createRequest( reporter ).setPom( new File( projectDir, "pom.xml" ) ).setGoals( + Arrays.asList( "initialize" ) ); maven.execute( request ); reporterCtl.verify(); } - // FIXME: Something keeps flip-flopping about this test, between the two reporter methods below...need to revisit this pronto. -// public void testReportErrorCreatingArtifactRepository_fromProfilesXml() -// throws IOException + // FIXME: Something keeps flip-flopping about this test, between the two reporter methods below...need to revisit + // this pronto. +// public void testReportErrorCreatingArtifactRepository_fromProfilesXml() +// throws IOException // { // File projectDir = prepareProjectDir( "bad-profile-repo" ); // @@ -1396,13 +1099,8 @@ reporterCtl.replay(); - MavenExecutionRequest request = new DefaultMavenExecutionRequest().setBaseDirectory( projectDir ) - .setSettings( settings ) - .setShowErrors( true ) - .setErrorReporter( reporter ) - .setGoals( Arrays.asList( new String[] { - "initialize" - } ) ); + MavenExecutionRequest request = + createRequest( projectDir, reporter ).setSettings( settings ).setGoals( Arrays.asList( "initialize" ) ); maven.execute( request ); @@ -1420,12 +1118,7 @@ reporterCtl.replay(); - MavenExecutionRequest request = new DefaultMavenExecutionRequest().setBaseDirectory( projectDir ) - .setShowErrors( true ) - .setErrorReporter( reporter ) - .setGoals( Arrays.asList( new String[] { - "initialize" - } ) ); + MavenExecutionRequest request = createRequest( projectDir, reporter ).setGoals( Arrays.asList( "initialize" ) ); maven.execute( request ); @@ -1443,12 +1136,7 @@ reporterCtl.replay(); - MavenExecutionRequest request = new DefaultMavenExecutionRequest().setBaseDirectory( projectDir ) - .setShowErrors( true ) - .setErrorReporter( reporter ) - .setGoals( Arrays.asList( new String[] { - "initialize" - } ) ); + MavenExecutionRequest request = createRequest( projectDir, reporter ).setGoals( Arrays.asList( "initialize" ) ); maven.execute( request ); @@ -1466,12 +1154,7 @@ reporterCtl.replay(); - MavenExecutionRequest request = new DefaultMavenExecutionRequest().setBaseDirectory( projectDir ) - .setShowErrors( true ) - .setErrorReporter( reporter ) - .setGoals( Arrays.asList( new String[] { - "initialize" - } ) ); + MavenExecutionRequest request = createRequest( projectDir, reporter ).setGoals( Arrays.asList( "initialize" ) ); maven.execute( request ); @@ -1496,13 +1179,9 @@ reporterCtl.replay(); - MavenExecutionRequest request = new DefaultMavenExecutionRequest().setBaseDirectory( projectDir ) - .setSettings( settings ) - .setShowErrors( true ) - .setErrorReporter( reporter ) - .setGoals( Arrays.asList( new String[] { - "missing-direct-invoke-mojo:test" - } ) ); + MavenExecutionRequest request = + createRequest( projectDir, reporter ).setSettings( settings ).setGoals( + Arrays.asList( "missing-direct-invoke-mojo:test" ) ); MavenExecutionResult result = maven.execute( request ); @@ -1531,13 +1210,9 @@ reporterCtl.replay(); - MavenExecutionRequest request = new DefaultMavenExecutionRequest().setBaseDirectory( project ) - .setSettings( settings ) - .setShowErrors( true ) - .setErrorReporter( reporter ) - .setGoals( Arrays.asList( new String[] { - "duplicated-attachments:test" - } ) ); + MavenExecutionRequest request = + createRequest( project, reporter ).setSettings( settings ).setGoals( + Arrays.asList( "duplicated-attachments:test" ) ); MavenExecutionResult result = maven.execute( request );
Modified: maven/components/trunk/maven-embedder/src/test/plugin-version-references/jar-pom.xml URL: http://svn.apache.org/viewvc/maven/components/trunk/maven-embedder/src/test/plugin-version-references/jar-pom.xml?rev=669222&r1=669221&r2=669222&view=diff ============================================================================== --- maven/components/trunk/maven-embedder/src/test/plugin-version-references/jar-pom.xml (original) +++ maven/components/trunk/maven-embedder/src/test/plugin-version-references/jar-pom.xml Wed Jun 18 09:56:56 2008 @@ -4,7 +4,7 @@ <plugins> <plugin> <artifactId>maven-surefire-plugin</artifactId> - <version>2.3.1</version> + <version>2.2</version> </plugin> <plugin> <artifactId>maven-deploy-plugin</artifactId> @@ -29,4 +29,4 @@ </plugins> </pluginManagement> </build> -</project> \ No newline at end of file +</project> Modified: maven/components/trunk/maven-embedder/src/test/plugin-version-references/maven-plugin-pom.xml URL: http://svn.apache.org/viewvc/maven/components/trunk/maven-embedder/src/test/plugin-version-references/maven-plugin-pom.xml?rev=669222&r1=669221&r2=669222&view=diff ============================================================================== --- maven/components/trunk/maven-embedder/src/test/plugin-version-references/maven-plugin-pom.xml (original) +++ maven/components/trunk/maven-embedder/src/test/plugin-version-references/maven-plugin-pom.xml Wed Jun 18 09:56:56 2008 @@ -4,7 +4,7 @@ <plugins> <plugin> <artifactId>maven-surefire-plugin</artifactId> - <version>2.3.1</version> + <version>2.2</version> </plugin> <plugin> <artifactId>maven-deploy-plugin</artifactId> @@ -33,4 +33,4 @@ </plugins> </pluginManagement> </build> -</project> \ No newline at end of file +</project> Modified: maven/components/trunk/maven-embedder/src/test/resources/pom2.xml URL: http://svn.apache.org/viewvc/maven/components/trunk/maven-embedder/src/test/resources/pom2.xml?rev=669222&r1=669221&r2=669222&view=diff ============================================================================== --- maven/components/trunk/maven-embedder/src/test/resources/pom2.xml (original) +++ maven/components/trunk/maven-embedder/src/test/resources/pom2.xml Wed Jun 18 09:56:56 2008 @@ -40,7 +40,7 @@ <plugin> <!-- it's here just for the extensions tag --> <artifactId>maven-surefire-plugin</artifactId> - <version>RELEASE</version> + <version>2.3</version> <extensions>true</extensions> </plugin> </plugins>
