[MSHARED-1202] update to parent POM 39 (#22)
* MSHARED-1202 update to parent POM 39
diff --git a/pom.xml b/pom.xml
index 31f2a44..3b456d3 100644
--- a/pom.xml
+++ b/pom.xml
@@ -23,7 +23,7 @@
<parent>
<groupId>org.apache.maven.shared</groupId>
<artifactId>maven-shared-components</artifactId>
- <version>34</version>
+ <version>39</version>
<relativePath />
</parent>
@@ -110,7 +110,7 @@
<artifactId>commons-io</artifactId>
<version>2.11.0</version>
</dependency>
-
+
<dependency>
<groupId>org.easymock</groupId>
<artifactId>easymock</artifactId>
diff --git a/src/main/java/org/apache/maven/shared/io/download/DefaultDownloadManager.java b/src/main/java/org/apache/maven/shared/io/download/DefaultDownloadManager.java
index 1353864..f1b994a 100644
--- a/src/main/java/org/apache/maven/shared/io/download/DefaultDownloadManager.java
+++ b/src/main/java/org/apache/maven/shared/io/download/DefaultDownloadManager.java
@@ -1,5 +1,3 @@
-package org.apache.maven.shared.io.download;
-
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
@@ -18,6 +16,7 @@
* specific language governing permissions and limitations
* under the License.
*/
+package org.apache.maven.shared.io.download;
import java.io.File;
import java.io.IOException;
@@ -46,9 +45,7 @@
* The Implementation of the {@link DownloadManager}
*
*/
-public class DefaultDownloadManager
- implements DownloadManager
-{
+public class DefaultDownloadManager implements DownloadManager {
/**
* Role hint.
@@ -62,152 +59,116 @@
/**
* Create an instance of the {@code DefaultDownloadManager}.
*/
- public DefaultDownloadManager()
- {
- }
+ public DefaultDownloadManager() {}
/**
* @param wagonManager {@link org.apache.maven.repository.legacy.WagonManager}
*/
- public DefaultDownloadManager( WagonManager wagonManager )
- {
+ public DefaultDownloadManager(WagonManager wagonManager) {
this.wagonManager = wagonManager;
}
/** {@inheritDoc} */
- public File download( String url, MessageHolder messageHolder )
- throws DownloadFailedException
- {
- return download( url, Collections.<TransferListener>emptyList(), messageHolder );
+ public File download(String url, MessageHolder messageHolder) throws DownloadFailedException {
+ return download(url, Collections.<TransferListener>emptyList(), messageHolder);
}
/** {@inheritDoc} */
- public File download( String url, List<TransferListener> transferListeners, MessageHolder messageHolder )
- throws DownloadFailedException
- {
- File downloaded = (File) cache.get( url );
+ public File download(String url, List<TransferListener> transferListeners, MessageHolder messageHolder)
+ throws DownloadFailedException {
+ File downloaded = (File) cache.get(url);
- if ( downloaded != null && downloaded.exists() )
- {
- messageHolder.addMessage( "Using cached download: " + downloaded.getAbsolutePath() );
+ if (downloaded != null && downloaded.exists()) {
+ messageHolder.addMessage("Using cached download: " + downloaded.getAbsolutePath());
return downloaded;
}
URL sourceUrl;
- try
- {
- sourceUrl = new URL( url );
- }
- catch ( MalformedURLException e )
- {
- throw new DownloadFailedException( url, "Download failed due to invalid URL.",
- e );
+ try {
+ sourceUrl = new URL(url);
+ } catch (MalformedURLException e) {
+ throw new DownloadFailedException(url, "Download failed due to invalid URL.", e);
}
Wagon wagon = null;
// Retrieve the correct Wagon instance used to download the remote archive
- try
- {
- wagon = wagonManager.getWagon( sourceUrl.getProtocol() );
- }
- catch ( UnsupportedProtocolException e )
- {
- throw new DownloadFailedException( url, "Download failed", e );
+ try {
+ wagon = wagonManager.getWagon(sourceUrl.getProtocol());
+ } catch (UnsupportedProtocolException e) {
+ throw new DownloadFailedException(url, "Download failed", e);
}
- messageHolder.addMessage( "Using wagon: " + wagon + " to download: " + url );
+ messageHolder.addMessage("Using wagon: " + wagon + " to download: " + url);
- try
- {
+ try {
// create the landing file in /tmp for the downloaded source archive
- downloaded = Files.createTempFile( "download-", null ).toFile();
+ downloaded = Files.createTempFile("download-", null).toFile();
// delete when the JVM exits, to avoid polluting the temp dir...
downloaded.deleteOnExit();
- }
- catch ( IOException e )
- {
- throw new DownloadFailedException( url, "Failed to create temporary file target for download.", e );
+ } catch (IOException e) {
+ throw new DownloadFailedException(url, "Failed to create temporary file target for download.", e);
}
- messageHolder.addMessage( "Download target is: " + downloaded.getAbsolutePath() );
+ messageHolder.addMessage("Download target is: " + downloaded.getAbsolutePath());
// split the download URL into base URL and remote path for connecting, then retrieving.
String remotePath = sourceUrl.getPath();
- String baseUrl = url.substring( 0, url.length() - remotePath.length() );
+ String baseUrl = url.substring(0, url.length() - remotePath.length());
- for ( Iterator<TransferListener> it = transferListeners.iterator(); it.hasNext(); )
- {
- wagon.addTransferListener( it.next() );
+ for (Iterator<TransferListener> it = transferListeners.iterator(); it.hasNext(); ) {
+ wagon.addTransferListener(it.next());
}
// connect to the remote site, and retrieve the archive. Note the separate methods in which
// base URL and remote path are used.
- Repository repo = new Repository( sourceUrl.getHost(), baseUrl );
+ Repository repo = new Repository(sourceUrl.getHost(), baseUrl);
- messageHolder.addMessage( "Connecting to: " + repo.getHost() + "(baseUrl: " + repo.getUrl() + ")" );
+ messageHolder.addMessage("Connecting to: " + repo.getHost() + "(baseUrl: " + repo.getUrl() + ")");
- try
- {
- wagon.connect( repo, wagonManager.getAuthenticationInfo( repo.getId() ),
- wagonManager.getProxy( sourceUrl.getProtocol() ) );
- }
- catch ( ConnectionException e )
- {
- throw new DownloadFailedException( url, "Download failed", e );
- }
- catch ( AuthenticationException e )
- {
- throw new DownloadFailedException( url, "Download failed", e );
+ try {
+ wagon.connect(
+ repo,
+ wagonManager.getAuthenticationInfo(repo.getId()),
+ wagonManager.getProxy(sourceUrl.getProtocol()));
+ } catch (ConnectionException e) {
+ throw new DownloadFailedException(url, "Download failed", e);
+ } catch (AuthenticationException e) {
+ throw new DownloadFailedException(url, "Download failed", e);
}
- messageHolder.addMessage( "Getting: " + remotePath );
+ messageHolder.addMessage("Getting: " + remotePath);
- try
- {
- wagon.get( remotePath, downloaded );
+ try {
+ wagon.get(remotePath, downloaded);
// cache this for later download requests to the same instance...
- cache.put( url, downloaded );
+ cache.put(url, downloaded);
return downloaded;
- }
- catch ( TransferFailedException e )
- {
- throw new DownloadFailedException( url, "Download failed", e );
- }
- catch ( ResourceDoesNotExistException e )
- {
- throw new DownloadFailedException( url, "Download failed", e );
- }
- catch ( AuthorizationException e )
- {
- throw new DownloadFailedException( url, "Download failed", e );
- }
- finally
- {
+ } catch (TransferFailedException e) {
+ throw new DownloadFailedException(url, "Download failed", e);
+ } catch (ResourceDoesNotExistException e) {
+ throw new DownloadFailedException(url, "Download failed", e);
+ } catch (AuthorizationException e) {
+ throw new DownloadFailedException(url, "Download failed", e);
+ } finally {
// ensure the Wagon instance is closed out properly.
- if ( wagon != null )
- {
- try
- {
- messageHolder.addMessage( "Disconnecting." );
+ if (wagon != null) {
+ try {
+ messageHolder.addMessage("Disconnecting.");
wagon.disconnect();
- }
- catch ( ConnectionException e )
- {
- messageHolder.addMessage( "Failed to disconnect wagon for: " + url, e );
+ } catch (ConnectionException e) {
+ messageHolder.addMessage("Failed to disconnect wagon for: " + url, e);
}
- for ( Iterator<TransferListener> it = transferListeners.iterator(); it.hasNext(); )
- {
- wagon.removeTransferListener( it.next() );
+ for (Iterator<TransferListener> it = transferListeners.iterator(); it.hasNext(); ) {
+ wagon.removeTransferListener(it.next());
}
}
}
}
-
}
diff --git a/src/main/java/org/apache/maven/shared/io/download/DownloadFailedException.java b/src/main/java/org/apache/maven/shared/io/download/DownloadFailedException.java
index 669ce8b..ad0c4d6 100644
--- a/src/main/java/org/apache/maven/shared/io/download/DownloadFailedException.java
+++ b/src/main/java/org/apache/maven/shared/io/download/DownloadFailedException.java
@@ -1,5 +1,3 @@
-package org.apache.maven.shared.io.download;
-
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
@@ -18,27 +16,24 @@
* specific language governing permissions and limitations
* under the License.
*/
+package org.apache.maven.shared.io.download;
/**
* The Download Failed Exception.
- *
*/
-public class DownloadFailedException
- extends Exception
-{
+public class DownloadFailedException extends Exception {
private static final long serialVersionUID = 1L;
private String url;
/**
- * @param url The url.
- * @param message The message.
- * @param cause The cause of the problem.
+ * @param url the url
+ * @param message the message
+ * @param cause the cause of the problem
*/
- public DownloadFailedException( String url, String message, Throwable cause )
- {
- super( message, cause );
+ public DownloadFailedException(String url, String message, Throwable cause) {
+ super(message, cause);
this.url = url;
}
@@ -46,18 +41,15 @@
* @param url The url.
* @param message The message.
*/
- public DownloadFailedException( String url, String message )
- {
- super( message );
+ public DownloadFailedException(String url, String message) {
+ super(message);
this.url = url;
}
/**
* @return The url.
*/
- public String getUrl()
- {
+ public String getUrl() {
return url;
}
-
}
diff --git a/src/main/java/org/apache/maven/shared/io/download/DownloadManager.java b/src/main/java/org/apache/maven/shared/io/download/DownloadManager.java
index 6d2e91a..d37f3de 100644
--- a/src/main/java/org/apache/maven/shared/io/download/DownloadManager.java
+++ b/src/main/java/org/apache/maven/shared/io/download/DownloadManager.java
@@ -1,5 +1,3 @@
-package org.apache.maven.shared.io.download;
-
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
@@ -18,6 +16,7 @@
* specific language governing permissions and limitations
* under the License.
*/
+package org.apache.maven.shared.io.download;
import java.io.File;
import java.util.List;
@@ -29,8 +28,7 @@
* The Download Manager interface.
*
*/
-public interface DownloadManager
-{
+public interface DownloadManager {
/**
* The Role.
*/
@@ -42,8 +40,7 @@
* @return {@link File}
* @throws DownloadFailedException in case of exception.
*/
- File download( String url, MessageHolder messageHolder )
- throws DownloadFailedException;
+ File download(String url, MessageHolder messageHolder) throws DownloadFailedException;
/**
* @param url The URL.
@@ -52,7 +49,6 @@
* @return {@link File}
* @throws DownloadFailedException in case of exception.
*/
- File download( String url, List<TransferListener> transferListeners, MessageHolder messageHolder )
- throws DownloadFailedException;
-
-}
\ No newline at end of file
+ File download(String url, List<TransferListener> transferListeners, MessageHolder messageHolder)
+ throws DownloadFailedException;
+}
diff --git a/src/main/java/org/apache/maven/shared/io/location/ArtifactLocation.java b/src/main/java/org/apache/maven/shared/io/location/ArtifactLocation.java
index dea6e68..cb7550f 100644
--- a/src/main/java/org/apache/maven/shared/io/location/ArtifactLocation.java
+++ b/src/main/java/org/apache/maven/shared/io/location/ArtifactLocation.java
@@ -1,5 +1,3 @@
-package org.apache.maven.shared.io.location;
-
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
@@ -18,25 +16,21 @@
* specific language governing permissions and limitations
* under the License.
*/
+package org.apache.maven.shared.io.location;
import org.apache.maven.artifact.Artifact;
/**
* The artifact location.
- *
*/
-public class ArtifactLocation
- extends FileLocation
-{
+public class ArtifactLocation extends FileLocation {
/**
* @param artifact {@link Artifact}
- * @param specification The specification.
+ * @param specification the specification
*/
- public ArtifactLocation( Artifact artifact, String specification )
- {
- super( specification );
- setFile( artifact.getFile() );
+ public ArtifactLocation(Artifact artifact, String specification) {
+ super(specification);
+ setFile(artifact.getFile());
}
-
}
diff --git a/src/main/java/org/apache/maven/shared/io/location/ArtifactLocatorStrategy.java b/src/main/java/org/apache/maven/shared/io/location/ArtifactLocatorStrategy.java
index 634b371..ced388d 100644
--- a/src/main/java/org/apache/maven/shared/io/location/ArtifactLocatorStrategy.java
+++ b/src/main/java/org/apache/maven/shared/io/location/ArtifactLocatorStrategy.java
@@ -1,5 +1,3 @@
-package org.apache.maven.shared.io.location;
-
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
@@ -18,6 +16,7 @@
* specific language governing permissions and limitations
* under the License.
*/
+package org.apache.maven.shared.io.location;
import java.util.List;
@@ -31,11 +30,8 @@
/**
* The locator strategy.
- *
*/
-public class ArtifactLocatorStrategy
- implements LocatorStrategy
-{
+public class ArtifactLocatorStrategy implements LocatorStrategy {
private final ArtifactFactory factory;
private final ArtifactResolver resolver;
@@ -54,9 +50,11 @@
* @param localRepository {@link ArtifactRepository}
* @param remoteRepositories {@link ArtifactRepository}
*/
- public ArtifactLocatorStrategy( ArtifactFactory factory, ArtifactResolver resolver,
- ArtifactRepository localRepository, List<ArtifactRepository> remoteRepositories )
- {
+ public ArtifactLocatorStrategy(
+ ArtifactFactory factory,
+ ArtifactResolver resolver,
+ ArtifactRepository localRepository,
+ List<ArtifactRepository> remoteRepositories) {
this.factory = factory;
this.resolver = resolver;
this.localRepository = localRepository;
@@ -70,10 +68,12 @@
* @param remoteRepositories {@link ArtifactRepository}
* @param defaultArtifactType default artifact type.
*/
- public ArtifactLocatorStrategy( ArtifactFactory factory, ArtifactResolver resolver,
- ArtifactRepository localRepository, List<ArtifactRepository> remoteRepositories,
- String defaultArtifactType )
- {
+ public ArtifactLocatorStrategy(
+ ArtifactFactory factory,
+ ArtifactResolver resolver,
+ ArtifactRepository localRepository,
+ List<ArtifactRepository> remoteRepositories,
+ String defaultArtifactType) {
this.factory = factory;
this.resolver = resolver;
this.localRepository = localRepository;
@@ -89,10 +89,13 @@
* @param defaultArtifactType default artifact type.
* @param defaultClassifier default classifier.
*/
- public ArtifactLocatorStrategy( ArtifactFactory factory, ArtifactResolver resolver,
- ArtifactRepository localRepository, List<ArtifactRepository> remoteRepositories,
- String defaultArtifactType, String defaultClassifier )
- {
+ public ArtifactLocatorStrategy(
+ ArtifactFactory factory,
+ ArtifactResolver resolver,
+ ArtifactRepository localRepository,
+ List<ArtifactRepository> remoteRepositories,
+ String defaultArtifactType,
+ String defaultClassifier) {
this.factory = factory;
this.resolver = resolver;
this.localRepository = localRepository;
@@ -109,85 +112,66 @@
* @param messageHolder {@link MessageHolder}
* @return location.
*/
- public Location resolve( String locationSpecification, MessageHolder messageHolder )
- {
- String[] parts = locationSpecification.split( ":" );
+ public Location resolve(String locationSpecification, MessageHolder messageHolder) {
+ String[] parts = locationSpecification.split(":");
Location location = null;
- if ( parts.length > 2 )
- {
+ if (parts.length > 2) {
String groupId = parts[0];
String artifactId = parts[1];
String version = parts[2];
String type = defaultArtifactType;
- if ( parts.length > 3 )
- {
- if ( parts[3].trim().length() > 0 )
- {
+ if (parts.length > 3) {
+ if (parts[3].trim().length() > 0) {
type = parts[3];
}
}
String classifier = defaultClassifier;
- if ( parts.length > 4 )
- {
+ if (parts.length > 4) {
classifier = parts[4];
}
- if ( parts.length > 5 )
- {
- messageHolder.newMessage().append( "Location specification has unused tokens: \'" );
+ if (parts.length > 5) {
+ messageHolder.newMessage().append("Location specification has unused tokens: \'");
- for ( int i = 5; i < parts.length; i++ )
- {
- messageHolder.append( ":" + parts[i] );
+ for (int i = 5; i < parts.length; i++) {
+ messageHolder.append(":" + parts[i]);
}
}
Artifact artifact;
- if ( classifier == null )
- {
- artifact = factory.createArtifact( groupId, artifactId, version, null, type );
- }
- else
- {
- artifact = factory.createArtifactWithClassifier( groupId, artifactId, version, type, classifier );
+ if (classifier == null) {
+ artifact = factory.createArtifact(groupId, artifactId, version, null, type);
+ } else {
+ artifact = factory.createArtifactWithClassifier(groupId, artifactId, version, type, classifier);
}
- try
- {
- resolver.resolve( artifact, remoteRepositories, localRepository );
+ try {
+ resolver.resolve(artifact, remoteRepositories, localRepository);
- if ( artifact.getFile() != null )
- {
- location = new ArtifactLocation( artifact, locationSpecification );
+ if (artifact.getFile() != null) {
+ location = new ArtifactLocation(artifact, locationSpecification);
+ } else {
+ messageHolder.addMessage(
+ "Supposedly resolved artifact: " + artifact.getId() + " does not have an associated file.");
}
- else
- {
- messageHolder.addMessage( "Supposedly resolved artifact: " + artifact.getId()
- + " does not have an associated file." );
- }
+ } catch (ArtifactResolutionException e) {
+ messageHolder.addMessage(
+ "Failed to resolve artifact: " + artifact.getId() + " for location: " + locationSpecification,
+ e);
+ } catch (ArtifactNotFoundException e) {
+ messageHolder.addMessage(
+ "Failed to resolve artifact: " + artifact.getId() + " for location: " + locationSpecification,
+ e);
}
- catch ( ArtifactResolutionException e )
- {
- messageHolder.addMessage( "Failed to resolve artifact: " + artifact.getId() + " for location: "
- + locationSpecification, e );
- }
- catch ( ArtifactNotFoundException e )
- {
- messageHolder.addMessage( "Failed to resolve artifact: " + artifact.getId() + " for location: "
- + locationSpecification, e );
- }
- }
- else
- {
- messageHolder.addMessage( "Invalid artifact specification: \'" + locationSpecification
- + "\'. Must contain at least three fields, separated by ':'." );
+ } else {
+ messageHolder.addMessage("Invalid artifact specification: \'" + locationSpecification
+ + "\'. Must contain at least three fields, separated by ':'.");
}
return location;
}
-
}
diff --git a/src/main/java/org/apache/maven/shared/io/location/ClasspathResourceLocatorStrategy.java b/src/main/java/org/apache/maven/shared/io/location/ClasspathResourceLocatorStrategy.java
index 4d850cf..aace0b6 100644
--- a/src/main/java/org/apache/maven/shared/io/location/ClasspathResourceLocatorStrategy.java
+++ b/src/main/java/org/apache/maven/shared/io/location/ClasspathResourceLocatorStrategy.java
@@ -1,5 +1,3 @@
-package org.apache.maven.shared.io.location;
-
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
@@ -18,6 +16,7 @@
* specific language governing permissions and limitations
* under the License.
*/
+package org.apache.maven.shared.io.location;
import java.net.URL;
@@ -27,9 +26,7 @@
* classpath resource locator strategy.
*
*/
-public class ClasspathResourceLocatorStrategy
- implements LocatorStrategy
-{
+public class ClasspathResourceLocatorStrategy implements LocatorStrategy {
private String tempFilePrefix = "location.";
@@ -40,44 +37,36 @@
/**
* Create instance.
*/
- public ClasspathResourceLocatorStrategy()
- {
- }
+ public ClasspathResourceLocatorStrategy() {}
/**
* @param tempFilePrefix Prefix.
* @param tempFileSuffix Suffix.
* @param tempFileDeleteOnExit delete on exit.
*/
- public ClasspathResourceLocatorStrategy( String tempFilePrefix, String tempFileSuffix,
- boolean tempFileDeleteOnExit )
- {
+ public ClasspathResourceLocatorStrategy(
+ String tempFilePrefix, String tempFileSuffix, boolean tempFileDeleteOnExit) {
this.tempFilePrefix = tempFilePrefix;
this.tempFileSuffix = tempFileSuffix;
this.tempFileDeleteOnExit = tempFileDeleteOnExit;
}
/** {@inheritDoc} */
- public Location resolve( String locationSpecification, MessageHolder messageHolder )
- {
+ public Location resolve(String locationSpecification, MessageHolder messageHolder) {
ClassLoader cloader = Thread.currentThread().getContextClassLoader();
- URL resource = cloader.getResource( locationSpecification );
+ URL resource = cloader.getResource(locationSpecification);
Location location = null;
- if ( resource != null )
- {
- location = new URLLocation( resource, locationSpecification, tempFilePrefix, tempFileSuffix,
- tempFileDeleteOnExit );
- }
- else
- {
- messageHolder.addMessage( "Failed to resolve classpath resource: " + locationSpecification
- + " from classloader: " + cloader );
+ if (resource != null) {
+ location = new URLLocation(
+ resource, locationSpecification, tempFilePrefix, tempFileSuffix, tempFileDeleteOnExit);
+ } else {
+ messageHolder.addMessage(
+ "Failed to resolve classpath resource: " + locationSpecification + " from classloader: " + cloader);
}
return location;
}
-
}
diff --git a/src/main/java/org/apache/maven/shared/io/location/FileLocation.java b/src/main/java/org/apache/maven/shared/io/location/FileLocation.java
index a8a62e3..3d60340 100644
--- a/src/main/java/org/apache/maven/shared/io/location/FileLocation.java
+++ b/src/main/java/org/apache/maven/shared/io/location/FileLocation.java
@@ -1,5 +1,3 @@
-package org.apache.maven.shared.io.location;
-
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
@@ -18,6 +16,7 @@
* specific language governing permissions and limitations
* under the License.
*/
+package org.apache.maven.shared.io.location;
import java.io.File;
import java.io.FileInputStream;
@@ -26,14 +25,10 @@
import java.nio.ByteBuffer;
import java.nio.channels.FileChannel;
-
/**
* file location implementation.
- *
*/
-public class FileLocation
- implements Location
-{
+public class FileLocation implements Location {
private File file;
private FileChannel channel;
@@ -44,8 +39,7 @@
* @param file {@link File}
* @param specification spec.
*/
- public FileLocation( File file, String specification )
- {
+ public FileLocation(File file, String specification) {
this.file = file;
this.specification = specification;
}
@@ -53,43 +47,31 @@
/**
* @param specification spec.
*/
- protected FileLocation( String specification )
- {
+ protected FileLocation(String specification) {
this.specification = specification;
}
/** {@inheritDoc} */
- public void close()
- {
- if ( ( channel != null ) && channel.isOpen() )
- {
- try
- {
+ public void close() {
+ if ((channel != null) && channel.isOpen()) {
+ try {
channel.close();
- }
- catch ( IOException e )
- {
- //swallow it.
+ } catch (IOException e) {
+ // swallow it.
}
}
- if ( stream != null )
- {
- try
- {
+ if (stream != null) {
+ try {
stream.close();
- }
- catch ( IOException e )
- {
+ } catch (IOException e) {
// swallow it.
}
}
}
/** {@inheritDoc} */
- public File getFile()
- throws IOException
- {
+ public File getFile() throws IOException {
initFile();
return unsafeGetFile();
@@ -98,8 +80,7 @@
/**
* @return {@link File}
*/
- protected File unsafeGetFile()
- {
+ protected File unsafeGetFile() {
return file;
}
@@ -107,70 +88,54 @@
* initialize file.
* @throws IOException in case error.
*/
- protected void initFile()
- throws IOException
- {
+ protected void initFile() throws IOException {
// TODO: Log this in the debug log-level...
- if ( file == null )
- {
- file = new File( specification );
+ if (file == null) {
+ file = new File(specification);
}
}
/**
* @param file {@link File}
*/
- protected void setFile( File file )
- {
- if ( channel != null )
- {
- throw new IllegalStateException( "Location is already open; cannot setFile(..)." );
+ protected void setFile(File file) {
+ if (channel != null) {
+ throw new IllegalStateException("Location is already open; cannot setFile(..).");
}
this.file = file;
}
/** {@inheritDoc} */
- public String getSpecification()
- {
+ public String getSpecification() {
return specification;
}
/** {@inheritDoc} */
- public void open()
- throws IOException
- {
- if ( stream == null )
- {
+ public void open() throws IOException {
+ if (stream == null) {
initFile();
- stream = new FileInputStream( file );
+ stream = new FileInputStream(file);
channel = stream.getChannel();
}
}
/** {@inheritDoc} */
- public int read( ByteBuffer buffer )
- throws IOException
- {
+ public int read(ByteBuffer buffer) throws IOException {
open();
- return channel.read( buffer );
+ return channel.read(buffer);
}
/** {@inheritDoc} */
- public int read( byte[] buffer )
- throws IOException
- {
+ public int read(byte[] buffer) throws IOException {
open();
- return channel.read( ByteBuffer.wrap( buffer ) );
+ return channel.read(ByteBuffer.wrap(buffer));
}
/** {@inheritDoc} */
- public InputStream getInputStream()
- throws IOException
- {
+ public InputStream getInputStream() throws IOException {
open();
return stream;
}
-
}
diff --git a/src/main/java/org/apache/maven/shared/io/location/FileLocatorStrategy.java b/src/main/java/org/apache/maven/shared/io/location/FileLocatorStrategy.java
index 92aa3dd..41d4bf2 100644
--- a/src/main/java/org/apache/maven/shared/io/location/FileLocatorStrategy.java
+++ b/src/main/java/org/apache/maven/shared/io/location/FileLocatorStrategy.java
@@ -1,5 +1,3 @@
-package org.apache.maven.shared.io.location;
-
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
@@ -18,6 +16,7 @@
* specific language governing permissions and limitations
* under the License.
*/
+package org.apache.maven.shared.io.location;
import java.io.File;
@@ -27,27 +26,20 @@
* file locator strategy.
*
*/
-public class FileLocatorStrategy
- implements LocatorStrategy
-{
+public class FileLocatorStrategy implements LocatorStrategy {
/** {@inheritDoc} */
- public Location resolve( String locationSpecification, MessageHolder messageHolder )
- {
- File file = new File( locationSpecification );
+ public Location resolve(String locationSpecification, MessageHolder messageHolder) {
+ File file = new File(locationSpecification);
Location location = null;
- if ( file.exists() )
- {
- location = new FileLocation( file, locationSpecification );
- }
- else
- {
- messageHolder.addMessage( "File: " + file.getAbsolutePath() + " does not exist." );
+ if (file.exists()) {
+ location = new FileLocation(file, locationSpecification);
+ } else {
+ messageHolder.addMessage("File: " + file.getAbsolutePath() + " does not exist.");
}
return location;
}
-
}
diff --git a/src/main/java/org/apache/maven/shared/io/location/Location.java b/src/main/java/org/apache/maven/shared/io/location/Location.java
index cfbd4ae..eba6075 100644
--- a/src/main/java/org/apache/maven/shared/io/location/Location.java
+++ b/src/main/java/org/apache/maven/shared/io/location/Location.java
@@ -1,5 +1,3 @@
-package org.apache.maven.shared.io.location;
-
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
@@ -18,6 +16,7 @@
* specific language governing permissions and limitations
* under the License.
*/
+package org.apache.maven.shared.io.location;
import java.io.File;
import java.io.IOException;
@@ -26,14 +25,12 @@
/**
* The location interface.
- *
*/
-public interface Location
-{
+public interface Location {
/**
- * @return {@link File}.
- * @throws IOException in case of an error.
+ * @return {@link File}
+ * @throws IOException in case of an error
*/
File getFile() throws IOException;
@@ -53,14 +50,14 @@
* @return number of read bytes.
* @throws IOException in case of an error.
*/
- int read( ByteBuffer buffer ) throws IOException;
+ int read(ByteBuffer buffer) throws IOException;
/**
* @param buffer The buffer.
* @return number of read bytes.
* @throws IOException in case of an error.
*/
- int read( byte[] buffer ) throws IOException;
+ int read(byte[] buffer) throws IOException;
/**
* @return the resulting input stream.
@@ -72,5 +69,4 @@
* @return spec.
*/
String getSpecification();
-
}
diff --git a/src/main/java/org/apache/maven/shared/io/location/Locator.java b/src/main/java/org/apache/maven/shared/io/location/Locator.java
index 45f27af..d838d7a 100644
--- a/src/main/java/org/apache/maven/shared/io/location/Locator.java
+++ b/src/main/java/org/apache/maven/shared/io/location/Locator.java
@@ -1,5 +1,3 @@
-package org.apache.maven.shared.io.location;
-
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
@@ -18,6 +16,7 @@
* specific language governing permissions and limitations
* under the License.
*/
+package org.apache.maven.shared.io.location;
import java.util.ArrayList;
import java.util.Iterator;
@@ -28,10 +27,8 @@
/**
* The Locator.
- *
*/
-public final class Locator
-{
+public final class Locator {
private List<LocatorStrategy> strategies;
private final MessageHolder messageHolder;
@@ -40,17 +37,15 @@
* @param strategies List of strategies.
* @param messageHolder {@link MessageHolder}
*/
- public Locator( List<LocatorStrategy> strategies, MessageHolder messageHolder )
- {
+ public Locator(List<LocatorStrategy> strategies, MessageHolder messageHolder) {
this.messageHolder = messageHolder;
- this.strategies = new ArrayList<LocatorStrategy>( strategies );
+ this.strategies = new ArrayList<LocatorStrategy>(strategies);
}
/**
* Create instance.
*/
- public Locator()
- {
+ public Locator() {
this.messageHolder = new DefaultMessageHolder();
this.strategies = new ArrayList<LocatorStrategy>();
}
@@ -58,41 +53,36 @@
/**
* @return {@link MessageHolder}
*/
- public MessageHolder getMessageHolder()
- {
+ public MessageHolder getMessageHolder() {
return messageHolder;
}
/**
* @param strategy The strategy to be added.
*/
- public void addStrategy( LocatorStrategy strategy )
- {
- this.strategies.add( strategy );
+ public void addStrategy(LocatorStrategy strategy) {
+ this.strategies.add(strategy);
}
/**
* @param strategy the strategy to remove.
*/
- public void removeStrategy( LocatorStrategy strategy )
- {
- this.strategies.remove( strategy );
+ public void removeStrategy(LocatorStrategy strategy) {
+ this.strategies.remove(strategy);
}
/**
* @param strategies the strategies to be set.
*/
- public void setStrategies( List<LocatorStrategy> strategies )
- {
+ public void setStrategies(List<LocatorStrategy> strategies) {
this.strategies.clear();
- this.strategies.addAll( strategies );
+ this.strategies.addAll(strategies);
}
/**
* @return list of strategies.
*/
- public List<LocatorStrategy> getStrategies()
- {
+ public List<LocatorStrategy> getStrategies() {
return strategies;
}
@@ -100,18 +90,15 @@
* @param locationSpecification location spec.
* @return {@link Location}
*/
- public Location resolve( String locationSpecification )
- {
+ public Location resolve(String locationSpecification) {
Location location = null;
- for ( Iterator<LocatorStrategy> it = strategies.iterator(); location == null && it.hasNext(); )
- {
+ for (Iterator<LocatorStrategy> it = strategies.iterator(); location == null && it.hasNext(); ) {
LocatorStrategy strategy = (LocatorStrategy) it.next();
- location = strategy.resolve( locationSpecification, messageHolder );
+ location = strategy.resolve(locationSpecification, messageHolder);
}
return location;
}
-
}
diff --git a/src/main/java/org/apache/maven/shared/io/location/LocatorStrategy.java b/src/main/java/org/apache/maven/shared/io/location/LocatorStrategy.java
index 03e9d23..56b2b93 100644
--- a/src/main/java/org/apache/maven/shared/io/location/LocatorStrategy.java
+++ b/src/main/java/org/apache/maven/shared/io/location/LocatorStrategy.java
@@ -1,5 +1,3 @@
-package org.apache.maven.shared.io.location;
-
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
@@ -18,21 +16,19 @@
* specific language governing permissions and limitations
* under the License.
*/
+package org.apache.maven.shared.io.location;
import org.apache.maven.shared.io.logging.MessageHolder;
/**
* Locator Strategy interface.
- *
*/
-public interface LocatorStrategy
-{
+public interface LocatorStrategy {
/**
* @param locationSpecification the specification.
* @param messageHolder {@link MessageHolder}
* @return {@link Location}
*/
- Location resolve( String locationSpecification, MessageHolder messageHolder );
-
+ Location resolve(String locationSpecification, MessageHolder messageHolder);
}
diff --git a/src/main/java/org/apache/maven/shared/io/location/URLLocation.java b/src/main/java/org/apache/maven/shared/io/location/URLLocation.java
index c412e52..ae9d645 100644
--- a/src/main/java/org/apache/maven/shared/io/location/URLLocation.java
+++ b/src/main/java/org/apache/maven/shared/io/location/URLLocation.java
@@ -1,5 +1,3 @@
-package org.apache.maven.shared.io.location;
-
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
@@ -18,6 +16,7 @@
* specific language governing permissions and limitations
* under the License.
*/
+package org.apache.maven.shared.io.location;
import java.io.File;
import java.io.IOException;
@@ -29,9 +28,7 @@
/**
* The URL Location.
*/
-public class URLLocation
- extends FileLocation
-{
+public class URLLocation extends FileLocation {
private final URL url;
@@ -48,10 +45,9 @@
* @param tempFileSuffix the suffix
* @param tempFileDeleteOnExit delete on exit
*/
- public URLLocation( URL url, String specification, String tempFilePrefix, String tempFileSuffix,
- boolean tempFileDeleteOnExit )
- {
- super( specification );
+ public URLLocation(
+ URL url, String specification, String tempFilePrefix, String tempFileSuffix, boolean tempFileDeleteOnExit) {
+ super(specification);
this.url = url;
this.tempFilePrefix = tempFilePrefix;
@@ -60,22 +56,17 @@
}
/** {@inheritDoc} */
- protected void initFile()
- throws IOException
- {
- if ( unsafeGetFile() == null )
- {
- File tempFile = Files.createTempFile( tempFilePrefix, tempFileSuffix ).toFile();
+ protected void initFile() throws IOException {
+ if (unsafeGetFile() == null) {
+ File tempFile = Files.createTempFile(tempFilePrefix, tempFileSuffix).toFile();
- if ( tempFileDeleteOnExit )
- {
+ if (tempFileDeleteOnExit) {
tempFile.deleteOnExit();
}
- FileUtils.copyURLToFile( url, tempFile );
+ FileUtils.copyURLToFile(url, tempFile);
- setFile( tempFile );
+ setFile(tempFile);
}
}
-
}
diff --git a/src/main/java/org/apache/maven/shared/io/location/URLLocatorStrategy.java b/src/main/java/org/apache/maven/shared/io/location/URLLocatorStrategy.java
index e7d259d..57d150b 100644
--- a/src/main/java/org/apache/maven/shared/io/location/URLLocatorStrategy.java
+++ b/src/main/java/org/apache/maven/shared/io/location/URLLocatorStrategy.java
@@ -1,5 +1,3 @@
-package org.apache.maven.shared.io.location;
-
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
@@ -18,6 +16,7 @@
* specific language governing permissions and limitations
* under the License.
*/
+package org.apache.maven.shared.io.location;
import java.net.MalformedURLException;
import java.net.URL;
@@ -26,11 +25,8 @@
/**
* URL Locator Strategy.
- *
*/
-public class URLLocatorStrategy
- implements LocatorStrategy
-{
+public class URLLocatorStrategy implements LocatorStrategy {
private String tempFilePrefix = "location.";
@@ -41,40 +37,32 @@
/**
* Create instance.
*/
- public URLLocatorStrategy()
- {
- }
+ public URLLocatorStrategy() {}
/**
* @param tempFilePrefix prefix.
* @param tempFileSuffix suffix.
* @param tempFileDeleteOnExit delete on exit.
*/
- public URLLocatorStrategy( String tempFilePrefix, String tempFileSuffix, boolean tempFileDeleteOnExit )
- {
+ public URLLocatorStrategy(String tempFilePrefix, String tempFileSuffix, boolean tempFileDeleteOnExit) {
this.tempFilePrefix = tempFilePrefix;
this.tempFileSuffix = tempFileSuffix;
this.tempFileDeleteOnExit = tempFileDeleteOnExit;
}
/** {@inheritDoc} */
- public Location resolve( String locationSpecification, MessageHolder messageHolder )
- {
+ public Location resolve(String locationSpecification, MessageHolder messageHolder) {
Location location = null;
- try
- {
- URL url = new URL( locationSpecification );
+ try {
+ URL url = new URL(locationSpecification);
- location = new URLLocation( url, locationSpecification, tempFilePrefix, tempFileSuffix,
- tempFileDeleteOnExit );
- }
- catch ( MalformedURLException e )
- {
- messageHolder.addMessage( "Building URL from location: " + locationSpecification, e );
+ location =
+ new URLLocation(url, locationSpecification, tempFilePrefix, tempFileSuffix, tempFileDeleteOnExit);
+ } catch (MalformedURLException e) {
+ messageHolder.addMessage("Building URL from location: " + locationSpecification, e);
}
return location;
}
-
}
diff --git a/src/main/java/org/apache/maven/shared/io/logging/DefaultMessageHolder.java b/src/main/java/org/apache/maven/shared/io/logging/DefaultMessageHolder.java
index 97eeb06..e3a47ec 100644
--- a/src/main/java/org/apache/maven/shared/io/logging/DefaultMessageHolder.java
+++ b/src/main/java/org/apache/maven/shared/io/logging/DefaultMessageHolder.java
@@ -1,5 +1,3 @@
-package org.apache.maven.shared.io.logging;
-
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
@@ -18,6 +16,7 @@
* specific language governing permissions and limitations
* under the License.
*/
+package org.apache.maven.shared.io.logging;
import java.io.PrintWriter;
import java.io.StringWriter;
@@ -29,9 +28,7 @@
* Default Message Holder.
*
*/
-public class DefaultMessageHolder
- implements MessageHolder
-{
+public class DefaultMessageHolder implements MessageHolder {
private List<Message> messages = new ArrayList<Message>();
@@ -46,19 +43,17 @@
/**
* Create instance.
*/
- public DefaultMessageHolder()
- {
- this.messageLevelStates = MessageLevels.getLevelStates( MessageLevels.LEVEL_INFO );
+ public DefaultMessageHolder() {
+ this.messageLevelStates = MessageLevels.getLevelStates(MessageLevels.LEVEL_INFO);
}
/**
* @param maxMessageLevel max message level.
* @param defaultMessageLevel default message level.
*/
- public DefaultMessageHolder( int maxMessageLevel, int defaultMessageLevel )
- {
+ public DefaultMessageHolder(int maxMessageLevel, int defaultMessageLevel) {
this.defaultMessageLevel = defaultMessageLevel;
- this.messageLevelStates = MessageLevels.getLevelStates( maxMessageLevel );
+ this.messageLevelStates = MessageLevels.getLevelStates(maxMessageLevel);
}
/**
@@ -66,17 +61,15 @@
* @param defaultMessageLevel default message level.
* @param onDemandSink {@link MessageSink}
*/
- public DefaultMessageHolder( int maxMessageLevel, int defaultMessageLevel, MessageSink onDemandSink )
- {
+ public DefaultMessageHolder(int maxMessageLevel, int defaultMessageLevel, MessageSink onDemandSink) {
this.defaultMessageLevel = defaultMessageLevel;
this.onDemandSink = onDemandSink;
- this.messageLevelStates = MessageLevels.getLevelStates( maxMessageLevel );
+ this.messageLevelStates = MessageLevels.getLevelStates(maxMessageLevel);
}
/** {@inheritDoc} */
- public MessageHolder addMessage( CharSequence messagePart, Throwable error )
- {
- return addMessage( defaultMessageLevel, messagePart, error );
+ public MessageHolder addMessage(CharSequence messagePart, Throwable error) {
+ return addMessage(defaultMessageLevel, messagePart, error);
}
/**
@@ -85,19 +78,17 @@
* @param error {@link Throwable}
* @return {@link MessageHolder}
*/
- protected MessageHolder addMessage( int level, CharSequence messagePart, Throwable error )
- {
- newMessage( level );
- append( messagePart.toString() );
- append( error );
+ protected MessageHolder addMessage(int level, CharSequence messagePart, Throwable error) {
+ newMessage(level);
+ append(messagePart.toString());
+ append(error);
return this;
}
/** {@inheritDoc} */
- public MessageHolder addMessage( CharSequence messagePart )
- {
- return addMessage( defaultMessageLevel, messagePart );
+ public MessageHolder addMessage(CharSequence messagePart) {
+ return addMessage(defaultMessageLevel, messagePart);
}
/**
@@ -105,18 +96,16 @@
* @param messagePart message part.
* @return {@link MessageHolder}
*/
- protected MessageHolder addMessage( int level, CharSequence messagePart )
- {
- newMessage( level );
- append( messagePart.toString() );
+ protected MessageHolder addMessage(int level, CharSequence messagePart) {
+ newMessage(level);
+ append(messagePart.toString());
return this;
}
/** {@inheritDoc} */
- public MessageHolder addMessage( Throwable error )
- {
- return addMessage( defaultMessageLevel, error );
+ public MessageHolder addMessage(Throwable error) {
+ return addMessage(defaultMessageLevel, error);
}
/**
@@ -124,50 +113,43 @@
* @param error {@link Throwable}
* @return {@link MessageHolder}
*/
- protected MessageHolder addMessage( int level, Throwable error )
- {
- newMessage( level );
- append( error );
+ protected MessageHolder addMessage(int level, Throwable error) {
+ newMessage(level);
+ append(error);
return this;
}
/** {@inheritDoc} */
- public MessageHolder append( CharSequence messagePart )
- {
- if ( currentMessage == null )
- {
+ public MessageHolder append(CharSequence messagePart) {
+ if (currentMessage == null) {
newMessage();
}
- currentMessage.append( messagePart.toString() );
+ currentMessage.append(messagePart.toString());
return this;
}
/** {@inheritDoc} */
- public MessageHolder append( Throwable error )
- {
- if ( currentMessage == null )
- {
+ public MessageHolder append(Throwable error) {
+ if (currentMessage == null) {
newMessage();
}
- currentMessage.setError( error );
+ currentMessage.setError(error);
return this;
}
/** {@inheritDoc} */
- public boolean isEmpty()
- {
+ public boolean isEmpty() {
return messages.isEmpty();
}
/** {@inheritDoc} */
- public MessageHolder newMessage()
- {
- newMessage( defaultMessageLevel );
+ public MessageHolder newMessage() {
+ newMessage(defaultMessageLevel);
return this;
}
@@ -175,50 +157,42 @@
/**
* @param messageLevel message level.
*/
- protected void newMessage( int messageLevel )
- {
- if ( onDemandSink != null && currentMessage != null )
- {
- renderTo( currentMessage, onDemandSink );
+ protected void newMessage(int messageLevel) {
+ if (onDemandSink != null && currentMessage != null) {
+ renderTo(currentMessage, onDemandSink);
}
- currentMessage = new Message( messageLevel, onDemandSink );
- messages.add( currentMessage );
+ currentMessage = new Message(messageLevel, onDemandSink);
+ messages.add(currentMessage);
}
/** {@inheritDoc} */
- public String render()
- {
+ public String render() {
StringBuffer buffer = new StringBuffer();
int counter = 1;
- for ( Iterator<Message> it = messages.iterator(); it.hasNext(); )
- {
+ for (Iterator<Message> it = messages.iterator(); it.hasNext(); ) {
Message message = (Message) it.next();
int ml = message.getMessageLevel();
- if ( ml >= messageLevelStates.length || ml < 0 )
- {
+ if (ml >= messageLevelStates.length || ml < 0) {
ml = MessageLevels.LEVEL_DEBUG;
}
- if ( !messageLevelStates[ml] )
- {
+ if (!messageLevelStates[ml]) {
continue;
}
CharSequence content = message.render();
- String label = MessageLevels.getLevelLabel( message.getMessageLevel() );
+ String label = MessageLevels.getLevelLabel(message.getMessageLevel());
- if ( content.length() > label.length() + 3 )
- {
- buffer.append( '[' ).append( counter++ ).append( "] " );
- buffer.append( content.toString() );
+ if (content.length() > label.length() + 3) {
+ buffer.append('[').append(counter++).append("] ");
+ buffer.append(content.toString());
- if ( it.hasNext() )
- {
- buffer.append( "\n\n" );
+ if (it.hasNext()) {
+ buffer.append("\n\n");
}
}
}
@@ -227,13 +201,11 @@
}
/** {@inheritDoc} */
- public int size()
- {
+ public int size() {
return messages.size();
}
- private static final class Message
- {
+ private static final class Message {
private StringBuffer message = new StringBuffer();
private Throwable error;
@@ -242,63 +214,56 @@
private final MessageSink onDemandSink;
- Message( int messageLevel, MessageSink onDemandSink )
- {
+ Message(int messageLevel, MessageSink onDemandSink) {
this.messageLevel = messageLevel;
this.onDemandSink = onDemandSink;
}
- public Message setError( Throwable pError )
- {
+ public Message setError(Throwable pError) {
this.error = pError;
return this;
}
- public Message append( CharSequence pMessage )
- {
- this.message.append( pMessage.toString() );
+ public Message append(CharSequence pMessage) {
+ this.message.append(pMessage.toString());
return this;
}
/**
* @return message level.
*/
- public int getMessageLevel()
- {
+ public int getMessageLevel() {
return messageLevel;
}
/**
* @return Sequence.
*/
- public CharSequence render()
- {
+ public CharSequence render() {
StringBuffer buffer = new StringBuffer();
- if ( onDemandSink == null )
- {
- buffer.append( '[' ).append( MessageLevels.getLevelLabel( messageLevel ) ).append( "] " );
+ if (onDemandSink == null) {
+ buffer.append('[')
+ .append(MessageLevels.getLevelLabel(messageLevel))
+ .append("] ");
}
- if ( message != null && message.length() > 0 )
- {
- buffer.append( message );
+ if (message != null && message.length() > 0) {
+ buffer.append(message);
- if ( error != null )
- {
- buffer.append( '\n' );
+ if (error != null) {
+ buffer.append('\n');
}
}
- if ( error != null )
- {
- buffer.append( "Error:\n" );
+ if (error != null) {
+ buffer.append("Error:\n");
StringWriter sw = new StringWriter();
- PrintWriter pw = new PrintWriter( sw );
- error.printStackTrace( pw );
+ PrintWriter pw = new PrintWriter(sw);
+ error.printStackTrace(pw);
- buffer.append( sw.toString() );
+ buffer.append(sw.toString());
}
return buffer;
@@ -306,143 +271,119 @@
}
/** {@inheritDoc} */
- public MessageHolder addDebugMessage( CharSequence messagePart, Throwable error )
- {
- return addMessage( MessageLevels.LEVEL_DEBUG, messagePart, error );
+ public MessageHolder addDebugMessage(CharSequence messagePart, Throwable error) {
+ return addMessage(MessageLevels.LEVEL_DEBUG, messagePart, error);
}
/** {@inheritDoc} */
- public MessageHolder addDebugMessage( CharSequence messagePart )
- {
- return addMessage( MessageLevels.LEVEL_DEBUG, messagePart );
+ public MessageHolder addDebugMessage(CharSequence messagePart) {
+ return addMessage(MessageLevels.LEVEL_DEBUG, messagePart);
}
/** {@inheritDoc} */
- public MessageHolder addDebugMessage( Throwable error )
- {
- return addMessage( MessageLevels.LEVEL_DEBUG, error );
+ public MessageHolder addDebugMessage(Throwable error) {
+ return addMessage(MessageLevels.LEVEL_DEBUG, error);
}
/** {@inheritDoc} */
- public MessageHolder addErrorMessage( CharSequence messagePart, Throwable error )
- {
- return addMessage( MessageLevels.LEVEL_ERROR, messagePart, error );
+ public MessageHolder addErrorMessage(CharSequence messagePart, Throwable error) {
+ return addMessage(MessageLevels.LEVEL_ERROR, messagePart, error);
}
/** {@inheritDoc} */
- public MessageHolder addErrorMessage( CharSequence messagePart )
- {
- return addMessage( MessageLevels.LEVEL_ERROR, messagePart );
+ public MessageHolder addErrorMessage(CharSequence messagePart) {
+ return addMessage(MessageLevels.LEVEL_ERROR, messagePart);
}
/** {@inheritDoc} */
- public MessageHolder addErrorMessage( Throwable error )
- {
- return addMessage( MessageLevels.LEVEL_ERROR, error );
+ public MessageHolder addErrorMessage(Throwable error) {
+ return addMessage(MessageLevels.LEVEL_ERROR, error);
}
/** {@inheritDoc} */
- public MessageHolder addInfoMessage( CharSequence messagePart, Throwable error )
- {
- return addMessage( MessageLevels.LEVEL_INFO, messagePart, error );
+ public MessageHolder addInfoMessage(CharSequence messagePart, Throwable error) {
+ return addMessage(MessageLevels.LEVEL_INFO, messagePart, error);
}
/** {@inheritDoc} */
- public MessageHolder addInfoMessage( CharSequence messagePart )
- {
- return addMessage( MessageLevels.LEVEL_INFO, messagePart );
+ public MessageHolder addInfoMessage(CharSequence messagePart) {
+ return addMessage(MessageLevels.LEVEL_INFO, messagePart);
}
/** {@inheritDoc} */
- public MessageHolder addInfoMessage( Throwable error )
- {
- return addMessage( MessageLevels.LEVEL_INFO, error );
+ public MessageHolder addInfoMessage(Throwable error) {
+ return addMessage(MessageLevels.LEVEL_INFO, error);
}
/** {@inheritDoc} */
- public MessageHolder addSevereMessage( CharSequence messagePart, Throwable error )
- {
- return addMessage( MessageLevels.LEVEL_SEVERE, messagePart, error );
+ public MessageHolder addSevereMessage(CharSequence messagePart, Throwable error) {
+ return addMessage(MessageLevels.LEVEL_SEVERE, messagePart, error);
}
/** {@inheritDoc} */
- public MessageHolder addSevereMessage( CharSequence messagePart )
- {
- return addMessage( MessageLevels.LEVEL_SEVERE, messagePart );
+ public MessageHolder addSevereMessage(CharSequence messagePart) {
+ return addMessage(MessageLevels.LEVEL_SEVERE, messagePart);
}
/** {@inheritDoc} */
- public MessageHolder addSevereMessage( Throwable error )
- {
- return addMessage( MessageLevels.LEVEL_SEVERE, error );
+ public MessageHolder addSevereMessage(Throwable error) {
+ return addMessage(MessageLevels.LEVEL_SEVERE, error);
}
/** {@inheritDoc} */
- public MessageHolder addWarningMessage( CharSequence messagePart, Throwable error )
- {
- return addMessage( MessageLevels.LEVEL_WARNING, messagePart, error );
+ public MessageHolder addWarningMessage(CharSequence messagePart, Throwable error) {
+ return addMessage(MessageLevels.LEVEL_WARNING, messagePart, error);
}
/** {@inheritDoc} */
- public MessageHolder addWarningMessage( CharSequence messagePart )
- {
- return addMessage( MessageLevels.LEVEL_WARNING, messagePart );
+ public MessageHolder addWarningMessage(CharSequence messagePart) {
+ return addMessage(MessageLevels.LEVEL_WARNING, messagePart);
}
/** {@inheritDoc} */
- public MessageHolder addWarningMessage( Throwable error )
- {
- return addMessage( MessageLevels.LEVEL_WARNING, error );
+ public MessageHolder addWarningMessage(Throwable error) {
+ return addMessage(MessageLevels.LEVEL_WARNING, error);
}
/** {@inheritDoc} */
- public int countDebugMessages()
- {
- return countMessagesOfType( MessageLevels.LEVEL_DEBUG );
+ public int countDebugMessages() {
+ return countMessagesOfType(MessageLevels.LEVEL_DEBUG);
}
/** {@inheritDoc} */
- public int countErrorMessages()
- {
- return countMessagesOfType( MessageLevels.LEVEL_ERROR );
+ public int countErrorMessages() {
+ return countMessagesOfType(MessageLevels.LEVEL_ERROR);
}
/** {@inheritDoc} */
- public int countInfoMessages()
- {
- return countMessagesOfType( MessageLevels.LEVEL_INFO );
+ public int countInfoMessages() {
+ return countMessagesOfType(MessageLevels.LEVEL_INFO);
}
/** {@inheritDoc} */
- public int countMessages()
- {
+ public int countMessages() {
return size();
}
/** {@inheritDoc} */
- public int countSevereMessages()
- {
- return countMessagesOfType( MessageLevels.LEVEL_SEVERE );
+ public int countSevereMessages() {
+ return countMessagesOfType(MessageLevels.LEVEL_SEVERE);
}
/** {@inheritDoc} */
- public int countWarningMessages()
- {
- return countMessagesOfType( MessageLevels.LEVEL_WARNING );
+ public int countWarningMessages() {
+ return countMessagesOfType(MessageLevels.LEVEL_WARNING);
}
/**
* @param messageLevel leve.
* @return number of messages.
*/
- private int countMessagesOfType( int messageLevel )
- {
+ private int countMessagesOfType(int messageLevel) {
int count = 0;
- for ( Message message : messages )
- {
- if ( messageLevel == message.getMessageLevel() )
- {
+ for (Message message : messages) {
+ if (messageLevel == message.getMessageLevel()) {
count++;
}
}
@@ -451,136 +392,112 @@
}
/** {@inheritDoc} */
- public boolean isDebugEnabled()
- {
+ public boolean isDebugEnabled() {
return messageLevelStates[MessageLevels.LEVEL_DEBUG];
}
/** {@inheritDoc} */
- public boolean isErrorEnabled()
- {
+ public boolean isErrorEnabled() {
return messageLevelStates[MessageLevels.LEVEL_ERROR];
}
/** {@inheritDoc} */
- public boolean isInfoEnabled()
- {
+ public boolean isInfoEnabled() {
return messageLevelStates[MessageLevels.LEVEL_INFO];
}
/** {@inheritDoc} */
- public boolean isSevereEnabled()
- {
+ public boolean isSevereEnabled() {
return messageLevelStates[MessageLevels.LEVEL_SEVERE];
}
/** {@inheritDoc} */
- public boolean isWarningEnabled()
- {
+ public boolean isWarningEnabled() {
return messageLevelStates[MessageLevels.LEVEL_WARNING];
}
/** {@inheritDoc} */
- public MessageHolder newDebugMessage()
- {
- if ( isDebugEnabled() )
- {
- newMessage( MessageLevels.LEVEL_DEBUG );
+ public MessageHolder newDebugMessage() {
+ if (isDebugEnabled()) {
+ newMessage(MessageLevels.LEVEL_DEBUG);
}
return this;
}
/** {@inheritDoc} */
- public MessageHolder newErrorMessage()
- {
- if ( isErrorEnabled() )
- {
- newMessage( MessageLevels.LEVEL_ERROR );
+ public MessageHolder newErrorMessage() {
+ if (isErrorEnabled()) {
+ newMessage(MessageLevels.LEVEL_ERROR);
}
return this;
}
/** {@inheritDoc} */
- public MessageHolder newInfoMessage()
- {
- if ( isInfoEnabled() )
- {
- newMessage( MessageLevels.LEVEL_INFO );
+ public MessageHolder newInfoMessage() {
+ if (isInfoEnabled()) {
+ newMessage(MessageLevels.LEVEL_INFO);
}
return this;
}
/** {@inheritDoc} */
- public MessageHolder newSevereMessage()
- {
- if ( isSevereEnabled() )
- {
- newMessage( MessageLevels.LEVEL_SEVERE );
+ public MessageHolder newSevereMessage() {
+ if (isSevereEnabled()) {
+ newMessage(MessageLevels.LEVEL_SEVERE);
}
return this;
}
/** {@inheritDoc} */
- public MessageHolder newWarningMessage()
- {
- if ( isWarningEnabled() )
- {
- newMessage( MessageLevels.LEVEL_WARNING );
+ public MessageHolder newWarningMessage() {
+ if (isWarningEnabled()) {
+ newMessage(MessageLevels.LEVEL_WARNING);
}
return this;
}
/** {@inheritDoc} */
- public void setDebugEnabled( boolean enabled )
- {
+ public void setDebugEnabled(boolean enabled) {
messageLevelStates[MessageLevels.LEVEL_DEBUG] = enabled;
}
/** {@inheritDoc} */
- public void setErrorEnabled( boolean enabled )
- {
+ public void setErrorEnabled(boolean enabled) {
messageLevelStates[MessageLevels.LEVEL_ERROR] = enabled;
}
/** {@inheritDoc} */
- public void setInfoEnabled( boolean enabled )
- {
+ public void setInfoEnabled(boolean enabled) {
messageLevelStates[MessageLevels.LEVEL_INFO] = enabled;
}
/** {@inheritDoc} */
- public void setSevereEnabled( boolean enabled )
- {
+ public void setSevereEnabled(boolean enabled) {
messageLevelStates[MessageLevels.LEVEL_SEVERE] = enabled;
}
/** {@inheritDoc} */
- public void setWarningEnabled( boolean enabled )
- {
+ public void setWarningEnabled(boolean enabled) {
messageLevelStates[MessageLevels.LEVEL_WARNING] = enabled;
}
/** {@inheritDoc} */
- public void flush()
- {
- if ( onDemandSink != null && currentMessage != null )
- {
- renderTo( currentMessage, onDemandSink );
+ public void flush() {
+ if (onDemandSink != null && currentMessage != null) {
+ renderTo(currentMessage, onDemandSink);
currentMessage = null;
}
}
/** {@inheritDoc} */
- public void render( MessageSink sink )
- {
- for ( Message message : messages )
- {
- renderTo( message, sink );
+ public void render(MessageSink sink) {
+ for (Message message : messages) {
+ renderTo(message, sink);
}
}
@@ -588,29 +505,26 @@
* @param message {@link Message}
* @param sink {@link MessageSink}
*/
- protected void renderTo( Message message, MessageSink sink )
- {
- switch ( message.getMessageLevel() )
- {
- case ( MessageLevels.LEVEL_SEVERE ):
- sink.severe( message.render().toString() );
+ protected void renderTo(Message message, MessageSink sink) {
+ switch (message.getMessageLevel()) {
+ case (MessageLevels.LEVEL_SEVERE):
+ sink.severe(message.render().toString());
break;
- case ( MessageLevels.LEVEL_ERROR ):
- sink.error( message.render().toString() );
+ case (MessageLevels.LEVEL_ERROR):
+ sink.error(message.render().toString());
break;
- case ( MessageLevels.LEVEL_WARNING ):
- sink.warning( message.render().toString() );
+ case (MessageLevels.LEVEL_WARNING):
+ sink.warning(message.render().toString());
break;
- case ( MessageLevels.LEVEL_INFO ):
- sink.info( message.render().toString() );
+ case (MessageLevels.LEVEL_INFO):
+ sink.info(message.render().toString());
break;
default:
- sink.debug( message.render().toString() );
+ sink.debug(message.render().toString());
}
}
-
}
diff --git a/src/main/java/org/apache/maven/shared/io/logging/MessageHolder.java b/src/main/java/org/apache/maven/shared/io/logging/MessageHolder.java
index be4f833..4334b0c 100644
--- a/src/main/java/org/apache/maven/shared/io/logging/MessageHolder.java
+++ b/src/main/java/org/apache/maven/shared/io/logging/MessageHolder.java
@@ -1,5 +1,3 @@
-package org.apache.maven.shared.io.logging;
-
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
@@ -18,13 +16,13 @@
* specific language governing permissions and limitations
* under the License.
*/
+package org.apache.maven.shared.io.logging;
/**
* Message Holder class.
*
*/
-public interface MessageHolder
-{
+public interface MessageHolder {
/**
* @return {@link MessageHolder}
@@ -60,127 +58,127 @@
* @param messagePart message part.
* @return {@link MessageHolder}
*/
- MessageHolder append( CharSequence messagePart );
+ MessageHolder append(CharSequence messagePart);
/**
* @param error {@link Throwable}
* @return {@link MessageHolder}
*/
- MessageHolder append( Throwable error );
+ MessageHolder append(Throwable error);
/**
* @param messagePart Message Part.
* @param error {@link Throwable}
* @return {@link MessageHolder}
*/
- MessageHolder addMessage( CharSequence messagePart, Throwable error );
+ MessageHolder addMessage(CharSequence messagePart, Throwable error);
/**
* @param messagePart message part.
* @return {@link MessageHolder}
*/
- MessageHolder addMessage( CharSequence messagePart );
+ MessageHolder addMessage(CharSequence messagePart);
/**
* @param error {@link Throwable}
* @return {@link MessageHolder}
*/
- MessageHolder addMessage( Throwable error );
+ MessageHolder addMessage(Throwable error);
/**
* @param messagePart message part.
* @param error {@link Throwable}
* @return {@link MessageHolder}
*/
- MessageHolder addDebugMessage( CharSequence messagePart, Throwable error );
+ MessageHolder addDebugMessage(CharSequence messagePart, Throwable error);
/**
* @param messagePart messages part.
* @return {@link MessageHolder}
*/
- MessageHolder addDebugMessage( CharSequence messagePart );
+ MessageHolder addDebugMessage(CharSequence messagePart);
/**
* @param error messages part.
* @return {@link MessageHolder}
*/
- MessageHolder addDebugMessage( Throwable error );
+ MessageHolder addDebugMessage(Throwable error);
/**
* @param messagePart message part.
* @param error {@link Throwable}
* @return {@link MessageHolder}
*/
- MessageHolder addInfoMessage( CharSequence messagePart, Throwable error );
+ MessageHolder addInfoMessage(CharSequence messagePart, Throwable error);
/**
* @param messagePart messages part.
* @return {@link MessageHolder}
*/
- MessageHolder addInfoMessage( CharSequence messagePart );
+ MessageHolder addInfoMessage(CharSequence messagePart);
/**
* @param error {@link Throwable}
* @return {@link MessageHolder}
*/
- MessageHolder addInfoMessage( Throwable error );
+ MessageHolder addInfoMessage(Throwable error);
/**
* @param messagePart message part.
* @param error {@link Throwable}
* @return {@link MessageHolder}
*/
- MessageHolder addWarningMessage( CharSequence messagePart, Throwable error );
+ MessageHolder addWarningMessage(CharSequence messagePart, Throwable error);
/**
* @param messagePart message part.
* @return {@link MessageHolder}
*/
- MessageHolder addWarningMessage( CharSequence messagePart );
+ MessageHolder addWarningMessage(CharSequence messagePart);
/**
* @param error {@link Throwable}
* @return {@link MessageHolder}
*/
- MessageHolder addWarningMessage( Throwable error );
+ MessageHolder addWarningMessage(Throwable error);
/**
* @param messagePart message part.
* @param error {@link Throwable}
* @return {@link MessageHolder}
*/
- MessageHolder addErrorMessage( CharSequence messagePart, Throwable error );
+ MessageHolder addErrorMessage(CharSequence messagePart, Throwable error);
/**
* @param messagePart message part.
* @return {@link MessageHolder}
*/
- MessageHolder addErrorMessage( CharSequence messagePart );
+ MessageHolder addErrorMessage(CharSequence messagePart);
/**
* @param error {@link Throwable}
* @return {@link MessageHolder}
*/
- MessageHolder addErrorMessage( Throwable error );
+ MessageHolder addErrorMessage(Throwable error);
/**
* @param messagePart message part.
* @param error {@link Throwable}
* @return {@link MessageHolder}
*/
- MessageHolder addSevereMessage( CharSequence messagePart, Throwable error );
+ MessageHolder addSevereMessage(CharSequence messagePart, Throwable error);
/**
* @param messagePart message part.
* @return {@link MessageHolder}
*/
- MessageHolder addSevereMessage( CharSequence messagePart );
+ MessageHolder addSevereMessage(CharSequence messagePart);
/**
* @param error The error.
* @return {@link MessageHolder}
*/
- MessageHolder addSevereMessage( Throwable error );
+ MessageHolder addSevereMessage(Throwable error);
/**
* @return the size.
@@ -225,7 +223,7 @@
/**
* @param enabled enable debug
*/
- void setDebugEnabled( boolean enabled );
+ void setDebugEnabled(boolean enabled);
/**
* @return true if info is enabled false otherwise.
@@ -235,7 +233,7 @@
/**
* @param enabled true info enable false otherwise.
*/
- void setInfoEnabled( boolean enabled );
+ void setInfoEnabled(boolean enabled);
/**
* @return true if warning is enabled false otherwise.
@@ -245,7 +243,7 @@
/**
* @param enabled enable warning or disable.
*/
- void setWarningEnabled( boolean enabled );
+ void setWarningEnabled(boolean enabled);
/**
* @return true if error is enabled false otherwise.
@@ -255,7 +253,7 @@
/**
* @param enabled enable error or disable.
*/
- void setErrorEnabled( boolean enabled );
+ void setErrorEnabled(boolean enabled);
/**
* @return true if server is enabled false otherwise.
@@ -265,7 +263,7 @@
/**
* @param enabled enable server or disable.
*/
- void setSevereEnabled( boolean enabled );
+ void setSevereEnabled(boolean enabled);
/**
* @return true if empty false otherwise.
@@ -280,11 +278,10 @@
/**
* @param sink {@link MessageSink}
*/
- void render( MessageSink sink );
+ void render(MessageSink sink);
/**
* flush.
*/
void flush();
-
}
diff --git a/src/main/java/org/apache/maven/shared/io/logging/MessageLevels.java b/src/main/java/org/apache/maven/shared/io/logging/MessageLevels.java
index 06fe3de..4487e36 100644
--- a/src/main/java/org/apache/maven/shared/io/logging/MessageLevels.java
+++ b/src/main/java/org/apache/maven/shared/io/logging/MessageLevels.java
@@ -1,5 +1,3 @@
-package org.apache.maven.shared.io.logging;
-
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
@@ -18,6 +16,7 @@
* specific language governing permissions and limitations
* under the License.
*/
+package org.apache.maven.shared.io.logging;
import java.util.ArrayList;
import java.util.Arrays;
@@ -25,10 +24,9 @@
import java.util.List;
/**
- *
+ *
*/
-public final class MessageLevels
-{
+public final class MessageLevels {
/**
* Debug.
@@ -57,43 +55,38 @@
private static final List<String> LEVEL_NAMES;
- static
- {
+ static {
List<String> names = new ArrayList<String>();
- names.add( "DEBUG" );
- names.add( "INFO" );
- names.add( "WARN" );
- names.add( "ERROR" );
- names.add( "SEVERE" );
+ names.add("DEBUG");
+ names.add("INFO");
+ names.add("WARN");
+ names.add("ERROR");
+ names.add("SEVERE");
- LEVEL_NAMES = Collections.unmodifiableList( names );
+ LEVEL_NAMES = Collections.unmodifiableList(names);
}
- private MessageLevels()
- {
- }
+ private MessageLevels() {}
/**
* @param maxMessageLevel for which level.
* @return level states.
*/
- public static boolean[] getLevelStates( int maxMessageLevel )
- {
+ public static boolean[] getLevelStates(int maxMessageLevel) {
boolean[] states = new boolean[5];
- Arrays.fill( states, false );
+ Arrays.fill(states, false);
- switch ( maxMessageLevel )
- {
- case ( LEVEL_DEBUG ):
+ switch (maxMessageLevel) {
+ case (LEVEL_DEBUG):
states[LEVEL_DEBUG] = true;
- case ( LEVEL_INFO ):
+ case (LEVEL_INFO):
states[LEVEL_INFO] = true;
- case ( LEVEL_WARNING ):
+ case (LEVEL_WARNING):
states[LEVEL_WARNING] = true;
- case ( LEVEL_ERROR ):
+ case (LEVEL_ERROR):
states[LEVEL_ERROR] = true;
- case ( LEVEL_SEVERE ):
+ case (LEVEL_SEVERE):
states[LEVEL_SEVERE] = true;
default:
}
@@ -105,13 +98,11 @@
* @param messageLevel the message leve.
* @return The label.
*/
- public static String getLevelLabel( int messageLevel )
- {
- if ( messageLevel > -1 && LEVEL_NAMES.size() > messageLevel )
- {
- return (String) LEVEL_NAMES.get( messageLevel );
+ public static String getLevelLabel(int messageLevel) {
+ if (messageLevel > -1 && LEVEL_NAMES.size() > messageLevel) {
+ return (String) LEVEL_NAMES.get(messageLevel);
}
- throw new IllegalArgumentException( "Invalid message level: " + messageLevel );
+ throw new IllegalArgumentException("Invalid message level: " + messageLevel);
}
}
diff --git a/src/main/java/org/apache/maven/shared/io/logging/MessageSink.java b/src/main/java/org/apache/maven/shared/io/logging/MessageSink.java
index 3856e21..b64b4dd 100644
--- a/src/main/java/org/apache/maven/shared/io/logging/MessageSink.java
+++ b/src/main/java/org/apache/maven/shared/io/logging/MessageSink.java
@@ -1,5 +1,3 @@
-package org.apache.maven.shared.io.logging;
-
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
@@ -18,38 +16,36 @@
* specific language governing permissions and limitations
* under the License.
*/
-
+package org.apache.maven.shared.io.logging;
/**
* Message Sink interface.
*
*/
-public interface MessageSink
-{
+public interface MessageSink {
/**
* @param message The message.
*/
- void debug( String message );
+ void debug(String message);
/**
* @param message The message.
*/
- void info( String message );
+ void info(String message);
/**
* @param message The message.
*/
- void warning( String message );
+ void warning(String message);
/**
* @param message The message.
*/
- void error( String message );
+ void error(String message);
/**
* @param message The message.
*/
- void severe( String message );
-
+ void severe(String message);
}
diff --git a/src/main/java/org/apache/maven/shared/io/logging/MojoLogSink.java b/src/main/java/org/apache/maven/shared/io/logging/MojoLogSink.java
index f98e818..8a09146 100644
--- a/src/main/java/org/apache/maven/shared/io/logging/MojoLogSink.java
+++ b/src/main/java/org/apache/maven/shared/io/logging/MojoLogSink.java
@@ -1,5 +1,3 @@
-package org.apache.maven.shared.io.logging;
-
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
@@ -18,56 +16,46 @@
* specific language governing permissions and limitations
* under the License.
*/
+package org.apache.maven.shared.io.logging;
import org.apache.maven.plugin.logging.Log;
-
/**
* The Mojo Log Sink.
- *
*/
-public class MojoLogSink
- implements MessageSink
-{
+public class MojoLogSink implements MessageSink {
private final Log logger;
/**
* @param logger {@link Log}
*/
- public MojoLogSink( Log logger )
- {
+ public MojoLogSink(Log logger) {
this.logger = logger;
}
/** {@inheritDoc} */
- public void debug( String message )
- {
- logger.debug( message );
+ public void debug(String message) {
+ logger.debug(message);
}
/** {@inheritDoc} */
- public void error( String message )
- {
- logger.error( message );
+ public void error(String message) {
+ logger.error(message);
}
/** {@inheritDoc} */
- public void info( String message )
- {
- logger.info( message );
+ public void info(String message) {
+ logger.info(message);
}
/** {@inheritDoc} */
- public void severe( String message )
- {
- logger.error( message );
+ public void severe(String message) {
+ logger.error(message);
}
/** {@inheritDoc} */
- public void warning( String message )
- {
- logger.warn( message );
+ public void warning(String message) {
+ logger.warn(message);
}
-
}
diff --git a/src/main/java/org/apache/maven/shared/io/logging/PlexusLoggerSink.java b/src/main/java/org/apache/maven/shared/io/logging/PlexusLoggerSink.java
index 8091dcc..be82209 100644
--- a/src/main/java/org/apache/maven/shared/io/logging/PlexusLoggerSink.java
+++ b/src/main/java/org/apache/maven/shared/io/logging/PlexusLoggerSink.java
@@ -1,5 +1,3 @@
-package org.apache.maven.shared.io.logging;
-
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
@@ -18,57 +16,49 @@
* specific language governing permissions and limitations
* under the License.
*/
+package org.apache.maven.shared.io.logging;
import org.codehaus.plexus.logging.Logger;
/**
* The plexus logger sink implementation.
- *
+ *
* @deprecated Plexus logging should no longer be used in Maven. Convert to SLF4J.
*/
@Deprecated
-public class PlexusLoggerSink
- implements MessageSink
-{
+public class PlexusLoggerSink implements MessageSink {
private final Logger logger;
/**
* @param logger The logger.
*/
- public PlexusLoggerSink( Logger logger )
- {
+ public PlexusLoggerSink(Logger logger) {
this.logger = logger;
}
/** {@inheritDoc} */
- public void debug( String message )
- {
- logger.debug( message );
+ public void debug(String message) {
+ logger.debug(message);
}
/** {@inheritDoc} */
- public void error( String message )
- {
- logger.error( message );
+ public void error(String message) {
+ logger.error(message);
}
/** {@inheritDoc} */
- public void info( String message )
- {
- logger.info( message );
+ public void info(String message) {
+ logger.info(message);
}
/** {@inheritDoc} */
- public void severe( String message )
- {
- logger.fatalError( message );
+ public void severe(String message) {
+ logger.fatalError(message);
}
/** {@inheritDoc} */
- public void warning( String message )
- {
- logger.warn( message );
+ public void warning(String message) {
+ logger.warn(message);
}
-
}
diff --git a/src/main/java/org/apache/maven/shared/io/scan/AbstractResourceInclusionScanner.java b/src/main/java/org/apache/maven/shared/io/scan/AbstractResourceInclusionScanner.java
index 2f05f09..e77b273 100644
--- a/src/main/java/org/apache/maven/shared/io/scan/AbstractResourceInclusionScanner.java
+++ b/src/main/java/org/apache/maven/shared/io/scan/AbstractResourceInclusionScanner.java
@@ -1,5 +1,3 @@
-package org.apache.maven.shared.io.scan;
-
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
@@ -18,6 +16,7 @@
* specific language governing permissions and limitations
* under the License.
*/
+package org.apache.maven.shared.io.scan;
import java.io.File;
import java.util.ArrayList;
@@ -32,23 +31,19 @@
* @author jdcasey
* @version $Id$
*/
-public abstract class AbstractResourceInclusionScanner
- implements ResourceInclusionScanner
-{
+public abstract class AbstractResourceInclusionScanner implements ResourceInclusionScanner {
private final List<SourceMapping> sourceMappings = new ArrayList<SourceMapping>();
/** {@inheritDoc} */
- public final void addSourceMapping( SourceMapping sourceMapping )
- {
- sourceMappings.add( sourceMapping );
+ public final void addSourceMapping(SourceMapping sourceMapping) {
+ sourceMappings.add(sourceMapping);
}
/**
* @return The source mapping.
*/
- protected final List<SourceMapping> getSourceMappings()
- {
- return Collections.unmodifiableList( sourceMappings );
+ protected final List<SourceMapping> getSourceMappings() {
+ return Collections.unmodifiableList(sourceMappings);
}
/**
@@ -57,35 +52,28 @@
* @param sourceExcludes source excludes.
* @return The resulting sources.
*/
- protected String[] scanForSources( File sourceDir, Set<String> sourceIncludes, Set<String> sourceExcludes )
- {
+ protected String[] scanForSources(File sourceDir, Set<String> sourceIncludes, Set<String> sourceExcludes) {
DirectoryScanner ds = new DirectoryScanner();
- ds.setFollowSymlinks( true );
- ds.setBasedir( sourceDir );
+ ds.setFollowSymlinks(true);
+ ds.setBasedir(sourceDir);
String[] includes;
- if ( sourceIncludes.isEmpty() )
- {
+ if (sourceIncludes.isEmpty()) {
includes = new String[0];
- }
- else
- {
- includes = (String[]) sourceIncludes.toArray( new String[sourceIncludes.size()] );
+ } else {
+ includes = (String[]) sourceIncludes.toArray(new String[sourceIncludes.size()]);
}
- ds.setIncludes( includes );
+ ds.setIncludes(includes);
String[] excludes;
- if ( sourceExcludes.isEmpty() )
- {
+ if (sourceExcludes.isEmpty()) {
excludes = new String[0];
- }
- else
- {
- excludes = (String[]) sourceExcludes.toArray( new String[sourceExcludes.size()] );
+ } else {
+ excludes = (String[]) sourceExcludes.toArray(new String[sourceExcludes.size()]);
}
- ds.setExcludes( excludes );
+ ds.setExcludes(excludes);
ds.addDefaultExcludes();
ds.scan();
diff --git a/src/main/java/org/apache/maven/shared/io/scan/InclusionScanException.java b/src/main/java/org/apache/maven/shared/io/scan/InclusionScanException.java
index 8843427..04ee8c3 100644
--- a/src/main/java/org/apache/maven/shared/io/scan/InclusionScanException.java
+++ b/src/main/java/org/apache/maven/shared/io/scan/InclusionScanException.java
@@ -1,5 +1,3 @@
-package org.apache.maven.shared.io.scan;
-
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
@@ -18,28 +16,25 @@
* specific language governing permissions and limitations
* under the License.
*/
+package org.apache.maven.shared.io.scan;
/**
* @author jdcasey
* @version $Id$
*/
-public class InclusionScanException
- extends Exception
-{
+public class InclusionScanException extends Exception {
/**
* @param message The message.
*/
- public InclusionScanException( String message )
- {
- super( message );
+ public InclusionScanException(String message) {
+ super(message);
}
/**
* @param message The message.
* @param cause The cause of the error.
*/
- public InclusionScanException( String message, Throwable cause )
- {
- super( message, cause );
+ public InclusionScanException(String message, Throwable cause) {
+ super(message, cause);
}
}
diff --git a/src/main/java/org/apache/maven/shared/io/scan/ResourceInclusionScanner.java b/src/main/java/org/apache/maven/shared/io/scan/ResourceInclusionScanner.java
index 5171124..69e2c1a 100644
--- a/src/main/java/org/apache/maven/shared/io/scan/ResourceInclusionScanner.java
+++ b/src/main/java/org/apache/maven/shared/io/scan/ResourceInclusionScanner.java
@@ -1,5 +1,3 @@
-package org.apache.maven.shared.io.scan;
-
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
@@ -18,22 +16,22 @@
* specific language governing permissions and limitations
* under the License.
*/
-
-import org.apache.maven.shared.io.scan.mapping.SourceMapping;
+package org.apache.maven.shared.io.scan;
import java.io.File;
import java.util.Set;
+import org.apache.maven.shared.io.scan.mapping.SourceMapping;
+
/**
* @author jdcasey
* @version $Id$
*/
-public interface ResourceInclusionScanner
-{
+public interface ResourceInclusionScanner {
/**
* @param sourceMapping {@link SourceMapping}
*/
- void addSourceMapping( SourceMapping sourceMapping );
+ void addSourceMapping(SourceMapping sourceMapping);
/**
* @param sourceDir {@link File}
@@ -41,6 +39,5 @@
* @return The included sources.
* @throws InclusionScanException in case of an error.
*/
- Set<File> getIncludedSources( File sourceDir, File targetDir )
- throws InclusionScanException;
+ Set<File> getIncludedSources(File sourceDir, File targetDir) throws InclusionScanException;
}
diff --git a/src/main/java/org/apache/maven/shared/io/scan/SimpleResourceInclusionScanner.java b/src/main/java/org/apache/maven/shared/io/scan/SimpleResourceInclusionScanner.java
index 16dd82d..c56c3d8 100644
--- a/src/main/java/org/apache/maven/shared/io/scan/SimpleResourceInclusionScanner.java
+++ b/src/main/java/org/apache/maven/shared/io/scan/SimpleResourceInclusionScanner.java
@@ -1,5 +1,3 @@
-package org.apache.maven.shared.io.scan;
-
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
@@ -18,6 +16,7 @@
* specific language governing permissions and limitations
* under the License.
*/
+package org.apache.maven.shared.io.scan;
import java.io.File;
import java.util.Collections;
@@ -31,9 +30,7 @@
* @author <a href="mailto:trygvis@inamo.no">Trygve Laugstøl</a>
* @version $Id$
*/
-public class SimpleResourceInclusionScanner
- extends AbstractResourceInclusionScanner
-{
+public class SimpleResourceInclusionScanner extends AbstractResourceInclusionScanner {
private final Set<String> sourceIncludes;
private final Set<String> sourceExcludes;
@@ -42,30 +39,25 @@
* @param sourceIncludes The source includes.
* @param sourceExcludes The source excludes.
*/
- public SimpleResourceInclusionScanner( Set<String> sourceIncludes, Set<String> sourceExcludes )
- {
+ public SimpleResourceInclusionScanner(Set<String> sourceIncludes, Set<String> sourceExcludes) {
this.sourceIncludes = sourceIncludes;
this.sourceExcludes = sourceExcludes;
}
/** {@inheritDoc} */
- public Set<File> getIncludedSources( File sourceDir, File targetDir )
- throws InclusionScanException
- {
+ public Set<File> getIncludedSources(File sourceDir, File targetDir) throws InclusionScanException {
List<SourceMapping> srcMappings = getSourceMappings();
- if ( srcMappings.isEmpty() )
- {
+ if (srcMappings.isEmpty()) {
return Collections.emptySet();
}
Set<File> matchingSources = new HashSet<>();
- String[] sourcePaths = scanForSources( sourceDir, sourceIncludes, sourceExcludes );
+ String[] sourcePaths = scanForSources(sourceDir, sourceIncludes, sourceExcludes);
- for ( String sourcePath : sourcePaths )
- {
- matchingSources.add( new File( sourceDir, sourcePath ) );
+ for (String sourcePath : sourcePaths) {
+ matchingSources.add(new File(sourceDir, sourcePath));
}
return matchingSources;
}
diff --git a/src/main/java/org/apache/maven/shared/io/scan/StaleResourceScanner.java b/src/main/java/org/apache/maven/shared/io/scan/StaleResourceScanner.java
index 62358be..1c394d0 100644
--- a/src/main/java/org/apache/maven/shared/io/scan/StaleResourceScanner.java
+++ b/src/main/java/org/apache/maven/shared/io/scan/StaleResourceScanner.java
@@ -1,5 +1,3 @@
-package org.apache.maven.shared.io.scan;
-
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
@@ -18,6 +16,7 @@
* specific language governing permissions and limitations
* under the License.
*/
+package org.apache.maven.shared.io.scan;
import java.io.File;
import java.util.Collections;
@@ -31,9 +30,7 @@
* @author jdcasey
* @version $Id$
*/
-public class StaleResourceScanner
- extends AbstractResourceInclusionScanner
-{
+public class StaleResourceScanner extends AbstractResourceInclusionScanner {
private final long lastUpdatedWithinMsecs;
private final Set<String> sourceIncludes;
@@ -47,17 +44,15 @@
/**
* Create instance with defaults.
*/
- public StaleResourceScanner()
- {
- this( 0, Collections.singleton( "**/*" ), Collections.<String>emptySet() );
+ public StaleResourceScanner() {
+ this(0, Collections.singleton("**/*"), Collections.<String>emptySet());
}
/**
* @param lastUpdatedWithinMsecs last update within milli seconds.
*/
- public StaleResourceScanner( long lastUpdatedWithinMsecs )
- {
- this( lastUpdatedWithinMsecs, Collections.singleton( "**/*" ), Collections.<String>emptySet() );
+ public StaleResourceScanner(long lastUpdatedWithinMsecs) {
+ this(lastUpdatedWithinMsecs, Collections.singleton("**/*"), Collections.<String>emptySet());
}
/**
@@ -65,8 +60,7 @@
* @param sourceIncludes source includes.
* @param sourceExcludes source excludes.
*/
- public StaleResourceScanner( long lastUpdatedWithinMsecs, Set<String> sourceIncludes, Set<String> sourceExcludes )
- {
+ public StaleResourceScanner(long lastUpdatedWithinMsecs, Set<String> sourceIncludes, Set<String> sourceExcludes) {
this.lastUpdatedWithinMsecs = lastUpdatedWithinMsecs;
this.sourceIncludes = sourceIncludes;
@@ -79,39 +73,33 @@
// ----------------------------------------------------------------------
/** {@inheritDoc} */
- public Set<File> getIncludedSources( File sourceDir, File targetDir )
- throws InclusionScanException
- {
+ public Set<File> getIncludedSources(File sourceDir, File targetDir) throws InclusionScanException {
List<SourceMapping> srcMappings = getSourceMappings();
- if ( srcMappings.isEmpty() )
- {
+ if (srcMappings.isEmpty()) {
return Collections.<File>emptySet();
}
- String[] potentialIncludes = scanForSources( sourceDir, sourceIncludes, sourceExcludes );
+ String[] potentialIncludes = scanForSources(sourceDir, sourceIncludes, sourceExcludes);
Set<File> matchingSources = new HashSet<File>();
- for ( int i = 0; i < potentialIncludes.length; i++ )
- {
+ for (int i = 0; i < potentialIncludes.length; i++) {
String path = potentialIncludes[i];
- File sourceFile = new File( sourceDir, path );
+ File sourceFile = new File(sourceDir, path);
- staleSourceFileTesting: for ( SourceMapping mapping : srcMappings )
- {
- Set<File> targetFiles = mapping.getTargetFiles( targetDir, path );
+ staleSourceFileTesting:
+ for (SourceMapping mapping : srcMappings) {
+ Set<File> targetFiles = mapping.getTargetFiles(targetDir, path);
// never include files that don't have corresponding target mappings.
// the targets don't have to exist on the filesystem, but the
// mappers must tell us to look for them.
- for ( File targetFile : targetFiles )
- {
- if ( !targetFile.exists()
- || ( targetFile.lastModified() + lastUpdatedWithinMsecs < sourceFile.lastModified() ) )
- {
- matchingSources.add( sourceFile );
+ for (File targetFile : targetFiles) {
+ if (!targetFile.exists()
+ || (targetFile.lastModified() + lastUpdatedWithinMsecs < sourceFile.lastModified())) {
+ matchingSources.add(sourceFile);
break staleSourceFileTesting;
}
}
diff --git a/src/main/java/org/apache/maven/shared/io/scan/mapping/SingleTargetMapping.java b/src/main/java/org/apache/maven/shared/io/scan/mapping/SingleTargetMapping.java
index 2d1f337..0ac1d11 100644
--- a/src/main/java/org/apache/maven/shared/io/scan/mapping/SingleTargetMapping.java
+++ b/src/main/java/org/apache/maven/shared/io/scan/mapping/SingleTargetMapping.java
@@ -1,5 +1,3 @@
-package org.apache.maven.shared.io.scan.mapping;
-
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
@@ -18,22 +16,21 @@
* specific language governing permissions and limitations
* under the License.
*/
+package org.apache.maven.shared.io.scan.mapping;
+
+import java.io.File;
+import java.util.Collections;
+import java.util.Set;
import org.apache.maven.shared.io.scan.InclusionScanException;
-import java.util.Set;
-import java.util.Collections;
-import java.io.File;
-
/**
* Maps a set of input files to a single output file.
*
* @author <a href="mailto:trygvis@inamo.no">Trygve Laugstøl</a>
* @version $Id$
*/
-public class SingleTargetMapping
- implements SourceMapping
-{
+public class SingleTargetMapping implements SourceMapping {
private String sourceSuffix;
private String outputFile;
@@ -42,22 +39,18 @@
* @param sourceSuffix source suffix.
* @param outputFile output file.
*/
- public SingleTargetMapping( String sourceSuffix, String outputFile )
- {
+ public SingleTargetMapping(String sourceSuffix, String outputFile) {
this.sourceSuffix = sourceSuffix;
this.outputFile = outputFile;
}
/** {@inheritDoc} */
- public Set<File> getTargetFiles( File targetDir, String source )
- throws InclusionScanException
- {
- if ( !source.endsWith( sourceSuffix ) )
- {
+ public Set<File> getTargetFiles(File targetDir, String source) throws InclusionScanException {
+ if (!source.endsWith(sourceSuffix)) {
return Collections.<File>emptySet();
}
- return Collections.singleton( new File( targetDir, outputFile ) );
+ return Collections.singleton(new File(targetDir, outputFile));
}
}
diff --git a/src/main/java/org/apache/maven/shared/io/scan/mapping/SourceMapping.java b/src/main/java/org/apache/maven/shared/io/scan/mapping/SourceMapping.java
index 7defc0b..117a193 100644
--- a/src/main/java/org/apache/maven/shared/io/scan/mapping/SourceMapping.java
+++ b/src/main/java/org/apache/maven/shared/io/scan/mapping/SourceMapping.java
@@ -1,5 +1,3 @@
-package org.apache.maven.shared.io.scan.mapping;
-
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
@@ -18,6 +16,7 @@
* specific language governing permissions and limitations
* under the License.
*/
+package org.apache.maven.shared.io.scan.mapping;
import java.io.File;
import java.util.Set;
@@ -28,14 +27,12 @@
* @author jdcasey
* @version $Id$
*/
-public interface SourceMapping
-{
+public interface SourceMapping {
/**
* @param targetDir target directory.
* @param source source.
* @return list of target files.
* @throws InclusionScanException in case of an error.
*/
- Set<File> getTargetFiles( File targetDir, String source )
- throws InclusionScanException;
+ Set<File> getTargetFiles(File targetDir, String source) throws InclusionScanException;
}
diff --git a/src/main/java/org/apache/maven/shared/io/scan/mapping/SuffixMapping.java b/src/main/java/org/apache/maven/shared/io/scan/mapping/SuffixMapping.java
index 75aa461..a794d26 100644
--- a/src/main/java/org/apache/maven/shared/io/scan/mapping/SuffixMapping.java
+++ b/src/main/java/org/apache/maven/shared/io/scan/mapping/SuffixMapping.java
@@ -1,5 +1,3 @@
-package org.apache.maven.shared.io.scan.mapping;
-
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
@@ -18,6 +16,7 @@
* specific language governing permissions and limitations
* under the License.
*/
+package org.apache.maven.shared.io.scan.mapping;
import java.io.File;
import java.util.Collections;
@@ -28,9 +27,7 @@
* @author jdcasey
* @version $Id$
*/
-public final class SuffixMapping
- implements SourceMapping
-{
+public final class SuffixMapping implements SourceMapping {
private final String sourceSuffix;
private final Set<String> targetSuffixes;
@@ -39,36 +36,31 @@
* @param sourceSuffix source suffix.
* @param targetSuffix target suffix.
*/
- public SuffixMapping( String sourceSuffix, String targetSuffix )
- {
+ public SuffixMapping(String sourceSuffix, String targetSuffix) {
this.sourceSuffix = sourceSuffix;
- this.targetSuffixes = Collections.singleton( targetSuffix );
+ this.targetSuffixes = Collections.singleton(targetSuffix);
}
/**
* @param sourceSuffix source suffix.
* @param targetSuffixes target suffixes.
*/
- public SuffixMapping( String sourceSuffix, Set<String> targetSuffixes )
- {
+ public SuffixMapping(String sourceSuffix, Set<String> targetSuffixes) {
this.sourceSuffix = sourceSuffix;
this.targetSuffixes = targetSuffixes;
}
/** {@inheritDoc} */
- public Set<File> getTargetFiles( File targetDir, String source )
- {
+ public Set<File> getTargetFiles(File targetDir, String source) {
Set<File> targetFiles = new HashSet<File>();
- if ( source.endsWith( sourceSuffix ) )
- {
- String base = source.substring( 0, source.length() - sourceSuffix.length() );
+ if (source.endsWith(sourceSuffix)) {
+ String base = source.substring(0, source.length() - sourceSuffix.length());
- for ( String suffix : targetSuffixes )
- {
- targetFiles.add( new File( targetDir, base + suffix ) );
+ for (String suffix : targetSuffixes) {
+ targetFiles.add(new File(targetDir, base + suffix));
}
}
diff --git a/src/test/java/org/apache/maven/shared/io/download/DefaultDownloadManagerTest.java b/src/test/java/org/apache/maven/shared/io/download/DefaultDownloadManagerTest.java
index 0042056..33bbaad 100644
--- a/src/test/java/org/apache/maven/shared/io/download/DefaultDownloadManagerTest.java
+++ b/src/test/java/org/apache/maven/shared/io/download/DefaultDownloadManagerTest.java
@@ -1,5 +1,3 @@
-package org.apache.maven.shared.io.download;
-
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
@@ -18,14 +16,7 @@
* specific language governing permissions and limitations
* under the License.
*/
-
-import static org.easymock.EasyMock.anyObject;
-import static org.easymock.EasyMock.anyString;
-import static org.easymock.EasyMock.createMock;
-import static org.easymock.EasyMock.expect;
-import static org.easymock.EasyMock.expectLastCall;
-import static org.easymock.EasyMock.replay;
-import static org.easymock.EasyMock.verify;
+package org.apache.maven.shared.io.download;
import java.io.File;
import java.io.IOException;
@@ -49,512 +40,403 @@
import org.apache.maven.wagon.repository.Repository;
import org.codehaus.plexus.PlexusTestCase;
-public class DefaultDownloadManagerTest
- extends PlexusTestCase
-{
+import static org.easymock.EasyMock.anyObject;
+import static org.easymock.EasyMock.anyString;
+import static org.easymock.EasyMock.createMock;
+import static org.easymock.EasyMock.expect;
+import static org.easymock.EasyMock.expectLastCall;
+import static org.easymock.EasyMock.replay;
+import static org.easymock.EasyMock.verify;
+
+public class DefaultDownloadManagerTest extends PlexusTestCase {
private WagonManager wagonManager;
private Wagon wagon;
- public void setUp()
- throws Exception
- {
+ public void setUp() throws Exception {
super.setUp();
- wagonManager = createMock( WagonManager.class );
- wagon = createMock( Wagon.class );
+ wagonManager = createMock(WagonManager.class);
+ wagon = createMock(Wagon.class);
}
- public void testShouldConstructWithNoParamsAndHaveNonNullMessageHolder()
- {
+ public void testShouldConstructWithNoParamsAndHaveNonNullMessageHolder() {
new DefaultDownloadManager();
}
- public void testShouldConstructWithWagonManager()
- {
- replay( wagonManager );
+ public void testShouldConstructWithWagonManager() {
+ replay(wagonManager);
- new DefaultDownloadManager( wagonManager );
+ new DefaultDownloadManager(wagonManager);
- verify( wagonManager );
+ verify(wagonManager);
}
- public void testShouldLookupInstanceDefaultRoleHint()
- throws Exception
- {
- lookup( DownloadManager.ROLE, DefaultDownloadManager.ROLE_HINT );
+ public void testShouldLookupInstanceDefaultRoleHint() throws Exception {
+ lookup(DownloadManager.ROLE, DefaultDownloadManager.ROLE_HINT);
}
- public void testShouldFailToDownloadMalformedURL()
- {
- replay( wagonManager );
+ public void testShouldFailToDownloadMalformedURL() {
+ replay(wagonManager);
- DownloadManager mgr = new DefaultDownloadManager( wagonManager );
+ DownloadManager mgr = new DefaultDownloadManager(wagonManager);
- try
- {
- mgr.download( "://nothing.com/index.html", new DefaultMessageHolder() );
+ try {
+ mgr.download("://nothing.com/index.html", new DefaultMessageHolder());
- fail( "Should not download with invalid URL." );
- }
- catch ( DownloadFailedException e )
- {
- assertTrue( e.getMessage().indexOf( "invalid URL" ) > -1 );
+ fail("Should not download with invalid URL.");
+ } catch (DownloadFailedException e) {
+ assertTrue(e.getMessage().indexOf("invalid URL") > -1);
}
- verify( wagonManager );
+ verify(wagonManager);
}
- public void testShouldDownloadFromTempFileWithNoTransferListeners()
- throws IOException, DownloadFailedException
- {
- File tempFile = Files.createTempFile( "download-source", "test" ).toFile();
+ public void testShouldDownloadFromTempFileWithNoTransferListeners() throws IOException, DownloadFailedException {
+ File tempFile = Files.createTempFile("download-source", "test").toFile();
tempFile.deleteOnExit();
setupDefaultMockConfiguration();
- replay( wagon, wagonManager );
+ replay(wagon, wagonManager);
- DownloadManager downloadManager = new DefaultDownloadManager( wagonManager );
+ DownloadManager downloadManager = new DefaultDownloadManager(wagonManager);
- downloadManager.download( tempFile.toURI().toASCIIString(), new DefaultMessageHolder() );
+ downloadManager.download(tempFile.toURI().toASCIIString(), new DefaultMessageHolder());
- verify( wagon, wagonManager );
+ verify(wagon, wagonManager);
}
- public void testShouldDownloadFromTempFileTwiceAndUseCache()
- throws IOException, DownloadFailedException
- {
- File tempFile = Files.createTempFile( "download-source", "test" ).toFile();
+ public void testShouldDownloadFromTempFileTwiceAndUseCache() throws IOException, DownloadFailedException {
+ File tempFile = Files.createTempFile("download-source", "test").toFile();
tempFile.deleteOnExit();
setupDefaultMockConfiguration();
- replay( wagon, wagonManager );
+ replay(wagon, wagonManager);
- DownloadManager downloadManager = new DefaultDownloadManager( wagonManager );
+ DownloadManager downloadManager = new DefaultDownloadManager(wagonManager);
- File first = downloadManager.download( tempFile.toURI().toASCIIString(), new DefaultMessageHolder() );
+ File first = downloadManager.download(tempFile.toURI().toASCIIString(), new DefaultMessageHolder());
MessageHolder mh = new DefaultMessageHolder();
- File second = downloadManager.download( tempFile.toURI().toASCIIString(), mh );
+ File second = downloadManager.download(tempFile.toURI().toASCIIString(), mh);
- assertSame( first, second );
- assertEquals( 1, mh.size() );
- assertTrue( mh.render().indexOf( "Using cached" ) > -1 );
+ assertSame(first, second);
+ assertEquals(1, mh.size());
+ assertTrue(mh.render().indexOf("Using cached") > -1);
- verify( wagon, wagonManager );
+ verify(wagon, wagonManager);
}
- public void testShouldDownloadFromTempFileWithOneTransferListener()
- throws IOException, DownloadFailedException
- {
- File tempFile = Files.createTempFile( "download-source", "test" ).toFile();
+ public void testShouldDownloadFromTempFileWithOneTransferListener() throws IOException, DownloadFailedException {
+ File tempFile = Files.createTempFile("download-source", "test").toFile();
tempFile.deleteOnExit();
setupDefaultMockConfiguration();
- TransferListener transferListener = createMock( TransferListener.class );
+ TransferListener transferListener = createMock(TransferListener.class);
- wagon.addTransferListener( transferListener );
+ wagon.addTransferListener(transferListener);
- wagon.removeTransferListener( transferListener );
+ wagon.removeTransferListener(transferListener);
- replay( wagon, wagonManager, transferListener );
+ replay(wagon, wagonManager, transferListener);
- DownloadManager downloadManager = new DefaultDownloadManager( wagonManager );
+ DownloadManager downloadManager = new DefaultDownloadManager(wagonManager);
- downloadManager.download( tempFile.toURI().toASCIIString(), Collections.singletonList( transferListener ),
- new DefaultMessageHolder() );
+ downloadManager.download(
+ tempFile.toURI().toASCIIString(),
+ Collections.singletonList(transferListener),
+ new DefaultMessageHolder());
- verify( wagon, wagonManager, transferListener );
+ verify(wagon, wagonManager, transferListener);
}
- public void testShouldFailToDownloadWhenWagonProtocolNotFound()
- throws IOException
- {
- File tempFile = Files.createTempFile( "download-source", "test" ).toFile();
+ public void testShouldFailToDownloadWhenWagonProtocolNotFound() throws IOException {
+ File tempFile = Files.createTempFile("download-source", "test").toFile();
tempFile.deleteOnExit();
- setupMocksWithWagonManagerGetException( new UnsupportedProtocolException( "not supported" ) );
+ setupMocksWithWagonManagerGetException(new UnsupportedProtocolException("not supported"));
- replay( wagon, wagonManager );
+ replay(wagon, wagonManager);
- DownloadManager downloadManager = new DefaultDownloadManager( wagonManager );
+ DownloadManager downloadManager = new DefaultDownloadManager(wagonManager);
- try
- {
- downloadManager.download( tempFile.toURI().toASCIIString(), new DefaultMessageHolder() );
+ try {
+ downloadManager.download(tempFile.toURI().toASCIIString(), new DefaultMessageHolder());
- fail( "should have failed to retrieve wagon." );
- }
- catch ( DownloadFailedException e )
- {
- assertTrue( ExceptionUtils.getStackTrace( e ).indexOf( "UnsupportedProtocolException" ) > -1 );
+ fail("should have failed to retrieve wagon.");
+ } catch (DownloadFailedException e) {
+ assertTrue(ExceptionUtils.getStackTrace(e).indexOf("UnsupportedProtocolException") > -1);
}
- verify( wagon, wagonManager );
+ verify(wagon, wagonManager);
}
- public void testShouldFailToDownloadWhenWagonConnectThrowsConnectionException()
- throws IOException
- {
- File tempFile = Files.createTempFile( "download-source", "test" ).toFile();
+ public void testShouldFailToDownloadWhenWagonConnectThrowsConnectionException() throws IOException {
+ File tempFile = Files.createTempFile("download-source", "test").toFile();
tempFile.deleteOnExit();
- setupMocksWithWagonConnectionException( new ConnectionException( "connect error" ) );
+ setupMocksWithWagonConnectionException(new ConnectionException("connect error"));
- replay( wagon, wagonManager );
+ replay(wagon, wagonManager);
- DownloadManager downloadManager = new DefaultDownloadManager( wagonManager );
+ DownloadManager downloadManager = new DefaultDownloadManager(wagonManager);
- try
- {
- downloadManager.download( tempFile.toURI().toASCIIString(), new DefaultMessageHolder() );
+ try {
+ downloadManager.download(tempFile.toURI().toASCIIString(), new DefaultMessageHolder());
- fail( "should have failed to connect wagon." );
- }
- catch ( DownloadFailedException e )
- {
- assertTrue( ExceptionUtils.getStackTrace( e ).indexOf( "ConnectionException" ) > -1 );
+ fail("should have failed to connect wagon.");
+ } catch (DownloadFailedException e) {
+ assertTrue(ExceptionUtils.getStackTrace(e).indexOf("ConnectionException") > -1);
}
- verify( wagon, wagonManager );
+ verify(wagon, wagonManager);
}
- public void testShouldFailToDownloadWhenWagonConnectThrowsAuthenticationException()
- throws IOException
- {
- File tempFile = Files.createTempFile( "download-source", "test" ).toFile();
+ public void testShouldFailToDownloadWhenWagonConnectThrowsAuthenticationException() throws IOException {
+ File tempFile = Files.createTempFile("download-source", "test").toFile();
tempFile.deleteOnExit();
- setupMocksWithWagonConnectionException( new AuthenticationException( "bad credentials" ) );
+ setupMocksWithWagonConnectionException(new AuthenticationException("bad credentials"));
- replay( wagon, wagonManager );
+ replay(wagon, wagonManager);
- DownloadManager downloadManager = new DefaultDownloadManager( wagonManager );
+ DownloadManager downloadManager = new DefaultDownloadManager(wagonManager);
- try
- {
- downloadManager.download( tempFile.toURI().toASCIIString(), new DefaultMessageHolder() );
+ try {
+ downloadManager.download(tempFile.toURI().toASCIIString(), new DefaultMessageHolder());
- fail( "should have failed to connect wagon." );
- }
- catch ( DownloadFailedException e )
- {
- assertTrue( ExceptionUtils.getStackTrace( e ).indexOf( "AuthenticationException" ) > -1 );
+ fail("should have failed to connect wagon.");
+ } catch (DownloadFailedException e) {
+ assertTrue(ExceptionUtils.getStackTrace(e).indexOf("AuthenticationException") > -1);
}
- verify( wagon, wagonManager );
+ verify(wagon, wagonManager);
}
- public void testShouldFailToDownloadWhenWagonGetThrowsTransferFailedException()
- throws IOException
- {
- File tempFile = Files.createTempFile( "download-source", "test" ).toFile();
+ public void testShouldFailToDownloadWhenWagonGetThrowsTransferFailedException() throws IOException {
+ File tempFile = Files.createTempFile("download-source", "test").toFile();
tempFile.deleteOnExit();
- setupMocksWithWagonGetException( new TransferFailedException( "bad transfer" ) );
+ setupMocksWithWagonGetException(new TransferFailedException("bad transfer"));
- replay( wagon, wagonManager );
+ replay(wagon, wagonManager);
- DownloadManager downloadManager = new DefaultDownloadManager( wagonManager );
+ DownloadManager downloadManager = new DefaultDownloadManager(wagonManager);
- try
- {
- downloadManager.download( tempFile.toURI().toASCIIString(), new DefaultMessageHolder() );
+ try {
+ downloadManager.download(tempFile.toURI().toASCIIString(), new DefaultMessageHolder());
- fail( "should have failed to get resource." );
- }
- catch ( DownloadFailedException e )
- {
- assertTrue( ExceptionUtils.getStackTrace( e ).indexOf( "TransferFailedException" ) > -1 );
+ fail("should have failed to get resource.");
+ } catch (DownloadFailedException e) {
+ assertTrue(ExceptionUtils.getStackTrace(e).indexOf("TransferFailedException") > -1);
}
- verify( wagon, wagonManager );
+ verify(wagon, wagonManager);
}
- public void testShouldFailToDownloadWhenWagonGetThrowsResourceDoesNotExistException()
- throws IOException
- {
- File tempFile = Files.createTempFile( "download-source", "test" ).toFile();
+ public void testShouldFailToDownloadWhenWagonGetThrowsResourceDoesNotExistException() throws IOException {
+ File tempFile = Files.createTempFile("download-source", "test").toFile();
tempFile.deleteOnExit();
- setupMocksWithWagonGetException( new ResourceDoesNotExistException( "bad resource" ) );
+ setupMocksWithWagonGetException(new ResourceDoesNotExistException("bad resource"));
- replay( wagon, wagonManager );
+ replay(wagon, wagonManager);
- DownloadManager downloadManager = new DefaultDownloadManager( wagonManager );
+ DownloadManager downloadManager = new DefaultDownloadManager(wagonManager);
- try
- {
- downloadManager.download( tempFile.toURI().toASCIIString(), new DefaultMessageHolder() );
+ try {
+ downloadManager.download(tempFile.toURI().toASCIIString(), new DefaultMessageHolder());
- fail( "should have failed to get resource." );
- }
- catch ( DownloadFailedException e )
- {
- assertTrue( ExceptionUtils.getStackTrace( e ).indexOf( "ResourceDoesNotExistException" ) > -1 );
+ fail("should have failed to get resource.");
+ } catch (DownloadFailedException e) {
+ assertTrue(ExceptionUtils.getStackTrace(e).indexOf("ResourceDoesNotExistException") > -1);
}
- verify( wagon, wagonManager );
+ verify(wagon, wagonManager);
}
- public void testShouldFailToDownloadWhenWagonGetThrowsAuthorizationException()
- throws IOException
- {
- File tempFile = Files.createTempFile( "download-source", "test" ).toFile();
+ public void testShouldFailToDownloadWhenWagonGetThrowsAuthorizationException() throws IOException {
+ File tempFile = Files.createTempFile("download-source", "test").toFile();
tempFile.deleteOnExit();
- setupMocksWithWagonGetException( new AuthorizationException( "bad transfer" ) );
+ setupMocksWithWagonGetException(new AuthorizationException("bad transfer"));
- replay( wagon, wagonManager );
+ replay(wagon, wagonManager);
- DownloadManager downloadManager = new DefaultDownloadManager( wagonManager );
+ DownloadManager downloadManager = new DefaultDownloadManager(wagonManager);
- try
- {
- downloadManager.download( tempFile.toURI().toASCIIString(), new DefaultMessageHolder() );
+ try {
+ downloadManager.download(tempFile.toURI().toASCIIString(), new DefaultMessageHolder());
- fail( "should have failed to get resource." );
- }
- catch ( DownloadFailedException e )
- {
- assertTrue( ExceptionUtils.getStackTrace( e ).indexOf( "AuthorizationException" ) > -1 );
+ fail("should have failed to get resource.");
+ } catch (DownloadFailedException e) {
+ assertTrue(ExceptionUtils.getStackTrace(e).indexOf("AuthorizationException") > -1);
}
- verify( wagon, wagonManager );
+ verify(wagon, wagonManager);
}
public void testShouldFailToDownloadWhenWagonDisconnectThrowsConnectionException()
- throws IOException, DownloadFailedException
- {
- File tempFile = Files.createTempFile( "download-source", "test" ).toFile();
+ throws IOException, DownloadFailedException {
+ File tempFile = Files.createTempFile("download-source", "test").toFile();
tempFile.deleteOnExit();
- setupMocksWithWagonDisconnectException( new ConnectionException( "not connected" ) );
+ setupMocksWithWagonDisconnectException(new ConnectionException("not connected"));
- replay( wagon, wagonManager );
+ replay(wagon, wagonManager);
- DownloadManager downloadManager = new DefaultDownloadManager( wagonManager );
+ DownloadManager downloadManager = new DefaultDownloadManager(wagonManager);
MessageHolder mh = new DefaultMessageHolder();
- downloadManager.download( tempFile.toURI().toASCIIString(), mh );
+ downloadManager.download(tempFile.toURI().toASCIIString(), mh);
- assertTrue( mh.render().indexOf( "ConnectionException" ) > -1 );
+ assertTrue(mh.render().indexOf("ConnectionException") > -1);
- verify( wagon, wagonManager );
+ verify(wagon, wagonManager);
}
- private void setupDefaultMockConfiguration()
- {
- try
- {
- expect( wagonManager.getWagon( "file" ) ).andReturn( wagon );
- }
- catch ( UnsupportedProtocolException e )
- {
- fail( "This shouldn't happen!!" );
+ private void setupDefaultMockConfiguration() {
+ try {
+ expect(wagonManager.getWagon("file")).andReturn(wagon);
+ } catch (UnsupportedProtocolException e) {
+ fail("This shouldn't happen!!");
}
- expect( wagonManager.getAuthenticationInfo( anyString() ) ).andReturn( null );
+ expect(wagonManager.getAuthenticationInfo(anyString())).andReturn(null);
- expect( wagonManager.getProxy( anyString() ) ).andReturn( null );
+ expect(wagonManager.getProxy(anyString())).andReturn(null);
- try
- {
- wagon.connect( anyObject( Repository.class ) , anyObject( AuthenticationInfo.class ), anyObject( ProxyInfo.class ) );
- }
- catch ( ConnectionException e )
- {
- fail( "This shouldn't happen!!" );
- }
- catch ( AuthenticationException e )
- {
- fail( "This shouldn't happen!!" );
+ try {
+ wagon.connect(anyObject(Repository.class), anyObject(AuthenticationInfo.class), anyObject(ProxyInfo.class));
+ } catch (ConnectionException e) {
+ fail("This shouldn't happen!!");
+ } catch (AuthenticationException e) {
+ fail("This shouldn't happen!!");
}
- try
- {
- wagon.get( anyString(), anyObject( File.class ) );
- }
- catch ( TransferFailedException e )
- {
- fail( "This shouldn't happen!!" );
- }
- catch ( ResourceDoesNotExistException e )
- {
- fail( "This shouldn't happen!!" );
- }
- catch ( AuthorizationException e )
- {
- fail( "This shouldn't happen!!" );
+ try {
+ wagon.get(anyString(), anyObject(File.class));
+ } catch (TransferFailedException e) {
+ fail("This shouldn't happen!!");
+ } catch (ResourceDoesNotExistException e) {
+ fail("This shouldn't happen!!");
+ } catch (AuthorizationException e) {
+ fail("This shouldn't happen!!");
}
- try
- {
+ try {
wagon.disconnect();
- }
- catch ( ConnectionException e )
- {
- fail( "This shouldn't happen!!" );
+ } catch (ConnectionException e) {
+ fail("This shouldn't happen!!");
}
}
- private void setupMocksWithWagonManagerGetException( Throwable error )
- {
- try
- {
- expect( wagonManager.getWagon( "file" ) ).andThrow( error );
- }
- catch ( UnsupportedProtocolException e )
- {
- fail( "This shouldn't happen!!" );
+ private void setupMocksWithWagonManagerGetException(Throwable error) {
+ try {
+ expect(wagonManager.getWagon("file")).andThrow(error);
+ } catch (UnsupportedProtocolException e) {
+ fail("This shouldn't happen!!");
}
}
- private void setupMocksWithWagonConnectionException( Throwable error )
- {
- try
- {
- expect( wagonManager.getWagon( "file" ) ).andReturn( wagon );
- }
- catch ( UnsupportedProtocolException e )
- {
- fail( "This shouldn't happen!!" );
+ private void setupMocksWithWagonConnectionException(Throwable error) {
+ try {
+ expect(wagonManager.getWagon("file")).andReturn(wagon);
+ } catch (UnsupportedProtocolException e) {
+ fail("This shouldn't happen!!");
}
- expect( wagonManager.getAuthenticationInfo( anyString() ) ).andReturn( null );
+ expect(wagonManager.getAuthenticationInfo(anyString())).andReturn(null);
- expect( wagonManager.getProxy( anyString() ) ).andReturn( null );
+ expect(wagonManager.getProxy(anyString())).andReturn(null);
- try
- {
- wagon.connect( anyObject( Repository.class ) , anyObject( AuthenticationInfo.class ), anyObject( ProxyInfo.class ) );
- expectLastCall().andThrow( error );
- }
- catch ( ConnectionException e )
- {
- fail( "This shouldn't happen!!" );
- }
- catch ( AuthenticationException e )
- {
- fail( "This shouldn't happen!!" );
+ try {
+ wagon.connect(anyObject(Repository.class), anyObject(AuthenticationInfo.class), anyObject(ProxyInfo.class));
+ expectLastCall().andThrow(error);
+ } catch (ConnectionException e) {
+ fail("This shouldn't happen!!");
+ } catch (AuthenticationException e) {
+ fail("This shouldn't happen!!");
}
}
- private void setupMocksWithWagonGetException( Throwable error )
- {
- try
- {
- expect( wagonManager.getWagon( "file" ) ).andReturn( wagon );
- }
- catch ( UnsupportedProtocolException e )
- {
- fail( "This shouldn't happen!!" );
+ private void setupMocksWithWagonGetException(Throwable error) {
+ try {
+ expect(wagonManager.getWagon("file")).andReturn(wagon);
+ } catch (UnsupportedProtocolException e) {
+ fail("This shouldn't happen!!");
}
- expect( wagonManager.getAuthenticationInfo( anyString() ) ).andReturn( null );
+ expect(wagonManager.getAuthenticationInfo(anyString())).andReturn(null);
- expect( wagonManager.getProxy( anyString() ) ).andReturn( null );
+ expect(wagonManager.getProxy(anyString())).andReturn(null);
- try
- {
- wagon.connect( anyObject( Repository.class ) , anyObject( AuthenticationInfo.class ), anyObject( ProxyInfo.class ) );
- }
- catch ( ConnectionException e )
- {
- fail( "This shouldn't happen!!" );
- }
- catch ( AuthenticationException e )
- {
- fail( "This shouldn't happen!!" );
+ try {
+ wagon.connect(anyObject(Repository.class), anyObject(AuthenticationInfo.class), anyObject(ProxyInfo.class));
+ } catch (ConnectionException e) {
+ fail("This shouldn't happen!!");
+ } catch (AuthenticationException e) {
+ fail("This shouldn't happen!!");
}
- try
- {
- wagon.get( anyString(), anyObject( File.class ) );
- expectLastCall().andThrow( error );
- }
- catch ( TransferFailedException e )
- {
- fail( "This shouldn't happen!!" );
- }
- catch ( ResourceDoesNotExistException e )
- {
- fail( "This shouldn't happen!!" );
- }
- catch ( AuthorizationException e )
- {
- fail( "This shouldn't happen!!" );
+ try {
+ wagon.get(anyString(), anyObject(File.class));
+ expectLastCall().andThrow(error);
+ } catch (TransferFailedException e) {
+ fail("This shouldn't happen!!");
+ } catch (ResourceDoesNotExistException e) {
+ fail("This shouldn't happen!!");
+ } catch (AuthorizationException e) {
+ fail("This shouldn't happen!!");
}
- try
- {
+ try {
wagon.disconnect();
- }
- catch ( ConnectionException e )
- {
- fail( "This shouldn't happen!!" );
+ } catch (ConnectionException e) {
+ fail("This shouldn't happen!!");
}
}
- private void setupMocksWithWagonDisconnectException( Throwable error )
- {
- try
- {
- expect( wagonManager.getWagon( "file" ) ).andReturn( wagon );
- }
- catch ( UnsupportedProtocolException e )
- {
- fail( "This shouldn't happen!!" );
+ private void setupMocksWithWagonDisconnectException(Throwable error) {
+ try {
+ expect(wagonManager.getWagon("file")).andReturn(wagon);
+ } catch (UnsupportedProtocolException e) {
+ fail("This shouldn't happen!!");
}
- expect( wagonManager.getAuthenticationInfo( anyString() ) ).andReturn( null );
+ expect(wagonManager.getAuthenticationInfo(anyString())).andReturn(null);
- expect( wagonManager.getProxy( anyString() ) ).andReturn( null );
+ expect(wagonManager.getProxy(anyString())).andReturn(null);
- try
- {
- wagon.connect( anyObject( Repository.class ) , anyObject( AuthenticationInfo.class ), anyObject( ProxyInfo.class ) );
- }
- catch ( ConnectionException e )
- {
- fail( "This shouldn't happen!!" );
- }
- catch ( AuthenticationException e )
- {
- fail( "This shouldn't happen!!" );
+ try {
+ wagon.connect(anyObject(Repository.class), anyObject(AuthenticationInfo.class), anyObject(ProxyInfo.class));
+ } catch (ConnectionException e) {
+ fail("This shouldn't happen!!");
+ } catch (AuthenticationException e) {
+ fail("This shouldn't happen!!");
}
- try
- {
- wagon.get( anyString(), anyObject( File.class ) );
- }
- catch ( TransferFailedException e )
- {
- fail( "This shouldn't happen!!" );
- }
- catch ( ResourceDoesNotExistException e )
- {
- fail( "This shouldn't happen!!" );
- }
- catch ( AuthorizationException e )
- {
- fail( "This shouldn't happen!!" );
+ try {
+ wagon.get(anyString(), anyObject(File.class));
+ } catch (TransferFailedException e) {
+ fail("This shouldn't happen!!");
+ } catch (ResourceDoesNotExistException e) {
+ fail("This shouldn't happen!!");
+ } catch (AuthorizationException e) {
+ fail("This shouldn't happen!!");
}
- try
- {
+ try {
wagon.disconnect();
- expectLastCall().andThrow( error );
- }
- catch ( ConnectionException e )
- {
- fail( "This shouldn't happen!!" );
+ expectLastCall().andThrow(error);
+ } catch (ConnectionException e) {
+ fail("This shouldn't happen!!");
}
}
}
diff --git a/src/test/java/org/apache/maven/shared/io/download/DownloadFailedExceptionTest.java b/src/test/java/org/apache/maven/shared/io/download/DownloadFailedExceptionTest.java
index a6c957c..c6a263e 100644
--- a/src/test/java/org/apache/maven/shared/io/download/DownloadFailedExceptionTest.java
+++ b/src/test/java/org/apache/maven/shared/io/download/DownloadFailedExceptionTest.java
@@ -1,5 +1,3 @@
-package org.apache.maven.shared.io.download;
-
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
@@ -18,27 +16,22 @@
* specific language governing permissions and limitations
* under the License.
*/
+package org.apache.maven.shared.io.download;
import junit.framework.TestCase;
-public class DownloadFailedExceptionTest
- extends TestCase
-{
+public class DownloadFailedExceptionTest extends TestCase {
- public void testShouldConstructWithUrlAndMessage()
- {
- new DownloadFailedException( "http://www.google.com", "can't find." );
+ public void testShouldConstructWithUrlAndMessage() {
+ new DownloadFailedException("http://www.google.com", "can't find.");
}
- public void testShouldConstructWithUrlMessageAndException()
- {
- new DownloadFailedException( "http://www.google.com", "can't find.", new NullPointerException() );
+ public void testShouldConstructWithUrlMessageAndException() {
+ new DownloadFailedException("http://www.google.com", "can't find.", new NullPointerException());
}
- public void testShouldRetrieveUrlFromConstructor()
- {
+ public void testShouldRetrieveUrlFromConstructor() {
String url = "http://www.google.com";
- assertEquals( url, new DownloadFailedException( url, "can't find." ).getUrl() );
+ assertEquals(url, new DownloadFailedException(url, "can't find.").getUrl());
}
-
}
diff --git a/src/test/java/org/apache/maven/shared/io/location/ArtifactLocationTest.java b/src/test/java/org/apache/maven/shared/io/location/ArtifactLocationTest.java
index dc5497b..be7e198 100644
--- a/src/test/java/org/apache/maven/shared/io/location/ArtifactLocationTest.java
+++ b/src/test/java/org/apache/maven/shared/io/location/ArtifactLocationTest.java
@@ -1,5 +1,3 @@
-package org.apache.maven.shared.io.location;
-
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
@@ -18,65 +16,70 @@
* specific language governing permissions and limitations
* under the License.
*/
+package org.apache.maven.shared.io.location;
import java.io.File;
import java.io.IOException;
import java.nio.file.Files;
import junit.framework.TestCase;
-
import org.apache.commons.io.FileUtils;
import org.apache.maven.artifact.Artifact;
import org.apache.maven.artifact.DefaultArtifact;
import org.apache.maven.artifact.handler.DefaultArtifactHandler;
import org.apache.maven.artifact.versioning.VersionRange;
-public class ArtifactLocationTest
- extends TestCase
-{
+public class ArtifactLocationTest extends TestCase {
- public void testShouldConstructFromTempFileSpecification()
- throws IOException
- {
- File f = Files.createTempFile( "artifact-location.", ".test" ).toFile();
+ public void testShouldConstructFromTempFileSpecification() throws IOException {
+ File f = Files.createTempFile("artifact-location.", ".test").toFile();
f.deleteOnExit();
- Artifact a = new DefaultArtifact( "group", "artifact", VersionRange.createFromVersion( "1" ), null, "jar",
- null, new DefaultArtifactHandler() );
+ Artifact a = new DefaultArtifact(
+ "group",
+ "artifact",
+ VersionRange.createFromVersion("1"),
+ null,
+ "jar",
+ null,
+ new DefaultArtifactHandler());
- a.setFile( f );
+ a.setFile(f);
- ArtifactLocation location = new ArtifactLocation( a, f.getAbsolutePath() );
+ ArtifactLocation location = new ArtifactLocation(a, f.getAbsolutePath());
- assertSame( f, location.getFile() );
+ assertSame(f, location.getFile());
}
- public void testShouldRead()
- throws IOException
- {
- File f = Files.createTempFile( "url-location.", ".test" ).toFile();
+ public void testShouldRead() throws IOException {
+ File f = Files.createTempFile("url-location.", ".test").toFile();
f.deleteOnExit();
String testStr = "This is a test";
- FileUtils.writeStringToFile( f, testStr, "US-ASCII" );
+ FileUtils.writeStringToFile(f, testStr, "US-ASCII");
- Artifact a = new DefaultArtifact( "group", "artifact", VersionRange.createFromVersion( "1" ), null, "jar",
- null, new DefaultArtifactHandler() );
+ Artifact a = new DefaultArtifact(
+ "group",
+ "artifact",
+ VersionRange.createFromVersion("1"),
+ null,
+ "jar",
+ null,
+ new DefaultArtifactHandler());
- a.setFile( f );
+ a.setFile(f);
- ArtifactLocation location = new ArtifactLocation( a, f.getAbsolutePath() );
+ ArtifactLocation location = new ArtifactLocation(a, f.getAbsolutePath());
location.open();
byte[] buffer = new byte[testStr.length()];
- int read = location.read( buffer );
+ int read = location.read(buffer);
- assertEquals( testStr.length(), read );
+ assertEquals(testStr.length(), read);
- assertEquals( testStr, new String( buffer, "US-ASCII" ) );
+ assertEquals(testStr, new String(buffer, "US-ASCII"));
}
-
}
diff --git a/src/test/java/org/apache/maven/shared/io/location/ArtifactLocatorStrategyTest.java b/src/test/java/org/apache/maven/shared/io/location/ArtifactLocatorStrategyTest.java
index 9516080..e0be807 100644
--- a/src/test/java/org/apache/maven/shared/io/location/ArtifactLocatorStrategyTest.java
+++ b/src/test/java/org/apache/maven/shared/io/location/ArtifactLocatorStrategyTest.java
@@ -1,5 +1,3 @@
-package org.apache.maven.shared.io.location;
-
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
@@ -18,6 +16,7 @@
* specific language governing permissions and limitations
* under the License.
*/
+package org.apache.maven.shared.io.location;
import java.io.File;
import java.io.IOException;
@@ -25,7 +24,6 @@
import java.util.Collections;
import junit.framework.TestCase;
-
import org.apache.maven.artifact.Artifact;
import org.apache.maven.artifact.factory.ArtifactFactory;
import org.apache.maven.artifact.repository.ArtifactRepository;
@@ -37,9 +35,7 @@
import static org.easymock.EasyMock.*;
-public class ArtifactLocatorStrategyTest
- extends TestCase
-{
+public class ArtifactLocatorStrategyTest extends TestCase {
private ArtifactFactory factory;
@@ -47,462 +43,414 @@
private ArtifactRepository localRepository;
- public void setUp()
- {
- factory = createMock( ArtifactFactory.class );
- resolver = createMock( ArtifactResolver.class );
- localRepository = createMock( ArtifactRepository.class );
+ public void setUp() {
+ factory = createMock(ArtifactFactory.class);
+ resolver = createMock(ArtifactResolver.class);
+ localRepository = createMock(ArtifactRepository.class);
}
- public void testShouldConstructWithoutDefaultArtifactType()
- {
- replay( factory, resolver, localRepository );
+ public void testShouldConstructWithoutDefaultArtifactType() {
+ replay(factory, resolver, localRepository);
- new ArtifactLocatorStrategy( factory, resolver, localRepository, Collections.EMPTY_LIST );
+ new ArtifactLocatorStrategy(factory, resolver, localRepository, Collections.EMPTY_LIST);
- verify( factory, resolver, localRepository );
+ verify(factory, resolver, localRepository);
}
- public void testShouldConstructWithDefaultArtifactType()
- {
- replay( factory, resolver, localRepository );
+ public void testShouldConstructWithDefaultArtifactType() {
+ replay(factory, resolver, localRepository);
- new ArtifactLocatorStrategy( factory, resolver, localRepository, Collections.EMPTY_LIST, "zip" );
+ new ArtifactLocatorStrategy(factory, resolver, localRepository, Collections.EMPTY_LIST, "zip");
- verify( factory, resolver, localRepository );
+ verify(factory, resolver, localRepository);
}
- public void testShouldFailToResolveSpecWithOneToken()
- {
- replay( factory, resolver, localRepository );
+ public void testShouldFailToResolveSpecWithOneToken() {
+ replay(factory, resolver, localRepository);
- LocatorStrategy strategy = new ArtifactLocatorStrategy( factory, resolver, localRepository,
- Collections.EMPTY_LIST, "zip" );
+ LocatorStrategy strategy =
+ new ArtifactLocatorStrategy(factory, resolver, localRepository, Collections.EMPTY_LIST, "zip");
MessageHolder mh = new DefaultMessageHolder();
- Location location = strategy.resolve( "one-token", mh );
+ Location location = strategy.resolve("one-token", mh);
- assertNull( location );
- assertEquals( 1, mh.size() );
+ assertNull(location);
+ assertEquals(1, mh.size());
- verify( factory, resolver, localRepository );
+ verify(factory, resolver, localRepository);
}
- public void testShouldFailToResolveSpecWithTwoTokens()
- {
- replay( factory, resolver, localRepository );
+ public void testShouldFailToResolveSpecWithTwoTokens() {
+ replay(factory, resolver, localRepository);
- LocatorStrategy strategy = new ArtifactLocatorStrategy( factory, resolver, localRepository,
- Collections.EMPTY_LIST, "zip" );
+ LocatorStrategy strategy =
+ new ArtifactLocatorStrategy(factory, resolver, localRepository, Collections.EMPTY_LIST, "zip");
MessageHolder mh = new DefaultMessageHolder();
- Location location = strategy.resolve( "two:tokens", mh );
+ Location location = strategy.resolve("two:tokens", mh);
- assertNull( location );
- assertEquals( 1, mh.size() );
+ assertNull(location);
+ assertEquals(1, mh.size());
- verify( factory, resolver, localRepository );
+ verify(factory, resolver, localRepository);
}
- public void testShouldResolveSpecWithThreeTokensUsingDefaultType()
- throws IOException
- {
- File tempFile = Files.createTempFile( "artifact-location.", ".temp" ).toFile();
+ public void testShouldResolveSpecWithThreeTokensUsingDefaultType() throws IOException {
+ File tempFile = Files.createTempFile("artifact-location.", ".temp").toFile();
tempFile.deleteOnExit();
- Artifact artifact = createMock( Artifact.class );
-
- expect( artifact.getFile() ).andReturn( tempFile );
- expect( artifact.getFile() ).andReturn( tempFile );
-
- expect( factory.createArtifact( "group", "artifact", "version", null, "jar" ) ).andReturn( artifact );
+ Artifact artifact = createMock(Artifact.class);
- try
- {
- resolver.resolve( artifact, Collections.<ArtifactRepository>emptyList(), localRepository );
- }
- catch ( ArtifactResolutionException e )
- {
+ expect(artifact.getFile()).andReturn(tempFile);
+ expect(artifact.getFile()).andReturn(tempFile);
+
+ expect(factory.createArtifact("group", "artifact", "version", null, "jar"))
+ .andReturn(artifact);
+
+ try {
+ resolver.resolve(artifact, Collections.<ArtifactRepository>emptyList(), localRepository);
+ } catch (ArtifactResolutionException e) {
// should never happen
- fail( "This should NEVER happen. It's a mock!" );
- }
- catch ( ArtifactNotFoundException e )
- {
+ fail("This should NEVER happen. It's a mock!");
+ } catch (ArtifactNotFoundException e) {
// should never happen
- fail( "This should NEVER happen. It's a mock!" );
+ fail("This should NEVER happen. It's a mock!");
}
- replay( factory, resolver, localRepository, artifact );
+ replay(factory, resolver, localRepository, artifact);
- LocatorStrategy strategy = new ArtifactLocatorStrategy( factory, resolver, localRepository,
- Collections.EMPTY_LIST );
+ LocatorStrategy strategy =
+ new ArtifactLocatorStrategy(factory, resolver, localRepository, Collections.EMPTY_LIST);
MessageHolder mh = new DefaultMessageHolder();
- Location location = strategy.resolve( "group:artifact:version", mh );
+ Location location = strategy.resolve("group:artifact:version", mh);
- assertNotNull( location );
- assertEquals( 0, mh.size() );
+ assertNotNull(location);
+ assertEquals(0, mh.size());
- assertSame( tempFile, location.getFile() );
+ assertSame(tempFile, location.getFile());
- verify( factory, resolver, localRepository, artifact );
+ verify(factory, resolver, localRepository, artifact);
}
- public void testShouldResolveSpecWithThreeTokensUsingCustomizedDefaultType()
- throws IOException
- {
- File tempFile = Files.createTempFile( "artifact-location.", ".temp" ).toFile();
+ public void testShouldResolveSpecWithThreeTokensUsingCustomizedDefaultType() throws IOException {
+ File tempFile = Files.createTempFile("artifact-location.", ".temp").toFile();
tempFile.deleteOnExit();
- Artifact artifact = createMock( Artifact.class );
-
- expect( artifact.getFile() ).andReturn( tempFile );
- expect( artifact.getFile() ).andReturn( tempFile );
-
- expect( factory.createArtifact( "group", "artifact", "version", null, "zip" ) ).andReturn( artifact );
+ Artifact artifact = createMock(Artifact.class);
- try
- {
- resolver.resolve( artifact, Collections.<ArtifactRepository>emptyList(), localRepository );
- }
- catch ( ArtifactResolutionException e )
- {
+ expect(artifact.getFile()).andReturn(tempFile);
+ expect(artifact.getFile()).andReturn(tempFile);
+
+ expect(factory.createArtifact("group", "artifact", "version", null, "zip"))
+ .andReturn(artifact);
+
+ try {
+ resolver.resolve(artifact, Collections.<ArtifactRepository>emptyList(), localRepository);
+ } catch (ArtifactResolutionException e) {
// should never happen
- fail( "This should NEVER happen. It's a mock!" );
- }
- catch ( ArtifactNotFoundException e )
- {
+ fail("This should NEVER happen. It's a mock!");
+ } catch (ArtifactNotFoundException e) {
// should never happen
- fail( "This should NEVER happen. It's a mock!" );
+ fail("This should NEVER happen. It's a mock!");
}
- replay( factory, resolver, localRepository, artifact );
+ replay(factory, resolver, localRepository, artifact);
- LocatorStrategy strategy = new ArtifactLocatorStrategy( factory, resolver, localRepository,
- Collections.EMPTY_LIST, "zip" );
+ LocatorStrategy strategy =
+ new ArtifactLocatorStrategy(factory, resolver, localRepository, Collections.EMPTY_LIST, "zip");
MessageHolder mh = new DefaultMessageHolder();
- Location location = strategy.resolve( "group:artifact:version", mh );
+ Location location = strategy.resolve("group:artifact:version", mh);
- assertNotNull( location );
- assertEquals( 0, mh.size() );
+ assertNotNull(location);
+ assertEquals(0, mh.size());
- assertSame( tempFile, location.getFile() );
+ assertSame(tempFile, location.getFile());
- verify( factory, resolver, localRepository, artifact );
+ verify(factory, resolver, localRepository, artifact);
}
- public void testShouldResolveSpecWithFourTokens()
- throws IOException
- {
- File tempFile = Files.createTempFile( "artifact-location.", ".temp" ).toFile();
+ public void testShouldResolveSpecWithFourTokens() throws IOException {
+ File tempFile = Files.createTempFile("artifact-location.", ".temp").toFile();
tempFile.deleteOnExit();
- Artifact artifact = createMock( Artifact.class );
-
- expect( artifact.getFile() ).andReturn( tempFile );
- expect( artifact.getFile() ).andReturn( tempFile );
-
- expect( factory.createArtifact( "group", "artifact", "version", null, "zip" ) ).andReturn( artifact );
+ Artifact artifact = createMock(Artifact.class);
- try
- {
- resolver.resolve( artifact, Collections.<ArtifactRepository>emptyList(), localRepository );
- }
- catch ( ArtifactResolutionException e )
- {
+ expect(artifact.getFile()).andReturn(tempFile);
+ expect(artifact.getFile()).andReturn(tempFile);
+
+ expect(factory.createArtifact("group", "artifact", "version", null, "zip"))
+ .andReturn(artifact);
+
+ try {
+ resolver.resolve(artifact, Collections.<ArtifactRepository>emptyList(), localRepository);
+ } catch (ArtifactResolutionException e) {
// should never happen
- fail( "This should NEVER happen. It's a mock!" );
- }
- catch ( ArtifactNotFoundException e )
- {
+ fail("This should NEVER happen. It's a mock!");
+ } catch (ArtifactNotFoundException e) {
// should never happen
- fail( "This should NEVER happen. It's a mock!" );
+ fail("This should NEVER happen. It's a mock!");
}
- replay( factory, resolver, localRepository, artifact );
+ replay(factory, resolver, localRepository, artifact);
- LocatorStrategy strategy = new ArtifactLocatorStrategy( factory, resolver, localRepository,
- Collections.EMPTY_LIST );
+ LocatorStrategy strategy =
+ new ArtifactLocatorStrategy(factory, resolver, localRepository, Collections.EMPTY_LIST);
MessageHolder mh = new DefaultMessageHolder();
- Location location = strategy.resolve( "group:artifact:version:zip", mh );
+ Location location = strategy.resolve("group:artifact:version:zip", mh);
- assertNotNull( location );
- assertEquals( 0, mh.size() );
+ assertNotNull(location);
+ assertEquals(0, mh.size());
- assertSame( tempFile, location.getFile() );
+ assertSame(tempFile, location.getFile());
- verify( factory, resolver, localRepository, artifact );
+ verify(factory, resolver, localRepository, artifact);
}
- public void testShouldResolveSpecWithFiveTokens()
- throws IOException
- {
- File tempFile = Files.createTempFile( "artifact-location.", ".temp" ).toFile();
+ public void testShouldResolveSpecWithFiveTokens() throws IOException {
+ File tempFile = Files.createTempFile("artifact-location.", ".temp").toFile();
tempFile.deleteOnExit();
- Artifact artifact = createMock( Artifact.class );
-
- expect( artifact.getFile() ).andReturn( tempFile );
- expect( artifact.getFile() ).andReturn( tempFile );
-
- expect( factory.createArtifactWithClassifier( "group", "artifact", "version", "zip", "classifier" ) )
- .andReturn( artifact );
+ Artifact artifact = createMock(Artifact.class);
- try
- {
- resolver.resolve( artifact, Collections.<ArtifactRepository>emptyList(), localRepository );
- }
- catch ( ArtifactResolutionException e )
- {
+ expect(artifact.getFile()).andReturn(tempFile);
+ expect(artifact.getFile()).andReturn(tempFile);
+
+ expect(factory.createArtifactWithClassifier("group", "artifact", "version", "zip", "classifier"))
+ .andReturn(artifact);
+
+ try {
+ resolver.resolve(artifact, Collections.<ArtifactRepository>emptyList(), localRepository);
+ } catch (ArtifactResolutionException e) {
// should never happen
- fail( "This should NEVER happen. It's a mock!" );
- }
- catch ( ArtifactNotFoundException e )
- {
+ fail("This should NEVER happen. It's a mock!");
+ } catch (ArtifactNotFoundException e) {
// should never happen
- fail( "This should NEVER happen. It's a mock!" );
+ fail("This should NEVER happen. It's a mock!");
}
- replay( factory, resolver, localRepository, artifact );
+ replay(factory, resolver, localRepository, artifact);
- LocatorStrategy strategy = new ArtifactLocatorStrategy( factory, resolver, localRepository,
- Collections.EMPTY_LIST );
+ LocatorStrategy strategy =
+ new ArtifactLocatorStrategy(factory, resolver, localRepository, Collections.EMPTY_LIST);
MessageHolder mh = new DefaultMessageHolder();
- Location location = strategy.resolve( "group:artifact:version:zip:classifier", mh );
+ Location location = strategy.resolve("group:artifact:version:zip:classifier", mh);
- assertNotNull( location );
- assertEquals( 0, mh.size() );
+ assertNotNull(location);
+ assertEquals(0, mh.size());
- assertSame( tempFile, location.getFile() );
+ assertSame(tempFile, location.getFile());
- verify( factory, resolver, localRepository, artifact );
+ verify(factory, resolver, localRepository, artifact);
}
- public void testShouldResolveSpecWithFiveTokensAndEmptyTypeToken()
- throws IOException
- {
- File tempFile = Files.createTempFile( "artifact-location.", ".temp" ).toFile();
+ public void testShouldResolveSpecWithFiveTokensAndEmptyTypeToken() throws IOException {
+ File tempFile = Files.createTempFile("artifact-location.", ".temp").toFile();
tempFile.deleteOnExit();
- Artifact artifact = createMock( Artifact.class );
-
- expect( artifact.getFile() ).andReturn( tempFile );
- expect( artifact.getFile() ).andReturn( tempFile );
-
- expect( factory.createArtifactWithClassifier( "group", "artifact", "version", "jar", "classifier" ) )
- .andReturn( artifact );
+ Artifact artifact = createMock(Artifact.class);
- try
- {
- resolver.resolve( artifact, Collections.<ArtifactRepository>emptyList(), localRepository );
- }
- catch ( ArtifactResolutionException e )
- {
+ expect(artifact.getFile()).andReturn(tempFile);
+ expect(artifact.getFile()).andReturn(tempFile);
+
+ expect(factory.createArtifactWithClassifier("group", "artifact", "version", "jar", "classifier"))
+ .andReturn(artifact);
+
+ try {
+ resolver.resolve(artifact, Collections.<ArtifactRepository>emptyList(), localRepository);
+ } catch (ArtifactResolutionException e) {
// should never happen
- fail( "This should NEVER happen. It's a mock!" );
- }
- catch ( ArtifactNotFoundException e )
- {
+ fail("This should NEVER happen. It's a mock!");
+ } catch (ArtifactNotFoundException e) {
// should never happen
- fail( "This should NEVER happen. It's a mock!" );
+ fail("This should NEVER happen. It's a mock!");
}
- replay( factory, resolver, localRepository, artifact );
+ replay(factory, resolver, localRepository, artifact);
- LocatorStrategy strategy = new ArtifactLocatorStrategy( factory, resolver, localRepository,
- Collections.EMPTY_LIST );
+ LocatorStrategy strategy =
+ new ArtifactLocatorStrategy(factory, resolver, localRepository, Collections.EMPTY_LIST);
MessageHolder mh = new DefaultMessageHolder();
- Location location = strategy.resolve( "group:artifact:version::classifier", mh );
+ Location location = strategy.resolve("group:artifact:version::classifier", mh);
- assertNotNull( location );
- assertEquals( 0, mh.size() );
+ assertNotNull(location);
+ assertEquals(0, mh.size());
- assertSame( tempFile, location.getFile() );
+ assertSame(tempFile, location.getFile());
- verify( factory, resolver, localRepository, artifact );
+ verify(factory, resolver, localRepository, artifact);
}
- public void testShouldResolveSpecWithMoreThanFiveTokens()
- throws IOException
- {
- File tempFile = Files.createTempFile( "artifact-location.", ".temp" ).toFile();
+ public void testShouldResolveSpecWithMoreThanFiveTokens() throws IOException {
+ File tempFile = Files.createTempFile("artifact-location.", ".temp").toFile();
tempFile.deleteOnExit();
- Artifact artifact = createMock( Artifact.class );
-
- expect( artifact.getFile() ).andReturn( tempFile );
- expect( artifact.getFile() ).andReturn( tempFile );
-
- expect( factory.createArtifactWithClassifier( "group", "artifact", "version", "zip", "classifier" ) )
- .andReturn( artifact );
+ Artifact artifact = createMock(Artifact.class);
- try
- {
- resolver.resolve( artifact, Collections.<ArtifactRepository>emptyList(), localRepository );
- }
- catch ( ArtifactResolutionException e )
- {
+ expect(artifact.getFile()).andReturn(tempFile);
+ expect(artifact.getFile()).andReturn(tempFile);
+
+ expect(factory.createArtifactWithClassifier("group", "artifact", "version", "zip", "classifier"))
+ .andReturn(artifact);
+
+ try {
+ resolver.resolve(artifact, Collections.<ArtifactRepository>emptyList(), localRepository);
+ } catch (ArtifactResolutionException e) {
// should never happen
- fail( "This should NEVER happen. It's a mock!" );
- }
- catch ( ArtifactNotFoundException e )
- {
+ fail("This should NEVER happen. It's a mock!");
+ } catch (ArtifactNotFoundException e) {
// should never happen
- fail( "This should NEVER happen. It's a mock!" );
+ fail("This should NEVER happen. It's a mock!");
}
- replay( factory, resolver, localRepository, artifact );
+ replay(factory, resolver, localRepository, artifact);
- LocatorStrategy strategy = new ArtifactLocatorStrategy( factory, resolver, localRepository,
- Collections.EMPTY_LIST );
+ LocatorStrategy strategy =
+ new ArtifactLocatorStrategy(factory, resolver, localRepository, Collections.EMPTY_LIST);
MessageHolder mh = new DefaultMessageHolder();
- Location location = strategy.resolve( "group:artifact:version:zip:classifier:six:seven", mh );
+ Location location = strategy.resolve("group:artifact:version:zip:classifier:six:seven", mh);
- assertNotNull( location );
- assertEquals( 1, mh.size() );
+ assertNotNull(location);
+ assertEquals(1, mh.size());
- assertTrue( mh.render().indexOf( ":six:seven" ) > -1 );
+ assertTrue(mh.render().indexOf(":six:seven") > -1);
- assertSame( tempFile, location.getFile() );
+ assertSame(tempFile, location.getFile());
- verify( factory, resolver, localRepository, artifact );
+ verify(factory, resolver, localRepository, artifact);
}
- public void testShouldNotResolveSpecToArtifactWithNullFile()
- throws IOException
- {
- Artifact artifact = createMock( Artifact.class );
-
- expect( artifact.getFile() ).andReturn( null );
- expect( artifact.getId() ).andReturn( "<some-artifact-id>" );
-
- expect( factory.createArtifact( "group", "artifact", "version", null, "jar" )).andReturn( artifact );
+ public void testShouldNotResolveSpecToArtifactWithNullFile() throws IOException {
+ Artifact artifact = createMock(Artifact.class);
- try
- {
- resolver.resolve( artifact, Collections.<ArtifactRepository>emptyList(), localRepository );
- }
- catch ( ArtifactResolutionException e )
- {
+ expect(artifact.getFile()).andReturn(null);
+ expect(artifact.getId()).andReturn("<some-artifact-id>");
+
+ expect(factory.createArtifact("group", "artifact", "version", null, "jar"))
+ .andReturn(artifact);
+
+ try {
+ resolver.resolve(artifact, Collections.<ArtifactRepository>emptyList(), localRepository);
+ } catch (ArtifactResolutionException e) {
// should never happen
- fail( "This should NEVER happen. It's a mock!" );
- }
- catch ( ArtifactNotFoundException e )
- {
+ fail("This should NEVER happen. It's a mock!");
+ } catch (ArtifactNotFoundException e) {
// should never happen
- fail( "This should NEVER happen. It's a mock!" );
+ fail("This should NEVER happen. It's a mock!");
}
- replay( factory, resolver, localRepository, artifact );
+ replay(factory, resolver, localRepository, artifact);
- LocatorStrategy strategy = new ArtifactLocatorStrategy( factory, resolver, localRepository,
- Collections.EMPTY_LIST );
+ LocatorStrategy strategy =
+ new ArtifactLocatorStrategy(factory, resolver, localRepository, Collections.EMPTY_LIST);
MessageHolder mh = new DefaultMessageHolder();
- Location location = strategy.resolve( "group:artifact:version", mh );
+ Location location = strategy.resolve("group:artifact:version", mh);
- assertNull( location );
- assertEquals( 1, mh.size() );
+ assertNull(location);
+ assertEquals(1, mh.size());
- assertTrue( mh.render().indexOf( "<some-artifact-id>" ) > -1 );
+ assertTrue(mh.render().indexOf("<some-artifact-id>") > -1);
- verify( factory, resolver, localRepository, artifact );
+ verify(factory, resolver, localRepository, artifact);
}
- public void testShouldNotResolveWhenArtifactNotFoundExceptionThrown()
- throws IOException
- {
- Artifact artifact = createMock( Artifact.class );
+ public void testShouldNotResolveWhenArtifactNotFoundExceptionThrown() throws IOException {
+ Artifact artifact = createMock(Artifact.class);
- expect( artifact.getId() ).andReturn( "<some-artifact-id>" );
+ expect(artifact.getId()).andReturn("<some-artifact-id>");
- expect( factory.createArtifact( "group", "artifact", "version", null, "jar" ) ).andReturn( artifact );
+ expect(factory.createArtifact("group", "artifact", "version", null, "jar"))
+ .andReturn(artifact);
- try
- {
- resolver.resolve( artifact, Collections.<ArtifactRepository>emptyList(), localRepository );
- expectLastCall().andThrow( new ArtifactNotFoundException( "not found", "group", "artifact", "version",
- "jar", null, Collections.<ArtifactRepository>emptyList(),
- "http://nowhere.com", Collections.<String>emptyList(),
- new NullPointerException() ) );
- }
- catch ( ArtifactResolutionException e )
- {
+ try {
+ resolver.resolve(artifact, Collections.<ArtifactRepository>emptyList(), localRepository);
+ expectLastCall()
+ .andThrow(new ArtifactNotFoundException(
+ "not found",
+ "group",
+ "artifact",
+ "version",
+ "jar",
+ null,
+ Collections.<ArtifactRepository>emptyList(),
+ "http://nowhere.com",
+ Collections.<String>emptyList(),
+ new NullPointerException()));
+ } catch (ArtifactResolutionException e) {
// should never happen
- fail( "This should NEVER happen. It's a mock!" );
- }
- catch ( ArtifactNotFoundException e )
- {
+ fail("This should NEVER happen. It's a mock!");
+ } catch (ArtifactNotFoundException e) {
// should never happen
- fail( "This should NEVER happen. It's a mock!" );
+ fail("This should NEVER happen. It's a mock!");
}
- replay( factory, resolver, localRepository, artifact );
+ replay(factory, resolver, localRepository, artifact);
- LocatorStrategy strategy = new ArtifactLocatorStrategy( factory, resolver, localRepository,
- Collections.EMPTY_LIST );
+ LocatorStrategy strategy =
+ new ArtifactLocatorStrategy(factory, resolver, localRepository, Collections.EMPTY_LIST);
MessageHolder mh = new DefaultMessageHolder();
- Location location = strategy.resolve( "group:artifact:version", mh );
+ Location location = strategy.resolve("group:artifact:version", mh);
- assertNull( location );
- assertEquals( 1, mh.size() );
+ assertNull(location);
+ assertEquals(1, mh.size());
- assertTrue( mh.render().indexOf( "<some-artifact-id>" ) > -1 );
- assertTrue( mh.render().indexOf( "not found" ) > -1 );
+ assertTrue(mh.render().indexOf("<some-artifact-id>") > -1);
+ assertTrue(mh.render().indexOf("not found") > -1);
- verify( factory, resolver, localRepository, artifact );
+ verify(factory, resolver, localRepository, artifact);
}
- public void testShouldNotResolveWhenArtifactResolutionExceptionThrown()
- throws IOException
- {
- Artifact artifact = createMock( Artifact.class );
+ public void testShouldNotResolveWhenArtifactResolutionExceptionThrown() throws IOException {
+ Artifact artifact = createMock(Artifact.class);
- expect( artifact.getId() ).andReturn( "<some-artifact-id>" );
+ expect(artifact.getId()).andReturn("<some-artifact-id>");
- expect( factory.createArtifact( "group", "artifact", "version", null, "jar" ) ).andReturn( artifact );
+ expect(factory.createArtifact("group", "artifact", "version", null, "jar"))
+ .andReturn(artifact);
- try
- {
- resolver.resolve( artifact, Collections.<ArtifactRepository>emptyList(), localRepository );
- expectLastCall().andThrow( new ArtifactResolutionException( "resolution failed", "group", "artifact",
- "version", "jar", null, Collections.<ArtifactRepository>emptyList(),
- Collections.<String>emptyList(),
- new NullPointerException() ) );
+ try {
+ resolver.resolve(artifact, Collections.<ArtifactRepository>emptyList(), localRepository);
+ expectLastCall()
+ .andThrow(new ArtifactResolutionException(
+ "resolution failed",
+ "group",
+ "artifact",
+ "version",
+ "jar",
+ null,
+ Collections.<ArtifactRepository>emptyList(),
+ Collections.<String>emptyList(),
+ new NullPointerException()));
- }
- catch ( ArtifactResolutionException e )
- {
+ } catch (ArtifactResolutionException e) {
// should never happen
- fail( "This should NEVER happen. It's a mock!" );
- }
- catch ( ArtifactNotFoundException e )
- {
+ fail("This should NEVER happen. It's a mock!");
+ } catch (ArtifactNotFoundException e) {
// should never happen
- fail( "This should NEVER happen. It's a mock!" );
+ fail("This should NEVER happen. It's a mock!");
}
- replay( factory, resolver, localRepository, artifact );
+ replay(factory, resolver, localRepository, artifact);
- LocatorStrategy strategy = new ArtifactLocatorStrategy( factory, resolver, localRepository,
- Collections.EMPTY_LIST );
+ LocatorStrategy strategy =
+ new ArtifactLocatorStrategy(factory, resolver, localRepository, Collections.EMPTY_LIST);
MessageHolder mh = new DefaultMessageHolder();
- Location location = strategy.resolve( "group:artifact:version", mh );
+ Location location = strategy.resolve("group:artifact:version", mh);
- assertNull( location );
- assertEquals( 1, mh.size() );
+ assertNull(location);
+ assertEquals(1, mh.size());
- assertTrue( mh.render().indexOf( "<some-artifact-id>" ) > -1 );
- assertTrue( mh.render().indexOf( "resolution failed" ) > -1 );
+ assertTrue(mh.render().indexOf("<some-artifact-id>") > -1);
+ assertTrue(mh.render().indexOf("resolution failed") > -1);
- verify( factory, resolver, localRepository, artifact );
+ verify(factory, resolver, localRepository, artifact);
}
-
}
diff --git a/src/test/java/org/apache/maven/shared/io/location/ClasspathResourceLocatorStrategyTest.java b/src/test/java/org/apache/maven/shared/io/location/ClasspathResourceLocatorStrategyTest.java
index e4cd734..e6d26a3 100644
--- a/src/test/java/org/apache/maven/shared/io/location/ClasspathResourceLocatorStrategyTest.java
+++ b/src/test/java/org/apache/maven/shared/io/location/ClasspathResourceLocatorStrategyTest.java
@@ -1,5 +1,3 @@
-package org.apache.maven.shared.io.location;
-
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
@@ -18,42 +16,35 @@
* specific language governing permissions and limitations
* under the License.
*/
+package org.apache.maven.shared.io.location;
+import junit.framework.TestCase;
import org.apache.maven.shared.io.logging.DefaultMessageHolder;
import org.apache.maven.shared.io.logging.MessageHolder;
-import junit.framework.TestCase;
+public class ClasspathResourceLocatorStrategyTest extends TestCase {
-public class ClasspathResourceLocatorStrategyTest
- extends TestCase
-{
-
- public void testShouldConstructWithNoParams()
- {
+ public void testShouldConstructWithNoParams() {
new ClasspathResourceLocatorStrategy();
}
- public void testShouldConstructWithTempFileOptions()
- {
- new ClasspathResourceLocatorStrategy( "prefix.", ".suffix", true );
+ public void testShouldConstructWithTempFileOptions() {
+ new ClasspathResourceLocatorStrategy("prefix.", ".suffix", true);
}
- public void testShouldFailToResolveMissingClasspathResource()
- {
+ public void testShouldFailToResolveMissingClasspathResource() {
MessageHolder mh = new DefaultMessageHolder();
- Location location = new ClasspathResourceLocatorStrategy().resolve( "/some/missing/path", mh );
+ Location location = new ClasspathResourceLocatorStrategy().resolve("/some/missing/path", mh);
- assertNull( location );
- assertEquals( 1, mh.size() );
+ assertNull(location);
+ assertEquals(1, mh.size());
}
- public void testShouldResolveExistingClasspathResourceWithoutPrecedingSlash()
- {
+ public void testShouldResolveExistingClasspathResourceWithoutPrecedingSlash() {
MessageHolder mh = new DefaultMessageHolder();
- Location location = new ClasspathResourceLocatorStrategy().resolve( "META-INF/maven/test.properties", mh );
+ Location location = new ClasspathResourceLocatorStrategy().resolve("META-INF/maven/test.properties", mh);
- assertNotNull( location );
- assertEquals( 0, mh.size() );
+ assertNotNull(location);
+ assertEquals(0, mh.size());
}
-
}
diff --git a/src/test/java/org/apache/maven/shared/io/location/FileLocationTest.java b/src/test/java/org/apache/maven/shared/io/location/FileLocationTest.java
index 351c794..b211dbf 100644
--- a/src/test/java/org/apache/maven/shared/io/location/FileLocationTest.java
+++ b/src/test/java/org/apache/maven/shared/io/location/FileLocationTest.java
@@ -1,7 +1,3 @@
-package org.apache.maven.shared.io.location;
-
-import org.apache.commons.io.FileUtils;
-
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
@@ -20,6 +16,7 @@
* specific language governing permissions and limitations
* under the License.
*/
+package org.apache.maven.shared.io.location;
import java.io.ByteArrayOutputStream;
import java.io.File;
@@ -27,154 +24,139 @@
import java.io.InputStream;
import java.nio.ByteBuffer;
import java.nio.file.Files;
+
import junit.framework.TestCase;
+import org.apache.commons.io.FileUtils;
import org.apache.commons.io.IOUtils;
-public class FileLocationTest
- extends TestCase
-{
+public class FileLocationTest extends TestCase {
- public void testShouldConstructWithFileThenRetrieveSameFile() throws IOException
- {
- File file = Files.createTempFile( "test.", ".file-location" ).toFile();
+ public void testShouldConstructWithFileThenRetrieveSameFile() throws IOException {
+ File file = Files.createTempFile("test.", ".file-location").toFile();
file.deleteOnExit();
- FileLocation location = new FileLocation( file, file.getAbsolutePath() );
+ FileLocation location = new FileLocation(file, file.getAbsolutePath());
- assertSame( file, location.getFile() );
- assertEquals( file.getAbsolutePath(), location.getSpecification() );
+ assertSame(file, location.getFile());
+ assertEquals(file.getAbsolutePath(), location.getSpecification());
}
- public void testShouldReadFileContentsUsingByteBuffer() throws IOException
- {
- File file = Files.createTempFile( "test.", ".file-location" ).toFile();
+ public void testShouldReadFileContentsUsingByteBuffer() throws IOException {
+ File file = Files.createTempFile("test.", ".file-location").toFile();
file.deleteOnExit();
String testStr = "This is a test";
FileUtils.writeStringToFile(file, testStr, "US-ASCII");
- FileLocation location = new FileLocation( file, file.getAbsolutePath() );
+ FileLocation location = new FileLocation(file, file.getAbsolutePath());
location.open();
- ByteBuffer buffer = ByteBuffer.allocate( testStr.length() );
- location.read( buffer );
+ ByteBuffer buffer = ByteBuffer.allocate(testStr.length());
+ location.read(buffer);
- assertEquals( testStr, new String( buffer.array(), "US-ASCII" ) );
+ assertEquals(testStr, new String(buffer.array(), "US-ASCII"));
}
- public void testShouldReadFileContentsUsingStream() throws IOException
- {
- File file = Files.createTempFile( "test.", ".file-location" ).toFile();
+ public void testShouldReadFileContentsUsingStream() throws IOException {
+ File file = Files.createTempFile("test.", ".file-location").toFile();
file.deleteOnExit();
String testStr = "This is a test";
FileUtils.writeStringToFile(file, testStr, "US-ASCII");
- FileLocation location = new FileLocation( file, file.getAbsolutePath() );
+ FileLocation location = new FileLocation(file, file.getAbsolutePath());
location.open();
- try ( InputStream stream = location.getInputStream() ) {
+ try (InputStream stream = location.getInputStream()) {
ByteArrayOutputStream out = new ByteArrayOutputStream();
- IOUtils.copy( stream, out );
-
- assertEquals( testStr, new String(out.toByteArray(), "US-ASCII" ) );
+ IOUtils.copy(stream, out);
+
+ assertEquals(testStr, new String(out.toByteArray(), "US-ASCII"));
}
}
- public void testShouldReadFileContentsUsingByteArray() throws IOException
- {
- File file = Files.createTempFile( "test.", ".file-location" ).toFile();
+ public void testShouldReadFileContentsUsingByteArray() throws IOException {
+ File file = Files.createTempFile("test.", ".file-location").toFile();
file.deleteOnExit();
String testStr = "This is a test";
FileUtils.writeStringToFile(file, testStr, "US-ASCII");
- FileLocation location = new FileLocation( file, file.getAbsolutePath() );
+ FileLocation location = new FileLocation(file, file.getAbsolutePath());
location.open();
- byte[] buffer = new byte[ testStr.length() ];
- location.read( buffer );
+ byte[] buffer = new byte[testStr.length()];
+ location.read(buffer);
- assertEquals( testStr, new String( buffer, "US-ASCII" ) );
+ assertEquals(testStr, new String(buffer, "US-ASCII"));
}
- public void testShouldReadThenClose() throws IOException
- {
- File file = Files.createTempFile( "test.", ".file-location" ).toFile();
+ public void testShouldReadThenClose() throws IOException {
+ File file = Files.createTempFile("test.", ".file-location").toFile();
file.deleteOnExit();
String testStr = "This is a test";
FileUtils.writeStringToFile(file, testStr, "US-ASCII");
- FileLocation location = new FileLocation( file, file.getAbsolutePath() );
+ FileLocation location = new FileLocation(file, file.getAbsolutePath());
location.open();
- byte[] buffer = new byte[ testStr.length() ];
- location.read( buffer );
+ byte[] buffer = new byte[testStr.length()];
+ location.read(buffer);
- assertEquals( testStr, new String( buffer, "US-ASCII" ) );
+ assertEquals(testStr, new String(buffer, "US-ASCII"));
location.close();
}
- public void testShouldOpenThenFailToSetFile() throws IOException
- {
- File file = Files.createTempFile( "test.", ".file-location" ).toFile();
+ public void testShouldOpenThenFailToSetFile() throws IOException {
+ File file = Files.createTempFile("test.", ".file-location").toFile();
file.deleteOnExit();
- TestFileLocation location = new TestFileLocation( file.getAbsolutePath() );
+ TestFileLocation location = new TestFileLocation(file.getAbsolutePath());
location.open();
- try
- {
- location.setFile( file );
+ try {
+ location.setFile(file);
- fail( "should not succeed." );
- }
- catch( IllegalStateException e )
- {
+ fail("should not succeed.");
+ } catch (IllegalStateException e) {
}
}
- public void testShouldConstructWithoutFileThenSetFileThenOpen() throws IOException
- {
- File file = Files.createTempFile( "test.", ".file-location" ).toFile();
+ public void testShouldConstructWithoutFileThenSetFileThenOpen() throws IOException {
+ File file = Files.createTempFile("test.", ".file-location").toFile();
file.deleteOnExit();
- TestFileLocation location = new TestFileLocation( file.getAbsolutePath() );
+ TestFileLocation location = new TestFileLocation(file.getAbsolutePath());
- location.setFile( file );
+ location.setFile(file);
location.open();
}
- public void testShouldConstructWithLocationThenRetrieveEquivalentFile() throws IOException
- {
- File file = Files.createTempFile( "test.", ".file-location" ).toFile();
+ public void testShouldConstructWithLocationThenRetrieveEquivalentFile() throws IOException {
+ File file = Files.createTempFile("test.", ".file-location").toFile();
file.deleteOnExit();
- Location location = new TestFileLocation( file.getAbsolutePath() );
+ Location location = new TestFileLocation(file.getAbsolutePath());
- assertEquals( file, location.getFile() );
- assertEquals( file.getAbsolutePath(), location.getSpecification() );
+ assertEquals(file, location.getFile());
+ assertEquals(file.getAbsolutePath(), location.getSpecification());
}
- private static final class TestFileLocation extends FileLocation
- {
+ private static final class TestFileLocation extends FileLocation {
- TestFileLocation( String specification )
- {
- super( specification );
+ TestFileLocation(String specification) {
+ super(specification);
}
-
}
-
}
diff --git a/src/test/java/org/apache/maven/shared/io/location/FileLocatorStrategyTest.java b/src/test/java/org/apache/maven/shared/io/location/FileLocatorStrategyTest.java
index 0a8fc6e..83d2b95 100644
--- a/src/test/java/org/apache/maven/shared/io/location/FileLocatorStrategyTest.java
+++ b/src/test/java/org/apache/maven/shared/io/location/FileLocatorStrategyTest.java
@@ -1,5 +1,3 @@
-package org.apache.maven.shared.io.location;
-
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
@@ -18,54 +16,49 @@
* specific language governing permissions and limitations
* under the License.
*/
+package org.apache.maven.shared.io.location;
import java.io.File;
import java.io.IOException;
import java.nio.file.Files;
+import junit.framework.TestCase;
import org.apache.maven.shared.io.logging.DefaultMessageHolder;
import org.apache.maven.shared.io.logging.MessageHolder;
-import junit.framework.TestCase;
+public class FileLocatorStrategyTest extends TestCase {
-public class FileLocatorStrategyTest
- extends TestCase
-{
-
- public void testShouldResolveExistingTempFileLocation() throws IOException
- {
- File f = Files.createTempFile( "file-locator.", ".test" ).toFile();
+ public void testShouldResolveExistingTempFileLocation() throws IOException {
+ File f = Files.createTempFile("file-locator.", ".test").toFile();
f.deleteOnExit();
FileLocatorStrategy fls = new FileLocatorStrategy();
MessageHolder mh = new DefaultMessageHolder();
- Location location = fls.resolve( f.getAbsolutePath(), mh );
+ Location location = fls.resolve(f.getAbsolutePath(), mh);
- assertNotNull( location );
+ assertNotNull(location);
- assertTrue( mh.isEmpty() );
+ assertTrue(mh.isEmpty());
- assertEquals( f, location.getFile() );
+ assertEquals(f, location.getFile());
}
- public void testShouldFailToResolveNonExistentFileLocation() throws IOException
- {
- File f = Files.createTempFile( "file-locator.", ".test" ).toFile();
+ public void testShouldFailToResolveNonExistentFileLocation() throws IOException {
+ File f = Files.createTempFile("file-locator.", ".test").toFile();
f.delete();
FileLocatorStrategy fls = new FileLocatorStrategy();
MessageHolder mh = new DefaultMessageHolder();
- Location location = fls.resolve( f.getAbsolutePath(), mh );
+ Location location = fls.resolve(f.getAbsolutePath(), mh);
- assertNull( location );
+ assertNull(location);
- System.out.println( mh.render() );
+ System.out.println(mh.render());
- assertEquals( 1, mh.size() );
+ assertEquals(1, mh.size());
}
-
}
diff --git a/src/test/java/org/apache/maven/shared/io/location/LocatorTest.java b/src/test/java/org/apache/maven/shared/io/location/LocatorTest.java
index ab976ec..f7bd3ca 100644
--- a/src/test/java/org/apache/maven/shared/io/location/LocatorTest.java
+++ b/src/test/java/org/apache/maven/shared/io/location/LocatorTest.java
@@ -1,5 +1,3 @@
-package org.apache.maven.shared.io.location;
-
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
@@ -18,121 +16,108 @@
* specific language governing permissions and limitations
* under the License.
*/
+package org.apache.maven.shared.io.location;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
+import junit.framework.TestCase;
import org.apache.maven.shared.io.logging.DefaultMessageHolder;
import org.apache.maven.shared.io.logging.MessageHolder;
-import junit.framework.TestCase;
-
import static org.easymock.EasyMock.*;
-public class LocatorTest
- extends TestCase
-{
+public class LocatorTest extends TestCase {
- public void testShouldConstructWithNoParams()
- {
+ public void testShouldConstructWithNoParams() {
new Locator();
}
- public void testShouldConstructWithStrategyStackAndMessageHolder()
- {
- new Locator( Collections.<LocatorStrategy>emptyList(), new DefaultMessageHolder() );
+ public void testShouldConstructWithStrategyStackAndMessageHolder() {
+ new Locator(Collections.<LocatorStrategy>emptyList(), new DefaultMessageHolder());
}
- public void testShouldAllowModificationOfStrategiesAfterConstructionWithUnmodifiableStack()
- {
- Locator locator = new Locator( Collections.unmodifiableList( Collections.<LocatorStrategy>emptyList() ),
- new DefaultMessageHolder() );
+ public void testShouldAllowModificationOfStrategiesAfterConstructionWithUnmodifiableStack() {
+ Locator locator = new Locator(
+ Collections.unmodifiableList(Collections.<LocatorStrategy>emptyList()), new DefaultMessageHolder());
- locator.addStrategy( new FileLocatorStrategy() );
+ locator.addStrategy(new FileLocatorStrategy());
- assertEquals( 1, locator.getStrategies().size() );
+ assertEquals(1, locator.getStrategies().size());
}
- public void testShouldRetrieveNonNullMessageHolderWhenConstructedWithoutParams()
- {
- assertNotNull( new Locator().getMessageHolder() );
+ public void testShouldRetrieveNonNullMessageHolderWhenConstructedWithoutParams() {
+ assertNotNull(new Locator().getMessageHolder());
}
- public void testSetStrategiesShouldClearAnyPreExistingStrategiesOut()
- {
- LocatorStrategy originalStrategy = createMock( LocatorStrategy.class );
- LocatorStrategy replacementStrategy = createMock( LocatorStrategy.class );
+ public void testSetStrategiesShouldClearAnyPreExistingStrategiesOut() {
+ LocatorStrategy originalStrategy = createMock(LocatorStrategy.class);
+ LocatorStrategy replacementStrategy = createMock(LocatorStrategy.class);
- replay( originalStrategy, replacementStrategy );
+ replay(originalStrategy, replacementStrategy);
Locator locator = new Locator();
- locator.addStrategy( originalStrategy );
+ locator.addStrategy(originalStrategy);
- locator.setStrategies( Collections.singletonList( replacementStrategy ) );
+ locator.setStrategies(Collections.singletonList(replacementStrategy));
List<LocatorStrategy> strategies = locator.getStrategies();
- assertFalse( strategies.contains( originalStrategy ) );
- assertTrue( strategies.contains( replacementStrategy ) );
+ assertFalse(strategies.contains(originalStrategy));
+ assertTrue(strategies.contains(replacementStrategy));
- verify( originalStrategy, replacementStrategy );
+ verify(originalStrategy, replacementStrategy);
}
- public void testShouldRemovePreviouslyAddedStrategy()
- {
- LocatorStrategy originalStrategy = createMock( LocatorStrategy.class );
+ public void testShouldRemovePreviouslyAddedStrategy() {
+ LocatorStrategy originalStrategy = createMock(LocatorStrategy.class);
- replay( originalStrategy );
+ replay(originalStrategy);
Locator locator = new Locator();
- locator.addStrategy( originalStrategy );
+ locator.addStrategy(originalStrategy);
List<LocatorStrategy> strategies = locator.getStrategies();
- assertTrue( strategies.contains( originalStrategy ) );
+ assertTrue(strategies.contains(originalStrategy));
- locator.removeStrategy( originalStrategy );
+ locator.removeStrategy(originalStrategy);
strategies = locator.getStrategies();
- assertFalse( strategies.contains( originalStrategy ) );
+ assertFalse(strategies.contains(originalStrategy));
- verify( originalStrategy );
+ verify(originalStrategy);
}
- public void testResolutionFallsThroughStrategyStackAndReturnsNullIfNotResolved()
- {
+ public void testResolutionFallsThroughStrategyStackAndReturnsNullIfNotResolved() {
List<LocatorStrategy> strategies = new ArrayList<LocatorStrategy>();
- strategies.add( new LoggingLocatorStrategy() );
- strategies.add( new LoggingLocatorStrategy() );
- strategies.add( new LoggingLocatorStrategy() );
+ strategies.add(new LoggingLocatorStrategy());
+ strategies.add(new LoggingLocatorStrategy());
+ strategies.add(new LoggingLocatorStrategy());
MessageHolder mh = new DefaultMessageHolder();
- Locator locator = new Locator( strategies, mh );
+ Locator locator = new Locator(strategies, mh);
- Location location = locator.resolve( "some-specification" );
+ Location location = locator.resolve("some-specification");
- assertNull( location );
+ assertNull(location);
- assertEquals( 3, mh.size() );
+ assertEquals(3, mh.size());
}
- public static final class LoggingLocatorStrategy implements LocatorStrategy
- {
+ public static final class LoggingLocatorStrategy implements LocatorStrategy {
static int instanceCounter = 0;
int counter = instanceCounter++;
- public Location resolve( String locationSpecification, MessageHolder messageHolder )
- {
- messageHolder.addMessage( "resolve hit on strategy-" + (counter) );
+ public Location resolve(String locationSpecification, MessageHolder messageHolder) {
+ messageHolder.addMessage("resolve hit on strategy-" + (counter));
return null;
}
-
}
-
}
diff --git a/src/test/java/org/apache/maven/shared/io/location/URLLocationTest.java b/src/test/java/org/apache/maven/shared/io/location/URLLocationTest.java
index dc8bf87..9575eb6 100644
--- a/src/test/java/org/apache/maven/shared/io/location/URLLocationTest.java
+++ b/src/test/java/org/apache/maven/shared/io/location/URLLocationTest.java
@@ -1,5 +1,3 @@
-package org.apache.maven.shared.io.location;
-
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
@@ -18,46 +16,41 @@
* specific language governing permissions and limitations
* under the License.
*/
+package org.apache.maven.shared.io.location;
import java.io.File;
import java.io.IOException;
import java.net.URL;
import java.nio.file.Files;
+import junit.framework.TestCase;
import org.apache.commons.io.FileUtils;
-import junit.framework.TestCase;
+public class URLLocationTest extends TestCase {
-public class URLLocationTest
- extends TestCase
-{
-
- public void testShouldConstructFromUrlAndTempFileSpecifications() throws IOException
- {
- File f = Files.createTempFile( "url-location.", ".test" ).toFile();
+ public void testShouldConstructFromUrlAndTempFileSpecifications() throws IOException {
+ File f = Files.createTempFile("url-location.", ".test").toFile();
f.deleteOnExit();
URL url = f.toURL();
- new URLLocation( url, f.getAbsolutePath(), "prefix.", ".suffix", true );
+ new URLLocation(url, f.getAbsolutePath(), "prefix.", ".suffix", true);
}
- public void testShouldTransferFromTempFile() throws IOException
- {
- File f = Files.createTempFile( "url-location.", ".test" ).toFile();
+ public void testShouldTransferFromTempFile() throws IOException {
+ File f = Files.createTempFile("url-location.", ".test").toFile();
f.deleteOnExit();
URL url = f.toURL();
- URLLocation location = new URLLocation( url, f.getAbsolutePath(), "prefix.", ".suffix", true );
+ URLLocation location = new URLLocation(url, f.getAbsolutePath(), "prefix.", ".suffix", true);
- assertNotNull( location.getFile() );
- assertFalse( f.equals( location.getFile() ) );
+ assertNotNull(location.getFile());
+ assertFalse(f.equals(location.getFile()));
}
- public void testShouldTransferFromTempFileThenRead() throws IOException
- {
- File f = Files.createTempFile( "url-location.", ".test" ).toFile();
+ public void testShouldTransferFromTempFileThenRead() throws IOException {
+ File f = Files.createTempFile("url-location.", ".test").toFile();
f.deleteOnExit();
String testStr = "This is a test";
@@ -66,17 +59,16 @@
URL url = f.toURL();
- URLLocation location = new URLLocation( url, f.getAbsolutePath(), "prefix.", ".suffix", true );
+ URLLocation location = new URLLocation(url, f.getAbsolutePath(), "prefix.", ".suffix", true);
location.open();
- byte[] buffer = new byte[ testStr.length() ];
+ byte[] buffer = new byte[testStr.length()];
- int read = location.read( buffer );
+ int read = location.read(buffer);
- assertEquals( testStr.length(), read );
+ assertEquals(testStr.length(), read);
- assertEquals( testStr, new String( buffer, "US-ASCII" ) );
+ assertEquals(testStr, new String(buffer, "US-ASCII"));
}
-
}
diff --git a/src/test/java/org/apache/maven/shared/io/location/URLLocatorStrategyTest.java b/src/test/java/org/apache/maven/shared/io/location/URLLocatorStrategyTest.java
index 1567a93..8cb0c37 100644
--- a/src/test/java/org/apache/maven/shared/io/location/URLLocatorStrategyTest.java
+++ b/src/test/java/org/apache/maven/shared/io/location/URLLocatorStrategyTest.java
@@ -1,5 +1,3 @@
-package org.apache.maven.shared.io.location;
-
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
@@ -18,44 +16,38 @@
* specific language governing permissions and limitations
* under the License.
*/
+package org.apache.maven.shared.io.location;
import java.io.File;
import java.io.IOException;
import java.nio.file.Files;
import junit.framework.TestCase;
-
import org.apache.commons.io.FileUtils;
import org.apache.maven.shared.io.logging.DefaultMessageHolder;
import org.apache.maven.shared.io.logging.MessageHolder;
-public class URLLocatorStrategyTest
- extends TestCase
-{
+public class URLLocatorStrategyTest extends TestCase {
- public void testShouldConstructWithNoParams()
- {
+ public void testShouldConstructWithNoParams() {
new URLLocatorStrategy();
}
- public void testShouldConstructWithTempFileOptions()
- {
- new URLLocatorStrategy( "prefix.", ".suffix", true );
+ public void testShouldConstructWithTempFileOptions() {
+ new URLLocatorStrategy("prefix.", ".suffix", true);
}
- public void testShouldFailToResolveWithMalformedUrl()
- {
+ public void testShouldFailToResolveWithMalformedUrl() {
MessageHolder mh = new DefaultMessageHolder();
- Location location = new URLLocatorStrategy().resolve( "://www.google.com", mh );
+ Location location = new URLLocatorStrategy().resolve("://www.google.com", mh);
- assertNull( location );
- assertEquals( 1, mh.size() );
+ assertNull(location);
+ assertEquals(1, mh.size());
}
- public void testShouldResolveUrlForTempFile() throws IOException
- {
- File tempFile = Files.createTempFile( "prefix.", ".suffix" ).toFile();
+ public void testShouldResolveUrlForTempFile() throws IOException {
+ File tempFile = Files.createTempFile("prefix.", ".suffix").toFile();
tempFile.deleteOnExit();
String testStr = "This is a test.";
@@ -64,17 +56,16 @@
MessageHolder mh = new DefaultMessageHolder();
- Location location = new URLLocatorStrategy().resolve( tempFile.toURL().toExternalForm(), mh );
+ Location location = new URLLocatorStrategy().resolve(tempFile.toURL().toExternalForm(), mh);
- assertNotNull( location );
- assertEquals( 0, mh.size() );
+ assertNotNull(location);
+ assertEquals(0, mh.size());
location.open();
byte[] buffer = new byte[testStr.length()];
- location.read( buffer );
+ location.read(buffer);
- assertEquals( testStr, new String( buffer, "US-ASCII" ) );
+ assertEquals(testStr, new String(buffer, "US-ASCII"));
}
-
}
diff --git a/src/test/java/org/apache/maven/shared/io/logging/DefaultMessageHolderTest.java b/src/test/java/org/apache/maven/shared/io/logging/DefaultMessageHolderTest.java
index ea3b805..ea20898 100644
--- a/src/test/java/org/apache/maven/shared/io/logging/DefaultMessageHolderTest.java
+++ b/src/test/java/org/apache/maven/shared/io/logging/DefaultMessageHolderTest.java
@@ -1,5 +1,3 @@
-package org.apache.maven.shared.io.logging;
-
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
@@ -18,98 +16,93 @@
* specific language governing permissions and limitations
* under the License.
*/
+package org.apache.maven.shared.io.logging;
import java.io.PrintWriter;
import java.io.StringWriter;
import junit.framework.TestCase;
-public class DefaultMessageHolderTest
- extends TestCase
-{
+public class DefaultMessageHolderTest extends TestCase {
// MessageHolder newMessage();
// int size();
// String render();
- public void testNewMessageIncrementsSizeWhenEmpty()
- {
+ public void testNewMessageIncrementsSizeWhenEmpty() {
MessageHolder mh = new DefaultMessageHolder();
- assertEquals( 0, mh.size() );
+ assertEquals(0, mh.size());
MessageHolder test = mh.newMessage();
- assertSame( mh, test );
+ assertSame(mh, test);
- assertEquals( 1, mh.size() );
+ assertEquals(1, mh.size());
- assertEquals( "", mh.render() );
+ assertEquals("", mh.render());
}
// MessageHolder append( CharSequence messagePart );
// int size();
// String render();
- public void testAppendCreatesNewMessageIfNoneCurrent()
- {
+ public void testAppendCreatesNewMessageIfNoneCurrent() {
MessageHolder mh = new DefaultMessageHolder();
- assertEquals( 0, mh.size() );
+ assertEquals(0, mh.size());
- MessageHolder test = mh.append( "test" );
+ MessageHolder test = mh.append("test");
- assertSame( mh, test );
+ assertSame(mh, test);
- assertEquals( 1, mh.size() );
+ assertEquals(1, mh.size());
- assertEquals( "[1] [INFO] test", mh.render() );
+ assertEquals("[1] [INFO] test", mh.render());
}
// MessageHolder append( Throwable error );
// int size();
// String render();
- public void testAppendErrorCreatesNewMessageIfNoneCurrent()
- {
+ public void testAppendErrorCreatesNewMessageIfNoneCurrent() {
MessageHolder mh = new DefaultMessageHolder();
- assertEquals( 0, mh.size() );
+ assertEquals(0, mh.size());
NullPointerException npe = new NullPointerException();
- MessageHolder test = mh.append( npe );
+ MessageHolder test = mh.append(npe);
- assertSame( mh, test );
+ assertSame(mh, test);
- assertEquals( 1, mh.size() );
+ assertEquals(1, mh.size());
StringWriter sw = new StringWriter();
- PrintWriter pw = new PrintWriter( sw );
+ PrintWriter pw = new PrintWriter(sw);
- npe.printStackTrace( pw );
+ npe.printStackTrace(pw);
- assertEquals( "[1] [INFO] Error:\n" + sw.toString(), mh.render() );
+ assertEquals("[1] [INFO] Error:\n" + sw.toString(), mh.render());
}
// MessageHolder newMessage();
// MessageHolder append( CharSequence messagePart );
// int size();
// String render();
- public void testNewMessageThenAppendOnlyIncrementsSizeByOne()
- {
+ public void testNewMessageThenAppendOnlyIncrementsSizeByOne() {
MessageHolder mh = new DefaultMessageHolder();
- assertEquals( 0, mh.size() );
+ assertEquals(0, mh.size());
MessageHolder test = mh.newMessage();
- assertSame( mh, test );
+ assertSame(mh, test);
- test = mh.append( "test" );
+ test = mh.append("test");
- assertSame( mh, test );
+ assertSame(mh, test);
- assertEquals( 1, mh.size() );
+ assertEquals(1, mh.size());
- assertEquals( "[1] [INFO] test", mh.render() );
+ assertEquals("[1] [INFO] test", mh.render());
}
// MessageHolder newMessage();
@@ -117,27 +110,26 @@
// MessageHolder append( CharSequence messagePart );
// int size();
// String render();
- public void testNewMessageThenAppendTwiceOnlyIncrementsSizeByOne()
- {
+ public void testNewMessageThenAppendTwiceOnlyIncrementsSizeByOne() {
MessageHolder mh = new DefaultMessageHolder();
- assertEquals( 0, mh.size() );
+ assertEquals(0, mh.size());
MessageHolder test = mh.newMessage();
- assertSame( mh, test );
+ assertSame(mh, test);
- test = mh.append( "test" );
+ test = mh.append("test");
- assertSame( mh, test );
+ assertSame(mh, test);
- test = mh.append( " again" );
+ test = mh.append(" again");
- assertSame( mh, test );
+ assertSame(mh, test);
- assertEquals( 1, mh.size() );
+ assertEquals(1, mh.size());
- assertEquals( "[1] [INFO] test again", mh.render() );
+ assertEquals("[1] [INFO] test again", mh.render());
}
// MessageHolder newMessage();
@@ -145,160 +137,150 @@
// MessageHolder append( Throwable error );
// int size();
// String render();
- public void testNewMessageThenAppendBothMessageAndErrorOnlyIncrementsSizeByOne()
- {
+ public void testNewMessageThenAppendBothMessageAndErrorOnlyIncrementsSizeByOne() {
MessageHolder mh = new DefaultMessageHolder();
- assertEquals( 0, mh.size() );
+ assertEquals(0, mh.size());
MessageHolder test = mh.newMessage();
- assertSame( mh, test );
+ assertSame(mh, test);
- test = mh.append( "test" );
+ test = mh.append("test");
- assertSame( mh, test );
+ assertSame(mh, test);
NullPointerException npe = new NullPointerException();
- test = mh.append( npe );
+ test = mh.append(npe);
- assertSame( mh, test );
+ assertSame(mh, test);
- assertEquals( 1, mh.size() );
+ assertEquals(1, mh.size());
StringWriter sw = new StringWriter();
- PrintWriter pw = new PrintWriter( sw );
+ PrintWriter pw = new PrintWriter(sw);
- npe.printStackTrace( pw );
+ npe.printStackTrace(pw);
- assertEquals( "[1] [INFO] test\nError:\n" + sw.toString(), mh.render() );
+ assertEquals("[1] [INFO] test\nError:\n" + sw.toString(), mh.render());
}
// MessageHolder addMessage( CharSequence messagePart );
// int size();
// String render();
- public void testAddMessageIncrementsSizeByOne()
- {
+ public void testAddMessageIncrementsSizeByOne() {
MessageHolder mh = new DefaultMessageHolder();
- MessageHolder check = mh.addMessage( "test" );
+ MessageHolder check = mh.addMessage("test");
- assertSame( mh, check );
+ assertSame(mh, check);
- assertEquals( 1, mh.size() );
- assertEquals( "[1] [INFO] test", mh.render() );
+ assertEquals(1, mh.size());
+ assertEquals("[1] [INFO] test", mh.render());
}
// MessageHolder addMessage( CharSequence messagePart );
// int size();
// String render();
- public void testAddMessageTwiceIncrementsSizeByTwo()
- {
+ public void testAddMessageTwiceIncrementsSizeByTwo() {
MessageHolder mh = new DefaultMessageHolder();
- MessageHolder check = mh.addMessage( "test" );
+ MessageHolder check = mh.addMessage("test");
- assertSame( mh, check );
+ assertSame(mh, check);
- check = mh.addMessage( "test2" );
+ check = mh.addMessage("test2");
- assertSame( mh, check );
+ assertSame(mh, check);
- assertEquals( 2, mh.size() );
- assertEquals( "[1] [INFO] test\n\n[2] [INFO] test2", mh.render() );
+ assertEquals(2, mh.size());
+ assertEquals("[1] [INFO] test\n\n[2] [INFO] test2", mh.render());
}
// MessageHolder addMessage( CharSequence messagePart, Throwable error );
// int size();
// String render();
- public void testAddMessageWithErrorIncrementsSizeByOne()
- {
+ public void testAddMessageWithErrorIncrementsSizeByOne() {
MessageHolder mh = new DefaultMessageHolder();
NullPointerException npe = new NullPointerException();
- MessageHolder check = mh.addMessage( "test", npe );
+ MessageHolder check = mh.addMessage("test", npe);
- assertSame( mh, check );
+ assertSame(mh, check);
- assertEquals( 1, mh.size() );
+ assertEquals(1, mh.size());
StringWriter sw = new StringWriter();
- PrintWriter pw = new PrintWriter( sw );
+ PrintWriter pw = new PrintWriter(sw);
- npe.printStackTrace( pw );
+ npe.printStackTrace(pw);
- assertEquals( "[1] [INFO] test\nError:\n" + sw.toString(), mh.render() );
+ assertEquals("[1] [INFO] test\nError:\n" + sw.toString(), mh.render());
}
// MessageHolder addMessage( CharSequence messagePart, Throwable error );
// MessageHolder addMessage( CharSequence messagePart );
// int size();
// String render();
- public void testAddMessageWithErrorThenWithJustMessageIncrementsSizeByTwo()
- {
+ public void testAddMessageWithErrorThenWithJustMessageIncrementsSizeByTwo() {
MessageHolder mh = new DefaultMessageHolder();
NullPointerException npe = new NullPointerException();
- MessageHolder check = mh.addMessage( "test", npe );
+ MessageHolder check = mh.addMessage("test", npe);
- assertSame( mh, check );
+ assertSame(mh, check);
- check = mh.addMessage( "test2" );
+ check = mh.addMessage("test2");
- assertSame( mh, check );
+ assertSame(mh, check);
- assertEquals( 2, mh.size() );
+ assertEquals(2, mh.size());
StringWriter sw = new StringWriter();
- PrintWriter pw = new PrintWriter( sw );
+ PrintWriter pw = new PrintWriter(sw);
- npe.printStackTrace( pw );
+ npe.printStackTrace(pw);
- assertEquals( "[1] [INFO] test\nError:\n" + sw.toString() + "\n\n[2] [INFO] test2", mh.render() );
+ assertEquals("[1] [INFO] test\nError:\n" + sw.toString() + "\n\n[2] [INFO] test2", mh.render());
}
// MessageHolder addMessage( Throwable error );
// int size();
// String render();
- public void testAddMessageWithJustErrorIncrementsSizeByOne()
- {
+ public void testAddMessageWithJustErrorIncrementsSizeByOne() {
MessageHolder mh = new DefaultMessageHolder();
NullPointerException npe = new NullPointerException();
- MessageHolder check = mh.addMessage( npe );
+ MessageHolder check = mh.addMessage(npe);
- assertSame( mh, check );
+ assertSame(mh, check);
- assertEquals( 1, mh.size() );
+ assertEquals(1, mh.size());
StringWriter sw = new StringWriter();
- PrintWriter pw = new PrintWriter( sw );
+ PrintWriter pw = new PrintWriter(sw);
- npe.printStackTrace( pw );
+ npe.printStackTrace(pw);
- assertEquals( "[1] [INFO] Error:\n" + sw.toString(), mh.render() );
+ assertEquals("[1] [INFO] Error:\n" + sw.toString(), mh.render());
}
// boolean isEmpty();
- public void testIsEmptyAfterConstruction()
- {
- assertTrue( new DefaultMessageHolder().isEmpty() );
+ public void testIsEmptyAfterConstruction() {
+ assertTrue(new DefaultMessageHolder().isEmpty());
}
// boolean isEmpty();
- public void testIsNotEmptyAfterConstructionAndNewMessageCall()
- {
- assertFalse( new DefaultMessageHolder().newMessage().isEmpty() );
+ public void testIsNotEmptyAfterConstructionAndNewMessageCall() {
+ assertFalse(new DefaultMessageHolder().newMessage().isEmpty());
}
- public void testAppendCharSequence()
- {
+ public void testAppendCharSequence() {
MessageHolder mh = new DefaultMessageHolder();
- mh.newMessage().append( new StringBuffer( "This is a test" ) );
+ mh.newMessage().append(new StringBuffer("This is a test"));
- assertTrue( mh.render().indexOf( "This is a test" ) > -1 );
+ assertTrue(mh.render().indexOf("This is a test") > -1);
}
-
}
diff --git a/src/test/java/org/apache/maven/shared/io/scan/SimpleResourceInclusionScannerTest.java b/src/test/java/org/apache/maven/shared/io/scan/SimpleResourceInclusionScannerTest.java
index e7b27d2..6e4ea99 100644
--- a/src/test/java/org/apache/maven/shared/io/scan/SimpleResourceInclusionScannerTest.java
+++ b/src/test/java/org/apache/maven/shared/io/scan/SimpleResourceInclusionScannerTest.java
@@ -1,5 +1,3 @@
-package org.apache.maven.shared.io.scan;
-
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
@@ -18,9 +16,7 @@
* specific language governing permissions and limitations
* under the License.
*/
-
-import org.apache.maven.shared.io.scan.mapping.SuffixMapping;
-import org.junit.Test;
+package org.apache.maven.shared.io.scan;
import java.io.File;
import java.io.IOException;
@@ -28,6 +24,9 @@
import java.util.HashSet;
import java.util.Set;
+import org.apache.maven.shared.io.scan.mapping.SuffixMapping;
+import org.junit.Test;
+
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;
@@ -37,24 +36,24 @@
public class SimpleResourceInclusionScannerTest {
@Test
- public void testGetIncludedSources() throws IOException, InclusionScanException
- {
- File baseDir = new File("target" );
+ public void testGetIncludedSources() throws IOException, InclusionScanException {
+ File baseDir = new File("target");
baseDir.deleteOnExit();
baseDir.mkdirs();
- File f = Files.createTempFile( baseDir.toPath(), "source1.", ".test" ).toFile();
+ File f = Files.createTempFile(baseDir.toPath(), "source1.", ".test").toFile();
Set<String> sourceIncludes = new HashSet<>();
- sourceIncludes.add( "**/*" + f.getName() );
+ sourceIncludes.add("**/*" + f.getName());
Set<String> sourceExcludes = new HashSet<>();
- SimpleResourceInclusionScanner simpleResourceInclusionScanner = new SimpleResourceInclusionScanner( sourceIncludes, sourceExcludes );
+ SimpleResourceInclusionScanner simpleResourceInclusionScanner =
+ new SimpleResourceInclusionScanner(sourceIncludes, sourceExcludes);
Set<String> targets = new HashSet<>();
- targets.add( ".class" );
- simpleResourceInclusionScanner.addSourceMapping(new SuffixMapping( ".java", targets ));
- Set results = simpleResourceInclusionScanner.getIncludedSources( baseDir, baseDir );
- assertTrue( results.size() > 0 );
+ targets.add(".class");
+ simpleResourceInclusionScanner.addSourceMapping(new SuffixMapping(".java", targets));
+ Set results = simpleResourceInclusionScanner.getIncludedSources(baseDir, baseDir);
+ assertTrue(results.size() > 0);
Object file = results.iterator().next();
- assertTrue( file instanceof File );
- assertEquals( f.getName(), ( (File) file ).getName() );
+ assertTrue(file instanceof File);
+ assertEquals(f.getName(), ((File) file).getName());
}
}
diff --git a/src/test/java/org/apache/maven/shared/io/scan/mapping/SuffixMappingTest.java b/src/test/java/org/apache/maven/shared/io/scan/mapping/SuffixMappingTest.java
index 8eb2315..eeb3d7c 100644
--- a/src/test/java/org/apache/maven/shared/io/scan/mapping/SuffixMappingTest.java
+++ b/src/test/java/org/apache/maven/shared/io/scan/mapping/SuffixMappingTest.java
@@ -1,5 +1,3 @@
-package org.apache.maven.shared.io.scan.mapping;
-
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
@@ -18,9 +16,7 @@
* specific language governing permissions and limitations
* under the License.
*/
-
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertTrue;
+package org.apache.maven.shared.io.scan.mapping;
import java.io.File;
import java.util.HashSet;
@@ -29,101 +25,96 @@
import org.apache.maven.shared.io.scan.InclusionScanException;
import org.junit.Test;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertTrue;
+
/**
* @author jdcasey
*/
-public class SuffixMappingTest
-{
+public class SuffixMappingTest {
@Test
- public void testShouldReturnSingleClassFileForSingleJavaFile()
- throws InclusionScanException
- {
+ public void testShouldReturnSingleClassFileForSingleJavaFile() throws InclusionScanException {
String base = "path/to/file";
- File basedir = new File( "." );
+ File basedir = new File(".");
- SuffixMapping mapping = new SuffixMapping( ".java", ".class" );
+ SuffixMapping mapping = new SuffixMapping(".java", ".class");
- Set<File> results = mapping.getTargetFiles( basedir, base + ".java" );
+ Set<File> results = mapping.getTargetFiles(basedir, base + ".java");
- assertEquals( "Returned wrong number of target files.", 1, results.size() );
+ assertEquals("Returned wrong number of target files.", 1, results.size());
- assertEquals( "Target file is wrong.", new File( basedir, base + ".class" ), results.iterator().next() );
+ assertEquals(
+ "Target file is wrong.",
+ new File(basedir, base + ".class"),
+ results.iterator().next());
}
@Test
- public void testShouldNotReturnClassFileWhenSourceFileHasWrongSuffix()
- throws InclusionScanException
- {
+ public void testShouldNotReturnClassFileWhenSourceFileHasWrongSuffix() throws InclusionScanException {
String base = "path/to/file";
- File basedir = new File( "." );
+ File basedir = new File(".");
- SuffixMapping mapping = new SuffixMapping( ".java", ".class" );
+ SuffixMapping mapping = new SuffixMapping(".java", ".class");
- Set<File> results = mapping.getTargetFiles( basedir, base + ".xml" );
+ Set<File> results = mapping.getTargetFiles(basedir, base + ".xml");
- assertTrue( "Returned wrong number of target files.", results.isEmpty() );
+ assertTrue("Returned wrong number of target files.", results.isEmpty());
}
@Test
- public void testShouldReturnOneClassFileAndOneXmlFileForSingleJavaFile()
- throws InclusionScanException
- {
+ public void testShouldReturnOneClassFileAndOneXmlFileForSingleJavaFile() throws InclusionScanException {
String base = "path/to/file";
- File basedir = new File( "." );
+ File basedir = new File(".");
Set<String> targets = new HashSet<String>();
- targets.add( ".class" );
- targets.add( ".xml" );
+ targets.add(".class");
+ targets.add(".xml");
- SuffixMapping mapping = new SuffixMapping( ".java", targets );
+ SuffixMapping mapping = new SuffixMapping(".java", targets);
- Set<File> results = mapping.getTargetFiles( basedir, base + ".java" );
+ Set<File> results = mapping.getTargetFiles(basedir, base + ".java");
- assertEquals( "Returned wrong number of target files.", 2, results.size() );
+ assertEquals("Returned wrong number of target files.", 2, results.size());
- assertTrue( "Targets do not contain class target.", results.contains( new File( basedir, base + ".class" ) ) );
+ assertTrue("Targets do not contain class target.", results.contains(new File(basedir, base + ".class")));
- assertTrue( "Targets do not contain class target.", results.contains( new File( basedir, base + ".xml" ) ) );
+ assertTrue("Targets do not contain class target.", results.contains(new File(basedir, base + ".xml")));
}
@Test
- public void testShouldReturnNoTargetFilesWhenSourceFileHasWrongSuffix()
- throws InclusionScanException
- {
+ public void testShouldReturnNoTargetFilesWhenSourceFileHasWrongSuffix() throws InclusionScanException {
String base = "path/to/file";
- File basedir = new File( "." );
+ File basedir = new File(".");
Set<String> targets = new HashSet<String>();
- targets.add( ".class" );
- targets.add( ".xml" );
+ targets.add(".class");
+ targets.add(".xml");
- SuffixMapping mapping = new SuffixMapping( ".java", targets );
+ SuffixMapping mapping = new SuffixMapping(".java", targets);
- Set<File> results = mapping.getTargetFiles( basedir, base + ".apt" );
+ Set<File> results = mapping.getTargetFiles(basedir, base + ".apt");
- assertTrue( "Returned wrong number of target files.", results.isEmpty() );
+ assertTrue("Returned wrong number of target files.", results.isEmpty());
}
@Test
- public void testSingleTargetMapper()
- throws InclusionScanException
- {
+ public void testSingleTargetMapper() throws InclusionScanException {
String base = "path/to/file";
- File basedir = new File( "target/" );
+ File basedir = new File("target/");
- SingleTargetMapping mapping = new SingleTargetMapping( ".cs", "/foo" );
+ SingleTargetMapping mapping = new SingleTargetMapping(".cs", "/foo");
- Set<File> results = mapping.getTargetFiles( basedir, base + ".apt" );
+ Set<File> results = mapping.getTargetFiles(basedir, base + ".apt");
- assertTrue( results.isEmpty() );
+ assertTrue(results.isEmpty());
- results = mapping.getTargetFiles( basedir, base + ".cs" );
+ results = mapping.getTargetFiles(basedir, base + ".cs");
- assertEquals( 1, results.size() );
+ assertEquals(1, results.size());
}
}