You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@maven.apache.org by ah...@apache.org on 2013/06/03 12:45:57 UTC

[16/50] git commit: added unit testst back after Eclipse Aether migration

added unit testst back after Eclipse Aether migration

Project: http://git-wip-us.apache.org/repos/asf/maven/repo
Commit: http://git-wip-us.apache.org/repos/asf/maven/commit/fa47f650
Tree: http://git-wip-us.apache.org/repos/asf/maven/tree/fa47f650
Diff: http://git-wip-us.apache.org/repos/asf/maven/diff/fa47f650

Branch: refs/heads/slf4j-log4j2
Commit: fa47f650cbfec7a07135cfc380a9cee0d2faa144
Parents: d7b31b3
Author: Hervé Boutemy <hb...@apache.org>
Authored: Wed Apr 10 01:42:32 2013 +0200
Committer: Hervé Boutemy <hb...@apache.org>
Committed: Wed Apr 10 01:42:32 2013 +0200

----------------------------------------------------------------------
 .../internal/AbstractRepositoryTestCase.java       |   85 ++++++
 .../internal/DefaultVersionResolverTest.java       |   96 +++++++
 .../repository/internal/RepositorySystemTest.java  |  220 +++++++++++++++
 .../internal/util/ConsoleRepositoryListener.java   |  132 +++++++++
 .../internal/util/ConsoleTransferListener.java     |  186 ++++++++++++
 5 files changed, 719 insertions(+), 0 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/maven/blob/fa47f650/maven-aether-provider/src/test/java/org/apache/maven/repository/internal/AbstractRepositoryTestCase.java
----------------------------------------------------------------------
diff --git a/maven-aether-provider/src/test/java/org/apache/maven/repository/internal/AbstractRepositoryTestCase.java b/maven-aether-provider/src/test/java/org/apache/maven/repository/internal/AbstractRepositoryTestCase.java
new file mode 100644
index 0000000..eea3830
--- /dev/null
+++ b/maven-aether-provider/src/test/java/org/apache/maven/repository/internal/AbstractRepositoryTestCase.java
@@ -0,0 +1,85 @@
+package org.apache.maven.repository.internal;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+import java.net.MalformedURLException;
+
+import org.apache.maven.repository.internal.util.ConsoleRepositoryListener;
+import org.apache.maven.repository.internal.util.ConsoleTransferListener;
+import org.codehaus.plexus.ContainerConfiguration;
+import org.codehaus.plexus.PlexusTestCase;
+import org.eclipse.aether.DefaultRepositorySystemSession;
+import org.eclipse.aether.RepositorySystem;
+import org.eclipse.aether.RepositorySystemSession;
+import org.eclipse.aether.repository.LocalRepository;
+import org.eclipse.aether.repository.RemoteRepository;
+
+public abstract class AbstractRepositoryTestCase
+    extends PlexusTestCase
+{
+    protected RepositorySystem system;
+
+    protected RepositorySystemSession session;
+
+    @Override
+    protected void customizeContainerConfiguration( ContainerConfiguration containerConfiguration )
+    {
+        super.customizeContainerConfiguration( containerConfiguration );
+        containerConfiguration.setAutoWiring( true );
+    }
+
+    @Override
+    protected void setUp()
+        throws Exception
+    {
+        super.setUp();
+        system = lookup( RepositorySystem.class );
+        session = newMavenRepositorySystemSession( system );
+    }
+
+    @Override
+    protected void tearDown()
+        throws Exception
+    {
+        session = null;
+        system = null;
+        super.tearDown();
+    }
+
+    public static RepositorySystemSession newMavenRepositorySystemSession( RepositorySystem system )
+    {
+        DefaultRepositorySystemSession session = MavenRepositorySystemUtils.newSession();
+
+        LocalRepository localRepo = new LocalRepository( "target/local-repo" );
+        session.setLocalRepositoryManager( system.newLocalRepositoryManager( session, localRepo ) );
+
+        session.setTransferListener( new ConsoleTransferListener() );
+        session.setRepositoryListener( new ConsoleRepositoryListener() );
+
+        return session;
+    }
+
+    public static RemoteRepository newTestRepository()
+        throws MalformedURLException
+    {
+        return new RemoteRepository.Builder( "repo", "default",
+                                             getTestFile( "target/test-classes/repo" ).toURI().toURL().toString() ).build();
+    }
+}

http://git-wip-us.apache.org/repos/asf/maven/blob/fa47f650/maven-aether-provider/src/test/java/org/apache/maven/repository/internal/DefaultVersionResolverTest.java
----------------------------------------------------------------------
diff --git a/maven-aether-provider/src/test/java/org/apache/maven/repository/internal/DefaultVersionResolverTest.java b/maven-aether-provider/src/test/java/org/apache/maven/repository/internal/DefaultVersionResolverTest.java
new file mode 100644
index 0000000..90dd6a4
--- /dev/null
+++ b/maven-aether-provider/src/test/java/org/apache/maven/repository/internal/DefaultVersionResolverTest.java
@@ -0,0 +1,96 @@
+package org.apache.maven.repository.internal;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+import org.eclipse.aether.artifact.Artifact;
+import org.eclipse.aether.impl.VersionResolver;
+import org.eclipse.aether.resolution.VersionRequest;
+import org.eclipse.aether.resolution.VersionResult;
+import org.eclipse.aether.artifact.DefaultArtifact;
+
+public class DefaultVersionResolverTest
+    extends AbstractRepositoryTestCase
+{
+    private DefaultVersionResolver versionResolver;
+
+    @Override
+    protected void setUp()
+        throws Exception
+    {
+        super.setUp();
+        // be sure we're testing the right class, i.e. DefaultVersionResolver.class
+        versionResolver = (DefaultVersionResolver) lookup( VersionResolver.class, "default" );
+    }
+
+    @Override
+    protected void tearDown()
+        throws Exception
+    {
+        versionResolver = null;
+        super.tearDown();
+    }
+
+    public void testResolveSeparateInstalledClassifiedNonUniqueVersionedArtifacts()
+        throws Exception
+    {
+        VersionRequest requestB = new VersionRequest();
+        requestB.addRepository( newTestRepository() );
+        Artifact artifactB =
+            new DefaultArtifact( "org.apache.maven.its", "dep-mng5324", "classifierB", "jar", "07.20.3-SNAPSHOT" );
+        requestB.setArtifact( artifactB );
+
+        VersionResult resultB = versionResolver.resolveVersion( session, requestB );
+        assertEquals( "07.20.3-20120809.112920-97", resultB.getVersion() );
+
+        VersionRequest requestA = new VersionRequest();
+        requestA.addRepository( newTestRepository() );
+
+        Artifact artifactA =
+            new DefaultArtifact( "org.apache.maven.its", "dep-mng5324", "classifierA", "jar", "07.20.3-SNAPSHOT" );
+        requestA.setArtifact( artifactA );
+
+        VersionResult resultA = versionResolver.resolveVersion( session, requestA );
+        assertEquals( "07.20.3-20120809.112124-88", resultA.getVersion() );
+    }
+
+    public void testResolveSeparateInstalledClassifiedNonVersionedArtifacts()
+        throws Exception
+    {
+        VersionRequest requestA = new VersionRequest();
+        requestA.addRepository( newTestRepository() );
+        String versionA = "07.20.3-20120809.112124-88";
+        Artifact artifactA =
+            new DefaultArtifact( "org.apache.maven.its", "dep-mng5324", "classifierA", "jar", versionA );
+        requestA.setArtifact( artifactA );
+
+        VersionResult resultA = versionResolver.resolveVersion( session, requestA );
+        assertEquals( versionA, resultA.getVersion() );
+
+        VersionRequest requestB = new VersionRequest();
+        requestB.addRepository( newTestRepository() );
+        String versionB = "07.20.3-20120809.112920-97";
+        Artifact artifactB =
+            new DefaultArtifact( "org.apache.maven.its", "dep-mng5324", "classifierB", "jar", versionB );
+        requestB.setArtifact( artifactB );
+
+        VersionResult resultB = versionResolver.resolveVersion( session, requestB );
+        assertEquals( versionB, resultB.getVersion() );
+    }
+}

http://git-wip-us.apache.org/repos/asf/maven/blob/fa47f650/maven-aether-provider/src/test/java/org/apache/maven/repository/internal/RepositorySystemTest.java
----------------------------------------------------------------------
diff --git a/maven-aether-provider/src/test/java/org/apache/maven/repository/internal/RepositorySystemTest.java b/maven-aether-provider/src/test/java/org/apache/maven/repository/internal/RepositorySystemTest.java
new file mode 100644
index 0000000..ffe1bc1
--- /dev/null
+++ b/maven-aether-provider/src/test/java/org/apache/maven/repository/internal/RepositorySystemTest.java
@@ -0,0 +1,220 @@
+package org.apache.maven.repository.internal;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+import java.util.Arrays;
+import java.util.List;
+
+import org.eclipse.aether.artifact.Artifact;
+import org.eclipse.aether.collection.CollectRequest;
+import org.eclipse.aether.collection.CollectResult;
+import org.eclipse.aether.graph.Dependency;
+import org.eclipse.aether.graph.DependencyNode;
+import org.eclipse.aether.resolution.ArtifactDescriptorRequest;
+import org.eclipse.aether.resolution.ArtifactDescriptorResult;
+import org.eclipse.aether.resolution.ArtifactRequest;
+import org.eclipse.aether.resolution.ArtifactResult;
+import org.eclipse.aether.artifact.DefaultArtifact;
+
+public class RepositorySystemTest
+    extends AbstractRepositoryTestCase
+{
+    public void testResolveVersionRange()
+        throws Exception
+    {
+        //VersionRangeResult resolveVersionRange( RepositorySystemSession session, VersionRangeRequest request )
+        //                throws VersionRangeResolutionException;
+
+    }
+
+    public void testResolveVersion()
+        throws Exception
+    {
+        //VersionResult resolveVersion( RepositorySystemSession session, VersionRequest request )
+        //                throws VersionResolutionException;
+    }
+
+    public void testReadArtifactDescriptor()
+        throws Exception
+    {
+        Artifact artifact = new DefaultArtifact( "ut.simple:artifact:extension:classifier:1.0" );
+
+        ArtifactDescriptorRequest request = new ArtifactDescriptorRequest();
+        request.setArtifact( artifact );
+        request.addRepository( newTestRepository() );
+        
+        ArtifactDescriptorResult result = system.readArtifactDescriptor( session, request );
+
+        List<Dependency> deps = result.getDependencies();
+        assertEquals( 2, deps.size() );
+        checkUtSimpleArtifactDependencies( deps.get( 0 ), deps.get( 1 ) );
+    }
+
+    /**
+     * check ut.simple:artifact:1.0 dependencies
+     */
+    private void checkUtSimpleArtifactDependencies( Dependency dep1, Dependency dep2 )
+    {
+        assertEquals( "compile", dep1.getScope() );
+        assertFalse( dep1.isOptional() );
+        assertEquals( 0, dep1.getExclusions().size() );
+        Artifact depArtifact = dep1.getArtifact();
+        assertEquals( "ut.simple", depArtifact.getGroupId() );
+        assertEquals( "dependency", depArtifact.getArtifactId() );
+        assertEquals( "1.0", depArtifact.getVersion() );
+        assertEquals( "1.0", depArtifact.getBaseVersion() );
+        assertNull( depArtifact.getFile() );
+        assertFalse( depArtifact.isSnapshot() );
+        assertEquals( "", depArtifact.getClassifier() );
+        assertEquals( "jar", depArtifact.getExtension() );
+        assertEquals( "java", depArtifact.getProperty( "language", null ) );
+        assertEquals( "jar", depArtifact.getProperty( "type", null ) );
+        assertEquals( "true", depArtifact.getProperty( "constitutesBuildPath", null ) );
+        assertEquals( "false", depArtifact.getProperty( "includesDependencies", null ) );
+        assertEquals( 4, depArtifact.getProperties().size() );
+
+        assertEquals( "compile", dep2.getScope() );
+        assertFalse( dep2.isOptional() );
+        assertEquals( 0, dep2.getExclusions().size() );
+        depArtifact = dep2.getArtifact();
+        assertEquals( "ut.simple", depArtifact.getGroupId() );
+        assertEquals( "dependency", depArtifact.getArtifactId() );
+        assertEquals( "1.0", depArtifact.getVersion() );
+        assertEquals( "1.0", depArtifact.getBaseVersion() );
+        assertNull( depArtifact.getFile() );
+        assertFalse( depArtifact.isSnapshot() );
+        assertEquals( "sources", depArtifact.getClassifier() );
+        assertEquals( "jar", depArtifact.getExtension() );
+        assertEquals( "java", depArtifact.getProperty( "language", null ) );
+        assertEquals( "jar", depArtifact.getProperty( "type", null ) ); // shouldn't it be java-sources given the classifier?
+        assertEquals( "true", depArtifact.getProperty( "constitutesBuildPath", null ) ); // shouldn't it be false given the classifier?
+        assertEquals( "false", depArtifact.getProperty( "includesDependencies", null ) );
+        assertEquals( 4, depArtifact.getProperties().size() );
+    }
+
+    public void testCollectDependencies()
+        throws Exception
+    {
+        Artifact artifact = new DefaultArtifact( "ut.simple:artifact:extension:classifier:1.0" );
+        // notice: extension and classifier not really used in this test...
+
+        CollectRequest collectRequest = new CollectRequest();
+        collectRequest.setRoot( new Dependency( artifact, null ) );
+        collectRequest.addRepository( newTestRepository() );
+
+        CollectResult collectResult = system.collectDependencies( session, collectRequest );
+
+        List<DependencyNode> nodes = collectResult.getRoot().getChildren();
+        assertEquals( 2, nodes.size() );
+        checkUtSimpleArtifactDependencies( nodes.get( 0 ).getDependency(), nodes.get( 1 ).getDependency() );
+    }
+
+    public void testResolveArtifact()
+        throws Exception
+    {
+        Artifact artifact = new DefaultArtifact( "ut.simple:artifact:1.0" );
+
+        ArtifactRequest artifactRequest = new ArtifactRequest();
+        artifactRequest.setArtifact( artifact );
+        artifactRequest.addRepository( newTestRepository() );
+
+        ArtifactResult artifactResult = system.resolveArtifact( session, artifactRequest );
+        checkArtifactResult( artifactResult, "artifact-1.0.jar" );
+
+        artifact = new DefaultArtifact( "ut.simple:artifact:zip:1.0" );
+        artifactRequest.setArtifact( artifact );
+        artifactResult = system.resolveArtifact( session, artifactRequest );
+        checkArtifactResult( artifactResult, "artifact-1.0.zip" );
+
+        artifact = new DefaultArtifact( "ut.simple:artifact:zip:classifier:1.0" );
+        artifactRequest.setArtifact( artifact );
+        artifactResult = system.resolveArtifact( session, artifactRequest );
+        checkArtifactResult( artifactResult, "artifact-1.0-classifier.zip" );
+    }
+
+    private void checkArtifactResult( ArtifactResult result, String filename )
+    {
+        assertFalse( result.isMissing() );
+        assertTrue( result.isResolved() );
+        Artifact artifact = result.getArtifact();
+        assertNotNull( artifact.getFile() );
+        assertEquals( filename, artifact.getFile().getName() );
+    }
+
+    public void testResolveArtifacts()
+        throws Exception
+    {
+        ArtifactRequest req1 = new ArtifactRequest();
+        req1.setArtifact( new DefaultArtifact( "ut.simple:artifact:1.0" ) );
+        req1.addRepository( newTestRepository() );
+
+        ArtifactRequest req2 = new ArtifactRequest();
+        req2.setArtifact( new DefaultArtifact( "ut.simple:artifact:zip:1.0" ) );
+        req2.addRepository( newTestRepository() );
+
+        ArtifactRequest req3 = new ArtifactRequest();
+        req3.setArtifact( new DefaultArtifact( "ut.simple:artifact:zip:classifier:1.0" ) );
+        req3.addRepository( newTestRepository() );
+
+        List<ArtifactRequest> requests = Arrays.asList( new ArtifactRequest[] { req1, req2, req3 } );
+
+        List<ArtifactResult> results = system.resolveArtifacts( session, requests );
+
+        assertEquals( 3, results.size() );
+        checkArtifactResult( results.get( 0 ), "artifact-1.0.jar" );
+        checkArtifactResult( results.get( 1 ), "artifact-1.0.zip" );
+        checkArtifactResult( results.get( 2 ), "artifact-1.0-classifier.zip" );
+    }
+
+    public void testResolveMetadata()
+        throws Exception
+    {
+        //List<MetadataResult> resolveMetadata( RepositorySystemSession session,
+        //                                      Collection<? extends MetadataRequest> requests );
+    }
+
+    public void testInstall()
+        throws Exception
+    {
+        //InstallResult install( RepositorySystemSession session, InstallRequest request )
+        //                throws InstallationException;
+        // release, snapshot unique ou non unique, attachement
+    }
+
+    public void testDeploy()
+        throws Exception
+    {
+        //DeployResult deploy( RepositorySystemSession session, DeployRequest request )
+        //                throws DeploymentException;
+    }
+
+    public void testNewLocalRepositoryManager()
+        throws Exception
+    {
+        //LocalRepositoryManager newLocalRepositoryManager( LocalRepository localRepository );
+    }
+
+    public void testNewSyncContext()
+        throws Exception
+    {
+        //SyncContext newSyncContext( RepositorySystemSession session, boolean shared );
+    }
+
+}

http://git-wip-us.apache.org/repos/asf/maven/blob/fa47f650/maven-aether-provider/src/test/java/org/apache/maven/repository/internal/util/ConsoleRepositoryListener.java
----------------------------------------------------------------------
diff --git a/maven-aether-provider/src/test/java/org/apache/maven/repository/internal/util/ConsoleRepositoryListener.java b/maven-aether-provider/src/test/java/org/apache/maven/repository/internal/util/ConsoleRepositoryListener.java
new file mode 100644
index 0000000..2879a9f
--- /dev/null
+++ b/maven-aether-provider/src/test/java/org/apache/maven/repository/internal/util/ConsoleRepositoryListener.java
@@ -0,0 +1,132 @@
+package org.apache.maven.repository.internal.util;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+import java.io.PrintStream;
+
+import org.eclipse.aether.AbstractRepositoryListener;
+import org.eclipse.aether.RepositoryEvent;
+
+public class ConsoleRepositoryListener
+    extends AbstractRepositoryListener
+{
+
+    private PrintStream out;
+
+    public ConsoleRepositoryListener()
+    {
+        this( null );
+    }
+
+    public ConsoleRepositoryListener( PrintStream out )
+    {
+        this.out = ( out != null ) ? out : System.out;
+    }
+
+    public void artifactDeployed( RepositoryEvent event )
+    {
+        println( "artifactDeployed", event.getArtifact() + " to " + event.getRepository() );
+    }
+
+    public void artifactDeploying( RepositoryEvent event )
+    {
+        println( "artifactDeploying", event.getArtifact() + " to " + event.getRepository() );
+    }
+
+    public void artifactDescriptorInvalid( RepositoryEvent event )
+    {
+        println( "artifactDescriptorInvalid", "for " + event.getArtifact() + ": " + event.getException().getMessage() );
+    }
+
+    public void artifactDescriptorMissing( RepositoryEvent event )
+    {
+        println( "artifactDescriptorMissing", "for " + event.getArtifact() );
+    }
+
+    public void artifactInstalled( RepositoryEvent event )
+    {
+        println( "artifactInstalled", event.getArtifact() + " to " + event.getFile() );
+    }
+
+    public void artifactInstalling( RepositoryEvent event )
+    {
+        println( "artifactInstalling", event.getArtifact() + " to " + event.getFile() );
+    }
+
+    public void artifactResolved( RepositoryEvent event )
+    {
+        println( "artifactResolved", event.getArtifact() + " from " + event.getRepository() );
+    }
+
+    public void artifactDownloading( RepositoryEvent event )
+    {
+        println( "artifactDownloading", event.getArtifact() + " from " + event.getRepository() );
+    }
+
+    public void artifactDownloaded( RepositoryEvent event )
+    {
+        println( "artifactDownloaded", event.getArtifact() + " from " + event.getRepository() );
+    }
+
+    public void artifactResolving( RepositoryEvent event )
+    {
+        println( "artifactResolving", event.getArtifact().toString() );
+    }
+
+    public void metadataDeployed( RepositoryEvent event )
+    {
+        println( "metadataDeployed", event.getMetadata() + " to " + event.getRepository() );
+    }
+
+    public void metadataDeploying( RepositoryEvent event )
+    {
+        println( "metadataDeploying", event.getMetadata() + " to " + event.getRepository() );
+    }
+
+    public void metadataInstalled( RepositoryEvent event )
+    {
+        println( "metadataInstalled", event.getMetadata() + " to " + event.getFile() );
+    }
+
+    public void metadataInstalling( RepositoryEvent event )
+    {
+        println( "metadataInstalling", event.getMetadata() + " to " + event.getFile() );
+    }
+
+    public void metadataInvalid( RepositoryEvent event )
+    {
+        println( "metadataInvalid", event.getMetadata().toString() );
+    }
+
+    public void metadataResolved( RepositoryEvent event )
+    {
+        println( "metadataResolved", event.getMetadata() + " from " + event.getRepository() );
+    }
+
+    public void metadataResolving( RepositoryEvent event )
+    {
+        println( "metadataResolving", event.getMetadata() + " from " + event.getRepository() );
+    }
+
+    private void println( String event, String message )
+    {
+        out.println( "Aether Repository - " + event + ": " + message );
+    }
+}

http://git-wip-us.apache.org/repos/asf/maven/blob/fa47f650/maven-aether-provider/src/test/java/org/apache/maven/repository/internal/util/ConsoleTransferListener.java
----------------------------------------------------------------------
diff --git a/maven-aether-provider/src/test/java/org/apache/maven/repository/internal/util/ConsoleTransferListener.java b/maven-aether-provider/src/test/java/org/apache/maven/repository/internal/util/ConsoleTransferListener.java
new file mode 100644
index 0000000..f5e8580
--- /dev/null
+++ b/maven-aether-provider/src/test/java/org/apache/maven/repository/internal/util/ConsoleTransferListener.java
@@ -0,0 +1,186 @@
+package org.apache.maven.repository.internal.util;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+import java.io.PrintStream;
+import java.text.DecimalFormat;
+import java.text.DecimalFormatSymbols;
+import java.util.Locale;
+import java.util.Map;
+import java.util.concurrent.ConcurrentHashMap;
+
+import org.eclipse.aether.transfer.AbstractTransferListener;
+import org.eclipse.aether.transfer.TransferEvent;
+import org.eclipse.aether.transfer.TransferResource;
+
+public class ConsoleTransferListener
+    extends AbstractTransferListener
+{
+
+    private PrintStream out;
+
+    private Map<TransferResource, Long> downloads = new ConcurrentHashMap<TransferResource, Long>();
+
+    private int lastLength;
+
+    public ConsoleTransferListener()
+    {
+        this( null );
+    }
+
+    public ConsoleTransferListener( PrintStream out )
+    {
+        this.out = ( out != null ) ? out : System.out;
+    }
+
+    @Override
+    public void transferInitiated( TransferEvent event )
+    {
+        String message = event.getRequestType() == TransferEvent.RequestType.PUT ? "Uploading" : "Downloading";
+
+        println( "transferInitiated", message + ": " + event.getResource().getRepositoryUrl() + event.getResource().getResourceName() );
+    }
+
+    @Override
+    public void transferProgressed( TransferEvent event )
+    {
+        TransferResource resource = event.getResource();
+        downloads.put( resource, Long.valueOf( event.getTransferredBytes() ) );
+
+        StringBuilder buffer = new StringBuilder( 64 );
+
+        for ( Map.Entry<TransferResource, Long> entry : downloads.entrySet() )
+        {
+            long total = entry.getKey().getContentLength();
+            long complete = entry.getValue().longValue();
+
+            buffer.append( getStatus( complete, total ) ).append( "  " );
+        }
+
+        int pad = lastLength - buffer.length();
+        lastLength = buffer.length();
+        pad( buffer, pad );
+        buffer.append( '\r' );
+
+        print( "transferProgressed", buffer.toString() );
+    }
+
+    private String getStatus( long complete, long total )
+    {
+        if ( total >= 1024 )
+        {
+            return toKB( complete ) + "/" + toKB( total ) + " KB ";
+        }
+        else if ( total >= 0 )
+        {
+            return complete + "/" + total + " B ";
+        }
+        else if ( complete >= 1024 )
+        {
+            return toKB( complete ) + " KB ";
+        }
+        else
+        {
+            return complete + " B ";
+        }
+    }
+
+    private void pad( StringBuilder buffer, int spaces )
+    {
+        String block = "                                        ";
+        while ( spaces > 0 )
+        {
+            int n = Math.min( spaces, block.length() );
+            buffer.append( block, 0, n );
+            spaces -= n;
+        }
+    }
+
+    @Override
+    public void transferSucceeded( TransferEvent event )
+    {
+        transferCompleted( event );
+
+        TransferResource resource = event.getResource();
+        long contentLength = event.getTransferredBytes();
+        if ( contentLength >= 0 )
+        {
+            String type = ( event.getRequestType() == TransferEvent.RequestType.PUT ? "Uploaded" : "Downloaded" );
+            String len = contentLength >= 1024 ? toKB( contentLength ) + " KB" : contentLength + " B";
+
+            String throughput = "";
+            long duration = System.currentTimeMillis() - resource.getTransferStartTime();
+            if ( duration > 0 )
+            {
+                DecimalFormat format = new DecimalFormat( "0.0", new DecimalFormatSymbols( Locale.ENGLISH ) );
+                double kbPerSec = ( contentLength / 1024.0 ) / ( duration / 1000.0 );
+                throughput = " at " + format.format( kbPerSec ) + " KB/sec";
+            }
+
+            println( "transferSucceeded", type + ": " + resource.getRepositoryUrl() + resource.getResourceName() + " ("
+                + len + throughput + ")" );
+        }
+    }
+
+    @Override
+    public void transferFailed( TransferEvent event )
+    {
+        transferCompleted( event );
+
+        println( "transferFailed", event.getException().getClass() + ": " + event.getException().getMessage()  );
+    }
+
+    private void transferCompleted( TransferEvent event )
+    {
+        downloads.remove( event.getResource() );
+
+        StringBuilder buffer = new StringBuilder( 64 );
+        pad( buffer, lastLength );
+        buffer.append( '\r' );
+        out.println( buffer );
+    }
+
+    @Override
+    public void transferCorrupted( TransferEvent event )
+    {
+        println( "transferCorrupted", event.getException().getClass() + ": " + event.getException().getMessage() );
+    }
+
+    protected long toKB( long bytes )
+    {
+        return ( bytes + 1023 ) / 1024;
+    }
+
+    private void println( String event, String message )
+    {
+        print( event, message );
+        out.println();
+    }
+
+    private void print( String event, String message )
+    {
+        out.print( "Aether Transfer - " + event );
+        if ( message != null )
+        {
+            out.print( ": " );
+            out.print( message );
+        }
+    }
+}