Modified: maven/maven-3/trunk/maven-compat/src/main/java/org/apache/maven/repository/metadata/MetadataResolutionResult.java URL: http://svn.apache.org/viewvc/maven/maven-3/trunk/maven-compat/src/main/java/org/apache/maven/repository/metadata/MetadataResolutionResult.java?rev=813604&r1=813603&r2=813604&view=diff ============================================================================== --- maven/maven-3/trunk/maven-compat/src/main/java/org/apache/maven/repository/metadata/MetadataResolutionResult.java (original) +++ maven/maven-3/trunk/maven-compat/src/main/java/org/apache/maven/repository/metadata/MetadataResolutionResult.java Thu Sep 10 21:49:53 2009 @@ -1,23 +1,42 @@ package org.apache.maven.repository.metadata; +/* + * 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.apache.maven.artifact.ArtifactScopeEnum; import org.codehaus.plexus.PlexusContainer; import org.codehaus.plexus.component.repository.exception.ComponentLookupException; -/** - * This object is tinted with ClasspathTransformation and GraphConflictResolver. +/** + * This object is tinted with ClasspathTransformation and GraphConflictResolver. * Get rid of them after debugging - * + * * @author <a href="o...@codehaus.org">Oleg Gusakov</a> */ public class MetadataResolutionResult { MetadataTreeNode treeRoot; - - /** + + /** * these components are are initialized on demand by - * explicit call of the initTreeProcessing() - */ + * explicit call of the initTreeProcessing() + */ ClasspathTransformation classpathTransformation; GraphConflictResolver conflictResolver; @@ -40,84 +59,112 @@ { this.treeRoot = root; } - + public void initTreeProcessing( PlexusContainer plexus ) throws ComponentLookupException { - classpathTransformation = (ClasspathTransformation)plexus.lookup(ClasspathTransformation.class); - conflictResolver = (GraphConflictResolver)plexus.lookup(GraphConflictResolver.class); + classpathTransformation = (ClasspathTransformation) plexus.lookup( ClasspathTransformation.class ); + conflictResolver = (GraphConflictResolver) plexus.lookup( GraphConflictResolver.class ); } //---------------------------------------------------------------------------- public MetadataGraph getGraph() throws MetadataResolutionException { - return treeRoot == null ? null : new MetadataGraph(treeRoot); + return treeRoot == null ? null : new MetadataGraph( treeRoot ); } //---------------------------------------------------------------------------- public MetadataGraph getGraph( ArtifactScopeEnum scope ) throws MetadataResolutionException, GraphConflictResolutionException { - if( treeRoot == null ) - return null; - - if( conflictResolver == null ) - return null; - + if ( treeRoot == null ) + { + return null; + } + + if ( conflictResolver == null ) + { + return null; + } + return conflictResolver.resolveConflicts( getGraph(), scope ); } //---------------------------------------------------------------------------- public MetadataGraph getGraph( MetadataResolutionRequestTypeEnum requestType ) throws MetadataResolutionException, GraphConflictResolutionException { - if( requestType == null ) - return null; - - if( treeRoot == null ) - return null; - - if( conflictResolver == null ) - return null; - - if( requestType.equals(MetadataResolutionRequestTypeEnum.classpathCompile) ) - return conflictResolver.resolveConflicts( getGraph(), ArtifactScopeEnum.compile ); - else if( requestType.equals(MetadataResolutionRequestTypeEnum.classpathRuntime) ) - return conflictResolver.resolveConflicts( getGraph(), ArtifactScopeEnum.runtime ); - else if( requestType.equals(MetadataResolutionRequestTypeEnum.classpathRuntime) ) - return conflictResolver.resolveConflicts( getGraph(), ArtifactScopeEnum.test ); - else if( requestType.equals(MetadataResolutionRequestTypeEnum.classpathRuntime) ) - return conflictResolver.resolveConflicts( getGraph(), ArtifactScopeEnum.test ); - else if( requestType.equals(MetadataResolutionRequestTypeEnum.graph) ) - return getGraph(); - else if( requestType.equals(MetadataResolutionRequestTypeEnum.versionedGraph) ) { - return new MetadataGraph( getTree(), true, false ); - } - else if( requestType.equals(MetadataResolutionRequestTypeEnum.scopedGraph) ) { - return new MetadataGraph( getTree(), true, true ); - } - return null; + if ( requestType == null ) + { + return null; + } + + if ( treeRoot == null ) + { + return null; + } + + if ( conflictResolver == null ) + { + return null; + } + + if ( requestType.equals( MetadataResolutionRequestTypeEnum.classpathCompile ) ) + { + return conflictResolver.resolveConflicts( getGraph(), ArtifactScopeEnum.compile ); + } + else if ( requestType.equals( MetadataResolutionRequestTypeEnum.classpathRuntime ) ) + { + return conflictResolver.resolveConflicts( getGraph(), ArtifactScopeEnum.runtime ); + } + else if ( requestType.equals( MetadataResolutionRequestTypeEnum.classpathRuntime ) ) + { + return conflictResolver.resolveConflicts( getGraph(), ArtifactScopeEnum.test ); + } + else if ( requestType.equals( MetadataResolutionRequestTypeEnum.classpathRuntime ) ) + { + return conflictResolver.resolveConflicts( getGraph(), ArtifactScopeEnum.test ); + } + else if ( requestType.equals( MetadataResolutionRequestTypeEnum.graph ) ) + { + return getGraph(); + } + else if ( requestType.equals( MetadataResolutionRequestTypeEnum.versionedGraph ) ) + { + return new MetadataGraph( getTree(), true, false ); + } + else if ( requestType.equals( MetadataResolutionRequestTypeEnum.scopedGraph ) ) + { + return new MetadataGraph( getTree(), true, true ); + } + return null; } //---------------------------------------------------------------------------- public ClasspathContainer getClasspath( ArtifactScopeEnum scope ) throws MetadataGraphTransformationException, MetadataResolutionException { - if( classpathTransformation == null ) - return null; - + if ( classpathTransformation == null ) + { + return null; + } + MetadataGraph dirtyGraph = getGraph(); - if( dirtyGraph == null ) - return null; - + if ( dirtyGraph == null ) + { + return null; + } + return classpathTransformation.transform( dirtyGraph, scope, false ); } - + //---------------------------------------------------------------------------- public MetadataTreeNode getClasspathTree( ArtifactScopeEnum scope ) throws MetadataGraphTransformationException, MetadataResolutionException { - ClasspathContainer cpc = getClasspath(scope); - if( cpc == null ) - return null; - + ClasspathContainer cpc = getClasspath( scope ); + if ( cpc == null ) + { + return null; + } + return cpc.getClasspathAsTree(); } //----------------------------------------------------------------------------
Modified: maven/maven-3/trunk/maven-compat/src/main/mdo/metadata.mdo URL: http://svn.apache.org/viewvc/maven/maven-3/trunk/maven-compat/src/main/mdo/metadata.mdo?rev=813604&r1=813603&r2=813604&view=diff ============================================================================== --- maven/maven-3/trunk/maven-compat/src/main/mdo/metadata.mdo (original) +++ maven/maven-3/trunk/maven-compat/src/main/mdo/metadata.mdo Thu Sep 10 21:49:53 2009 @@ -147,8 +147,8 @@ versioning.setLastUpdated( v.getLastUpdated() ); } - if ( v.getLastUpdated() == null || v.getLastUpdated().length() == 0 || - versioning.getLastUpdated().compareTo( v.getLastUpdated() ) >= 0 ) + if ( v.getLastUpdated() == null || v.getLastUpdated().length() == 0 + || versioning.getLastUpdated().compareTo( v.getLastUpdated() ) >= 0 ) { changed = true; v.setLastUpdated( versioning.getLastUpdated() ); Modified: maven/maven-3/trunk/maven-compat/src/test/java/org/apache/maven/repository/MirrorProcessorTest.java URL: http://svn.apache.org/viewvc/maven/maven-3/trunk/maven-compat/src/test/java/org/apache/maven/repository/MirrorProcessorTest.java?rev=813604&r1=813603&r2=813604&view=diff ============================================================================== --- maven/maven-3/trunk/maven-compat/src/test/java/org/apache/maven/repository/MirrorProcessorTest.java (original) +++ maven/maven-3/trunk/maven-compat/src/test/java/org/apache/maven/repository/MirrorProcessorTest.java Thu Sep 10 21:49:53 2009 @@ -1,12 +1,30 @@ package org.apache.maven.repository; +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + import java.io.File; import java.util.Arrays; import java.util.List; import org.apache.maven.artifact.repository.ArtifactRepository; import org.apache.maven.artifact.repository.ArtifactRepositoryFactory; -import org.apache.maven.artifact.repository.DefaultArtifactRepository; import org.apache.maven.artifact.repository.layout.DefaultRepositoryLayout; import org.codehaus.plexus.PlexusTestCase; @@ -15,7 +33,7 @@ { private DefaultMirrorBuilder mirrorBuilder; private ArtifactRepositoryFactory repositorySystem; - + protected void setUp() throws Exception { @@ -23,38 +41,40 @@ repositorySystem = lookup( ArtifactRepositoryFactory.class ); mirrorBuilder.clearMirrors(); } - + @Override - protected void tearDown() throws Exception { - mirrorBuilder = null; - super.tearDown(); + protected void tearDown() + throws Exception + { + mirrorBuilder = null; + super.tearDown(); } - + public void testAddMirrorWithNullRepositoryId() { mirrorBuilder.addMirror( null, "test", "http://www.nowhere.com/", null ); } - + public void testExternalURL() { - assertTrue( mirrorBuilder.isExternalRepo( getRepo( "foo", "http://somehost" ) ) ); - assertTrue( mirrorBuilder.isExternalRepo( getRepo( "foo", "http://somehost:9090/somepath" ) ) ); - assertTrue( mirrorBuilder.isExternalRepo( getRepo( "foo", "ftp://somehost" ) ) ); - assertTrue( mirrorBuilder.isExternalRepo( getRepo( "foo", "http://192.168.101.1" ) ) ); - assertTrue( mirrorBuilder.isExternalRepo( getRepo( "foo", "http://" ) ) ); + assertTrue( DefaultMirrorBuilder.isExternalRepo( getRepo( "foo", "http://somehost" ) ) ); + assertTrue( DefaultMirrorBuilder.isExternalRepo( getRepo( "foo", "http://somehost:9090/somepath" ) ) ); + assertTrue( DefaultMirrorBuilder.isExternalRepo( getRepo( "foo", "ftp://somehost" ) ) ); + assertTrue( DefaultMirrorBuilder.isExternalRepo( getRepo( "foo", "http://192.168.101.1" ) ) ); + assertTrue( DefaultMirrorBuilder.isExternalRepo( getRepo( "foo", "http://" ) ) ); // these are local - assertFalse( mirrorBuilder.isExternalRepo( getRepo( "foo", "http://localhost:8080" ) ) ); - assertFalse( mirrorBuilder.isExternalRepo( getRepo( "foo", "http://127.0.0.1:9090" ) ) ); - assertFalse( mirrorBuilder.isExternalRepo( getRepo( "foo", "file://localhost/somepath" ) ) ); - assertFalse( mirrorBuilder.isExternalRepo( getRepo( "foo", "file://localhost/D:/somepath" ) ) ); - assertFalse( mirrorBuilder.isExternalRepo( getRepo( "foo", "http://localhost" ) ) ); - assertFalse( mirrorBuilder.isExternalRepo( getRepo( "foo", "http://127.0.0.1" ) ) ); - assertFalse( mirrorBuilder.isExternalRepo( getRepo( "foo", "file:///somepath" ) ) ); - assertFalse( mirrorBuilder.isExternalRepo( getRepo( "foo", "file://D:/somepath" ) ) ); + assertFalse( DefaultMirrorBuilder.isExternalRepo( getRepo( "foo", "http://localhost:8080" ) ) ); + assertFalse( DefaultMirrorBuilder.isExternalRepo( getRepo( "foo", "http://127.0.0.1:9090" ) ) ); + assertFalse( DefaultMirrorBuilder.isExternalRepo( getRepo( "foo", "file://localhost/somepath" ) ) ); + assertFalse( DefaultMirrorBuilder.isExternalRepo( getRepo( "foo", "file://localhost/D:/somepath" ) ) ); + assertFalse( DefaultMirrorBuilder.isExternalRepo( getRepo( "foo", "http://localhost" ) ) ); + assertFalse( DefaultMirrorBuilder.isExternalRepo( getRepo( "foo", "http://127.0.0.1" ) ) ); + assertFalse( DefaultMirrorBuilder.isExternalRepo( getRepo( "foo", "file:///somepath" ) ) ); + assertFalse( DefaultMirrorBuilder.isExternalRepo( getRepo( "foo", "file://D:/somepath" ) ) ); // not a proper url so returns false; - assertFalse( mirrorBuilder.isExternalRepo( getRepo( "foo", "192.168.101.1" ) ) ); - assertFalse( mirrorBuilder.isExternalRepo( getRepo( "foo", "" ) ) ); + assertFalse( DefaultMirrorBuilder.isExternalRepo( getRepo( "foo", "192.168.101.1" ) ) ); + assertFalse( DefaultMirrorBuilder.isExternalRepo( getRepo( "foo", "" ) ) ); } public void testMirrorLookup() @@ -98,12 +118,12 @@ mirrorBuilder.addMirror( "a2", "a,b", "http://a2", null ); mirrorBuilder.addMirror( "a", "a", "http://a", null ); //make sure repeated entries are skipped - mirrorBuilder.addMirror( "a", "a", "http://a3", null ); - + mirrorBuilder.addMirror( "a", "a", "http://a3", null ); + mirrorBuilder.addMirror( "b", "b", "http://b", null ); mirrorBuilder.addMirror( "c", "d,e", "http://de", null ); mirrorBuilder.addMirror( "c", "*", "http://wildcard", null ); - mirrorBuilder.addMirror( "c", "e,f", "http://ef", null ); + mirrorBuilder.addMirror( "c", "e,f", "http://ef", null ); ArtifactRepository repo = null; repo = mirrorBuilder.getMirrorRepository( getRepo( "a", "http://a.a" ) ); @@ -114,68 +134,68 @@ repo = mirrorBuilder.getMirrorRepository( getRepo( "c", "http://c.c" ) ); assertEquals( "http://wildcard", repo.getUrl() ); - + repo = mirrorBuilder.getMirrorRepository( getRepo( "d", "http://d" ) ); assertEquals( "http://de", repo.getUrl() ); - + repo = mirrorBuilder.getMirrorRepository( getRepo( "e", "http://e" ) ); assertEquals( "http://de", repo.getUrl() ); - + repo = mirrorBuilder.getMirrorRepository( getRepo( "f", "http://f" ) ); assertEquals( "http://wildcard", repo.getUrl() ); } - + public void testPatterns() { - assertTrue( mirrorBuilder.matchPattern( getRepo( "a" ), "*" ) ); - assertTrue( mirrorBuilder.matchPattern( getRepo( "a" ), "*," ) ); - assertTrue( mirrorBuilder.matchPattern( getRepo( "a" ), ",*," ) ); - assertTrue( mirrorBuilder.matchPattern( getRepo( "a" ), "*," ) ); - - assertTrue( mirrorBuilder.matchPattern( getRepo( "a" ), "a" ) ); - assertTrue( mirrorBuilder.matchPattern( getRepo( "a" ), "a," ) ); - assertTrue( mirrorBuilder.matchPattern( getRepo( "a" ), ",a," ) ); - assertTrue( mirrorBuilder.matchPattern( getRepo( "a" ), "a," ) ); - - assertFalse( mirrorBuilder.matchPattern( getRepo( "b" ), "a" ) ); - assertFalse( mirrorBuilder.matchPattern( getRepo( "b" ), "a," ) ); - assertFalse( mirrorBuilder.matchPattern( getRepo( "b" ), ",a" ) ); - assertFalse( mirrorBuilder.matchPattern( getRepo( "b" ), ",a," ) ); - - assertTrue( mirrorBuilder.matchPattern( getRepo( "a" ), "a,b" ) ); - assertTrue( mirrorBuilder.matchPattern( getRepo( "b" ), "a,b" ) ); - - assertFalse( mirrorBuilder.matchPattern( getRepo( "c" ), "a,b" ) ); - - assertTrue( mirrorBuilder.matchPattern( getRepo( "a" ), "*" ) ); - assertTrue( mirrorBuilder.matchPattern( getRepo( "a" ), "*,b" ) ); - assertTrue( mirrorBuilder.matchPattern( getRepo( "a" ), "*,!b" ) ); + assertTrue( DefaultMirrorBuilder.matchPattern( getRepo( "a" ), "*" ) ); + assertTrue( DefaultMirrorBuilder.matchPattern( getRepo( "a" ), "*," ) ); + assertTrue( DefaultMirrorBuilder.matchPattern( getRepo( "a" ), ",*," ) ); + assertTrue( DefaultMirrorBuilder.matchPattern( getRepo( "a" ), "*," ) ); + + assertTrue( DefaultMirrorBuilder.matchPattern( getRepo( "a" ), "a" ) ); + assertTrue( DefaultMirrorBuilder.matchPattern( getRepo( "a" ), "a," ) ); + assertTrue( DefaultMirrorBuilder.matchPattern( getRepo( "a" ), ",a," ) ); + assertTrue( DefaultMirrorBuilder.matchPattern( getRepo( "a" ), "a," ) ); + + assertFalse( DefaultMirrorBuilder.matchPattern( getRepo( "b" ), "a" ) ); + assertFalse( DefaultMirrorBuilder.matchPattern( getRepo( "b" ), "a," ) ); + assertFalse( DefaultMirrorBuilder.matchPattern( getRepo( "b" ), ",a" ) ); + assertFalse( DefaultMirrorBuilder.matchPattern( getRepo( "b" ), ",a," ) ); + + assertTrue( DefaultMirrorBuilder.matchPattern( getRepo( "a" ), "a,b" ) ); + assertTrue( DefaultMirrorBuilder.matchPattern( getRepo( "b" ), "a,b" ) ); + + assertFalse( DefaultMirrorBuilder.matchPattern( getRepo( "c" ), "a,b" ) ); + + assertTrue( DefaultMirrorBuilder.matchPattern( getRepo( "a" ), "*" ) ); + assertTrue( DefaultMirrorBuilder.matchPattern( getRepo( "a" ), "*,b" ) ); + assertTrue( DefaultMirrorBuilder.matchPattern( getRepo( "a" ), "*,!b" ) ); - assertFalse( mirrorBuilder.matchPattern( getRepo( "a" ), "*,!a" ) ); - assertFalse( mirrorBuilder.matchPattern( getRepo( "a" ), "!a,*" ) ); + assertFalse( DefaultMirrorBuilder.matchPattern( getRepo( "a" ), "*,!a" ) ); + assertFalse( DefaultMirrorBuilder.matchPattern( getRepo( "a" ), "!a,*" ) ); - assertTrue( mirrorBuilder.matchPattern( getRepo( "c" ), "*,!a" ) ); - assertTrue( mirrorBuilder.matchPattern( getRepo( "c" ), "!a,*" ) ); + assertTrue( DefaultMirrorBuilder.matchPattern( getRepo( "c" ), "*,!a" ) ); + assertTrue( DefaultMirrorBuilder.matchPattern( getRepo( "c" ), "!a,*" ) ); - assertFalse( mirrorBuilder.matchPattern( getRepo( "c" ), "!a,!c" ) ); - assertFalse( mirrorBuilder.matchPattern( getRepo( "d" ), "!a,!c*" ) ); + assertFalse( DefaultMirrorBuilder.matchPattern( getRepo( "c" ), "!a,!c" ) ); + assertFalse( DefaultMirrorBuilder.matchPattern( getRepo( "d" ), "!a,!c*" ) ); } public void testPatternsWithExternal() { - assertTrue( mirrorBuilder.matchPattern( getRepo( "a", "http://localhost" ), "*" ) ); - assertFalse( mirrorBuilder.matchPattern( getRepo( "a", "http://localhost" ), "external:*" ) ); + assertTrue( DefaultMirrorBuilder.matchPattern( getRepo( "a", "http://localhost" ), "*" ) ); + assertFalse( DefaultMirrorBuilder.matchPattern( getRepo( "a", "http://localhost" ), "external:*" ) ); - assertTrue( mirrorBuilder.matchPattern( getRepo( "a", "http://localhost" ), "external:*,a" ) ); - assertFalse( mirrorBuilder.matchPattern( getRepo( "a", "http://localhost" ), "external:*,!a" ) ); - assertTrue( mirrorBuilder.matchPattern( getRepo( "a", "http://localhost" ), "a,external:*" ) ); - assertFalse( mirrorBuilder.matchPattern( getRepo( "a", "http://localhost" ), "!a,external:*" ) ); - - assertFalse( mirrorBuilder.matchPattern( getRepo( "c", "http://localhost" ), "!a,external:*" ) ); - assertTrue( mirrorBuilder.matchPattern( getRepo( "c", "http://somehost" ), "!a,external:*" ) ); - } + assertTrue( DefaultMirrorBuilder.matchPattern( getRepo( "a", "http://localhost" ), "external:*,a" ) ); + assertFalse( DefaultMirrorBuilder.matchPattern( getRepo( "a", "http://localhost" ), "external:*,!a" ) ); + assertTrue( DefaultMirrorBuilder.matchPattern( getRepo( "a", "http://localhost" ), "a,external:*" ) ); + assertFalse( DefaultMirrorBuilder.matchPattern( getRepo( "a", "http://localhost" ), "!a,external:*" ) ); + + assertFalse( DefaultMirrorBuilder.matchPattern( getRepo( "c", "http://localhost" ), "!a,external:*" ) ); + assertTrue( DefaultMirrorBuilder.matchPattern( getRepo( "c", "http://somehost" ), "!a,external:*" ) ); + } public void testMirrorProperUrlAndProtocolAndBasedir() { @@ -192,7 +212,7 @@ /** * Build an ArtifactRepository object. - * + * * @param id * @param url * @return @@ -204,12 +224,12 @@ /** * Build an ArtifactRepository object. - * + * * @param id * @return */ private ArtifactRepository getRepo( String id ) { return getRepo( id, "http://something" ); - } + } } Modified: maven/maven-3/trunk/maven-compat/src/test/java/org/apache/maven/repository/legacy/DefaultWagonManagerTest.java URL: http://svn.apache.org/viewvc/maven/maven-3/trunk/maven-compat/src/test/java/org/apache/maven/repository/legacy/DefaultWagonManagerTest.java?rev=813604&r1=813603&r2=813604&view=diff ============================================================================== --- maven/maven-3/trunk/maven-compat/src/test/java/org/apache/maven/repository/legacy/DefaultWagonManagerTest.java (original) +++ maven/maven-3/trunk/maven-compat/src/test/java/org/apache/maven/repository/legacy/DefaultWagonManagerTest.java Thu Sep 10 21:49:53 2009 @@ -34,10 +34,6 @@ import org.apache.maven.artifact.repository.layout.ArtifactRepositoryLayout; import org.apache.maven.artifact.repository.layout.DefaultRepositoryLayout; import org.apache.maven.artifact.versioning.VersionRange; -import org.apache.maven.repository.legacy.ChecksumFailedException; -import org.apache.maven.repository.legacy.DefaultWagonManager; -import org.apache.maven.repository.legacy.UpdateCheckManager; -import org.apache.maven.repository.legacy.WagonManager; import org.apache.maven.wagon.ResourceDoesNotExistException; import org.apache.maven.wagon.TransferFailedException; import org.apache.maven.wagon.UnsupportedProtocolException; @@ -63,48 +59,59 @@ private TransferListener transferListener = new Debug(); private ArtifactFactory artifactFactory; - + private ArtifactRepositoryFactory artifactRepositoryFactory; protected void setUp() throws Exception { super.setUp(); - wagonManager = (DefaultWagonManager) lookup( WagonManager.class ); + wagonManager = (DefaultWagonManager) lookup( WagonManager.class ); artifactFactory = lookup( ArtifactFactory.class ); artifactRepositoryFactory = lookup( ArtifactRepositoryFactory.class ); } - + @Override - protected void tearDown() throws Exception { - wagonManager = null; - artifactFactory = null; - super.tearDown(); + protected void tearDown() + throws Exception + { + wagonManager = null; + artifactFactory = null; + super.tearDown(); } - - public void testUnnecessaryRepositoryLookup() throws Exception { + + public void testUnnecessaryRepositoryLookup() + throws Exception + { Artifact artifact = createTestPomArtifact( "target/test-data/get-missing-pom" ); List<ArtifactRepository> repos = new ArrayList<ArtifactRepository>(); - repos.add(artifactRepositoryFactory.createArtifactRepository( "repo1", "string://url1", new ArtifactRepositoryLayoutStub(), null, null )); - repos.add(artifactRepositoryFactory.createArtifactRepository( "repo2", "string://url2", new ArtifactRepositoryLayoutStub(), null, null )); + repos.add( artifactRepositoryFactory.createArtifactRepository( "repo1", "string://url1", + new ArtifactRepositoryLayoutStub(), null, null ) ); + repos.add( artifactRepositoryFactory.createArtifactRepository( "repo2", "string://url2", + new ArtifactRepositoryLayoutStub(), null, null ) ); StringWagon wagon = (StringWagon) wagonManager.getWagon( "string" ); - wagon.addExpectedContent( repos.get(0).getLayout().pathOf( artifact ), "expected" ); - wagon.addExpectedContent( repos.get(1).getLayout().pathOf( artifact ), "expected" ); - - class TransferListener extends AbstractTransferListener { - public List<TransferEvent> events = new ArrayList<TransferEvent>(); - @Override - public void transferInitiated(TransferEvent transferEvent) { - events.add(transferEvent); - } - }; + wagon.addExpectedContent( repos.get( 0 ).getLayout().pathOf( artifact ), "expected" ); + wagon.addExpectedContent( repos.get( 1 ).getLayout().pathOf( artifact ), "expected" ); + + class TransferListener + extends AbstractTransferListener + { + public List<TransferEvent> events = new ArrayList<TransferEvent>(); + + @Override + public void transferInitiated( TransferEvent transferEvent ) + { + events.add( transferEvent ); + } + } + TransferListener listener = new TransferListener(); wagonManager.getArtifact( artifact, repos, listener ); - assertEquals(1, listener.events.size()); + assertEquals( 1, listener.events.size() ); } - + public void testGetPomExistsLocallyForced() throws IOException, TransferFailedException, ResourceDoesNotExistException, UnsupportedProtocolException { @@ -131,43 +138,43 @@ public void testGetMissingJar() throws TransferFailedException, UnsupportedProtocolException, IOException { Artifact artifact = createTestArtifact( "target/test-data/get-missing-jar", "jar" ); - + ArtifactRepository repo = createStringRepo(); - + try { wagonManager.getArtifact( artifact, repo, null ); - + fail(); } catch ( ResourceDoesNotExistException e ) { assertTrue( true ); } - + assertFalse( artifact.getFile().exists() ); } public void testGetMissingJarForced() throws TransferFailedException, UnsupportedProtocolException, IOException { Artifact artifact = createTestArtifact( "target/test-data/get-missing-jar", "jar" ); - + ArtifactRepository repo = createStringRepo(); - + try { wagonManager.getArtifact( artifact, repo, null ); - + fail(); } catch ( ResourceDoesNotExistException e ) { assertTrue( true ); } - + assertFalse( artifact.getFile().exists() ); } - + public void testGetRemoteJar() throws TransferFailedException, ResourceDoesNotExistException, UnsupportedProtocolException, IOException, AuthorizationException @@ -249,10 +256,10 @@ { return artifactRepositoryFactory.createArtifactRepository( "id", "string://url", new ArtifactRepositoryLayoutStub(), null, null ); } - + /** * Build an ArtifactRepository object. - * + * * @param id * @param url * @return @@ -264,7 +271,7 @@ /** * Build an ArtifactRepository object. - * + * * @param id * @return */ @@ -311,7 +318,7 @@ /* getArtifact */ assertFalse( "Transfer listener is registered before test", wagon.getTransferEventSupport().hasTransferListener( transferListener ) ); - wagonManager.getArtifact( artifact, repo, transferListener); + wagonManager.getArtifact( artifact, repo, transferListener ); assertFalse( "Transfer listener still registered after getArtifact", wagon.getTransferEventSupport().hasTransferListener( transferListener ) ); @@ -331,16 +338,16 @@ throws Exception { ArtifactRepositoryPolicy policy = new ArtifactRepositoryPolicy( true, ArtifactRepositoryPolicy.UPDATE_POLICY_ALWAYS, ArtifactRepositoryPolicy.CHECKSUM_POLICY_FAIL ); - + ArtifactRepository repo = artifactRepositoryFactory.createArtifactRepository( "id", "string://url", new ArtifactRepositoryLayoutStub(), policy, policy ); Artifact artifact = new DefaultArtifact( "sample.group", "sample-art", VersionRange.createFromVersion( "1.0" ), "scope", "jar", "classifier", null ); - artifact.setFile( getTestFile( "target/sample-art" ) ); + artifact.setFile( getTestFile( "target/sample-art" ) ); StringWagon wagon = (StringWagon) wagonManager.getWagon( "string" ); - + wagon.clearExpectedContent(); wagon.addExpectedContent( "path", "lower-case-checksum" ); wagon.addExpectedContent( "path.sha1", "2a25dc564a3b34f68237fc849066cbc7bb7a36a1" ); @@ -437,7 +444,7 @@ { return "test"; } - + public String pathOfRemoteRepositoryMetadata( ArtifactMetadata metadata ) { return "path"; Modified: maven/maven-3/trunk/maven-compat/src/test/java/org/apache/maven/repository/legacy/resolver/DefaultArtifactCollectorTest.java URL: http://svn.apache.org/viewvc/maven/maven-3/trunk/maven-compat/src/test/java/org/apache/maven/repository/legacy/resolver/DefaultArtifactCollectorTest.java?rev=813604&r1=813603&r2=813604&view=diff ============================================================================== --- maven/maven-3/trunk/maven-compat/src/test/java/org/apache/maven/repository/legacy/resolver/DefaultArtifactCollectorTest.java (original) +++ maven/maven-3/trunk/maven-compat/src/test/java/org/apache/maven/repository/legacy/resolver/DefaultArtifactCollectorTest.java Thu Sep 10 21:49:53 2009 @@ -48,7 +48,6 @@ import org.apache.maven.artifact.versioning.OverConstrainedVersionException; import org.apache.maven.artifact.versioning.VersionRange; import org.apache.maven.repository.legacy.metadata.MetadataResolutionRequest; -import org.apache.maven.repository.legacy.resolver.LegacyArtifactCollector; import org.codehaus.plexus.PlexusTestCase; /** @@ -84,10 +83,12 @@ } @Override - protected void tearDown() throws Exception { - artifactCollector = null; - artifactFactory = null; - super.tearDown(); + protected void tearDown() + throws Exception + { + artifactCollector = null; + artifactFactory = null; + super.tearDown(); } // works, but we don't fail on cycles presently @@ -738,7 +739,7 @@ private ArtifactResolutionResult collect( Set artifacts, ArtifactFilter filter ) throws ArtifactResolutionException - { + { return artifactCollector.collect( artifacts, projectArtifact.artifact, null, null, null, source, filter, Collections.EMPTY_LIST, null ); }