http://git-wip-us.apache.org/repos/asf/maven-resolver/blob/3a1b8ae0/aether-impl/src/main/java/org/eclipse/aether/internal/impl/package-info.java ---------------------------------------------------------------------- diff --git a/aether-impl/src/main/java/org/eclipse/aether/internal/impl/package-info.java b/aether-impl/src/main/java/org/eclipse/aether/internal/impl/package-info.java deleted file mode 100644 index 813b21d..0000000 --- a/aether-impl/src/main/java/org/eclipse/aether/internal/impl/package-info.java +++ /dev/null @@ -1,24 +0,0 @@ -// CHECKSTYLE_OFF: RegexpHeader -/* - * 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. - */ -/** - * The various sub components that collectively implement the repository system. - */ -package org.eclipse.aether.internal.impl; -
http://git-wip-us.apache.org/repos/asf/maven-resolver/blob/3a1b8ae0/aether-impl/src/main/java/org/eclipse/aether/internal/impl/slf4j/Slf4jLoggerFactory.java ---------------------------------------------------------------------- diff --git a/aether-impl/src/main/java/org/eclipse/aether/internal/impl/slf4j/Slf4jLoggerFactory.java b/aether-impl/src/main/java/org/eclipse/aether/internal/impl/slf4j/Slf4jLoggerFactory.java deleted file mode 100644 index 840fe21..0000000 --- a/aether-impl/src/main/java/org/eclipse/aether/internal/impl/slf4j/Slf4jLoggerFactory.java +++ /dev/null @@ -1,201 +0,0 @@ -package org.eclipse.aether.internal.impl.slf4j; - -/* - * 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 javax.inject.Inject; -import javax.inject.Named; - -import org.eclipse.aether.spi.locator.Service; -import org.eclipse.aether.spi.locator.ServiceLocator; -import org.eclipse.aether.spi.log.Logger; -import org.eclipse.aether.spi.log.LoggerFactory; -import org.eclipse.sisu.Nullable; -import org.slf4j.ILoggerFactory; -import org.slf4j.spi.LocationAwareLogger; - -/** - * A logger factory that delegates to <a href="http://www.slf4j.org/" target="_blank">SLF4J</a> logging. - */ -@Named( "slf4j" ) -public class Slf4jLoggerFactory - implements LoggerFactory, Service -{ - - private static final boolean AVAILABLE; - - static - { - boolean available; - try - { - Slf4jLoggerFactory.class.getClassLoader().loadClass( "org.slf4j.ILoggerFactory" ); - available = true; - } - catch ( Exception e ) - { - available = false; - } - catch ( LinkageError e ) - { - available = false; - } - AVAILABLE = available; - } - - public static boolean isSlf4jAvailable() - { - return AVAILABLE; - } - - private ILoggerFactory factory; - - /** - * Creates an instance of this logger factory. - */ - public Slf4jLoggerFactory() - { - // enables no-arg constructor - } - - @Inject - Slf4jLoggerFactory( @Nullable ILoggerFactory factory ) - { - setLoggerFactory( factory ); - } - - public void initService( ServiceLocator locator ) - { - setLoggerFactory( locator.getService( ILoggerFactory.class ) ); - } - - public Slf4jLoggerFactory setLoggerFactory( ILoggerFactory factory ) - { - this.factory = factory; - return this; - } - - public Logger getLogger( String name ) - { - org.slf4j.Logger logger = getFactory().getLogger( name ); - if ( logger instanceof LocationAwareLogger ) - { - return new Slf4jLoggerEx( (LocationAwareLogger) logger ); - } - return new Slf4jLogger( logger ); - } - - private ILoggerFactory getFactory() - { - if ( factory == null ) - { - factory = org.slf4j.LoggerFactory.getILoggerFactory(); - } - return factory; - } - - private static final class Slf4jLogger - implements Logger - { - - private final org.slf4j.Logger logger; - - public Slf4jLogger( org.slf4j.Logger logger ) - { - this.logger = logger; - } - - public boolean isDebugEnabled() - { - return logger.isDebugEnabled(); - } - - public void debug( String msg ) - { - logger.debug( msg ); - } - - public void debug( String msg, Throwable error ) - { - logger.debug( msg, error ); - } - - public boolean isWarnEnabled() - { - return logger.isWarnEnabled(); - } - - public void warn( String msg ) - { - logger.warn( msg ); - } - - public void warn( String msg, Throwable error ) - { - logger.warn( msg, error ); - } - - } - - private static final class Slf4jLoggerEx - implements Logger - { - - private static final String FQCN = Slf4jLoggerEx.class.getName(); - - private final LocationAwareLogger logger; - - public Slf4jLoggerEx( LocationAwareLogger logger ) - { - this.logger = logger; - } - - public boolean isDebugEnabled() - { - return logger.isDebugEnabled(); - } - - public void debug( String msg ) - { - logger.log( null, FQCN, LocationAwareLogger.DEBUG_INT, msg, null, null ); - } - - public void debug( String msg, Throwable error ) - { - logger.log( null, FQCN, LocationAwareLogger.DEBUG_INT, msg, null, error ); - } - - public boolean isWarnEnabled() - { - return logger.isWarnEnabled(); - } - - public void warn( String msg ) - { - logger.log( null, FQCN, LocationAwareLogger.WARN_INT, msg, null, null ); - } - - public void warn( String msg, Throwable error ) - { - logger.log( null, FQCN, LocationAwareLogger.WARN_INT, msg, null, error ); - } - - } - -} http://git-wip-us.apache.org/repos/asf/maven-resolver/blob/3a1b8ae0/aether-impl/src/main/java/org/eclipse/aether/internal/impl/slf4j/package-info.java ---------------------------------------------------------------------- diff --git a/aether-impl/src/main/java/org/eclipse/aether/internal/impl/slf4j/package-info.java b/aether-impl/src/main/java/org/eclipse/aether/internal/impl/slf4j/package-info.java deleted file mode 100644 index 307c22e..0000000 --- a/aether-impl/src/main/java/org/eclipse/aether/internal/impl/slf4j/package-info.java +++ /dev/null @@ -1,24 +0,0 @@ -// CHECKSTYLE_OFF: RegexpHeader -/* - * 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. - */ -/** - * The integration with the logging framework <a href="http://www.slf4j.org/" target="_blank">SLF4J</a>. - */ -package org.eclipse.aether.internal.impl.slf4j; - http://git-wip-us.apache.org/repos/asf/maven-resolver/blob/3a1b8ae0/aether-impl/src/site/site.xml ---------------------------------------------------------------------- diff --git a/aether-impl/src/site/site.xml b/aether-impl/src/site/site.xml deleted file mode 100644 index 946c950..0000000 --- a/aether-impl/src/site/site.xml +++ /dev/null @@ -1,37 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> - -<!-- -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. ---> - -<project xmlns="http://maven.apache.org/DECORATION/1.0.0" - xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" - xsi:schemaLocation="http://maven.apache.org/DECORATION/1.0.0 http://maven.apache.org/xsd/decoration-1.0.0.xsd" - name="Implementation"> - <body> - <menu name="Overview"> - <item name="Introduction" href="index.html"/> - <item name="JavaDocs" href="apidocs/index.html"/> - <item name="Source Xref" href="xref/index.html"/> - <!--item name="FAQ" href="faq.html"/--> - </menu> - - <menu ref="parent"/> - <menu ref="reports"/> - </body> -</project> \ No newline at end of file http://git-wip-us.apache.org/repos/asf/maven-resolver/blob/3a1b8ae0/aether-impl/src/test/java/org/eclipse/aether/impl/DefaultServiceLocatorTest.java ---------------------------------------------------------------------- diff --git a/aether-impl/src/test/java/org/eclipse/aether/impl/DefaultServiceLocatorTest.java b/aether-impl/src/test/java/org/eclipse/aether/impl/DefaultServiceLocatorTest.java deleted file mode 100644 index 657b4ac..0000000 --- a/aether-impl/src/test/java/org/eclipse/aether/impl/DefaultServiceLocatorTest.java +++ /dev/null @@ -1,103 +0,0 @@ -package org.eclipse.aether.impl; - -/* - * 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 static org.junit.Assert.*; - -import java.util.Arrays; -import java.util.List; - -import org.eclipse.aether.RepositorySystem; -import org.eclipse.aether.impl.ArtifactDescriptorReader; -import org.eclipse.aether.impl.DefaultServiceLocator; -import org.eclipse.aether.impl.VersionRangeResolver; -import org.eclipse.aether.impl.VersionResolver; -import org.eclipse.aether.spi.locator.Service; -import org.eclipse.aether.spi.locator.ServiceLocator; -import org.junit.Test; - -/** - */ -public class DefaultServiceLocatorTest -{ - - @Test - public void testGetRepositorySystem() - { - DefaultServiceLocator locator = new DefaultServiceLocator(); - locator.addService( ArtifactDescriptorReader.class, StubArtifactDescriptorReader.class ); - locator.addService( VersionResolver.class, StubVersionResolver.class ); - locator.addService( VersionRangeResolver.class, StubVersionRangeResolver.class ); - - RepositorySystem repoSys = locator.getService( RepositorySystem.class ); - assertNotNull( repoSys ); - } - - @Test - public void testGetServicesUnmodifiable() - { - DefaultServiceLocator locator = new DefaultServiceLocator(); - locator.setServices( String.class, "one", "two" ); - List<String> services = locator.getServices( String.class ); - assertNotNull( services ); - try - { - services.set( 0, "fail" ); - fail( "service list is modifable" ); - } - catch ( UnsupportedOperationException e ) - { - // expected - } - } - - @Test - public void testSetInstancesAddClass() - { - DefaultServiceLocator locator = new DefaultServiceLocator(); - locator.setServices( String.class, "one", "two" ); - locator.addService( String.class, String.class ); - assertEquals( Arrays.asList( "one", "two", "" ), locator.getServices( String.class ) ); - } - - @Test - public void testInitService() - { - DefaultServiceLocator locator = new DefaultServiceLocator(); - locator.setService( DummyService.class, DummyService.class ); - DummyService service = locator.getService( DummyService.class ); - assertNotNull( service ); - assertNotNull( service.locator ); - } - - private static class DummyService - implements Service - { - - public ServiceLocator locator; - - public void initService( ServiceLocator locator ) - { - this.locator = locator; - } - - } - -} http://git-wip-us.apache.org/repos/asf/maven-resolver/blob/3a1b8ae0/aether-impl/src/test/java/org/eclipse/aether/impl/StubArtifactDescriptorReader.java ---------------------------------------------------------------------- diff --git a/aether-impl/src/test/java/org/eclipse/aether/impl/StubArtifactDescriptorReader.java b/aether-impl/src/test/java/org/eclipse/aether/impl/StubArtifactDescriptorReader.java deleted file mode 100644 index a5e650f..0000000 --- a/aether-impl/src/test/java/org/eclipse/aether/impl/StubArtifactDescriptorReader.java +++ /dev/null @@ -1,40 +0,0 @@ -package org.eclipse.aether.impl; - -/* - * 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.RepositorySystemSession; -import org.eclipse.aether.impl.ArtifactDescriptorReader; -import org.eclipse.aether.resolution.ArtifactDescriptorException; -import org.eclipse.aether.resolution.ArtifactDescriptorRequest; -import org.eclipse.aether.resolution.ArtifactDescriptorResult; - -public class StubArtifactDescriptorReader - implements ArtifactDescriptorReader -{ - - public ArtifactDescriptorResult readArtifactDescriptor( RepositorySystemSession session, - ArtifactDescriptorRequest request ) - throws ArtifactDescriptorException - { - ArtifactDescriptorResult result = new ArtifactDescriptorResult( request ); - return result; - } - -} http://git-wip-us.apache.org/repos/asf/maven-resolver/blob/3a1b8ae0/aether-impl/src/test/java/org/eclipse/aether/impl/StubVersionRangeResolver.java ---------------------------------------------------------------------- diff --git a/aether-impl/src/test/java/org/eclipse/aether/impl/StubVersionRangeResolver.java b/aether-impl/src/test/java/org/eclipse/aether/impl/StubVersionRangeResolver.java deleted file mode 100644 index 81e000e..0000000 --- a/aether-impl/src/test/java/org/eclipse/aether/impl/StubVersionRangeResolver.java +++ /dev/null @@ -1,39 +0,0 @@ -package org.eclipse.aether.impl; - -/* - * 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.RepositorySystemSession; -import org.eclipse.aether.impl.VersionRangeResolver; -import org.eclipse.aether.resolution.VersionRangeRequest; -import org.eclipse.aether.resolution.VersionRangeResolutionException; -import org.eclipse.aether.resolution.VersionRangeResult; - -public class StubVersionRangeResolver - implements VersionRangeResolver -{ - - public VersionRangeResult resolveVersionRange( RepositorySystemSession session, VersionRangeRequest request ) - throws VersionRangeResolutionException - { - VersionRangeResult result = new VersionRangeResult( request ); - return result; - } - -} http://git-wip-us.apache.org/repos/asf/maven-resolver/blob/3a1b8ae0/aether-impl/src/test/java/org/eclipse/aether/impl/StubVersionResolver.java ---------------------------------------------------------------------- diff --git a/aether-impl/src/test/java/org/eclipse/aether/impl/StubVersionResolver.java b/aether-impl/src/test/java/org/eclipse/aether/impl/StubVersionResolver.java deleted file mode 100644 index f59fa11..0000000 --- a/aether-impl/src/test/java/org/eclipse/aether/impl/StubVersionResolver.java +++ /dev/null @@ -1,39 +0,0 @@ -package org.eclipse.aether.impl; - -/* - * 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.RepositorySystemSession; -import org.eclipse.aether.impl.VersionResolver; -import org.eclipse.aether.resolution.VersionRequest; -import org.eclipse.aether.resolution.VersionResolutionException; -import org.eclipse.aether.resolution.VersionResult; - -public class StubVersionResolver - implements VersionResolver -{ - - public VersionResult resolveVersion( RepositorySystemSession session, VersionRequest request ) - throws VersionResolutionException - { - VersionResult result = new VersionResult( request ); - return result; - } - -} http://git-wip-us.apache.org/repos/asf/maven-resolver/blob/3a1b8ae0/aether-impl/src/test/java/org/eclipse/aether/impl/guice/AetherModuleTest.java ---------------------------------------------------------------------- diff --git a/aether-impl/src/test/java/org/eclipse/aether/impl/guice/AetherModuleTest.java b/aether-impl/src/test/java/org/eclipse/aether/impl/guice/AetherModuleTest.java deleted file mode 100644 index efcda19..0000000 --- a/aether-impl/src/test/java/org/eclipse/aether/impl/guice/AetherModuleTest.java +++ /dev/null @@ -1,85 +0,0 @@ -package org.eclipse.aether.impl.guice; - -/* - * 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 static org.junit.Assert.*; - -import java.util.Collections; -import java.util.Set; - -import org.eclipse.aether.RepositorySystem; -import org.eclipse.aether.impl.ArtifactDescriptorReader; -import org.eclipse.aether.impl.MetadataGeneratorFactory; -import org.eclipse.aether.impl.StubArtifactDescriptorReader; -import org.eclipse.aether.impl.StubVersionRangeResolver; -import org.eclipse.aether.impl.StubVersionResolver; -import org.eclipse.aether.impl.VersionRangeResolver; -import org.eclipse.aether.impl.VersionResolver; -import org.eclipse.aether.spi.connector.RepositoryConnectorFactory; -import org.eclipse.aether.spi.connector.transport.TransporterFactory; -import org.junit.Test; - -import com.google.inject.AbstractModule; -import com.google.inject.Guice; -import com.google.inject.Provides; - -public class AetherModuleTest -{ - - @Test - public void testModuleCompleteness() - { - assertNotNull( Guice.createInjector( new SystemModule() ).getInstance( RepositorySystem.class ) ); - } - - static class SystemModule - extends AbstractModule - { - - @Override - protected void configure() - { - install( new AetherModule() ); - bind( ArtifactDescriptorReader.class ).to( StubArtifactDescriptorReader.class ); - bind( VersionRangeResolver.class ).to( StubVersionRangeResolver.class ); - bind( VersionResolver.class ).to( StubVersionResolver.class ); - } - - @Provides - public Set<MetadataGeneratorFactory> metadataGeneratorFactories() - { - return Collections.emptySet(); - } - - @Provides - public Set<RepositoryConnectorFactory> repositoryConnectorFactories() - { - return Collections.emptySet(); - } - - @Provides - public Set<TransporterFactory> transporterFactories() - { - return Collections.emptySet(); - } - - } - -} http://git-wip-us.apache.org/repos/asf/maven-resolver/blob/3a1b8ae0/aether-impl/src/test/java/org/eclipse/aether/internal/impl/DataPoolTest.java ---------------------------------------------------------------------- diff --git a/aether-impl/src/test/java/org/eclipse/aether/internal/impl/DataPoolTest.java b/aether-impl/src/test/java/org/eclipse/aether/internal/impl/DataPoolTest.java deleted file mode 100644 index 43651f6..0000000 --- a/aether-impl/src/test/java/org/eclipse/aether/internal/impl/DataPoolTest.java +++ /dev/null @@ -1,66 +0,0 @@ -package org.eclipse.aether.internal.impl; - -/* - * 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 static org.junit.Assert.*; - -import org.eclipse.aether.DefaultRepositorySystemSession; -import org.eclipse.aether.artifact.DefaultArtifact; -import org.eclipse.aether.graph.Dependency; -import org.eclipse.aether.repository.RemoteRepository; -import org.eclipse.aether.resolution.ArtifactDescriptorRequest; -import org.eclipse.aether.resolution.ArtifactDescriptorResult; -import org.junit.Test; - -public class DataPoolTest -{ - - private DataPool newDataPool() - { - return new DataPool( new DefaultRepositorySystemSession() ); - } - - @Test - public void testArtifactDescriptorCaching() - { - ArtifactDescriptorRequest request = new ArtifactDescriptorRequest(); - request.setArtifact( new DefaultArtifact( "gid:aid:1" ) ); - ArtifactDescriptorResult result = new ArtifactDescriptorResult( request ); - result.setArtifact( new DefaultArtifact( "gid:aid:2" ) ); - result.addRelocation( request.getArtifact() ); - result.addDependency( new Dependency( new DefaultArtifact( "gid:dep:3" ), "compile" ) ); - result.addManagedDependency( new Dependency( new DefaultArtifact( "gid:mdep:3" ), "runtime" ) ); - result.addRepository( new RemoteRepository.Builder( "test", "default", "http://localhost" ).build() ); - result.addAlias( new DefaultArtifact( "gid:alias:4" ) ); - - DataPool pool = newDataPool(); - Object key = pool.toKey( request ); - pool.putDescriptor( key, result ); - ArtifactDescriptorResult cached = pool.getDescriptor( key, request ); - assertNotNull( cached ); - assertEquals( result.getArtifact(), cached.getArtifact() ); - assertEquals( result.getRelocations(), cached.getRelocations() ); - assertEquals( result.getDependencies(), cached.getDependencies() ); - assertEquals( result.getManagedDependencies(), cached.getManagedDependencies() ); - assertEquals( result.getRepositories(), cached.getRepositories() ); - assertEquals( result.getAliases(), cached.getAliases() ); - } - -} http://git-wip-us.apache.org/repos/asf/maven-resolver/blob/3a1b8ae0/aether-impl/src/test/java/org/eclipse/aether/internal/impl/DefaultArtifactResolverTest.java ---------------------------------------------------------------------- diff --git a/aether-impl/src/test/java/org/eclipse/aether/internal/impl/DefaultArtifactResolverTest.java b/aether-impl/src/test/java/org/eclipse/aether/internal/impl/DefaultArtifactResolverTest.java deleted file mode 100644 index f776e9c..0000000 --- a/aether-impl/src/test/java/org/eclipse/aether/internal/impl/DefaultArtifactResolverTest.java +++ /dev/null @@ -1,909 +0,0 @@ -package org.eclipse.aether.internal.impl; - -/* - * 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 static org.junit.Assert.*; - -import java.io.File; -import java.io.IOException; -import java.util.Arrays; -import java.util.Collection; -import java.util.HashMap; -import java.util.List; -import java.util.Map; - -import org.eclipse.aether.DefaultRepositorySystemSession; -import org.eclipse.aether.RepositoryEvent; -import org.eclipse.aether.RepositorySystemSession; -import org.eclipse.aether.RepositoryEvent.EventType; -import org.eclipse.aether.artifact.Artifact; -import org.eclipse.aether.artifact.ArtifactProperties; -import org.eclipse.aether.artifact.DefaultArtifact; -import org.eclipse.aether.impl.UpdateCheckManager; -import org.eclipse.aether.impl.VersionResolver; -import org.eclipse.aether.internal.impl.DefaultArtifactResolver; -import org.eclipse.aether.internal.impl.DefaultUpdateCheckManager; -import org.eclipse.aether.internal.test.util.TestFileProcessor; -import org.eclipse.aether.internal.test.util.TestFileUtils; -import org.eclipse.aether.internal.test.util.TestLocalRepositoryManager; -import org.eclipse.aether.internal.test.util.TestUtils; -import org.eclipse.aether.metadata.Metadata; -import org.eclipse.aether.repository.LocalArtifactRegistration; -import org.eclipse.aether.repository.LocalArtifactRequest; -import org.eclipse.aether.repository.LocalArtifactResult; -import org.eclipse.aether.repository.LocalMetadataRegistration; -import org.eclipse.aether.repository.LocalMetadataRequest; -import org.eclipse.aether.repository.LocalMetadataResult; -import org.eclipse.aether.repository.LocalRepository; -import org.eclipse.aether.repository.LocalRepositoryManager; -import org.eclipse.aether.repository.RemoteRepository; -import org.eclipse.aether.repository.RepositoryPolicy; -import org.eclipse.aether.repository.WorkspaceReader; -import org.eclipse.aether.repository.WorkspaceRepository; -import org.eclipse.aether.resolution.ArtifactRequest; -import org.eclipse.aether.resolution.ArtifactResolutionException; -import org.eclipse.aether.resolution.ArtifactResult; -import org.eclipse.aether.resolution.VersionRequest; -import org.eclipse.aether.resolution.VersionResolutionException; -import org.eclipse.aether.resolution.VersionResult; -import org.eclipse.aether.spi.connector.ArtifactDownload; -import org.eclipse.aether.spi.connector.MetadataDownload; -import org.eclipse.aether.transfer.ArtifactNotFoundException; -import org.eclipse.aether.transfer.ArtifactTransferException; -import org.eclipse.aether.util.repository.SimpleResolutionErrorPolicy; -import org.junit.After; -import org.junit.Before; -import org.junit.Test; - -/** - */ -public class DefaultArtifactResolverTest -{ - private DefaultArtifactResolver resolver; - - private DefaultRepositorySystemSession session; - - private TestLocalRepositoryManager lrm; - - private StubRepositoryConnectorProvider repositoryConnectorProvider; - - private Artifact artifact; - - private RecordingRepositoryConnector connector; - - @Before - public void setup() - throws IOException - { - UpdateCheckManager updateCheckManager = new StaticUpdateCheckManager( true ); - repositoryConnectorProvider = new StubRepositoryConnectorProvider(); - VersionResolver versionResolver = new StubVersionResolver(); - session = TestUtils.newSession(); - lrm = (TestLocalRepositoryManager) session.getLocalRepositoryManager(); - resolver = new DefaultArtifactResolver(); - resolver.setFileProcessor( new TestFileProcessor() ); - resolver.setRepositoryEventDispatcher( new StubRepositoryEventDispatcher() ); - resolver.setVersionResolver( versionResolver ); - resolver.setUpdateCheckManager( updateCheckManager ); - resolver.setRepositoryConnectorProvider( repositoryConnectorProvider ); - resolver.setRemoteRepositoryManager( new StubRemoteRepositoryManager() ); - resolver.setSyncContextFactory( new StubSyncContextFactory() ); - resolver.setOfflineController( new DefaultOfflineController() ); - - artifact = new DefaultArtifact( "gid", "aid", "", "ext", "ver" ); - - connector = new RecordingRepositoryConnector(); - repositoryConnectorProvider.setConnector( connector ); - } - - @After - public void teardown() - throws Exception - { - if ( session.getLocalRepository() != null ) - { - TestFileUtils.deleteFile( session.getLocalRepository().getBasedir() ); - } - } - - @Test - public void testResolveLocalArtifactSuccessful() - throws IOException, ArtifactResolutionException - { - File tmpFile = TestFileUtils.createTempFile( "tmp" ); - Map<String, String> properties = new HashMap<String, String>(); - properties.put( ArtifactProperties.LOCAL_PATH, tmpFile.getAbsolutePath() ); - artifact = artifact.setProperties( properties ); - - ArtifactRequest request = new ArtifactRequest( artifact, null, "" ); - ArtifactResult result = resolver.resolveArtifact( session, request ); - - assertTrue( result.getExceptions().isEmpty() ); - - Artifact resolved = result.getArtifact(); - assertNotNull( resolved.getFile() ); - resolved = resolved.setFile( null ); - - assertEquals( artifact, resolved ); - } - - @Test - public void testResolveLocalArtifactUnsuccessful() - throws IOException, ArtifactResolutionException - { - File tmpFile = TestFileUtils.createTempFile( "tmp" ); - Map<String, String> properties = new HashMap<String, String>(); - properties.put( ArtifactProperties.LOCAL_PATH, tmpFile.getAbsolutePath() ); - artifact = artifact.setProperties( properties ); - - tmpFile.delete(); - - ArtifactRequest request = new ArtifactRequest( artifact, null, "" ); - - try - { - resolver.resolveArtifact( session, request ); - fail( "expected exception" ); - } - catch ( ArtifactResolutionException e ) - { - assertNotNull( e.getResults() ); - assertEquals( 1, e.getResults().size() ); - - ArtifactResult result = e.getResults().get( 0 ); - - assertSame( request, result.getRequest() ); - - assertFalse( result.getExceptions().isEmpty() ); - assertTrue( result.getExceptions().get( 0 ) instanceof ArtifactNotFoundException ); - - Artifact resolved = result.getArtifact(); - assertNull( resolved ); - } - - } - - @Test - public void testResolveRemoteArtifact() - throws IOException, ArtifactResolutionException - { - connector.setExpectGet( artifact ); - - ArtifactRequest request = new ArtifactRequest( artifact, null, "" ); - request.addRepository( new RemoteRepository.Builder( "id", "default", "file:///" ).build() ); - - ArtifactResult result = resolver.resolveArtifact( session, request ); - - assertTrue( result.getExceptions().isEmpty() ); - - Artifact resolved = result.getArtifact(); - assertNotNull( resolved.getFile() ); - - resolved = resolved.setFile( null ); - assertEquals( artifact, resolved ); - - connector.assertSeenExpected(); - } - - @Test - public void testResolveRemoteArtifactUnsuccessful() - throws IOException, ArtifactResolutionException - { - RecordingRepositoryConnector connector = new RecordingRepositoryConnector() - { - - @Override - public void get( Collection<? extends ArtifactDownload> artifactDownloads, - Collection<? extends MetadataDownload> metadataDownloads ) - { - super.get( artifactDownloads, metadataDownloads ); - ArtifactDownload download = artifactDownloads.iterator().next(); - ArtifactTransferException exception = - new ArtifactNotFoundException( download.getArtifact(), null, "not found" ); - download.setException( exception ); - } - - }; - - connector.setExpectGet( artifact ); - repositoryConnectorProvider.setConnector( connector ); - - ArtifactRequest request = new ArtifactRequest( artifact, null, "" ); - request.addRepository( new RemoteRepository.Builder( "id", "default", "file:///" ).build() ); - - try - { - resolver.resolveArtifact( session, request ); - fail( "expected exception" ); - } - catch ( ArtifactResolutionException e ) - { - connector.assertSeenExpected(); - assertNotNull( e.getResults() ); - assertEquals( 1, e.getResults().size() ); - - ArtifactResult result = e.getResults().get( 0 ); - - assertSame( request, result.getRequest() ); - - assertFalse( result.getExceptions().isEmpty() ); - assertTrue( result.getExceptions().get( 0 ) instanceof ArtifactNotFoundException ); - - Artifact resolved = result.getArtifact(); - assertNull( resolved ); - } - - } - - @Test - public void testArtifactNotFoundCache() - throws Exception - { - RecordingRepositoryConnector connector = new RecordingRepositoryConnector() - { - @Override - public void get( Collection<? extends ArtifactDownload> artifactDownloads, - Collection<? extends MetadataDownload> metadataDownloads ) - { - super.get( artifactDownloads, metadataDownloads ); - for ( ArtifactDownload download : artifactDownloads ) - { - download.getFile().delete(); - ArtifactTransferException exception = - new ArtifactNotFoundException( download.getArtifact(), null, "not found" ); - download.setException( exception ); - } - } - }; - - repositoryConnectorProvider.setConnector( connector ); - resolver.setUpdateCheckManager( new DefaultUpdateCheckManager().setUpdatePolicyAnalyzer( new DefaultUpdatePolicyAnalyzer() ) ); - - session.setResolutionErrorPolicy( new SimpleResolutionErrorPolicy( true, false ) ); - session.setUpdatePolicy( RepositoryPolicy.UPDATE_POLICY_NEVER ); - - RemoteRepository remoteRepo = new RemoteRepository.Builder( "id", "default", "file:///" ).build(); - - Artifact artifact1 = artifact; - Artifact artifact2 = artifact.setVersion( "ver2" ); - - ArtifactRequest request1 = new ArtifactRequest( artifact1, Arrays.asList( remoteRepo ), "" ); - ArtifactRequest request2 = new ArtifactRequest( artifact2, Arrays.asList( remoteRepo ), "" ); - - connector.setExpectGet( new Artifact[] { artifact1, artifact2 } ); - try - { - resolver.resolveArtifacts( session, Arrays.asList( request1, request2 ) ); - fail( "expected exception" ); - } - catch ( ArtifactResolutionException e ) - { - connector.assertSeenExpected(); - } - - TestFileUtils.writeString( new File( lrm.getRepository().getBasedir(), lrm.getPathForLocalArtifact( artifact2 ) ), - "artifact" ); - lrm.setArtifactAvailability( artifact2, false ); - - DefaultUpdateCheckManagerTest.resetSessionData( session ); - connector.resetActual(); - connector.setExpectGet( new Artifact[0] ); - try - { - resolver.resolveArtifacts( session, Arrays.asList( request1, request2 ) ); - fail( "expected exception" ); - } - catch ( ArtifactResolutionException e ) - { - connector.assertSeenExpected(); - for ( ArtifactResult result : e.getResults() ) - { - Throwable t = result.getExceptions().get( 0 ); - assertEquals( t.toString(), true, t instanceof ArtifactNotFoundException ); - assertEquals( t.toString(), true, t.getMessage().contains( "cached" ) ); - } - } - } - - @Test - public void testResolveFromWorkspace() - throws IOException, ArtifactResolutionException - { - WorkspaceReader workspace = new WorkspaceReader() - { - - public WorkspaceRepository getRepository() - { - return new WorkspaceRepository( "default" ); - } - - public List<String> findVersions( Artifact artifact ) - { - return Arrays.asList( artifact.getVersion() ); - } - - public File findArtifact( Artifact artifact ) - { - try - { - return TestFileUtils.createTempFile( artifact.toString() ); - } - catch ( IOException e ) - { - throw new RuntimeException( e.getMessage(), e ); - } - } - }; - session.setWorkspaceReader( workspace ); - - ArtifactRequest request = new ArtifactRequest( artifact, null, "" ); - request.addRepository( new RemoteRepository.Builder( "id", "default", "file:///" ).build() ); - - ArtifactResult result = resolver.resolveArtifact( session, request ); - - assertTrue( result.getExceptions().isEmpty() ); - - Artifact resolved = result.getArtifact(); - assertNotNull( resolved.getFile() ); - - assertEquals( resolved.toString(), TestFileUtils.readString( resolved.getFile() ) ); - - resolved = resolved.setFile( null ); - assertEquals( artifact, resolved ); - - connector.assertSeenExpected(); - } - - @Test - public void testResolveFromWorkspaceFallbackToRepository() - throws IOException, ArtifactResolutionException - { - WorkspaceReader workspace = new WorkspaceReader() - { - - public WorkspaceRepository getRepository() - { - return new WorkspaceRepository( "default" ); - } - - public List<String> findVersions( Artifact artifact ) - { - return Arrays.asList( artifact.getVersion() ); - } - - public File findArtifact( Artifact artifact ) - { - return null; - } - }; - session.setWorkspaceReader( workspace ); - - connector.setExpectGet( artifact ); - repositoryConnectorProvider.setConnector( connector ); - - ArtifactRequest request = new ArtifactRequest( artifact, null, "" ); - request.addRepository( new RemoteRepository.Builder( "id", "default", "file:///" ).build() ); - - ArtifactResult result = resolver.resolveArtifact( session, request ); - - assertTrue( "exception on resolveArtifact", result.getExceptions().isEmpty() ); - - Artifact resolved = result.getArtifact(); - assertNotNull( resolved.getFile() ); - - resolved = resolved.setFile( null ); - assertEquals( artifact, resolved ); - - connector.assertSeenExpected(); - } - - @Test - public void testRepositoryEventsSuccessfulLocal() - throws ArtifactResolutionException, IOException - { - RecordingRepositoryListener listener = new RecordingRepositoryListener(); - session.setRepositoryListener( listener ); - - File tmpFile = TestFileUtils.createTempFile( "tmp" ); - Map<String, String> properties = new HashMap<String, String>(); - properties.put( ArtifactProperties.LOCAL_PATH, tmpFile.getAbsolutePath() ); - artifact = artifact.setProperties( properties ); - - ArtifactRequest request = new ArtifactRequest( artifact, null, "" ); - resolver.resolveArtifact( session, request ); - - List<RepositoryEvent> events = listener.getEvents(); - assertEquals( 2, events.size() ); - RepositoryEvent event = events.get( 0 ); - assertEquals( EventType.ARTIFACT_RESOLVING, event.getType() ); - assertNull( event.getException() ); - assertEquals( artifact, event.getArtifact() ); - - event = events.get( 1 ); - assertEquals( EventType.ARTIFACT_RESOLVED, event.getType() ); - assertNull( event.getException() ); - assertEquals( artifact, event.getArtifact().setFile( null ) ); - } - - @Test - public void testRepositoryEventsUnsuccessfulLocal() - throws IOException - { - RecordingRepositoryListener listener = new RecordingRepositoryListener(); - session.setRepositoryListener( listener ); - - Map<String, String> properties = new HashMap<String, String>(); - properties.put( ArtifactProperties.LOCAL_PATH, "doesnotexist" ); - artifact = artifact.setProperties( properties ); - - ArtifactRequest request = new ArtifactRequest( artifact, null, "" ); - try - { - resolver.resolveArtifact( session, request ); - fail( "expected exception" ); - } - catch ( ArtifactResolutionException e ) - { - } - - List<RepositoryEvent> events = listener.getEvents(); - assertEquals( 2, events.size() ); - - RepositoryEvent event = events.get( 0 ); - assertEquals( artifact, event.getArtifact() ); - assertEquals( EventType.ARTIFACT_RESOLVING, event.getType() ); - - event = events.get( 1 ); - assertEquals( artifact, event.getArtifact() ); - assertEquals( EventType.ARTIFACT_RESOLVED, event.getType() ); - assertNotNull( event.getException() ); - assertEquals( 1, event.getExceptions().size() ); - - } - - @Test - public void testRepositoryEventsSuccessfulRemote() - throws ArtifactResolutionException - { - RecordingRepositoryListener listener = new RecordingRepositoryListener(); - session.setRepositoryListener( listener ); - - ArtifactRequest request = new ArtifactRequest( artifact, null, "" ); - request.addRepository( new RemoteRepository.Builder( "id", "default", "file:///" ).build() ); - - resolver.resolveArtifact( session, request ); - - List<RepositoryEvent> events = listener.getEvents(); - assertEquals( events.toString(), 4, events.size() ); - RepositoryEvent event = events.get( 0 ); - assertEquals( EventType.ARTIFACT_RESOLVING, event.getType() ); - assertNull( event.getException() ); - assertEquals( artifact, event.getArtifact() ); - - event = events.get( 1 ); - assertEquals( EventType.ARTIFACT_DOWNLOADING, event.getType() ); - assertNull( event.getException() ); - assertEquals( artifact, event.getArtifact().setFile( null ) ); - - event = events.get( 2 ); - assertEquals( EventType.ARTIFACT_DOWNLOADED, event.getType() ); - assertNull( event.getException() ); - assertEquals( artifact, event.getArtifact().setFile( null ) ); - - event = events.get( 3 ); - assertEquals( EventType.ARTIFACT_RESOLVED, event.getType() ); - assertNull( event.getException() ); - assertEquals( artifact, event.getArtifact().setFile( null ) ); - } - - @Test - public void testRepositoryEventsUnsuccessfulRemote() - throws IOException, ArtifactResolutionException - { - RecordingRepositoryConnector connector = new RecordingRepositoryConnector() - { - - @Override - public void get( Collection<? extends ArtifactDownload> artifactDownloads, - Collection<? extends MetadataDownload> metadataDownloads ) - { - super.get( artifactDownloads, metadataDownloads ); - ArtifactDownload download = artifactDownloads.iterator().next(); - ArtifactTransferException exception = - new ArtifactNotFoundException( download.getArtifact(), null, "not found" ); - download.setException( exception ); - } - - }; - repositoryConnectorProvider.setConnector( connector ); - - RecordingRepositoryListener listener = new RecordingRepositoryListener(); - session.setRepositoryListener( listener ); - - ArtifactRequest request = new ArtifactRequest( artifact, null, "" ); - request.addRepository( new RemoteRepository.Builder( "id", "default", "file:///" ).build() ); - - try - { - resolver.resolveArtifact( session, request ); - fail( "expected exception" ); - } - catch ( ArtifactResolutionException e ) - { - } - - List<RepositoryEvent> events = listener.getEvents(); - assertEquals( events.toString(), 4, events.size() ); - - RepositoryEvent event = events.get( 0 ); - assertEquals( artifact, event.getArtifact() ); - assertEquals( EventType.ARTIFACT_RESOLVING, event.getType() ); - - event = events.get( 1 ); - assertEquals( artifact, event.getArtifact() ); - assertEquals( EventType.ARTIFACT_DOWNLOADING, event.getType() ); - - event = events.get( 2 ); - assertEquals( artifact, event.getArtifact() ); - assertEquals( EventType.ARTIFACT_DOWNLOADED, event.getType() ); - assertNotNull( event.getException() ); - assertEquals( 1, event.getExceptions().size() ); - - event = events.get( 3 ); - assertEquals( artifact, event.getArtifact() ); - assertEquals( EventType.ARTIFACT_RESOLVED, event.getType() ); - assertNotNull( event.getException() ); - assertEquals( 1, event.getExceptions().size() ); - } - - @Test - public void testVersionResolverFails() - { - resolver.setVersionResolver( new VersionResolver() - { - - public VersionResult resolveVersion( RepositorySystemSession session, VersionRequest request ) - throws VersionResolutionException - { - throw new VersionResolutionException( new VersionResult( request ) ); - } - } ); - - ArtifactRequest request = new ArtifactRequest( artifact, null, "" ); - try - { - resolver.resolveArtifact( session, request ); - fail( "expected exception" ); - } - catch ( ArtifactResolutionException e ) - { - connector.assertSeenExpected(); - assertNotNull( e.getResults() ); - assertEquals( 1, e.getResults().size() ); - - ArtifactResult result = e.getResults().get( 0 ); - - assertSame( request, result.getRequest() ); - - assertFalse( result.getExceptions().isEmpty() ); - assertTrue( result.getExceptions().get( 0 ) instanceof VersionResolutionException ); - - Artifact resolved = result.getArtifact(); - assertNull( resolved ); - } - } - - @Test - public void testRepositoryEventsOnVersionResolverFail() - { - resolver.setVersionResolver( new VersionResolver() - { - - public VersionResult resolveVersion( RepositorySystemSession session, VersionRequest request ) - throws VersionResolutionException - { - throw new VersionResolutionException( new VersionResult( request ) ); - } - } ); - - RecordingRepositoryListener listener = new RecordingRepositoryListener(); - session.setRepositoryListener( listener ); - - ArtifactRequest request = new ArtifactRequest( artifact, null, "" ); - try - { - resolver.resolveArtifact( session, request ); - fail( "expected exception" ); - } - catch ( ArtifactResolutionException e ) - { - } - - List<RepositoryEvent> events = listener.getEvents(); - assertEquals( 2, events.size() ); - - RepositoryEvent event = events.get( 0 ); - assertEquals( artifact, event.getArtifact() ); - assertEquals( EventType.ARTIFACT_RESOLVING, event.getType() ); - - event = events.get( 1 ); - assertEquals( artifact, event.getArtifact() ); - assertEquals( EventType.ARTIFACT_RESOLVED, event.getType() ); - assertNotNull( event.getException() ); - assertEquals( 1, event.getExceptions().size() ); - } - - @Test - public void testLocalArtifactAvailable() - throws ArtifactResolutionException - { - session.setLocalRepositoryManager( new LocalRepositoryManager() - { - - public LocalRepository getRepository() - { - return null; - } - - public String getPathForRemoteMetadata( Metadata metadata, RemoteRepository repository, String context ) - { - return null; - } - - public String getPathForRemoteArtifact( Artifact artifact, RemoteRepository repository, String context ) - { - return null; - } - - public String getPathForLocalMetadata( Metadata metadata ) - { - return null; - } - - public String getPathForLocalArtifact( Artifact artifact ) - { - return null; - } - - public LocalArtifactResult find( RepositorySystemSession session, LocalArtifactRequest request ) - { - - LocalArtifactResult result = new LocalArtifactResult( request ); - result.setAvailable( true ); - try - { - result.setFile( TestFileUtils.createTempFile( "" ) ); - } - catch ( IOException e ) - { - e.printStackTrace(); - } - return result; - } - - public void add( RepositorySystemSession session, LocalArtifactRegistration request ) - { - } - - public LocalMetadataResult find( RepositorySystemSession session, LocalMetadataRequest request ) - { - LocalMetadataResult result = new LocalMetadataResult( request ); - try - { - result.setFile( TestFileUtils.createTempFile( "" ) ); - } - catch ( IOException e ) - { - e.printStackTrace(); - } - return result; - } - - public void add( RepositorySystemSession session, LocalMetadataRegistration request ) - { - } - } ); - - ArtifactRequest request = new ArtifactRequest( artifact, null, "" ); - request.addRepository( new RemoteRepository.Builder( "id", "default", "file:///" ).build() ); - - ArtifactResult result = resolver.resolveArtifact( session, request ); - - assertTrue( result.getExceptions().isEmpty() ); - - Artifact resolved = result.getArtifact(); - assertNotNull( resolved.getFile() ); - - resolved = resolved.setFile( null ); - assertEquals( artifact, resolved ); - - } - - @Test - public void testFindInLocalRepositoryWhenVersionWasFoundInLocalRepository() - throws ArtifactResolutionException - { - session.setLocalRepositoryManager( new LocalRepositoryManager() - { - - public LocalRepository getRepository() - { - return null; - } - - public String getPathForRemoteMetadata( Metadata metadata, RemoteRepository repository, String context ) - { - return null; - } - - public String getPathForRemoteArtifact( Artifact artifact, RemoteRepository repository, String context ) - { - return null; - } - - public String getPathForLocalMetadata( Metadata metadata ) - { - return null; - } - - public String getPathForLocalArtifact( Artifact artifact ) - { - return null; - } - - public LocalArtifactResult find( RepositorySystemSession session, LocalArtifactRequest request ) - { - - LocalArtifactResult result = new LocalArtifactResult( request ); - result.setAvailable( false ); - try - { - result.setFile( TestFileUtils.createTempFile( "" ) ); - } - catch ( IOException e ) - { - e.printStackTrace(); - } - return result; - } - - public void add( RepositorySystemSession session, LocalArtifactRegistration request ) - { - } - - public LocalMetadataResult find( RepositorySystemSession session, LocalMetadataRequest request ) - { - LocalMetadataResult result = new LocalMetadataResult( request ); - return result; - } - - public void add( RepositorySystemSession session, LocalMetadataRegistration request ) - { - } - } ); - ArtifactRequest request = new ArtifactRequest( artifact, null, "" ); - request.addRepository( new RemoteRepository.Builder( "id", "default", "file:///" ).build() ); - - resolver.setVersionResolver( new VersionResolver() - { - - public VersionResult resolveVersion( RepositorySystemSession session, VersionRequest request ) - throws VersionResolutionException - { - return new VersionResult( request ).setRepository( new LocalRepository( "id" ) ).setVersion( request.getArtifact().getVersion() ); - } - } ); - ArtifactResult result = resolver.resolveArtifact( session, request ); - - assertTrue( result.getExceptions().isEmpty() ); - - Artifact resolved = result.getArtifact(); - assertNotNull( resolved.getFile() ); - - resolved = resolved.setFile( null ); - assertEquals( artifact, resolved ); - } - - @Test - public void testFindInLocalRepositoryWhenVersionRangeWasResolvedFromLocalRepository() - throws ArtifactResolutionException - { - session.setLocalRepositoryManager( new LocalRepositoryManager() - { - - public LocalRepository getRepository() - { - return null; - } - - public String getPathForRemoteMetadata( Metadata metadata, RemoteRepository repository, String context ) - { - return null; - } - - public String getPathForRemoteArtifact( Artifact artifact, RemoteRepository repository, String context ) - { - return null; - } - - public String getPathForLocalMetadata( Metadata metadata ) - { - return null; - } - - public String getPathForLocalArtifact( Artifact artifact ) - { - return null; - } - - public LocalArtifactResult find( RepositorySystemSession session, LocalArtifactRequest request ) - { - - LocalArtifactResult result = new LocalArtifactResult( request ); - result.setAvailable( false ); - try - { - result.setFile( TestFileUtils.createTempFile( "" ) ); - } - catch ( IOException e ) - { - e.printStackTrace(); - } - return result; - } - - public void add( RepositorySystemSession session, LocalArtifactRegistration request ) - { - } - - public LocalMetadataResult find( RepositorySystemSession session, LocalMetadataRequest request ) - { - LocalMetadataResult result = new LocalMetadataResult( request ); - return result; - } - - public void add( RepositorySystemSession session, LocalMetadataRegistration request ) - { - } - - } ); - ArtifactRequest request = new ArtifactRequest( artifact, null, "" ); - - resolver.setVersionResolver( new VersionResolver() - { - - public VersionResult resolveVersion( RepositorySystemSession session, VersionRequest request ) - throws VersionResolutionException - { - return new VersionResult( request ).setVersion( request.getArtifact().getVersion() ); - } - } ); - ArtifactResult result = resolver.resolveArtifact( session, request ); - - assertTrue( result.getExceptions().isEmpty() ); - - Artifact resolved = result.getArtifact(); - assertNotNull( resolved.getFile() ); - - resolved = resolved.setFile( null ); - assertEquals( artifact, resolved ); - } - -} http://git-wip-us.apache.org/repos/asf/maven-resolver/blob/3a1b8ae0/aether-impl/src/test/java/org/eclipse/aether/internal/impl/DefaultChecksumPolicyProviderTest.java ---------------------------------------------------------------------- diff --git a/aether-impl/src/test/java/org/eclipse/aether/internal/impl/DefaultChecksumPolicyProviderTest.java b/aether-impl/src/test/java/org/eclipse/aether/internal/impl/DefaultChecksumPolicyProviderTest.java deleted file mode 100644 index 82318e5..0000000 --- a/aether-impl/src/test/java/org/eclipse/aether/internal/impl/DefaultChecksumPolicyProviderTest.java +++ /dev/null @@ -1,145 +0,0 @@ -package org.eclipse.aether.internal.impl; - -/* - * 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 static org.junit.Assert.*; - -import org.eclipse.aether.DefaultRepositorySystemSession; -import org.eclipse.aether.internal.test.util.TestUtils; -import org.eclipse.aether.repository.RemoteRepository; -import org.eclipse.aether.repository.RepositoryPolicy; -import org.eclipse.aether.spi.connector.checksum.ChecksumPolicy; -import org.eclipse.aether.transfer.TransferResource; -import org.junit.After; -import org.junit.Before; -import org.junit.Test; - -public class DefaultChecksumPolicyProviderTest -{ - - private static final String CHECKSUM_POLICY_UNKNOWN = "unknown"; - - private DefaultRepositorySystemSession session; - - private DefaultChecksumPolicyProvider provider; - - private RemoteRepository repository; - - private TransferResource resource; - - @Before - public void setup() - throws Exception - { - session = TestUtils.newSession(); - provider = new DefaultChecksumPolicyProvider(); - repository = new RemoteRepository.Builder( "test", "default", "file:/void" ).build(); - resource = new TransferResource( repository.getUrl(), "file.txt", null, null ); - } - - @After - public void teardown() - throws Exception - { - provider = null; - session = null; - repository = null; - resource = null; - } - - @Test - public void testNewChecksumPolicy_Fail() - { - ChecksumPolicy policy = - provider.newChecksumPolicy( session, repository, resource, RepositoryPolicy.CHECKSUM_POLICY_FAIL ); - assertNotNull( policy ); - assertEquals( FailChecksumPolicy.class, policy.getClass() ); - } - - @Test - public void testNewChecksumPolicy_Warn() - { - ChecksumPolicy policy = - provider.newChecksumPolicy( session, repository, resource, RepositoryPolicy.CHECKSUM_POLICY_WARN ); - assertNotNull( policy ); - assertEquals( WarnChecksumPolicy.class, policy.getClass() ); - } - - @Test - public void testNewChecksumPolicy_Ignore() - { - ChecksumPolicy policy = - provider.newChecksumPolicy( session, repository, resource, RepositoryPolicy.CHECKSUM_POLICY_IGNORE ); - assertNull( policy ); - } - - @Test - public void testNewChecksumPolicy_Unknown() - { - ChecksumPolicy policy = provider.newChecksumPolicy( session, repository, resource, CHECKSUM_POLICY_UNKNOWN ); - assertNotNull( policy ); - assertEquals( WarnChecksumPolicy.class, policy.getClass() ); - } - - @Test - public void testGetEffectiveChecksumPolicy_EqualPolicies() - { - String[] policies = - { RepositoryPolicy.CHECKSUM_POLICY_FAIL, RepositoryPolicy.CHECKSUM_POLICY_WARN, - RepositoryPolicy.CHECKSUM_POLICY_IGNORE, CHECKSUM_POLICY_UNKNOWN }; - for ( String policy : policies ) - { - assertEquals( policy, policy, provider.getEffectiveChecksumPolicy( session, policy, policy ) ); - } - } - - @Test - public void testGetEffectiveChecksumPolicy_DifferentPolicies() - { - String[][] testCases = - { { RepositoryPolicy.CHECKSUM_POLICY_WARN, RepositoryPolicy.CHECKSUM_POLICY_FAIL }, - { RepositoryPolicy.CHECKSUM_POLICY_IGNORE, RepositoryPolicy.CHECKSUM_POLICY_FAIL }, - { RepositoryPolicy.CHECKSUM_POLICY_IGNORE, RepositoryPolicy.CHECKSUM_POLICY_WARN } }; - for ( String[] testCase : testCases ) - { - assertEquals( testCase[0] + " vs " + testCase[1], testCase[0], - provider.getEffectiveChecksumPolicy( session, testCase[0], testCase[1] ) ); - assertEquals( testCase[0] + " vs " + testCase[1], testCase[0], - provider.getEffectiveChecksumPolicy( session, testCase[1], testCase[0] ) ); - } - } - - @Test - public void testGetEffectiveChecksumPolicy_UnknownPolicies() - { - String[][] testCases = - { { RepositoryPolicy.CHECKSUM_POLICY_WARN, RepositoryPolicy.CHECKSUM_POLICY_FAIL }, - { RepositoryPolicy.CHECKSUM_POLICY_WARN, RepositoryPolicy.CHECKSUM_POLICY_WARN }, - { RepositoryPolicy.CHECKSUM_POLICY_IGNORE, RepositoryPolicy.CHECKSUM_POLICY_IGNORE } }; - for ( String[] testCase : testCases ) - { - assertEquals( "unknown vs " + testCase[1], testCase[0], - provider.getEffectiveChecksumPolicy( session, CHECKSUM_POLICY_UNKNOWN, testCase[1] ) ); - assertEquals( "unknown vs " + testCase[1], testCase[0], - provider.getEffectiveChecksumPolicy( session, testCase[1], CHECKSUM_POLICY_UNKNOWN ) ); - } - } - -}