http://git-wip-us.apache.org/repos/asf/maven-integration-testing/blob/3987b9fd/core-it-support/core-it-plugins/maven-it-plugin-uses-wagon/src/main/java/org/apache/maven/plugin/coreit/DumpAuthMojo.java ---------------------------------------------------------------------- diff --git a/core-it-support/core-it-plugins/maven-it-plugin-uses-wagon/src/main/java/org/apache/maven/plugin/coreit/DumpAuthMojo.java b/core-it-support/core-it-plugins/maven-it-plugin-uses-wagon/src/main/java/org/apache/maven/plugin/coreit/DumpAuthMojo.java index cdeeb1b..8efdb9b 100644 --- a/core-it-support/core-it-plugins/maven-it-plugin-uses-wagon/src/main/java/org/apache/maven/plugin/coreit/DumpAuthMojo.java +++ b/core-it-support/core-it-plugins/maven-it-plugin-uses-wagon/src/main/java/org/apache/maven/plugin/coreit/DumpAuthMojo.java @@ -33,12 +33,11 @@ import java.util.Properties; /** * Dumps the authentication info registered with the wagon manager for a server to a properties file. - * - * @goal dump-auth - * @phase validate - * + * * @author Benjamin Bentmann * @version $Id$ + * @goal dump-auth + * @phase validate */ public class DumpAuthMojo extends AbstractMojo @@ -46,7 +45,7 @@ public class DumpAuthMojo /** * Project base directory used for manual path alignment. - * + * * @parameter default-value="${basedir}" * @readonly */ @@ -54,28 +53,28 @@ public class DumpAuthMojo /** * The Wagon manager used to retrieve authentication infos. - * + * * @component */ private WagonManager wagonManager; /** * The path to the properties file used to dump the auth infos. - * + * * @parameter property="wagon.propertiesFile" */ private File propertiesFile; /** * The set of server identifiers whose auth infos should be dumped. - * + * * @parameter */ private String[] serverIds; /** * Runs this mojo. - * + * * @throws MojoFailureException If the output file could not be created. */ public void execute() @@ -83,9 +82,8 @@ public class DumpAuthMojo { Properties authProperties = new Properties(); - for ( int i = 0; i < serverIds.length; i++ ) + for ( String serverId : serverIds ) { - String serverId = serverIds[i]; getLog().info( "[MAVEN-CORE-IT-LOG] Getting authentication info for server " + serverId ); AuthenticationInfo authInfo = wagonManager.getAuthenticationInfo( serverId );
http://git-wip-us.apache.org/repos/asf/maven-integration-testing/blob/3987b9fd/core-it-support/core-it-plugins/maven-it-plugin-uses-wagon/src/main/java/org/apache/maven/plugin/coreit/LoadResourceMojo.java ---------------------------------------------------------------------- diff --git a/core-it-support/core-it-plugins/maven-it-plugin-uses-wagon/src/main/java/org/apache/maven/plugin/coreit/LoadResourceMojo.java b/core-it-support/core-it-plugins/maven-it-plugin-uses-wagon/src/main/java/org/apache/maven/plugin/coreit/LoadResourceMojo.java index 00e8987..62161b4 100644 --- a/core-it-support/core-it-plugins/maven-it-plugin-uses-wagon/src/main/java/org/apache/maven/plugin/coreit/LoadResourceMojo.java +++ b/core-it-support/core-it-plugins/maven-it-plugin-uses-wagon/src/main/java/org/apache/maven/plugin/coreit/LoadResourceMojo.java @@ -37,12 +37,11 @@ import java.util.Properties; /** * Loads resources from a class loader used to load a wagon provider. The wagon is merely used to access the extension * class loader it came from which is otherwise not accessible to a plugin. - * - * @goal load-resource - * @phase validate - * + * * @author Benjamin Bentmann * @version $Id$ + * @goal load-resource + * @phase validate */ public class LoadResourceMojo extends AbstractMojo @@ -50,14 +49,14 @@ public class LoadResourceMojo /** * The Wagon manager used to retrieve wagon providers. - * + * * @component */ private WagonManager wagonManager; /** * The path to the properties file used to track the results of the resource loading via the wagon's class loader. - * + * * @parameter property="wagon.wagonClassLoaderOutput" */ private File wagonClassLoaderOutput; @@ -65,14 +64,14 @@ public class LoadResourceMojo /** * The role hint for the wagon provider to load. The class loader of this provider will be used to load the * resources. - * + * * @parameter property="wagon.wagonProtocol" */ private String wagonProtocol; /** * The repository to load the wagon for, if applicable. - * + * * @parameter property="wagon.repositoryId" */ private String repositoryId; @@ -82,14 +81,14 @@ public class LoadResourceMojo * loaded, the generated properties files will contain a key named <code>ARP</code> whose value gives the URL to the * resource. In addition, the keys <code>ARP.count</code>, <code>ARP.0</code>, <code>ARP.1</code> etc. will * enumerate all URLs matching the resource name. - * + * * @parameter */ private String[] resourcePaths; /** * Runs this mojo. - * + * * @throws MojoFailureException If the attached file has not been set. */ public void execute() @@ -123,18 +122,17 @@ public class LoadResourceMojo if ( resourcePaths != null ) { - for ( int i = 0; i < resourcePaths.length; i++ ) + for ( String path : resourcePaths ) { - String path = resourcePaths[i]; getLog().info( "[MAVEN-CORE-IT-LOG] Loading resource " + path ); - + URL url = classLoader.getResource( path ); getLog().info( "[MAVEN-CORE-IT-LOG] Loaded resource from " + url ); if ( url != null ) { loaderProperties.setProperty( path, url.toString() ); } - + try { List urls = Collections.list( classLoader.getResources( path ) ); http://git-wip-us.apache.org/repos/asf/maven-integration-testing/blob/3987b9fd/core-it-support/core-it-wagon/src/main/java/org/apache/maven/wagon/providers/coreit/CoreItHttpWagon.java ---------------------------------------------------------------------- diff --git a/core-it-support/core-it-wagon/src/main/java/org/apache/maven/wagon/providers/coreit/CoreItHttpWagon.java b/core-it-support/core-it-wagon/src/main/java/org/apache/maven/wagon/providers/coreit/CoreItHttpWagon.java index bf61929..ff0387d 100644 --- a/core-it-support/core-it-wagon/src/main/java/org/apache/maven/wagon/providers/coreit/CoreItHttpWagon.java +++ b/core-it-support/core-it-wagon/src/main/java/org/apache/maven/wagon/providers/coreit/CoreItHttpWagon.java @@ -19,15 +19,6 @@ package org.apache.maven.wagon.providers.coreit; * under the License. */ -import java.io.ByteArrayInputStream; -import java.io.ByteArrayOutputStream; -import java.io.File; -import java.io.FileOutputStream; -import java.io.IOException; -import java.io.InputStream; -import java.io.OutputStream; -import java.util.Properties; - import org.apache.maven.wagon.AbstractWagon; import org.apache.maven.wagon.ConnectionException; import org.apache.maven.wagon.InputData; @@ -38,6 +29,15 @@ import org.apache.maven.wagon.authentication.AuthenticationException; import org.apache.maven.wagon.authorization.AuthorizationException; import org.apache.maven.wagon.resource.Resource; +import java.io.ByteArrayInputStream; +import java.io.ByteArrayOutputStream; +import java.io.File; +import java.io.FileOutputStream; +import java.io.IOException; +import java.io.InputStream; +import java.io.OutputStream; +import java.util.Properties; + /** * Shamelessly copied from ScpExternalWagon in this same project... * @@ -63,8 +63,8 @@ public class CoreItHttpWagon if ( is == null ) { - throw new TransferFailedException( getRepository().getUrl() - + " - Could not open input stream for resource: '" + resource + "'" ); + throw new TransferFailedException( + getRepository().getUrl() + " - Could not open input stream for resource: '" + resource + "'" ); } createParentDirectories( destination ); @@ -95,8 +95,8 @@ public class CoreItHttpWagon if ( os == null ) { - throw new TransferFailedException( getRepository().getUrl() - + " - Could not open output stream for resource: '" + resource + "'" ); + throw new TransferFailedException( + getRepository().getUrl() + " - Could not open output stream for resource: '" + resource + "'" ); } putTransfer( outputData.getResource(), source, os, true ); @@ -153,16 +153,11 @@ public class CoreItHttpWagon try { new File( "target" ).mkdirs(); - - OutputStream os = new FileOutputStream( "target/wagon.properties" ); - try + + try ( OutputStream os = new FileOutputStream( "target/wagon.properties" ) ) { props.store( os, "MAVEN-CORE-IT-WAGON" ); } - finally - { - os.close(); - } } catch ( IOException e ) { http://git-wip-us.apache.org/repos/asf/maven-integration-testing/blob/3987b9fd/core-it-support/core-it-wagon/src/main/java/org/apache/maven/wagon/providers/coreit/CoreItWagon.java ---------------------------------------------------------------------- diff --git a/core-it-support/core-it-wagon/src/main/java/org/apache/maven/wagon/providers/coreit/CoreItWagon.java b/core-it-support/core-it-wagon/src/main/java/org/apache/maven/wagon/providers/coreit/CoreItWagon.java index 5c03d7f..fddf5dc 100644 --- a/core-it-support/core-it-wagon/src/main/java/org/apache/maven/wagon/providers/coreit/CoreItWagon.java +++ b/core-it-support/core-it-wagon/src/main/java/org/apache/maven/wagon/providers/coreit/CoreItWagon.java @@ -19,15 +19,6 @@ package org.apache.maven.wagon.providers.coreit; * under the License. */ -import java.io.ByteArrayInputStream; -import java.io.ByteArrayOutputStream; -import java.io.File; -import java.io.FileOutputStream; -import java.io.IOException; -import java.io.InputStream; -import java.io.OutputStream; -import java.util.Properties; - import org.apache.maven.wagon.AbstractWagon; import org.apache.maven.wagon.ConnectionException; import org.apache.maven.wagon.InputData; @@ -39,6 +30,15 @@ import org.apache.maven.wagon.authentication.AuthenticationInfo; import org.apache.maven.wagon.authorization.AuthorizationException; import org.apache.maven.wagon.resource.Resource; +import java.io.ByteArrayInputStream; +import java.io.ByteArrayOutputStream; +import java.io.File; +import java.io.FileOutputStream; +import java.io.IOException; +import java.io.InputStream; +import java.io.OutputStream; +import java.util.Properties; + /** * Shamelessly copied from ScpExternalWagon in this same project... * @@ -64,8 +64,8 @@ public class CoreItWagon if ( is == null ) { - throw new TransferFailedException( getRepository().getUrl() - + " - Could not open input stream for resource: '" + resource + "'" ); + throw new TransferFailedException( + getRepository().getUrl() + " - Could not open input stream for resource: '" + resource + "'" ); } createParentDirectories( destination ); @@ -96,8 +96,8 @@ public class CoreItWagon if ( os == null ) { - throw new TransferFailedException( getRepository().getUrl() - + " - Could not open output stream for resource: '" + resource + "'" ); + throw new TransferFailedException( + getRepository().getUrl() + " - Could not open output stream for resource: '" + resource + "'" ); } putTransfer( outputData.getResource(), source, os, true ); @@ -164,16 +164,11 @@ public class CoreItWagon { File file = new File( "target/wagon.properties" ).getAbsoluteFile(); file.getParentFile().mkdirs(); - - OutputStream os = new FileOutputStream( file ); - try + + try ( OutputStream os = new FileOutputStream( file ) ) { props.store( os, "MAVEN-CORE-IT-WAGON" ); } - finally - { - os.close(); - } } catch ( IOException e ) { http://git-wip-us.apache.org/repos/asf/maven-integration-testing/blob/3987b9fd/core-it-support/core-it-wagon/src/main/java/org/apache/maven/wagon/providers/ssh/external/ScpExternalWagon.java ---------------------------------------------------------------------- diff --git a/core-it-support/core-it-wagon/src/main/java/org/apache/maven/wagon/providers/ssh/external/ScpExternalWagon.java b/core-it-support/core-it-wagon/src/main/java/org/apache/maven/wagon/providers/ssh/external/ScpExternalWagon.java index 0d4908c..41cfed6 100644 --- a/core-it-support/core-it-wagon/src/main/java/org/apache/maven/wagon/providers/ssh/external/ScpExternalWagon.java +++ b/core-it-support/core-it-wagon/src/main/java/org/apache/maven/wagon/providers/ssh/external/ScpExternalWagon.java @@ -19,15 +19,6 @@ package org.apache.maven.wagon.providers.ssh.external; * under the License. */ -import java.io.ByteArrayInputStream; -import java.io.ByteArrayOutputStream; -import java.io.File; -import java.io.FileOutputStream; -import java.io.IOException; -import java.io.InputStream; -import java.io.OutputStream; -import java.util.Properties; - import org.apache.maven.wagon.AbstractWagon; import org.apache.maven.wagon.ConnectionException; import org.apache.maven.wagon.InputData; @@ -38,10 +29,19 @@ import org.apache.maven.wagon.authentication.AuthenticationException; import org.apache.maven.wagon.authorization.AuthorizationException; import org.apache.maven.wagon.resource.Resource; +import java.io.ByteArrayInputStream; +import java.io.ByteArrayOutputStream; +import java.io.File; +import java.io.FileOutputStream; +import java.io.IOException; +import java.io.InputStream; +import java.io.OutputStream; +import java.util.Properties; + /** * NOTE: Plexus will only pick this correctly if the Class package and name are the same as that in core. This is * because the core component descriptor is read, but the class is read from the latter JAR. - * + * * @plexus.component role="org.apache.maven.wagon.Wagon" role-hint="scpexe" instantiation-strategy="per-lookup" */ public class ScpExternalWagon @@ -64,8 +64,8 @@ public class ScpExternalWagon if ( is == null ) { - throw new TransferFailedException( getRepository().getUrl() - + " - Could not open input stream for resource: '" + resource + "'" ); + throw new TransferFailedException( + getRepository().getUrl() + " - Could not open input stream for resource: '" + resource + "'" ); } createParentDirectories( destination ); @@ -98,8 +98,8 @@ public class ScpExternalWagon if ( os == null ) { - throw new TransferFailedException( getRepository().getUrl() - + " - Could not open output stream for resource: '" + resource + "'" ); + throw new TransferFailedException( + getRepository().getUrl() + " - Could not open output stream for resource: '" + resource + "'" ); } putTransfer( outputData.getResource(), source, os, true ); @@ -145,15 +145,10 @@ public class ScpExternalWagon try { - OutputStream os = new FileOutputStream( new File( dir, "wagon.properties" ) ); - try + try ( OutputStream os = new FileOutputStream( new File( dir, "wagon.properties" ) ) ) { props.store( os, "MAVEN-CORE-IT-WAGON" ); } - finally - { - os.close(); - } } catch ( IOException e ) { http://git-wip-us.apache.org/repos/asf/maven-integration-testing/blob/3987b9fd/core-it-support/maven-it-helper/src/main/java/org/apache/maven/it/AbstractMavenIntegrationTestCase.java ---------------------------------------------------------------------- diff --git a/core-it-support/maven-it-helper/src/main/java/org/apache/maven/it/AbstractMavenIntegrationTestCase.java b/core-it-support/maven-it-helper/src/main/java/org/apache/maven/it/AbstractMavenIntegrationTestCase.java index 1b1b7f4..36aa888 100644 --- a/core-it-support/maven-it-helper/src/main/java/org/apache/maven/it/AbstractMavenIntegrationTestCase.java +++ b/core-it-support/maven-it-helper/src/main/java/org/apache/maven/it/AbstractMavenIntegrationTestCase.java @@ -19,6 +19,7 @@ package org.apache.maven.it; * under the License. */ +import junit.framework.TestCase; import org.apache.maven.artifact.versioning.ArtifactVersion; import org.apache.maven.artifact.versioning.DefaultArtifactVersion; import org.apache.maven.artifact.versioning.InvalidVersionSpecificationException; @@ -34,8 +35,6 @@ import java.util.Locale; import java.util.regex.Matcher; import java.util.regex.Pattern; -import junit.framework.TestCase; - /** * @author Jason van Zyl * @author Kenney Westerhof @@ -58,7 +57,7 @@ public abstract class AbstractMavenIntegrationTestCase * The zero-based column index where to print the test result. */ private static final int RESULT_COLUMN = 60; - + private boolean skip; private static ArtifactVersion javaVersion; @@ -99,13 +98,13 @@ public abstract class AbstractMavenIntegrationTestCase else { out.println( "WARNING: " + getITName() + ": version range '" + versionRange - + "' supplied but no Maven version - not skipping test." ); + + "' supplied but no Maven version - not skipping test." ); } } /** * Gets the Java version used to run this test. - * + * * @return The Java version, never <code>null</code>. */ private ArtifactVersion getJavaVersion() @@ -126,7 +125,7 @@ public abstract class AbstractMavenIntegrationTestCase /** * Gets the Maven version used to run this test. - * + * * @return The Maven version or <code>null</code> if unknown. */ private ArtifactVersion getMavenVersion() @@ -190,7 +189,7 @@ public abstract class AbstractMavenIntegrationTestCase else { out.println( "WARNING: " + getITName() + ": version range '" + versionRange - + "' supplied but no Maven version found - returning true for match check." ); + + "' supplied but no Maven version found - returning true for match check." ); return true; } @@ -243,9 +242,9 @@ public abstract class AbstractMavenIntegrationTestCase * Guards the execution of a test case by checking that the current Java version matches the specified version * range. If the check fails, an exception will be thrown which aborts the current test and marks it as skipped. One * would usually call this method right at the start of a test method. - * + * * @param versionRange The version range that specifies the acceptable Java versions for the test, must not be - * <code>null</code>. + * <code>null</code>. */ protected void requiresJavaVersion( String versionRange ) { @@ -270,9 +269,9 @@ public abstract class AbstractMavenIntegrationTestCase * Guards the execution of a test case by checking that the current Maven version matches the specified version * range. If the check fails, an exception will be thrown which aborts the current test and marks it as skipped. One * would usually call this method right at the start of a test method. - * + * * @param versionRange The version range that specifies the acceptable Maven versions for the test, must not be - * <code>null</code>. + * <code>null</code>. */ protected void requiresMavenVersion( String versionRange ) { @@ -297,7 +296,7 @@ public abstract class AbstractMavenIntegrationTestCase else { out.println( "WARNING: " + getITName() + ": version range '" + versionRange - + "' supplied but no Maven version found - not skipping test." ); + + "' supplied but no Maven version found - not skipping test." ); } } @@ -358,7 +357,7 @@ public abstract class AbstractMavenIntegrationTestCase private String pad( int chars ) { - StringBuffer buffer = new StringBuffer( 128 ); + StringBuilder buffer = new StringBuilder( 128 ); for ( int i = 0; i < chars; i++ ) { buffer.append( '.' ); @@ -449,7 +448,7 @@ public abstract class AbstractMavenIntegrationTestCase // Make is easier to run ITs from m2e in Maven IT mode without having to set any additional // properties. // - settingsFile = new File( "target/test-classes", settingsFile.getPath() ); + settingsFile = new File( "target/test-classes", settingsFile.getPath() ); } }