Modified: maven/artifact/trunk/src/test/java/org/apache/maven/artifact/AbstractArtifactComponentTestCase.java
URL: http://svn.apache.org/viewvc/maven/artifact/trunk/src/test/java/org/apache/maven/artifact/AbstractArtifactComponentTestCase.java?rev=667464&r1=667463&r2=667464&view=diff
==============================================================================
--- maven/artifact/trunk/src/test/java/org/apache/maven/artifact/AbstractArtifactComponentTestCase.java (original)
+++ maven/artifact/trunk/src/test/java/org/apache/maven/artifact/AbstractArtifactComponentTestCase.java Fri Jun 13 03:40:13 2008
@@ -35,8 +35,7 @@
/**
* @author <a href="mailto:jason@maven.org">Jason van Zyl </a>
- * @version $Id: AbstractArtifactComponentTestCase.java,v 1.5 2004/10/23 13:33:59
- * jvanzyl Exp $
+ * @version $Id$
*/
public abstract class AbstractArtifactComponentTestCase
extends PlexusTestCase
@@ -45,7 +44,7 @@
/**
* Return an existing file, not a directory - causes creation to fail.
- *
+ *
* @throws Exception
*/
protected ArtifactRepository badLocalRepository()
@@ -57,8 +56,8 @@
f.createNewFile();
- ArtifactRepositoryLayout repoLayout = (ArtifactRepositoryLayout) lookup( ArtifactRepositoryLayout.ROLE,
- "legacy" );
+ ArtifactRepositoryLayout repoLayout =
+ (ArtifactRepositoryLayout) lookup( ArtifactRepositoryLayout.ROLE, "legacy" );
return new DefaultArtifactRepository( "test", "file://" + f.getPath(), repoLayout );
}
@@ -75,8 +74,8 @@
File f = new File( getBasedir(), path );
- ArtifactRepositoryLayout repoLayout = (ArtifactRepositoryLayout) lookup( ArtifactRepositoryLayout.ROLE,
- "legacy" );
+ ArtifactRepositoryLayout repoLayout =
+ (ArtifactRepositoryLayout) lookup( ArtifactRepositoryLayout.ROLE, "legacy" );
return new DefaultArtifactRepository( "local", "file://" + f.getPath(), repoLayout );
}
@@ -88,8 +87,8 @@
File f = new File( getBasedir(), path );
- ArtifactRepositoryLayout repoLayout = (ArtifactRepositoryLayout) lookup( ArtifactRepositoryLayout.ROLE,
- "legacy" );
+ ArtifactRepositoryLayout repoLayout =
+ (ArtifactRepositoryLayout) lookup( ArtifactRepositoryLayout.ROLE, "legacy" );
return new DefaultArtifactRepository( "test", "file://" + f.getPath(), repoLayout,
new ArtifactRepositoryPolicy(), new ArtifactRepositoryPolicy() );
@@ -98,8 +97,8 @@
protected ArtifactRepository badRemoteRepository()
throws Exception
{
- ArtifactRepositoryLayout repoLayout = (ArtifactRepositoryLayout) lookup( ArtifactRepositoryLayout.ROLE,
- "legacy" );
+ ArtifactRepositoryLayout repoLayout =
+ (ArtifactRepositoryLayout) lookup( ArtifactRepositoryLayout.ROLE, "legacy" );
return new DefaultArtifactRepository( "test", "http://foo.bar/repository", repoLayout );
}
@@ -168,10 +167,10 @@
//
// ----------------------------------------------------------------------
- protected List remoteRepositories()
+ protected List<ArtifactRepository> remoteRepositories()
throws Exception
{
- List remoteRepositories = new ArrayList();
+ List<ArtifactRepository> remoteRepositories = new ArrayList<ArtifactRepository>();
remoteRepositories.add( remoteRepository() );
@@ -275,4 +274,3 @@
}
}
}
-
Modified: maven/artifact/trunk/src/test/java/org/apache/maven/artifact/deployer/SimpleArtifactMetadataSource.java
URL: http://svn.apache.org/viewvc/maven/artifact/trunk/src/test/java/org/apache/maven/artifact/deployer/SimpleArtifactMetadataSource.java?rev=667464&r1=667463&r2=667464&view=diff
==============================================================================
--- maven/artifact/trunk/src/test/java/org/apache/maven/artifact/deployer/SimpleArtifactMetadataSource.java (original)
+++ maven/artifact/trunk/src/test/java/org/apache/maven/artifact/deployer/SimpleArtifactMetadataSource.java Fri Jun 13 03:40:13 2008
@@ -6,6 +6,7 @@
import org.apache.maven.artifact.metadata.ResolutionGroup;
import org.apache.maven.artifact.repository.ArtifactRepository;
import org.apache.maven.artifact.versioning.DefaultArtifactVersion;
+import org.apache.maven.artifact.versioning.ArtifactVersion;
import java.util.ArrayList;
import java.util.List;
@@ -14,22 +15,17 @@
public class SimpleArtifactMetadataSource
implements ArtifactMetadataSource
{
- public ResolutionGroup retrieve( Artifact artifact,
- ArtifactRepository localRepository,
- List remoteRepositories )
+ public ResolutionGroup retrieve( Artifact artifact, ArtifactRepository localRepository, List remoteRepositories )
throws ArtifactMetadataRetrievalException
{
- ResolutionGroup rg = new ResolutionGroup( null, null, null );
-
- return rg;
+ return new ResolutionGroup( null, null, null );
}
- public List retrieveAvailableVersions( Artifact artifact,
- ArtifactRepository localRepository,
- List remoteRepositories )
+ public List<ArtifactVersion> retrieveAvailableVersions( Artifact artifact, ArtifactRepository localRepository,
+ List<ArtifactRepository> remoteRepositories )
throws ArtifactMetadataRetrievalException
{
- List versions = new ArrayList();
+ List<ArtifactVersion> versions = new ArrayList<ArtifactVersion>();
versions.add( new DefaultArtifactVersion( "10.1.3" ) );
Modified: maven/artifact/trunk/src/test/java/org/apache/maven/artifact/manager/DefaultWagonManagerTest.java
URL: http://svn.apache.org/viewvc/maven/artifact/trunk/src/test/java/org/apache/maven/artifact/manager/DefaultWagonManagerTest.java?rev=667464&r1=667463&r2=667464&view=diff
==============================================================================
--- maven/artifact/trunk/src/test/java/org/apache/maven/artifact/manager/DefaultWagonManagerTest.java (original)
+++ maven/artifact/trunk/src/test/java/org/apache/maven/artifact/manager/DefaultWagonManagerTest.java Fri Jun 13 03:40:13 2008
@@ -58,34 +58,32 @@
wagonManager = (WagonManager) lookup( WagonManager.ROLE );
}
-
/**
* checks the handling of urls
*/
public void testExternalURL()
{
DefaultWagonManager mgr = new DefaultWagonManager();
- assertTrue(mgr.isExternalRepo( getRepo( "foo", "http://somehost" ) ));
- assertTrue(mgr.isExternalRepo( getRepo( "foo", "http://somehost:9090/somepath" ) ));
- assertTrue(mgr.isExternalRepo( getRepo( "foo", "ftp://somehost" ) ));
- assertTrue(mgr.isExternalRepo( getRepo( "foo", "http://192.168.101.1" ) ));
- assertTrue(mgr.isExternalRepo( getRepo( "foo", "http://" ) ));
- //these are local
- assertFalse(mgr.isExternalRepo( getRepo( "foo", "http://localhost:8080" ) ));
- assertFalse(mgr.isExternalRepo( getRepo( "foo", "http://127.0.0.1:9090" ) ));
- assertFalse(mgr.isExternalRepo( getRepo( "foo", "file://localhost/somepath" ) ));
- assertFalse(mgr.isExternalRepo( getRepo( "foo", "file://localhost/D:/somepath" ) ));
- assertFalse(mgr.isExternalRepo( getRepo( "foo", "http://localhost" ) ));
- assertFalse(mgr.isExternalRepo( getRepo( "foo", "http://127.0.0.1" ) ));
- assertFalse(mgr.isExternalRepo( getRepo( "foo", "file:///somepath" ) ));
- assertFalse(mgr.isExternalRepo( getRepo( "foo", "file://D:/somepath" ) ));
-
- //not a proper url so returns false;
- assertFalse(mgr.isExternalRepo( getRepo( "foo", "192.168.101.1" ) ));
- assertFalse(mgr.isExternalRepo( getRepo( "foo", "" ) ));
+ assertTrue( mgr.isExternalRepo( getRepo( "foo", "http://somehost" ) ) );
+ assertTrue( mgr.isExternalRepo( getRepo( "foo", "http://somehost:9090/somepath" ) ) );
+ assertTrue( mgr.isExternalRepo( getRepo( "foo", "ftp://somehost" ) ) );
+ assertTrue( mgr.isExternalRepo( getRepo( "foo", "http://192.168.101.1" ) ) );
+ assertTrue( mgr.isExternalRepo( getRepo( "foo", "http://" ) ) );
+ // these are local
+ assertFalse( mgr.isExternalRepo( getRepo( "foo", "http://localhost:8080" ) ) );
+ assertFalse( mgr.isExternalRepo( getRepo( "foo", "http://127.0.0.1:9090" ) ) );
+ assertFalse( mgr.isExternalRepo( getRepo( "foo", "file://localhost/somepath" ) ) );
+ assertFalse( mgr.isExternalRepo( getRepo( "foo", "file://localhost/D:/somepath" ) ) );
+ assertFalse( mgr.isExternalRepo( getRepo( "foo", "http://localhost" ) ) );
+ assertFalse( mgr.isExternalRepo( getRepo( "foo", "http://127.0.0.1" ) ) );
+ assertFalse( mgr.isExternalRepo( getRepo( "foo", "file:///somepath" ) ) );
+ assertFalse( mgr.isExternalRepo( getRepo( "foo", "file://D:/somepath" ) ) );
+
+ // not a proper url so returns false;
+ assertFalse( mgr.isExternalRepo( getRepo( "foo", "192.168.101.1" ) ) );
+ assertFalse( mgr.isExternalRepo( getRepo( "foo", "" ) ) );
}
-
/**
* Check that lookups with exact matches work and that no matches don't corrupt the repo.
*/
@@ -93,20 +91,19 @@
{
wagonManager.addMirror( "a", "a", "http://a" );
wagonManager.addMirror( "b", "b", "http://b" );
-
+
ArtifactRepository repo = null;
- repo = wagonManager.getMirrorRepository( getRepo("a","http://a.a" ));
+ repo = wagonManager.getMirrorRepository( getRepo( "a", "http://a.a" ) );
assertEquals( "http://a", repo.getUrl() );
-
- repo = wagonManager.getMirrorRepository( getRepo("b","http://a.a" ));
+
+ repo = wagonManager.getMirrorRepository( getRepo( "b", "http://a.a" ) );
assertEquals( "http://b", repo.getUrl() );
-
- repo = wagonManager.getMirrorRepository( getRepo("c","http://c.c") );
+
+ repo = wagonManager.getMirrorRepository( getRepo( "c", "http://c.c" ) );
assertEquals( "http://c.c", repo.getUrl() );
-
-
+
}
-
+
/**
* Check that wildcards don't override exact id matches.
*/
@@ -115,107 +112,104 @@
wagonManager.addMirror( "a", "a", "http://a" );
wagonManager.addMirror( "b", "b", "http://b" );
wagonManager.addMirror( "c", "*", "http://wildcard" );
-
+
ArtifactRepository repo = null;
- repo = wagonManager.getMirrorRepository( getRepo("a","http://a.a" ));
+ repo = wagonManager.getMirrorRepository( getRepo( "a", "http://a.a" ) );
assertEquals( "http://a", repo.getUrl() );
-
- repo = wagonManager.getMirrorRepository( getRepo("b","http://a.a" ));
+
+ repo = wagonManager.getMirrorRepository( getRepo( "b", "http://a.a" ) );
assertEquals( "http://b", repo.getUrl() );
-
- repo = wagonManager.getMirrorRepository( getRepo("c","http://c.c") );
- assertEquals( "http://wildcard", repo.getUrl() );
-
+
+ repo = wagonManager.getMirrorRepository( getRepo( "c", "http://c.c" ) );
+ assertEquals( "http://wildcard", repo.getUrl() );
+
}
/**
- * Check that patterns are processed correctly
- * Valid patterns:
- * * = everything
- * external:* = everything not on the localhost and not file based.
- * repo,repo1 = repo or repo1
- * *,!repo1 = everything except repo1
- *
+ * Check that patterns are processed correctly Valid patterns: * = everything external:* = everything not on the
+ * localhost and not file based. repo,repo1 = repo or repo1 *,!repo1 = everything except repo1
*/
public void testPatterns()
{
DefaultWagonManager mgr = new DefaultWagonManager();
-
- assertTrue(mgr.matchPattern( getRepo("a"), "*" ));
- assertTrue(mgr.matchPattern( getRepo("a"), "*," ));
- assertTrue(mgr.matchPattern( getRepo("a"), ",*," ));
- assertTrue(mgr.matchPattern( getRepo("a"), "*," ));
-
- assertTrue(mgr.matchPattern( getRepo("a"), "a" ));
- assertTrue(mgr.matchPattern( getRepo("a"), "a," ));
- assertTrue(mgr.matchPattern( getRepo("a"), ",a," ));
- assertTrue(mgr.matchPattern( getRepo("a"), "a," ));
-
- assertFalse(mgr.matchPattern( getRepo("b"), "a" ));
- assertFalse(mgr.matchPattern( getRepo("b"), "a," ));
- assertFalse(mgr.matchPattern( getRepo("b"), ",a" ));
- assertFalse(mgr.matchPattern( getRepo("b"), ",a," ));
-
- assertTrue(mgr.matchPattern( getRepo("a"), "a,b" ));
- assertTrue(mgr.matchPattern( getRepo("b"), "a,b" ));
-
- assertFalse(mgr.matchPattern( getRepo("c"), "a,b" ));
-
- assertTrue(mgr.matchPattern( getRepo("a"), "*" ));
- assertTrue(mgr.matchPattern( getRepo("a"), "*,b" ));
- assertTrue(mgr.matchPattern( getRepo("a"), "*,!b" ));
-
- assertFalse(mgr.matchPattern( getRepo("a"), "*,!a" ));
- assertFalse(mgr.matchPattern( getRepo("a"), "!a,*" ));
-
- assertTrue(mgr.matchPattern( getRepo("c"), "*,!a" ));
- assertTrue(mgr.matchPattern( getRepo("c"), "!a,*" ));
-
- assertFalse(mgr.matchPattern( getRepo("c"), "!a,!c" ));
- assertFalse(mgr.matchPattern( getRepo("d"), "!a,!c*" ));
+
+ assertTrue( mgr.matchPattern( getRepo( "a" ), "*" ) );
+ assertTrue( mgr.matchPattern( getRepo( "a" ), "*," ) );
+ assertTrue( mgr.matchPattern( getRepo( "a" ), ",*," ) );
+ assertTrue( mgr.matchPattern( getRepo( "a" ), "*," ) );
+
+ assertTrue( mgr.matchPattern( getRepo( "a" ), "a" ) );
+ assertTrue( mgr.matchPattern( getRepo( "a" ), "a," ) );
+ assertTrue( mgr.matchPattern( getRepo( "a" ), ",a," ) );
+ assertTrue( mgr.matchPattern( getRepo( "a" ), "a," ) );
+
+ assertFalse( mgr.matchPattern( getRepo( "b" ), "a" ) );
+ assertFalse( mgr.matchPattern( getRepo( "b" ), "a," ) );
+ assertFalse( mgr.matchPattern( getRepo( "b" ), ",a" ) );
+ assertFalse( mgr.matchPattern( getRepo( "b" ), ",a," ) );
+
+ assertTrue( mgr.matchPattern( getRepo( "a" ), "a,b" ) );
+ assertTrue( mgr.matchPattern( getRepo( "b" ), "a,b" ) );
+
+ assertFalse( mgr.matchPattern( getRepo( "c" ), "a,b" ) );
+
+ assertTrue( mgr.matchPattern( getRepo( "a" ), "*" ) );
+ assertTrue( mgr.matchPattern( getRepo( "a" ), "*,b" ) );
+ assertTrue( mgr.matchPattern( getRepo( "a" ), "*,!b" ) );
+
+ assertFalse( mgr.matchPattern( getRepo( "a" ), "*,!a" ) );
+ assertFalse( mgr.matchPattern( getRepo( "a" ), "!a,*" ) );
+
+ assertTrue( mgr.matchPattern( getRepo( "c" ), "*,!a" ) );
+ assertTrue( mgr.matchPattern( getRepo( "c" ), "!a,*" ) );
+
+ assertFalse( mgr.matchPattern( getRepo( "c" ), "!a,!c" ) );
+ assertFalse( mgr.matchPattern( getRepo( "d" ), "!a,!c*" ) );
}
-
+
/**
- * make sure the external if is fully exercised. We can assume file and ips are also handled because they
- * have a separate test above.
+ * make sure the external if is fully exercised. We can assume file and ips are also handled because they have a
+ * separate test above.
*/
public void testPatternsWithExternal()
{
DefaultWagonManager mgr = new DefaultWagonManager();
- assertTrue( mgr.matchPattern( getRepo( "a","http://localhost" ), "*" ) );
- assertFalse( mgr.matchPattern( getRepo( "a","http://localhost" ), "external:*" ) );
-
- assertTrue( mgr.matchPattern( getRepo( "a","http://localhost" ), "external:*,a" ) );
- assertFalse( mgr.matchPattern( getRepo( "a","http://localhost" ), "external:*,!a" ) );
- assertTrue( mgr.matchPattern( getRepo( "a","http://localhost" ), "a,external:*" ) );
- assertFalse( mgr.matchPattern( getRepo( "a","http://localhost" ), "!a,external:*" ) );
-
- assertFalse( mgr.matchPattern( getRepo( "c","http://localhost" ), "!a,external:*" ) );
- assertTrue( mgr.matchPattern( getRepo( "c","http://somehost" ), "!a,external:*" ) );
+ assertTrue( mgr.matchPattern( getRepo( "a", "http://localhost" ), "*" ) );
+ assertFalse( mgr.matchPattern( getRepo( "a", "http://localhost" ), "external:*" ) );
+
+ assertTrue( mgr.matchPattern( getRepo( "a", "http://localhost" ), "external:*,a" ) );
+ assertFalse( mgr.matchPattern( getRepo( "a", "http://localhost" ), "external:*,!a" ) );
+ assertTrue( mgr.matchPattern( getRepo( "a", "http://localhost" ), "a,external:*" ) );
+ assertFalse( mgr.matchPattern( getRepo( "a", "http://localhost" ), "!a,external:*" ) );
+
+ assertFalse( mgr.matchPattern( getRepo( "c", "http://localhost" ), "!a,external:*" ) );
+ assertTrue( mgr.matchPattern( getRepo( "c", "http://somehost" ), "!a,external:*" ) );
}
+
/**
* Build an ArtifactRepository object.
+ *
* @param id
* @param url
* @return
*/
- private ArtifactRepository getRepo (String id, String url)
+ private ArtifactRepository getRepo( String id, String url )
{
- return (ArtifactRepository) new DefaultArtifactRepository(id,url,new DefaultRepositoryLayout());
+ return new DefaultArtifactRepository( id, url, new DefaultRepositoryLayout() );
}
-
+
/**
* Build an ArtifactRepository object.
+ *
* @param id
- * @param url
* @return
*/
- private ArtifactRepository getRepo (String id)
+ private ArtifactRepository getRepo( String id )
{
- return getRepo(id,"http://something");
+ return getRepo( id, "http://something" );
}
-
+
public void testDefaultWagonManager()
throws Exception
{
@@ -237,7 +231,7 @@
}
catch ( UnsupportedProtocolException e )
{
- //ok
+ // ok
assertTrue( true );
}
}
@@ -261,7 +255,7 @@
}
catch ( UnsupportedProtocolException e )
{
- //ok
+ // ok
assertTrue( true );
}
}
@@ -275,13 +269,13 @@
repository.setProtocol( null );
- Wagon wagon = (Wagon) wagonManager.getWagon( repository );
+ Wagon wagon = wagonManager.getWagon( repository );
fail( "Expected :" + UnsupportedProtocolException.class.getName() );
}
catch ( UnsupportedProtocolException e )
{
- //ok
+ // ok
assertTrue( true );
}
}
@@ -297,28 +291,29 @@
try
{
tmpFile.deleteOnExit();
- Artifact artifact = new DefaultArtifact( "sample.group", "sample-art", VersionRange
- .createFromVersion( "1.0" ), "artifactScope", "type", "classifier", null );
+ Artifact artifact =
+ new DefaultArtifact( "sample.group", "sample-art", VersionRange.createFromVersion( "1.0" ),
+ "artifactScope", "type", "classifier", null );
artifact.setFile( tmpFile );
- ArtifactRepository repo = new DefaultArtifactRepository( "id", "noop://url",
- new ArtifactRepositoryLayoutStub() );
+ ArtifactRepository repo =
+ new DefaultArtifactRepository( "id", "noop://url", new ArtifactRepositoryLayoutStub() );
WagonNoOp wagon = (WagonNoOp) wagonManager.getWagon( "noop" );
/* getArtifact */
- assertFalse( "Transfer listener is registered before test", wagon.getTransferEventSupport()
- .hasTransferListener( transferListener ) );
+ assertFalse( "Transfer listener is registered before test",
+ wagon.getTransferEventSupport().hasTransferListener( transferListener ) );
wagonManager.setDownloadMonitor( transferListener );
wagonManager.getArtifact( artifact, repo );
- assertFalse( "Transfer listener still registered after getArtifact", wagon.getTransferEventSupport()
- .hasTransferListener( transferListener ) );
+ assertFalse( "Transfer listener still registered after getArtifact",
+ wagon.getTransferEventSupport().hasTransferListener( transferListener ) );
/* putArtifact */
- assertFalse( "Transfer listener is registered before test", wagon.getTransferEventSupport()
- .hasTransferListener( transferListener ) );
+ assertFalse( "Transfer listener is registered before test",
+ wagon.getTransferEventSupport().hasTransferListener( transferListener ) );
wagonManager.setDownloadMonitor( transferListener );
wagonManager.putArtifact( new File( "sample file" ), artifact, repo );
- assertFalse( "Transfer listener still registered after putArtifact", wagon.getTransferEventSupport()
- .hasTransferListener( transferListener ) );
+ assertFalse( "Transfer listener still registered after putArtifact",
+ wagon.getTransferEventSupport().hasTransferListener( transferListener ) );
}
finally
{
Modified: maven/artifact/trunk/src/test/java/org/apache/maven/artifact/repository/DefaultArtifactRepositoryFactoryTest.java
URL: http://svn.apache.org/viewvc/maven/artifact/trunk/src/test/java/org/apache/maven/artifact/repository/DefaultArtifactRepositoryFactoryTest.java?rev=667464&r1=667463&r2=667464&view=diff
==============================================================================
--- maven/artifact/trunk/src/test/java/org/apache/maven/artifact/repository/DefaultArtifactRepositoryFactoryTest.java (original)
+++ maven/artifact/trunk/src/test/java/org/apache/maven/artifact/repository/DefaultArtifactRepositoryFactoryTest.java Fri Jun 13 03:40:13 2008
@@ -10,7 +10,6 @@
import java.io.File;
import java.io.IOException;
import java.util.HashSet;
-import java.util.Iterator;
import java.util.Set;
public class DefaultArtifactRepositoryFactoryTest
@@ -18,7 +17,7 @@
{
private ArtifactRepositoryFactory repoFactory;
- private Set toDelete = new HashSet();
+ private Set<File> toDelete = new HashSet<File>();
public void setUp()
throws Exception
@@ -31,10 +30,8 @@
public void tearDown()
throws Exception
{
- for ( Iterator it = toDelete.iterator(); it.hasNext(); )
+ for ( File f : toDelete )
{
- File f = (File) it.next();
-
if ( f.exists() )
{
FileUtils.forceDelete( f );
Modified: maven/artifact/trunk/src/test/java/org/apache/maven/artifact/resolver/ArtifactResolutionExceptionTest.java
URL: http://svn.apache.org/viewvc/maven/artifact/trunk/src/test/java/org/apache/maven/artifact/resolver/ArtifactResolutionExceptionTest.java?rev=667464&r1=667463&r2=667464&view=diff
==============================================================================
--- maven/artifact/trunk/src/test/java/org/apache/maven/artifact/resolver/ArtifactResolutionExceptionTest.java (original)
+++ maven/artifact/trunk/src/test/java/org/apache/maven/artifact/resolver/ArtifactResolutionExceptionTest.java Fri Jun 13 03:40:13 2008
@@ -26,7 +26,7 @@
/**
* Test the artifact resolution exception message
- *
+ *
* @author Mauro Talevi
*/
public class ArtifactResolutionExceptionTest
@@ -44,26 +44,21 @@
String type = "jar";
String classifier = "aClassifier";
String downloadUrl = "http://somewhere.com/download";
- List path = Arrays.asList(new String[]{"dependency1", "dependency2"});
- String expected = "Missing artifact" + LS +
- LS +
- " Try downloading the file manually from: " + LS +
- " http://somewhere.com/download" + LS +
- LS +
- " Then, install it using the command: " + LS +
- " mvn install:install-file -DgroupId=aGroupId -DartifactId=anArtifactId -Dversion=aVersion "+
- "-Dclassifier=aClassifier -Dpackaging=jar -Dfile=/path/to/file" + LS +
- LS +
- " Alternatively, if you host your own repository you can deploy the file there: " + LS +
- " mvn deploy:deploy-file -DgroupId=aGroupId -DartifactId=anArtifactId"+
- " -Dversion=aVersion -Dclassifier=aClassifier -Dpackaging=jar -Dfile=/path/to/file"+
- " -Durl=[url] -DrepositoryId=[id]" + LS +
- LS +
- " Path to dependency: " + LS +
- " \t1) dependency1" + LS +
- " \t2) dependency2" + LS +
- LS;
- String actual = AbstractArtifactResolutionException.constructMissingArtifactMessage(message, indentation, groupId, artifactId, version, type, classifier, downloadUrl, path);
- assertEquals(expected, actual);
+ List path = Arrays.asList( "dependency1", "dependency2" );
+ String expected =
+ "Missing artifact" + LS + LS + " Try downloading the file manually from: " + LS
+ + " http://somewhere.com/download" + LS + LS + " Then, install it using the command: " + LS
+ + " mvn install:install-file -DgroupId=aGroupId -DartifactId=anArtifactId -Dversion=aVersion "
+ + "-Dclassifier=aClassifier -Dpackaging=jar -Dfile=/path/to/file" + LS + LS
+ + " Alternatively, if you host your own repository you can deploy the file there: " + LS
+ + " mvn deploy:deploy-file -DgroupId=aGroupId -DartifactId=anArtifactId"
+ + " -Dversion=aVersion -Dclassifier=aClassifier -Dpackaging=jar -Dfile=/path/to/file"
+ + " -Durl=[url] -DrepositoryId=[id]" + LS + LS + " Path to dependency: " + LS + " \t1) dependency1"
+ + LS + " \t2) dependency2" + LS + LS;
+ String actual =
+ AbstractArtifactResolutionException.constructMissingArtifactMessage( message, indentation, groupId,
+ artifactId, version, type, classifier,
+ downloadUrl, path );
+ assertEquals( expected, actual );
}
}
Modified: maven/artifact/trunk/src/test/java/org/apache/maven/artifact/resolver/ArtifactResolverTest.java
URL: http://svn.apache.org/viewvc/maven/artifact/trunk/src/test/java/org/apache/maven/artifact/resolver/ArtifactResolverTest.java?rev=667464&r1=667463&r2=667464&view=diff
==============================================================================
--- maven/artifact/trunk/src/test/java/org/apache/maven/artifact/resolver/ArtifactResolverTest.java (original)
+++ maven/artifact/trunk/src/test/java/org/apache/maven/artifact/resolver/ArtifactResolverTest.java Fri Jun 13 03:40:13 2008
@@ -136,9 +136,9 @@
}
};
- ArtifactResolutionResult result = artifactResolver.resolveTransitively( Collections.singleton( g ),
- projectArtifact, remoteRepositories(),
- localRepository(), mds );
+ ArtifactResolutionResult result =
+ artifactResolver.resolveTransitively( Collections.singleton( g ), projectArtifact, remoteRepositories(),
+ localRepository(), mds );
assertEquals( 2, result.getArtifacts().size() );
@@ -192,9 +192,9 @@
}
};
- ArtifactResolutionResult result = artifactResolver.resolveTransitively( Collections.singleton( i ),
- projectArtifact, remoteRepositories(),
- localRepository(), mds );
+ ArtifactResolutionResult result =
+ artifactResolver.resolveTransitively( Collections.singleton( i ), projectArtifact, remoteRepositories(),
+ localRepository(), mds );
assertEquals( 2, result.getArtifacts().size() );
@@ -229,7 +229,7 @@
Artifact l = createRemoteArtifact( "l", "1.0-SNAPSHOT" );
deleteLocalArtifact( l );
- List repositories = new ArrayList();
+ List<ArtifactRepository> repositories = new ArrayList<ArtifactRepository>();
repositories.add( remoteRepository() );
repositories.add( badRemoteRepository() );
@@ -269,7 +269,8 @@
set.add( n );
set.add( m );
- result = artifactResolver.resolveTransitively( set, projectArtifact, remoteRepositories(), localRepository(), mds );
+ result =
+ artifactResolver.resolveTransitively( set, projectArtifact, remoteRepositories(), localRepository(), mds );
Iterator i = result.getArtifacts().iterator();
assertEquals( "n should be first", n, i.next() );
@@ -280,7 +281,8 @@
set.add( m );
set.add( n );
- result = artifactResolver.resolveTransitively( set, projectArtifact, remoteRepositories(), localRepository(), mds );
+ result =
+ artifactResolver.resolveTransitively( set, projectArtifact, remoteRepositories(), localRepository(), mds );
i = result.getArtifacts().iterator();
assertEquals( "m should be first", m, i.next() );
Modified: maven/artifact/trunk/src/test/java/org/apache/maven/artifact/resolver/ArtifactUpdatePolicyTest.java
URL: http://svn.apache.org/viewvc/maven/artifact/trunk/src/test/java/org/apache/maven/artifact/resolver/ArtifactUpdatePolicyTest.java?rev=667464&r1=667463&r2=667464&view=diff
==============================================================================
--- maven/artifact/trunk/src/test/java/org/apache/maven/artifact/resolver/ArtifactUpdatePolicyTest.java (original)
+++ maven/artifact/trunk/src/test/java/org/apache/maven/artifact/resolver/ArtifactUpdatePolicyTest.java Fri Jun 13 03:40:13 2008
@@ -46,7 +46,7 @@
private ArtifactResolver artifactResolver;
- private List remoteRepositories;
+ private List<ArtifactRepository> remoteRepositories;
private WagonManager wagonManager;
@@ -94,20 +94,19 @@
super.tearDown();
}
-
private void assertTransfers( String[] expected )
{
StringBuffer expectedSB = new StringBuffer();
- for ( int i = 0; i < expected.length; i++ )
+ for ( String anExpected : expected )
{
- expectedSB.append( expected[ i ] ).append( "\n" );
+ expectedSB.append( anExpected ).append( "\n" );
}
- List actual = listener.getTransfers();
+ List<String> actual = listener.getTransfers();
StringBuffer actualSB = new StringBuffer();
- for ( int i = 0; i < actual.size(); i++ )
+ for ( String anActual : actual )
{
- actualSB.append( actual.get( i ) ).append( "\n" );
+ actualSB.append( anActual ).append( "\n" );
}
assertEquals( expectedSB.toString(), actualSB.toString() );
@@ -119,8 +118,8 @@
file.delete();
}
-
- private Artifact createLocalCopy( String artifactId, String version ) throws Exception
+ private Artifact createLocalCopy( String artifactId, String version )
+ throws Exception
{
Artifact a = createArtifact( artifactId, version );
@@ -146,25 +145,24 @@
artifactResolver.resolveAlways( a, remoteRepositories, localRepository );
- assertTransfers( new String[] {
- "get org.apache.maven/jars/o-0.0.1-SNAPSHOT.jar",
+ assertTransfers( new String[] { "get org.apache.maven/jars/o-0.0.1-SNAPSHOT.jar",
"getTransfer org.apache.maven/jars/o-0.0.1-SNAPSHOT.jar",
- "get org.apache.maven/jars/o-0.0.1-SNAPSHOT.jar.sha1",
- "get org.apache.maven/jars/o-0.0.1-SNAPSHOT.jar.md5" } );
+ "get org.apache.maven/jars/o-0.0.1-SNAPSHOT.jar.sha1", "get org.apache.maven/jars/o-0.0.1-SNAPSHOT.jar.md5" } );
}
- public void testForceButNoNewUpdates() throws Exception
+ public void testForceButNoNewUpdates()
+ throws Exception
{
Artifact a = createRemoteArtifact( "o", "0.0.1-SNAPSHOT" );
createArtifact( a, localRepository );
artifactResolver.resolveAlways( a, remoteRepositories, localRepository );
- assertTransfers( new String[] {
- "getIfNewer org.apache.maven/jars/o-0.0.1-SNAPSHOT.jar" } );
+ assertTransfers( new String[] { "getIfNewer org.apache.maven/jars/o-0.0.1-SNAPSHOT.jar" } );
}
- public void testForceNewUpdate() throws Exception
+ public void testForceNewUpdate()
+ throws Exception
{
Artifact a = createRemoteArtifact( "o", "0.0.1-SNAPSHOT" );
createArtifact( a, localRepository );
@@ -172,14 +170,13 @@
artifactResolver.resolveAlways( a, remoteRepositories, localRepository );
- assertTransfers( new String[] {
- "getIfNewer org.apache.maven/jars/o-0.0.1-SNAPSHOT.jar",
+ assertTransfers( new String[] { "getIfNewer org.apache.maven/jars/o-0.0.1-SNAPSHOT.jar",
"getTransfer org.apache.maven/jars/o-0.0.1-SNAPSHOT.jar",
- "get org.apache.maven/jars/o-0.0.1-SNAPSHOT.jar.sha1",
- "get org.apache.maven/jars/o-0.0.1-SNAPSHOT.jar.md5" } );
+ "get org.apache.maven/jars/o-0.0.1-SNAPSHOT.jar.sha1", "get org.apache.maven/jars/o-0.0.1-SNAPSHOT.jar.md5" } );
}
- public void testForceUpdateMissing() throws Exception
+ public void testForceUpdateMissing()
+ throws Exception
{
Artifact a = createArtifact( "o", "0.0.1-SNAPSHOT" );
@@ -203,13 +200,13 @@
// expected
}
- assertTransfers( new String[] {
- "get org.apache.maven/jars/o-0.0.1-SNAPSHOT.jar",
+ assertTransfers( new String[] { "get org.apache.maven/jars/o-0.0.1-SNAPSHOT.jar",
"get org.apache.maven/jars/o-0.0.1-SNAPSHOT.jar" } );
}
- public void testSnapshotUpdate() throws Exception
+ public void testSnapshotUpdate()
+ throws Exception
{
Artifact a = createRemoteArtifact( "o", "0.0.1-SNAPSHOT" );
createArtifact( a, localRepository );
@@ -217,14 +214,13 @@
artifactResolver.resolve( a, remoteRepositories, localRepository );
- assertTransfers( new String[] {
- "getIfNewer org.apache.maven/jars/o-0.0.1-SNAPSHOT.jar",
+ assertTransfers( new String[] { "getIfNewer org.apache.maven/jars/o-0.0.1-SNAPSHOT.jar",
"getTransfer org.apache.maven/jars/o-0.0.1-SNAPSHOT.jar",
- "get org.apache.maven/jars/o-0.0.1-SNAPSHOT.jar.sha1",
- "get org.apache.maven/jars/o-0.0.1-SNAPSHOT.jar.md5" } );
+ "get org.apache.maven/jars/o-0.0.1-SNAPSHOT.jar.sha1", "get org.apache.maven/jars/o-0.0.1-SNAPSHOT.jar.md5" } );
}
- public void testSnapshotNoUpdates() throws Exception
+ public void testSnapshotNoUpdates()
+ throws Exception
{
Artifact a = createRemoteArtifact( "o", "0.0.1-SNAPSHOT" );
createArtifact( a, localRepository );
@@ -234,11 +230,11 @@
artifactResolver.resolve( a, remoteRepositories, localRepository );
- assertTransfers( new String[] {
- "getIfNewer org.apache.maven/jars/o-0.0.1-SNAPSHOT.jar" } );
+ assertTransfers( new String[] { "getIfNewer org.apache.maven/jars/o-0.0.1-SNAPSHOT.jar" } );
}
- public void testSnapshotPolicyCheck() throws Exception
+ public void testSnapshotPolicyCheck()
+ throws Exception
{
Artifact a = createRemoteArtifact( "o", "0.0.1-SNAPSHOT" );
createArtifact( a, localRepository );
@@ -248,10 +244,11 @@
artifactResolver.resolve( a, remoteRepositories, localRepository );
- assertTransfers( new String[] { } );
+ assertTransfers( new String[] {} );
}
- public void testLocalCopy() throws Exception
+ public void testLocalCopy()
+ throws Exception
{
Artifact a = createRemoteArtifact( "o", "0.0.1-SNAPSHOT" );
a = createLocalCopy( a.getArtifactId(), a.getVersion() );
@@ -260,10 +257,11 @@
artifactResolver.resolve( a, remoteRepositories, localRepository );
- assertTransfers( new String[] { } );
+ assertTransfers( new String[] {} );
}
- public void testForceUpdateLocalCopy() throws Exception
+ public void testForceUpdateLocalCopy()
+ throws Exception
{
Artifact a = createRemoteArtifact( "o", "0.0.1-SNAPSHOT" );
a = createLocalCopy( a.getArtifactId(), a.getVersion() );
@@ -272,17 +270,14 @@
artifactResolver.resolveAlways( a, remoteRepositories, localRepository );
- assertTransfers( new String[] {
- "getIfNewer org.apache.maven/jars/o-0.0.1-SNAPSHOT.jar",
+ assertTransfers( new String[] { "getIfNewer org.apache.maven/jars/o-0.0.1-SNAPSHOT.jar",
"getTransfer org.apache.maven/jars/o-0.0.1-SNAPSHOT.jar",
- "get org.apache.maven/jars/o-0.0.1-SNAPSHOT.jar.sha1",
- "get org.apache.maven/jars/o-0.0.1-SNAPSHOT.jar.md5" } );
+ "get org.apache.maven/jars/o-0.0.1-SNAPSHOT.jar.sha1", "get org.apache.maven/jars/o-0.0.1-SNAPSHOT.jar.md5" } );
}
private void setLastModified( Artifact a, long timestamp, ArtifactRepository repository )
{
- File file = new File ( repository.getBasedir(),
- repository.pathOf( a ) );
+ File file = new File( repository.getBasedir(), repository.pathOf( a ) );
file.setLastModified( timestamp );
}
@@ -311,8 +306,7 @@
// expected
}
- assertTransfers( new String[] {
- "get org.apache.maven/jars/o-0.0.1-SNAPSHOT.jar" } );
+ assertTransfers( new String[] { "get org.apache.maven/jars/o-0.0.1-SNAPSHOT.jar" } );
}
public void testResolutionOfArtifactsDeletedFromLocalRepo()
@@ -352,9 +346,9 @@
{
ArtifactRepository remoteRepository1 = remoteRepository( "remote-repository1" );
ArtifactRepository remoteRepository2 = remoteRepository( "remote-repository2" );
- ArrayList remoteRepositories = new ArrayList();
- remoteRepositories.add(remoteRepository1);
- remoteRepositories.add(remoteRepository2);
+ ArrayList<ArtifactRepository> remoteRepositories = new ArrayList<ArtifactRepository>();
+ remoteRepositories.add( remoteRepository1 );
+ remoteRepositories.add( remoteRepository2 );
Artifact a = createArtifact( "a", "0.0.0-SNAPSHOT" );
createArtifact( a, remoteRepository2 );
@@ -372,8 +366,8 @@
FileUtils.deleteDirectory( f );
- ArtifactRepositoryLayout repoLayout = (ArtifactRepositoryLayout) lookup( ArtifactRepositoryLayout.ROLE,
- "legacy" );
+ ArtifactRepositoryLayout repoLayout =
+ (ArtifactRepositoryLayout) lookup( ArtifactRepositoryLayout.ROLE, "legacy" );
return new DefaultArtifactRepository( name, "file://" + f.getPath(), repoLayout,
new ArtifactRepositoryPolicy(), new ArtifactRepositoryPolicy() );
Modified: maven/artifact/trunk/src/test/java/org/apache/maven/artifact/resolver/DefaultArtifactCollectorTest.java
URL: http://svn.apache.org/viewvc/maven/artifact/trunk/src/test/java/org/apache/maven/artifact/resolver/DefaultArtifactCollectorTest.java?rev=667464&r1=667463&r2=667464&view=diff
==============================================================================
--- maven/artifact/trunk/src/test/java/org/apache/maven/artifact/resolver/DefaultArtifactCollectorTest.java (original)
+++ maven/artifact/trunk/src/test/java/org/apache/maven/artifact/resolver/DefaultArtifactCollectorTest.java Fri Jun 13 03:40:13 2008
@@ -47,7 +47,7 @@
/**
* Test the default artifact collector.
- *
+ *
* @author <a href="mailto:brett@apache.org">Brett Porter</a>
* @version $Id$
*/
@@ -123,12 +123,12 @@
ArtifactSpec d = b.addDependency( "d", "4.0" );
ArtifactResolutionResult res = collect( a );
- assertEquals( "Check artifact list", createSet( new Object[]{a.artifact, b.artifact, c.artifact, d.artifact} ),
- res.getArtifacts() );
+ assertEquals( "Check artifact list",
+ createSet( new Object[] { a.artifact, b.artifact, c.artifact, d.artifact } ), res.getArtifacts() );
- ArtifactFilter filter = new ExclusionSetFilter( new String[]{"b"} );
+ ArtifactFilter filter = new ExclusionSetFilter( new String[] { "b" } );
res = collect( a, filter );
- assertEquals( "Check artifact list", createSet( new Object[]{a.artifact, c.artifact} ), res.getArtifacts() );
+ assertEquals( "Check artifact list", createSet( new Object[] { a.artifact, c.artifact } ), res.getArtifacts() );
}
public void testResolveCorrectDependenciesWhenDifferentDependenciesOnNearest()
@@ -143,10 +143,9 @@
ArtifactSpec c1 = e.addDependency( "c", "1.0" );
ArtifactSpec f = c1.addDependency( "f", "1.0" );
- ArtifactResolutionResult res = collect( createSet( new Object[]{a.artifact, e.artifact} ) );
- assertEquals( "Check artifact list",
- createSet( new Object[]{a.artifact, b.artifact, e.artifact, c1.artifact, f.artifact} ),
- res.getArtifacts() );
+ ArtifactResolutionResult res = collect( createSet( new Object[] { a.artifact, e.artifact } ) );
+ assertEquals( "Check artifact list", createSet( new Object[] { a.artifact, b.artifact, e.artifact, c1.artifact,
+ f.artifact } ), res.getArtifacts() );
assertEquals( "Check version", "1.0", getArtifact( "c", res.getArtifacts() ).getVersion() );
}
@@ -163,10 +162,9 @@
ArtifactSpec c1 = e.addDependency( "c", "1.0" );
c1.addDependency( "f", "1.0" );
- ArtifactResolutionResult res = collect( createSet( new Object[]{a.artifact, e.artifact} ) );
- assertEquals( "Check artifact list",
- createSet( new Object[]{a.artifact, b.artifact, e.artifact, c2.artifact, d.artifact} ),
- res.getArtifacts() );
+ ArtifactResolutionResult res = collect( createSet( new Object[] { a.artifact, e.artifact } ) );
+ assertEquals( "Check artifact list", createSet( new Object[] { a.artifact, b.artifact, e.artifact, c2.artifact,
+ d.artifact } ), res.getArtifacts() );
assertEquals( "Check version", "2.0", getArtifact( "c", res.getArtifacts() ).getVersion() );
}
@@ -184,8 +182,8 @@
ArtifactSpec e = b2.addDependency( "e", "1.0" );
ArtifactSpec g = d1.addDependency( "g", "1.0" );
- ArtifactResolutionResult res = collect( createSet( new Object[]{a.artifact} ) );
- Object[] artifacts = new Object[]{a.artifact, c.artifact, d1.artifact, b2.artifact, e.artifact, g.artifact};
+ ArtifactResolutionResult res = collect( createSet( new Object[] { a.artifact } ) );
+ Object[] artifacts = new Object[] { a.artifact, c.artifact, d1.artifact, b2.artifact, e.artifact, g.artifact };
assertEquals( "Check artifact list", createSet( artifacts ), res.getArtifacts() );
assertEquals( "Check version", "1.0", getArtifact( "d", res.getArtifacts() ).getVersion() );
assertEquals( "Check version", "2.0", getArtifact( "b", res.getArtifacts() ).getVersion() );
@@ -201,7 +199,7 @@
b.addDependency( "c", "2.0" );
ArtifactResolutionResult res = collect( a );
- assertEquals( "Check artifact list", createSet( new Object[]{a.artifact, b.artifact, c.artifact} ),
+ assertEquals( "Check artifact list", createSet( new Object[] { a.artifact, b.artifact, c.artifact } ),
res.getArtifacts() );
assertEquals( "Check version", "3.0", getArtifact( "c", res.getArtifacts() ).getVersion() );
}
@@ -216,7 +214,7 @@
b.addDependency( "c", "3.0" );
ArtifactResolutionResult res = collect( a );
- assertEquals( "Check artifact list", createSet( new Object[]{a.artifact, b.artifact, c.artifact} ),
+ assertEquals( "Check artifact list", createSet( new Object[] { a.artifact, b.artifact, c.artifact } ),
res.getArtifacts() );
assertEquals( "Check version", "2.0", getArtifact( "c", res.getArtifacts() ).getVersion() );
}
@@ -228,8 +226,8 @@
a.addDependency( "b", "2.0" );
ArtifactSpec b = createArtifactSpec( "b", "3.0" );
- ArtifactResolutionResult res = collect( createSet( new Object[]{a.artifact, b.artifact} ) );
- assertEquals( "Check artifact list", createSet( new Object[]{a.artifact, b.artifact} ), res.getArtifacts() );
+ ArtifactResolutionResult res = collect( createSet( new Object[] { a.artifact, b.artifact } ) );
+ assertEquals( "Check artifact list", createSet( new Object[] { a.artifact, b.artifact } ), res.getArtifacts() );
assertEquals( "Check version", "3.0", getArtifact( "b", res.getArtifacts() ).getVersion() );
}
@@ -240,8 +238,8 @@
a.addDependency( "b", "3.0" );
ArtifactSpec b = createArtifactSpec( "b", "2.0" );
- ArtifactResolutionResult res = collect( createSet( new Object[]{a.artifact, b.artifact} ) );
- assertEquals( "Check artifact list", createSet( new Object[]{a.artifact, b.artifact} ), res.getArtifacts() );
+ ArtifactResolutionResult res = collect( createSet( new Object[] { a.artifact, b.artifact } ) );
+ assertEquals( "Check artifact list", createSet( new Object[] { a.artifact, b.artifact } ), res.getArtifacts() );
assertEquals( "Check version", "2.0", getArtifact( "b", res.getArtifacts() ).getVersion() );
}
@@ -252,8 +250,8 @@
a.addDependency( "junit", "3.7" );
ArtifactSpec b = createArtifactSpec( "junit", "3.8.1", Artifact.SCOPE_TEST );
- ArtifactResolutionResult res = collect( createSet( new Object[]{a.artifact, b.artifact} ) );
- assertEquals( "Check artifact list", createSet( new Object[]{a.artifact, b.artifact} ), res.getArtifacts() );
+ ArtifactResolutionResult res = collect( createSet( new Object[] { a.artifact, b.artifact } ) );
+ assertEquals( "Check artifact list", createSet( new Object[] { a.artifact, b.artifact } ), res.getArtifacts() );
assertEquals( "Check version", "3.8.1", getArtifact( "junit", res.getArtifacts() ).getVersion() );
assertEquals( "Check artifactScope", Artifact.SCOPE_TEST, getArtifact( "junit", res.getArtifacts() ).getScope() );
}
@@ -265,8 +263,8 @@
ArtifactSpec a = createArtifactSpec( "commons-logging", "1.0" );
a.addDependency( "junit", "3.7" );
- ArtifactResolutionResult res = collect( createSet( new Object[]{a.artifact, b.artifact} ) );
- assertEquals( "Check artifact list", createSet( new Object[]{a.artifact, b.artifact} ), res.getArtifacts() );
+ ArtifactResolutionResult res = collect( createSet( new Object[] { a.artifact, b.artifact } ) );
+ assertEquals( "Check artifact list", createSet( new Object[] { a.artifact, b.artifact } ), res.getArtifacts() );
assertEquals( "Check version", "3.8.1", getArtifact( "junit", res.getArtifacts() ).getVersion() );
assertEquals( "Check artifactScope", Artifact.SCOPE_TEST, getArtifact( "junit", res.getArtifacts() ).getScope() );
}
@@ -281,7 +279,7 @@
b.addDependency( "c", "[1.0,3.0]" );
ArtifactResolutionResult res = collect( a );
- assertEquals( "Check artifact list", createSet( new Object[]{a.artifact, b.artifact, c.artifact} ),
+ assertEquals( "Check artifact list", createSet( new Object[] { a.artifact, b.artifact, c.artifact } ),
res.getArtifacts() );
assertEquals( "Check version", "2.0", getArtifact( "c", res.getArtifacts() ).getVersion() );
}
@@ -311,7 +309,7 @@
ArtifactResolutionResult res = collect( a );
- assertEquals( "Check artifact list", createSet( new Object[]{a.artifact, b.artifact, c.artifact} ),
+ assertEquals( "Check artifact list", createSet( new Object[] { a.artifact, b.artifact, c.artifact } ),
res.getArtifacts() );
assertEquals( "Check version", "2.5", getArtifact( "c", res.getArtifacts() ).getVersion() );
}
@@ -354,7 +352,7 @@
ArtifactResolutionResult res = collect( a );
- assertEquals( "Check artifact list", createSet( new Object[]{a.artifact, c.artifact} ), res.getArtifacts() );
+ assertEquals( "Check artifact list", createSet( new Object[] { a.artifact, c.artifact } ), res.getArtifacts() );
assertEquals( "Check version", "2.0", getArtifact( "c", res.getArtifacts() ).getVersion() );
}
@@ -380,7 +378,7 @@
Artifact modifiedB = createArtifactSpec( "b", "5.0", Artifact.SCOPE_RUNTIME ).artifact;
ArtifactResolutionResult res = collect( a, managedVersion );
- assertEquals( "Check artifact list", createSet( new Object[]{a.artifact, modifiedB} ), res.getArtifacts() );
+ assertEquals( "Check artifact list", createSet( new Object[] { a.artifact, modifiedB } ), res.getArtifacts() );
}
public void testCollectChangesVersionOfOriginatingArtifactIfInDependencyManagementHasDifferentVersion()
@@ -395,7 +393,7 @@
assertEquals( "collect has modified version in originating artifact", "1.0", artifact.getVersion() );
- Artifact resolvedArtifact = (Artifact) result.getArtifacts().iterator().next();
+ Artifact resolvedArtifact = result.getArtifacts().iterator().next();
assertEquals( "Resolved version don't match original artifact version", "1.0", resolvedArtifact.getVersion() );
}
@@ -410,11 +408,11 @@
Artifact modifiedC = createArtifactSpec( "c", "3.0", Artifact.SCOPE_COMPILE ).artifact;
- ArtifactResolutionResult res = collect( createSet( new Object[]{a.artifact, c.artifact} ) );
- assertEquals( "Check artifact list", createSet( new Object[]{a.artifact, modifiedC} ), res.getArtifacts() );
+ ArtifactResolutionResult res = collect( createSet( new Object[] { a.artifact, c.artifact } ) );
+ assertEquals( "Check artifact list", createSet( new Object[] { a.artifact, modifiedC } ), res.getArtifacts() );
Artifact artifact = getArtifact( "c", res.getArtifacts() );
// local wins now, and irrelevant if not local as test/provided aren't transitive
-// assertEquals( "Check artifactScope", Artifact.SCOPE_COMPILE, artifact.getArtifactScope() );
+ // assertEquals( "Check artifactScope", Artifact.SCOPE_COMPILE, artifact.getArtifactScope() );
assertEquals( "Check artifactScope", Artifact.SCOPE_TEST, artifact.getScope() );
}
@@ -428,11 +426,11 @@
Artifact modifiedC = createArtifactSpec( "c", "3.0", Artifact.SCOPE_RUNTIME ).artifact;
- ArtifactResolutionResult res = collect( createSet( new Object[]{a.artifact, c.artifact} ) );
- assertEquals( "Check artifact list", createSet( new Object[]{a.artifact, modifiedC} ), res.getArtifacts() );
+ ArtifactResolutionResult res = collect( createSet( new Object[] { a.artifact, c.artifact } ) );
+ assertEquals( "Check artifact list", createSet( new Object[] { a.artifact, modifiedC } ), res.getArtifacts() );
Artifact artifact = getArtifact( "c", res.getArtifacts() );
// local wins now, and irrelevant if not local as test/provided aren't transitive
-// assertEquals( "Check artifactScope", Artifact.SCOPE_RUNTIME, artifact.getArtifactScope() );
+ // assertEquals( "Check artifactScope", Artifact.SCOPE_RUNTIME, artifact.getArtifactScope() );
assertEquals( "Check artifactScope", Artifact.SCOPE_TEST, artifact.getScope() );
}
@@ -447,8 +445,8 @@
Artifact modifiedC = createArtifactSpec( "c", "3.0", Artifact.SCOPE_COMPILE ).artifact;
- ArtifactResolutionResult res = collect( createSet( new Object[]{root.artifact} ) );
- assertEquals( "Check artifact list", createSet( new Object[]{a.artifact, root.artifact, modifiedC} ),
+ ArtifactResolutionResult res = collect( createSet( new Object[] { root.artifact } ) );
+ assertEquals( "Check artifact list", createSet( new Object[] { a.artifact, root.artifact, modifiedC } ),
res.getArtifacts() );
Artifact artifact = getArtifact( "c", res.getArtifacts() );
assertEquals( "Check artifactScope", Artifact.SCOPE_COMPILE, artifact.getScope() );
@@ -464,11 +462,11 @@
Artifact modifiedC = createArtifactSpec( "c", "3.0", Artifact.SCOPE_COMPILE ).artifact;
- ArtifactResolutionResult res = collect( createSet( new Object[]{a.artifact, c.artifact} ) );
- assertEquals( "Check artifact list", createSet( new Object[]{a.artifact, modifiedC} ), res.getArtifacts() );
+ ArtifactResolutionResult res = collect( createSet( new Object[] { a.artifact, c.artifact } ) );
+ assertEquals( "Check artifact list", createSet( new Object[] { a.artifact, modifiedC } ), res.getArtifacts() );
Artifact artifact = getArtifact( "c", res.getArtifacts() );
// local wins now, and irrelevant if not local as test/provided aren't transitive
-// assertEquals( "Check artifactScope", Artifact.SCOPE_COMPILE, artifact.getArtifactScope() );
+ // assertEquals( "Check artifactScope", Artifact.SCOPE_COMPILE, artifact.getArtifactScope() );
assertEquals( "Check artifactScope", Artifact.SCOPE_PROVIDED, artifact.getScope() );
}
@@ -482,11 +480,11 @@
Artifact modifiedC = createArtifactSpec( "c", "3.0", Artifact.SCOPE_RUNTIME ).artifact;
- ArtifactResolutionResult res = collect( createSet( new Object[]{a.artifact, c.artifact} ) );
- assertEquals( "Check artifact list", createSet( new Object[]{a.artifact, modifiedC} ), res.getArtifacts() );
+ ArtifactResolutionResult res = collect( createSet( new Object[] { a.artifact, c.artifact } ) );
+ assertEquals( "Check artifact list", createSet( new Object[] { a.artifact, modifiedC } ), res.getArtifacts() );
Artifact artifact = getArtifact( "c", res.getArtifacts() );
// local wins now, and irrelevant if not local as test/provided aren't transitive
-// assertEquals( "Check artifactScope", Artifact.SCOPE_RUNTIME, artifact.getArtifactScope() );
+ // assertEquals( "Check artifactScope", Artifact.SCOPE_RUNTIME, artifact.getArtifactScope() );
assertEquals( "Check artifactScope", Artifact.SCOPE_PROVIDED, artifact.getScope() );
}
@@ -497,8 +495,8 @@
ArtifactSpec b = createArtifactSpec( "b", "1.0" );
b.addDependency( "c", "3.0", Artifact.SCOPE_PROVIDED );
- ArtifactResolutionResult res = collect( createSet( new Object[]{a.artifact, b.artifact} ) );
- assertEquals( "Check artifact list", createSet( new Object[]{a.artifact, b.artifact} ), res.getArtifacts() );
+ ArtifactResolutionResult res = collect( createSet( new Object[] { a.artifact, b.artifact } ) );
+ assertEquals( "Check artifact list", createSet( new Object[] { a.artifact, b.artifact } ), res.getArtifacts() );
}
public void testOptionalNotTransitive()
@@ -508,8 +506,8 @@
ArtifactSpec b = createArtifactSpec( "b", "1.0" );
b.addDependency( "c", "3.0", true );
- ArtifactResolutionResult res = collect( createSet( new Object[]{a.artifact, b.artifact} ) );
- assertEquals( "Check artifact list", createSet( new Object[]{a.artifact, b.artifact} ), res.getArtifacts() );
+ ArtifactResolutionResult res = collect( createSet( new Object[] { a.artifact, b.artifact } ) );
+ assertEquals( "Check artifact list", createSet( new Object[] { a.artifact, b.artifact } ), res.getArtifacts() );
}
public void testOptionalIncludedAtRoot()
@@ -519,8 +517,8 @@
ArtifactSpec b = createArtifactSpec( "b", "1.0", true );
- ArtifactResolutionResult res = collect( createSet( new Object[]{a.artifact, b.artifact} ) );
- assertEquals( "Check artifact list", createSet( new Object[]{a.artifact, b.artifact} ), res.getArtifacts() );
+ ArtifactResolutionResult res = collect( createSet( new Object[] { a.artifact, b.artifact } ) );
+ assertEquals( "Check artifact list", createSet( new Object[] { a.artifact, b.artifact } ), res.getArtifacts() );
}
public void testScopeUpdate()
@@ -620,14 +618,14 @@
filter = new ScopeArtifactFilter( expectedScope );
}
- ArtifactResolutionResult res = collect( createSet( new Object[]{a.artifact, b.artifact} ), filter );
+ ArtifactResolutionResult res = collect( createSet( new Object[] { a.artifact, b.artifact } ), filter );
Artifact artifact = getArtifact( "d", res.getArtifacts() );
assertNotNull( "MNG-1895 Dependency was not added to resolution", artifact );
assertEquals( "Check artifactScope", expectedScope, artifact.getScope() );
assertEquals( "Check version", expectedVersion, artifact.getVersion() );
ArtifactSpec d = createArtifactSpec( "d", "1.0" );
- res = collect( createSet( new Object[]{a.artifact, b.artifact, d.artifact} ), filter );
+ res = collect( createSet( new Object[] { a.artifact, b.artifact, d.artifact } ), filter );
artifact = getArtifact( "d", res.getArtifacts() );
assertNotNull( "MNG-1895 Dependency was not added to resolution", artifact );
assertEquals( "Check artifactScope", d.artifact.getScope(), artifact.getScope() );
@@ -646,10 +644,9 @@
ArtifactSpec c = createArtifactSpec( "c", "3.0" );
- ArtifactResolutionResult res = collect( createSet( new Object[]{a.artifact, b.artifact} ) );
- assertEquals( "Check artifact list",
- createSet( new Object[]{a.artifact, b.artifact, c.artifact, d.artifact, e.artifact} ),
- res.getArtifacts() );
+ ArtifactResolutionResult res = collect( createSet( new Object[] { a.artifact, b.artifact } ) );
+ assertEquals( "Check artifact list", createSet( new Object[] { a.artifact, b.artifact, c.artifact, d.artifact,
+ e.artifact } ), res.getArtifacts() );
Artifact artifact = getArtifact( "c", res.getArtifacts() );
assertEquals( "Check version", "3.0", artifact.getVersion() );
}
@@ -661,8 +658,8 @@
ArtifactSpec b = createArtifactSpec( "b", "1.0" );
b.addDependency( "c", "3.0", Artifact.SCOPE_TEST );
- ArtifactResolutionResult res = collect( createSet( new Object[]{a.artifact, b.artifact} ) );
- assertEquals( "Check artifact list", createSet( new Object[]{a.artifact, b.artifact} ), res.getArtifacts() );
+ ArtifactResolutionResult res = collect( createSet( new Object[] { a.artifact, b.artifact } ) );
+ assertEquals( "Check artifact list", createSet( new Object[] { a.artifact, b.artifact } ), res.getArtifacts() );
}
public void testSnapshotNotIncluded()
@@ -677,16 +674,10 @@
assertTrue( res.hasVersionRangeViolations() );
/*
- try
- {
- ArtifactResolutionResult res = collect( a );
- fail( "Expected b not to resolve: " + res );
- }
- catch ( OverConstrainedVersionException e )
- {
- assertTrue( e.getMessage().indexOf( "[1.0-SNAPSHOT]" ) < e.getMessage().indexOf( "[1.0,)" ) );
- }
- */
+ * try { ArtifactResolutionResult res = collect( a ); fail( "Expected b not to resolve: " + res ); } catch (
+ * OverConstrainedVersionException e ) { assertTrue( e.getMessage().indexOf( "[1.0-SNAPSHOT]" ) <
+ * e.getMessage().indexOf( "[1.0,)" ) ); }
+ */
}
public void testOverConstrainedVersionException()
@@ -703,12 +694,12 @@
try
{
- ArtifactResolutionResult res = collect( createSet( new Object[]{a.artifact} ) );
+ ArtifactResolutionResult res = collect( createSet( new Object[] { a.artifact } ) );
}
catch ( OverConstrainedVersionException e )
{
- assertTrue( "Versions unordered", e.getMessage().indexOf( "[3.2.1-v3235e, 3.3.0-v3346]" ) != -1);
- assertTrue( "DependencyTrail unresolved", e.getMessage().indexOf( "Path to dependency:" ) != -1);
+ assertTrue( "Versions unordered", e.getMessage().indexOf( "[3.2.1-v3235e, 3.3.0-v3346]" ) != -1 );
+ assertTrue( "DependencyTrail unresolved", e.getMessage().indexOf( "Path to dependency:" ) != -1 );
}
}
@@ -779,12 +770,13 @@
}
private ArtifactSpec createArtifactSpec( String id, String version, String scope, String inheritedScope,
- boolean optional )
+ boolean optional )
throws InvalidVersionSpecificationException
{
VersionRange versionRange = VersionRange.createFromVersionSpec( version );
- Artifact artifact = artifactFactory.createDependencyArtifact( GROUP_ID, id, versionRange, "jar", null, scope,
- inheritedScope, optional );
+ Artifact artifact =
+ artifactFactory.createDependencyArtifact( GROUP_ID, id, versionRange, "jar", null, scope, inheritedScope,
+ optional );
ArtifactSpec spec = null;
if ( artifact != null )
{
@@ -849,8 +841,7 @@
private Map versions = new HashMap();
- public ResolutionGroup retrieve( Artifact artifact, ArtifactRepository localRepository,
- List remoteRepositories )
+ public ResolutionGroup retrieve( Artifact artifact, ArtifactRepository localRepository, List remoteRepositories )
throws ArtifactMetadataRetrievalException
{
String key = getKey( artifact );
@@ -861,7 +852,7 @@
return new ResolutionGroup( artifact, createArtifacts( artifactFactory, a.dependencies,
artifact.getScope(),
artifact.getDependencyFilter() ),
- Collections.EMPTY_LIST );
+ Collections.EMPTY_LIST );
}
catch ( InvalidVersionSpecificationException e )
{
@@ -897,14 +888,16 @@
if ( d.getScope().equals( Artifact.SCOPE_TEST ) || d.getScope().equals( Artifact.SCOPE_PROVIDED ) )
{
/* don't call createDependencyArtifact as it'll ignore test and provided scopes */
- artifact = artifactFactory.createArtifact( d.getGroupId(), d.getArtifactId(), d.getVersion(), d
- .getScope(), d.getType() );
+ artifact =
+ artifactFactory.createArtifact( d.getGroupId(), d.getArtifactId(), d.getVersion(),
+ d.getScope(), d.getType() );
}
else
{
- artifact = artifactFactory.createDependencyArtifact( d.getGroupId(), d.getArtifactId(),
- versionRange, d.getType(), d.getClassifier(),
- d.getScope(), inheritedScope, d.isOptional() );
+ artifact =
+ artifactFactory.createDependencyArtifact( d.getGroupId(), d.getArtifactId(), versionRange,
+ d.getType(), d.getClassifier(), d.getScope(),
+ inheritedScope, d.isOptional() );
}
if ( artifact != null && ( dependencyFilter == null || dependencyFilter.include( artifact ) ) )
Modified: maven/artifact/trunk/src/test/java/org/apache/maven/artifact/resolver/TestTransferListener.java
URL: http://svn.apache.org/viewvc/maven/artifact/trunk/src/test/java/org/apache/maven/artifact/resolver/TestTransferListener.java?rev=667464&r1=667463&r2=667464&view=diff
==============================================================================
--- maven/artifact/trunk/src/test/java/org/apache/maven/artifact/resolver/TestTransferListener.java (original)
+++ maven/artifact/trunk/src/test/java/org/apache/maven/artifact/resolver/TestTransferListener.java Fri Jun 13 03:40:13 2008
@@ -28,9 +28,9 @@
extends AbstractTransferListener
{
- private final List transfers = new ArrayList();
+ private final List<String> transfers = new ArrayList<String>();
- public List getTransfers()
+ public List<String> getTransfers()
{
return transfers;
}
Modified: maven/artifact/trunk/src/test/java/org/apache/maven/artifact/testutils/TestFileManager.java
URL: http://svn.apache.org/viewvc/maven/artifact/trunk/src/test/java/org/apache/maven/artifact/testutils/TestFileManager.java?rev=667464&r1=667463&r2=667464&view=diff
==============================================================================
--- maven/artifact/trunk/src/test/java/org/apache/maven/artifact/testutils/TestFileManager.java (original)
+++ maven/artifact/trunk/src/test/java/org/apache/maven/artifact/testutils/TestFileManager.java Fri Jun 13 03:40:13 2008
@@ -57,7 +57,7 @@
public static final String TEMP_DIR_PATH = System.getProperty( "java.io.tmpdir" );
- private List filesToDelete = new ArrayList();
+ private List<File> filesToDelete = new ArrayList<File>();
private final String baseFilename;
@@ -118,6 +118,7 @@
}
catch ( InterruptedException e )
{
+ // ignore
}
File dir = new File( TEMP_DIR_PATH, baseFilename + System.currentTimeMillis() );
@@ -143,7 +144,7 @@
{
for ( Iterator it = filesToDelete.iterator(); it.hasNext(); )
{
- File file = ( File ) it.next();
+ File file = (File) it.next();
if ( file.exists() )
{
Modified: maven/artifact/trunk/src/test/java/org/apache/maven/artifact/versioning/ComparableVersionTest.java
URL: http://svn.apache.org/viewvc/maven/artifact/trunk/src/test/java/org/apache/maven/artifact/versioning/ComparableVersionTest.java?rev=667464&r1=667463&r2=667464&view=diff
==============================================================================
--- maven/artifact/trunk/src/test/java/org/apache/maven/artifact/versioning/ComparableVersionTest.java (original)
+++ maven/artifact/trunk/src/test/java/org/apache/maven/artifact/versioning/ComparableVersionTest.java Fri Jun 13 03:40:13 2008
@@ -25,7 +25,7 @@
/**
* Test ComparableVersion.
- *
+ *
* @author <a href="mailto:hboutemy@apache.org">Herve Boutemy</a>
* @version $Id$
*/
@@ -37,28 +37,27 @@
return new ComparableVersion( version );
}
- private static final String[] VERSIONS_QUALIFIER = {
- "1-SNAPSHOT", "1-alpha2snapshot", "1-alpha2", "1-alpha-123", "1-beta-2", "1-beta123", "1-m2", "1-m11", "1-rc",
- "1-cr2", "1-rc123", "1", "1-sp", "1-sp2", "1-sp123", "1-abc", "1-def", "1-1-snapshot", "1-1", "1-2", "1-123"
- };
-
- private static final String[] VERSIONS_NUMBER = {
- "2.0", "2-1", "2.0.a", "2.0.0.a", "2.0.2", "2.0.123", "2.1.0", "2.1-a", "2.1b", "2.1-c", "2.1-1", "2.1.0.1",
- "2.2", "2.123", "11.a2", "11.a11", "11.b2", "11.b11", "11.m2", "11.m11", "11", "11.a", "11b", "11c", "11m"
- };
+ private static final String[] VERSIONS_QUALIFIER =
+ { "1-SNAPSHOT", "1-alpha2snapshot", "1-alpha2", "1-alpha-123", "1-beta-2", "1-beta123", "1-m2", "1-m11",
+ "1-rc", "1-cr2", "1-rc123", "1", "1-sp", "1-sp2", "1-sp123", "1-abc", "1-def", "1-1-snapshot", "1-1",
+ "1-2", "1-123" };
+
+ private static final String[] VERSIONS_NUMBER =
+ { "2.0", "2-1", "2.0.a", "2.0.0.a", "2.0.2", "2.0.123", "2.1.0", "2.1-a", "2.1b", "2.1-c", "2.1-1", "2.1.0.1",
+ "2.2", "2.123", "11.a2", "11.a11", "11.b2", "11.b11", "11.m2", "11.m11", "11", "11.a", "11b", "11c", "11m" };
private void checkVersionsOrder( String[] versions )
{
- Comparable[] c = new Comparable[ versions.length ];
- for( int i = 0; i < versions.length; i++ )
+ Comparable[] c = new Comparable[versions.length];
+ for ( int i = 0; i < versions.length; i++ )
{
c[i] = newComparable( versions[i] );
}
- for( int i = 1; i < versions.length; i++)
+ for ( int i = 1; i < versions.length; i++ )
{
Comparable low = c[i - 1];
- for( int j = i; j < versions.length; j++ )
+ for ( int j = i; j < versions.length; j++ )
{
Comparable high = c[j];
assertTrue( "expected " + low + " < " + high, low.compareTo( high ) < 0 );
@@ -160,9 +159,9 @@
Locale[] locales = { Locale.ENGLISH, new Locale( "tr" ), Locale.getDefault() };
try
{
- for ( int i = 0; i < locales.length; i++ )
+ for ( Locale locale : locales )
{
- Locale.setDefault( locales[i] );
+ Locale.setDefault( locale );
checkVersionsEqual( "1-abcdefghijklmnopqrstuvwxyz", "1-ABCDEFGHIJKLMNOPQRSTUVWXYZ" );
}
}
|