diff options
Diffstat (limited to 'framework/src/maven/apache-maven-3.3.3/maven-compat/src/test/java/org/apache/maven/artifact')
21 files changed, 0 insertions, 2229 deletions
diff --git a/framework/src/maven/apache-maven-3.3.3/maven-compat/src/test/java/org/apache/maven/artifact/AbstractArtifactComponentTestCase.java b/framework/src/maven/apache-maven-3.3.3/maven-compat/src/test/java/org/apache/maven/artifact/AbstractArtifactComponentTestCase.java deleted file mode 100644 index 010c566b..00000000 --- a/framework/src/maven/apache-maven-3.3.3/maven-compat/src/test/java/org/apache/maven/artifact/AbstractArtifactComponentTestCase.java +++ /dev/null @@ -1,371 +0,0 @@ -package org.apache.maven.artifact; - -/* - * 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.io.FileOutputStream; -import java.io.IOException; -import java.io.OutputStreamWriter; -import java.io.Writer; -import java.util.ArrayList; -import java.util.List; - -import org.apache.maven.artifact.factory.ArtifactFactory; -import org.apache.maven.artifact.repository.ArtifactRepository; -import org.apache.maven.plugin.LegacySupport; -import org.apache.maven.repository.legacy.repository.ArtifactRepositoryFactory; -import org.apache.maven.artifact.repository.ArtifactRepositoryPolicy; -import org.apache.maven.artifact.repository.layout.ArtifactRepositoryLayout; -import org.apache.maven.execution.DefaultMavenExecutionRequest; -import org.apache.maven.execution.DefaultMavenExecutionResult; -import org.apache.maven.execution.MavenSession; -import org.codehaus.plexus.ContainerConfiguration; -import org.codehaus.plexus.PlexusConstants; -import org.codehaus.plexus.PlexusTestCase; -import org.eclipse.aether.DefaultRepositorySystemSession; -import org.eclipse.aether.RepositorySystemSession; -import org.eclipse.aether.collection.DependencyGraphTransformer; -import org.eclipse.aether.collection.DependencyManager; -import org.eclipse.aether.collection.DependencySelector; -import org.eclipse.aether.collection.DependencyTraverser; -import org.eclipse.aether.internal.impl.SimpleLocalRepositoryManagerFactory; -import org.eclipse.aether.repository.LocalRepository; -import org.eclipse.aether.util.graph.manager.ClassicDependencyManager; -import org.eclipse.aether.util.graph.selector.AndDependencySelector; -import org.eclipse.aether.util.graph.selector.ExclusionDependencySelector; -import org.eclipse.aether.util.graph.selector.OptionalDependencySelector; -import org.eclipse.aether.util.graph.selector.ScopeDependencySelector; -import org.eclipse.aether.util.graph.transformer.ChainedDependencyGraphTransformer; -import org.eclipse.aether.util.graph.transformer.ConflictResolver; -import org.eclipse.aether.util.graph.transformer.JavaScopeDeriver; -import org.eclipse.aether.util.graph.transformer.JavaScopeSelector; -import org.eclipse.aether.util.graph.transformer.JavaDependencyContextRefiner; -import org.eclipse.aether.util.graph.transformer.NearestVersionSelector; -import org.eclipse.aether.util.graph.transformer.SimpleOptionalitySelector; -import org.eclipse.aether.util.graph.traverser.FatArtifactTraverser; -import org.eclipse.aether.util.repository.SimpleArtifactDescriptorPolicy; - -/** - * @author <a href="mailto:jason@maven.org">Jason van Zyl </a> - */ -public abstract class AbstractArtifactComponentTestCase - extends PlexusTestCase -{ - protected ArtifactFactory artifactFactory; - - protected ArtifactRepositoryFactory artifactRepositoryFactory; - - @Override - protected void customizeContainerConfiguration( ContainerConfiguration containerConfiguration ) - { - super.customizeContainerConfiguration( containerConfiguration ); - containerConfiguration.setAutoWiring( true ); - containerConfiguration.setClassPathScanning( PlexusConstants.SCANNING_INDEX ); - } - - @Override - protected void setUp() - throws Exception - { - super.setUp(); - artifactFactory = lookup( ArtifactFactory.class); - artifactRepositoryFactory = lookup( ArtifactRepositoryFactory.class ); - - RepositorySystemSession repoSession = initRepoSession(); - MavenSession session = - new MavenSession( getContainer(), repoSession, new DefaultMavenExecutionRequest(), - new DefaultMavenExecutionResult() ); - - LegacySupport legacySupport = lookup(LegacySupport.class); - legacySupport.setSession( session ); - } - - @Override - protected void tearDown() - throws Exception - { - release( artifactFactory ); - - super.tearDown(); - } - - protected abstract String component(); - - /** - * Return an existing file, not a directory - causes creation to fail. - * - * @throws Exception - */ - protected ArtifactRepository badLocalRepository() - throws Exception - { - String path = "target/test-repositories/" + component() + "/bad-local-repository"; - - File f = new File( getBasedir(), path ); - - f.createNewFile(); - - ArtifactRepositoryLayout repoLayout = - (ArtifactRepositoryLayout) lookup( ArtifactRepositoryLayout.ROLE, "default" ); - - return artifactRepositoryFactory.createArtifactRepository( "test", "file://" + f.getPath(), repoLayout, null, null ); - } - - protected String getRepositoryLayout() - { - return "default"; - } - - protected ArtifactRepository localRepository() - throws Exception - { - String path = "target/test-repositories/" + component() + "/local-repository"; - - File f = new File( getBasedir(), path ); - - ArtifactRepositoryLayout repoLayout = - (ArtifactRepositoryLayout) lookup( ArtifactRepositoryLayout.ROLE, "default" ); - - return artifactRepositoryFactory.createArtifactRepository( "local", "file://" + f.getPath(), repoLayout, null, null ); - } - - protected ArtifactRepository remoteRepository() - throws Exception - { - String path = "target/test-repositories/" + component() + "/remote-repository"; - - File f = new File( getBasedir(), path ); - - ArtifactRepositoryLayout repoLayout = - (ArtifactRepositoryLayout) lookup( ArtifactRepositoryLayout.ROLE, "default" ); - - return artifactRepositoryFactory.createArtifactRepository( "test", "file://" + f.getPath(), repoLayout, - new ArtifactRepositoryPolicy(), new ArtifactRepositoryPolicy() ); - } - - protected ArtifactRepository badRemoteRepository() - throws Exception - { - ArtifactRepositoryLayout repoLayout = - (ArtifactRepositoryLayout) lookup( ArtifactRepositoryLayout.ROLE, "default" ); - - return artifactRepositoryFactory.createArtifactRepository( "test", "http://foo.bar/repository", repoLayout, null, null ); - } - - protected void assertRemoteArtifactPresent( Artifact artifact ) - throws Exception - { - ArtifactRepository remoteRepo = remoteRepository(); - - String path = remoteRepo.pathOf( artifact ); - - File file = new File( remoteRepo.getBasedir(), path ); - - if ( !file.exists() ) - { - fail( "Remote artifact " + file + " should be present." ); - } - } - - protected void assertLocalArtifactPresent( Artifact artifact ) - throws Exception - { - ArtifactRepository localRepo = localRepository(); - - String path = localRepo.pathOf( artifact ); - - File file = new File( localRepo.getBasedir(), path ); - - if ( !file.exists() ) - { - fail( "Local artifact " + file + " should be present." ); - } - } - - protected void assertRemoteArtifactNotPresent( Artifact artifact ) - throws Exception - { - ArtifactRepository remoteRepo = remoteRepository(); - - String path = remoteRepo.pathOf( artifact ); - - File file = new File( remoteRepo.getBasedir(), path ); - - if ( file.exists() ) - { - fail( "Remote artifact " + file + " should not be present." ); - } - } - - protected void assertLocalArtifactNotPresent( Artifact artifact ) - throws Exception - { - ArtifactRepository localRepo = localRepository(); - - String path = localRepo.pathOf( artifact ); - - File file = new File( localRepo.getBasedir(), path ); - - if ( file.exists() ) - { - fail( "Local artifact " + file + " should not be present." ); - } - } - - // ---------------------------------------------------------------------- - // - // ---------------------------------------------------------------------- - - protected List<ArtifactRepository> remoteRepositories() - throws Exception - { - List<ArtifactRepository> remoteRepositories = new ArrayList<ArtifactRepository>(); - - remoteRepositories.add( remoteRepository() ); - - return remoteRepositories; - } - - // ---------------------------------------------------------------------- - // Test artifact generation for unit tests - // ---------------------------------------------------------------------- - - protected Artifact createLocalArtifact( String artifactId, String version ) - throws Exception - { - Artifact artifact = createArtifact( artifactId, version ); - - createArtifact( artifact, localRepository() ); - - return artifact; - } - - protected Artifact createRemoteArtifact( String artifactId, String version ) - throws Exception - { - Artifact artifact = createArtifact( artifactId, version ); - - createArtifact( artifact, remoteRepository() ); - - return artifact; - } - - protected void createLocalArtifact( Artifact artifact ) - throws Exception - { - createArtifact( artifact, localRepository() ); - } - - protected void createRemoteArtifact( Artifact artifact ) - throws Exception - { - createArtifact( artifact, remoteRepository() ); - } - - protected void createArtifact( Artifact artifact, ArtifactRepository repository ) - throws Exception - { - String path = repository.pathOf( artifact ); - - File artifactFile = new File( repository.getBasedir(), path ); - - if ( !artifactFile.getParentFile().exists() ) - { - artifactFile.getParentFile().mkdirs(); - } - - Writer writer = new OutputStreamWriter( new FileOutputStream( artifactFile ), "ISO-8859-1" ); - - writer.write( artifact.getId() ); - - writer.close(); - } - - protected Artifact createArtifact( String artifactId, String version ) - throws Exception - { - return createArtifact( artifactId, version, "jar" ); - } - - protected Artifact createArtifact( String artifactId, String version, String type ) - throws Exception - { - return createArtifact( "org.apache.maven", artifactId, version, type ); - } - - protected Artifact createArtifact( String groupId, String artifactId, String version, String type ) - throws Exception - { - Artifact a = artifactFactory.createBuildArtifact( groupId, artifactId, version, type ); - - return a; - } - - protected void deleteLocalArtifact( Artifact artifact ) - throws Exception - { - deleteArtifact( artifact, localRepository() ); - } - - protected void deleteArtifact( Artifact artifact, ArtifactRepository repository ) - throws Exception - { - String path = repository.pathOf( artifact ); - - File artifactFile = new File( repository.getBasedir(), path ); - - if ( artifactFile.exists() ) - { - if ( !artifactFile.delete() ) - { - throw new IOException( "Failure while attempting to delete artifact " + artifactFile ); - } - } - } - - protected RepositorySystemSession initRepoSession() - throws Exception - { - DefaultRepositorySystemSession session = new DefaultRepositorySystemSession(); - session.setArtifactDescriptorPolicy( new SimpleArtifactDescriptorPolicy( true, true ) ); - DependencyTraverser depTraverser = new FatArtifactTraverser(); - session.setDependencyTraverser( depTraverser ); - - DependencyManager depManager = new ClassicDependencyManager(); - session.setDependencyManager( depManager ); - - DependencySelector depFilter = - new AndDependencySelector( new ScopeDependencySelector( "test", "provided" ), - new OptionalDependencySelector(), new ExclusionDependencySelector() ); - session.setDependencySelector( depFilter ); - - DependencyGraphTransformer transformer = - new ConflictResolver( new NearestVersionSelector(), new JavaScopeSelector(), - new SimpleOptionalitySelector(), new JavaScopeDeriver() ); - new ChainedDependencyGraphTransformer( transformer, new JavaDependencyContextRefiner() ); - session.setDependencyGraphTransformer( transformer ); - - LocalRepository localRepo = new LocalRepository( localRepository().getBasedir() ); - session.setLocalRepositoryManager( new SimpleLocalRepositoryManagerFactory().newInstance( session, localRepo ) ); - - return session; - } - -} diff --git a/framework/src/maven/apache-maven-3.3.3/maven-compat/src/test/java/org/apache/maven/artifact/ArtifactUtilsTest.java b/framework/src/maven/apache-maven-3.3.3/maven-compat/src/test/java/org/apache/maven/artifact/ArtifactUtilsTest.java deleted file mode 100644 index 7b20eb5d..00000000 --- a/framework/src/maven/apache-maven-3.3.3/maven-compat/src/test/java/org/apache/maven/artifact/ArtifactUtilsTest.java +++ /dev/null @@ -1,79 +0,0 @@ -package org.apache.maven.artifact; - -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -import java.util.ArrayList; -import java.util.List; -import java.util.Map; - -import org.apache.maven.artifact.versioning.VersionRange; - -import junit.framework.TestCase; - -/** - * Tests {@link ArtifactUtils}. - * - * @author Benjamin Bentmann - */ -public class ArtifactUtilsTest - extends TestCase -{ - - private Artifact newArtifact( String aid ) - { - return new DefaultArtifact( "group", aid, VersionRange.createFromVersion( "1.0" ), "test", "jar", "tests", null ); - } - - public void testIsSnapshot() - { - assertEquals( false, ArtifactUtils.isSnapshot( null ) ); - assertEquals( false, ArtifactUtils.isSnapshot( "" ) ); - assertEquals( false, ArtifactUtils.isSnapshot( "1.2.3" ) ); - assertEquals( true, ArtifactUtils.isSnapshot( "1.2.3-SNAPSHOT" ) ); - assertEquals( true, ArtifactUtils.isSnapshot( "1.2.3-snapshot" ) ); - assertEquals( true, ArtifactUtils.isSnapshot( "1.2.3-20090413.094722-2" ) ); - } - - public void testToSnapshotVersion() - { - assertEquals( "1.2.3", ArtifactUtils.toSnapshotVersion( "1.2.3" ) ); - assertEquals( "1.2.3-SNAPSHOT", ArtifactUtils.toSnapshotVersion( "1.2.3-SNAPSHOT" ) ); - assertEquals( "1.2.3-SNAPSHOT", ArtifactUtils.toSnapshotVersion( "1.2.3-20090413.094722-2" ) ); - } - - /** - * Tests that the ordering of the map resembles the ordering of the input collection of artifacts. - */ - public void testArtifactMapByVersionlessIdOrdering() - throws Exception - { - List<Artifact> list = new ArrayList<Artifact>(); - list.add( newArtifact( "b" ) ); - list.add( newArtifact( "a" ) ); - list.add( newArtifact( "c" ) ); - list.add( newArtifact( "e" ) ); - list.add( newArtifact( "d" ) ); - - Map<String, Artifact> map = ArtifactUtils.artifactMapByVersionlessId( list ); - assertNotNull( map ); - assertEquals( list, new ArrayList<Artifact>( map.values() ) ); - } - -} diff --git a/framework/src/maven/apache-maven-3.3.3/maven-compat/src/test/java/org/apache/maven/artifact/DefaultArtifactTest.java b/framework/src/maven/apache-maven-3.3.3/maven-compat/src/test/java/org/apache/maven/artifact/DefaultArtifactTest.java deleted file mode 100644 index fbd01191..00000000 --- a/framework/src/maven/apache-maven-3.3.3/maven-compat/src/test/java/org/apache/maven/artifact/DefaultArtifactTest.java +++ /dev/null @@ -1,140 +0,0 @@ -package org.apache.maven.artifact; - -/* - * 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 junit.framework.TestCase; - -import org.apache.maven.artifact.handler.ArtifactHandlerMock; -import org.apache.maven.artifact.versioning.VersionRange; - -public class DefaultArtifactTest - extends TestCase -{ - - private DefaultArtifact artifact; - - private DefaultArtifact snapshotArtifact; - - private String groupId = "groupid", artifactId = "artifactId", version = "1.0", scope = "artifactScope", type = "type", - classifier = "classifier"; - - private String snapshotSpecVersion = "1.0-SNAPSHOT"; - private String snapshotResolvedVersion = "1.0-20070606.010101-1"; - - private VersionRange versionRange; - private VersionRange snapshotVersionRange; - - private ArtifactHandlerMock artifactHandler; - - protected void setUp() - throws Exception - { - super.setUp(); - artifactHandler = new ArtifactHandlerMock(); - versionRange = VersionRange.createFromVersion( version ); - artifact = new DefaultArtifact( groupId, artifactId, versionRange, scope, type, classifier, artifactHandler ); - - snapshotVersionRange = VersionRange.createFromVersion( snapshotResolvedVersion ); - snapshotArtifact = new DefaultArtifact( groupId, artifactId, snapshotVersionRange, scope, type, classifier, artifactHandler ); - } - - public void testGetVersionReturnsResolvedVersionOnSnapshot() - { - assertEquals( snapshotResolvedVersion, snapshotArtifact.getVersion() ); - - // this is FOUL! -// snapshotArtifact.isSnapshot(); - - assertEquals( snapshotSpecVersion, snapshotArtifact.getBaseVersion() ); - } - - public void testGetDependencyConflictId() - { - assertEquals( groupId + ":" + artifactId + ":" + type + ":" + classifier, artifact.getDependencyConflictId() ); - } - - public void testGetDependencyConflictIdNullGroupId() - { - artifact.setGroupId( null ); - assertEquals( null + ":" + artifactId + ":" + type + ":" + classifier, artifact.getDependencyConflictId() ); - } - - public void testGetDependencyConflictIdNullClassifier() - { - artifact = new DefaultArtifact( groupId, artifactId, versionRange, scope, type, null, artifactHandler ); - assertEquals( groupId + ":" + artifactId + ":" + type, artifact.getDependencyConflictId() ); - } - - public void testGetDependencyConflictIdNullScope() - { - artifact.setScope( null ); - assertEquals( groupId + ":" + artifactId + ":" + type + ":" + classifier, artifact.getDependencyConflictId() ); - } - - public void testToString() - { - assertEquals( groupId + ":" + artifactId + ":" + type + ":" + classifier + ":" + version + ":" + scope, - artifact.toString() ); - } - - public void testToStringNullGroupId() - { - artifact.setGroupId( null ); - assertEquals( artifactId + ":" + type + ":" + classifier + ":" + version + ":" + scope, artifact.toString() ); - } - - public void testToStringNullClassifier() - { - artifact = new DefaultArtifact( groupId, artifactId, versionRange, scope, type, null, artifactHandler ); - assertEquals( groupId + ":" + artifactId + ":" + type + ":" + version + ":" + scope, artifact.toString() ); - } - - public void testToStringNullScope() - { - artifact.setScope( null ); - assertEquals( groupId + ":" + artifactId + ":" + type + ":" + classifier + ":" + version, artifact.toString() ); - } - - public void testComparisonByVersion() - { - Artifact artifact1 = new DefaultArtifact( groupId, artifactId, VersionRange.createFromVersion( "5.0" ), scope, - type, classifier, artifactHandler ); - Artifact artifact2 = new DefaultArtifact( groupId, artifactId, VersionRange.createFromVersion( "12.0" ), scope, - type, classifier, artifactHandler ); - - assertTrue( artifact1.compareTo( artifact2 ) < 0 ); - assertTrue( artifact2.compareTo( artifact1 ) > 0 ); - - Artifact artifact = new DefaultArtifact( groupId, artifactId, VersionRange.createFromVersion( "5.0" ), scope, - type, classifier, artifactHandler ); - assertTrue( artifact.compareTo( artifact1 ) == 0 ); - assertTrue( artifact1.compareTo( artifact ) == 0 ); - } - - public void testNonResolvedVersionRangeConsistentlyYieldsNullVersions() - throws Exception - { - VersionRange vr = VersionRange.createFromVersionSpec( "[1.0,2.0)" ); - artifact = new DefaultArtifact( groupId, artifactId, vr, scope, type, null, artifactHandler ); - assertEquals( null, artifact.getVersion() ); - assertEquals( null, artifact.getBaseVersion() ); - } - -} diff --git a/framework/src/maven/apache-maven-3.3.3/maven-compat/src/test/java/org/apache/maven/artifact/deployer/ArtifactDeployerTest.java b/framework/src/maven/apache-maven-3.3.3/maven-compat/src/test/java/org/apache/maven/artifact/deployer/ArtifactDeployerTest.java deleted file mode 100644 index f929f480..00000000 --- a/framework/src/maven/apache-maven-3.3.3/maven-compat/src/test/java/org/apache/maven/artifact/deployer/ArtifactDeployerTest.java +++ /dev/null @@ -1,67 +0,0 @@ -package org.apache.maven.artifact.deployer; - -/* - * 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 org.apache.maven.artifact.AbstractArtifactComponentTestCase; -import org.apache.maven.artifact.Artifact; -import org.apache.maven.artifact.repository.ArtifactRepository; -import org.codehaus.plexus.util.FileUtils; - -/** - * @author <a href="mailto:jason@maven.org">Jason van Zyl</a> - */ -public class ArtifactDeployerTest - extends AbstractArtifactComponentTestCase -{ - private ArtifactDeployer artifactDeployer; - - protected void setUp() - throws Exception - { - super.setUp(); - - artifactDeployer = (ArtifactDeployer) lookup( ArtifactDeployer.ROLE ); - } - - protected String component() - { - return "deployer"; - } - - public void testArtifactInstallation() - throws Exception - { - String artifactBasedir = new File( getBasedir(), "src/test/resources/artifact-install" ).getAbsolutePath(); - - Artifact artifact = createArtifact( "artifact", "1.0" ); - - File file = new File( artifactBasedir, "artifact-1.0.jar" ); - assertEquals( "dummy", FileUtils.fileRead( file, "UTF-8" ).trim() ); - - artifactDeployer.deploy( file, artifact, remoteRepository(), localRepository() ); - - ArtifactRepository remoteRepository = remoteRepository(); - File deployedFile = new File( remoteRepository.getBasedir(), remoteRepository.pathOf( artifact ) ); - assertTrue( deployedFile.exists() ); - assertEquals( "dummy", FileUtils.fileRead( deployedFile, "UTF-8" ).trim() ); - } -}
\ No newline at end of file diff --git a/framework/src/maven/apache-maven-3.3.3/maven-compat/src/test/java/org/apache/maven/artifact/deployer/SimpleArtifactMetadataSource.java b/framework/src/maven/apache-maven-3.3.3/maven-compat/src/test/java/org/apache/maven/artifact/deployer/SimpleArtifactMetadataSource.java deleted file mode 100644 index f6bebcba..00000000 --- a/framework/src/maven/apache-maven-3.3.3/maven-compat/src/test/java/org/apache/maven/artifact/deployer/SimpleArtifactMetadataSource.java +++ /dev/null @@ -1,66 +0,0 @@ -package org.apache.maven.artifact.deployer; - -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -import java.util.Collections; -import java.util.List; - -import org.apache.maven.artifact.Artifact; -import org.apache.maven.artifact.repository.ArtifactRepository; -import org.apache.maven.artifact.versioning.ArtifactVersion; -import org.apache.maven.artifact.versioning.DefaultArtifactVersion; -import org.apache.maven.repository.legacy.metadata.ArtifactMetadataRetrievalException; -import org.apache.maven.repository.legacy.metadata.ArtifactMetadataSource; -import org.apache.maven.repository.legacy.metadata.MetadataResolutionRequest; -import org.apache.maven.repository.legacy.metadata.ResolutionGroup; - -/** @author Jason van Zyl */ -public class SimpleArtifactMetadataSource - implements ArtifactMetadataSource -{ - public ResolutionGroup retrieve( Artifact artifact, ArtifactRepository localRepository, - List<ArtifactRepository> remoteRepositories ) - throws ArtifactMetadataRetrievalException - { - throw new UnsupportedOperationException( "Cannot retrieve metadata in this test case" ); - } - - public List<ArtifactVersion> retrieveAvailableVersions( Artifact artifact, ArtifactRepository localRepository, - List<ArtifactRepository> remoteRepositories ) - throws ArtifactMetadataRetrievalException - { - return Collections.<ArtifactVersion>singletonList( new DefaultArtifactVersion( "10.1.3" ) ); - } - - public List<ArtifactVersion> retrieveAvailableVersionsFromDeploymentRepository( Artifact artifact, - ArtifactRepository localRepository, - ArtifactRepository remoteRepository ) - throws ArtifactMetadataRetrievalException - { - return Collections.<ArtifactVersion>singletonList( new DefaultArtifactVersion( "10.1.3" ) ); - } - - public ResolutionGroup retrieve( MetadataResolutionRequest request ) - throws ArtifactMetadataRetrievalException - { - return retrieve( request.getArtifact(), request.getLocalRepository(), request.getRemoteRepositories() ); - } - -} diff --git a/framework/src/maven/apache-maven-3.3.3/maven-compat/src/test/java/org/apache/maven/artifact/factory/DefaultArtifactFactoryTest.java b/framework/src/maven/apache-maven-3.3.3/maven-compat/src/test/java/org/apache/maven/artifact/factory/DefaultArtifactFactoryTest.java deleted file mode 100644 index 0d109acb..00000000 --- a/framework/src/maven/apache-maven-3.3.3/maven-compat/src/test/java/org/apache/maven/artifact/factory/DefaultArtifactFactoryTest.java +++ /dev/null @@ -1,49 +0,0 @@ -package org.apache.maven.artifact.factory; - -/* - * 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.Artifact; -import org.apache.maven.artifact.versioning.VersionRange; -import org.codehaus.plexus.PlexusTestCase; - -public class DefaultArtifactFactoryTest - extends PlexusTestCase -{ - - public void testPropagationOfSystemScopeRegardlessOfInheritedScope() throws Exception - { - ArtifactFactory factory = (ArtifactFactory) lookup( ArtifactFactory.ROLE ); - - Artifact artifact = factory.createDependencyArtifact( "test-grp", "test-artifact", VersionRange.createFromVersion("1.0"), "type", null, "system", "provided" ); - Artifact artifact2 = factory.createDependencyArtifact( "test-grp", "test-artifact-2", VersionRange.createFromVersion("1.0"), "type", null, "system", "test" ); - Artifact artifact3 = factory.createDependencyArtifact( "test-grp", "test-artifact-3", VersionRange.createFromVersion("1.0"), "type", null, "system", "runtime" ); - Artifact artifact4 = factory.createDependencyArtifact( "test-grp", "test-artifact-4", VersionRange.createFromVersion("1.0"), "type", null, "system", "compile" ); - - // this one should never happen in practice... - Artifact artifact5 = factory.createDependencyArtifact( "test-grp", "test-artifact-5", VersionRange.createFromVersion("1.0"), "type", null, "system", "system" ); - - assertEquals( "system", artifact.getScope() ); - assertEquals( "system", artifact2.getScope() ); - assertEquals( "system", artifact3.getScope() ); - assertEquals( "system", artifact4.getScope() ); - assertEquals( "system", artifact5.getScope() ); - } - -} diff --git a/framework/src/maven/apache-maven-3.3.3/maven-compat/src/test/java/org/apache/maven/artifact/handler/ArtifactHandlerMock.java b/framework/src/maven/apache-maven-3.3.3/maven-compat/src/test/java/org/apache/maven/artifact/handler/ArtifactHandlerMock.java deleted file mode 100644 index a9f335e6..00000000 --- a/framework/src/maven/apache-maven-3.3.3/maven-compat/src/test/java/org/apache/maven/artifact/handler/ArtifactHandlerMock.java +++ /dev/null @@ -1,100 +0,0 @@ -package org.apache.maven.artifact.handler; - -/* - * 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. - */ - -public class ArtifactHandlerMock - implements ArtifactHandler -{ - - private String extension, directory, classifier, packaging, language; - - private boolean includesDependencies, addedToClasspath; - - public void setExtension( String extension ) - { - this.extension = extension; - } - - public String getExtension() - { - return extension; - } - - public void setDirectory( String directory ) - { - this.directory = directory; - } - - public String getDirectory() - { - return directory; - } - - public void setClassifier( String classifier ) - { - this.classifier = classifier; - } - - public String getClassifier() - { - return classifier; - } - - public void setPackaging( String packaging ) - { - this.packaging = packaging; - } - - public String getPackaging() - { - return packaging; - } - - public void setIncludesDependencies( boolean includesDependencies ) - { - this.includesDependencies = includesDependencies; - } - - public boolean isIncludesDependencies() - { - return includesDependencies; - } - - public void setLanguage( String language ) - { - this.language = language; - } - - public String getLanguage() - { - return language; - } - - public void setAddedToClasspath( boolean addedToClasspath ) - { - this.addedToClasspath = addedToClasspath; - } - - public boolean isAddedToClasspath() - { - return addedToClasspath; - } - -} diff --git a/framework/src/maven/apache-maven-3.3.3/maven-compat/src/test/java/org/apache/maven/artifact/installer/ArtifactInstallerTest.java b/framework/src/maven/apache-maven-3.3.3/maven-compat/src/test/java/org/apache/maven/artifact/installer/ArtifactInstallerTest.java deleted file mode 100644 index 21bfb2b7..00000000 --- a/framework/src/maven/apache-maven-3.3.3/maven-compat/src/test/java/org/apache/maven/artifact/installer/ArtifactInstallerTest.java +++ /dev/null @@ -1,61 +0,0 @@ -package org.apache.maven.artifact.installer; - -/* - * 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 org.apache.maven.artifact.AbstractArtifactComponentTestCase; -import org.apache.maven.artifact.Artifact; - -/** - * @author <a href="mailto:jason@maven.org">Jason van Zyl</a> - */ -public class ArtifactInstallerTest - extends AbstractArtifactComponentTestCase -{ - private ArtifactInstaller artifactInstaller; - - protected void setUp() - throws Exception - { - super.setUp(); - - artifactInstaller = (ArtifactInstaller) lookup( ArtifactInstaller.ROLE ); - } - - protected String component() - { - return "installer"; - } - - public void testArtifactInstallation() - throws Exception - { - String artifactBasedir = new File( getBasedir(), "src/test/resources/artifact-install" ).getAbsolutePath(); - - Artifact artifact = createArtifact( "artifact", "1.0" ); - - File source = new File( artifactBasedir, "artifact-1.0.jar" ); - - artifactInstaller.install( source, artifact, localRepository() ); - - assertLocalArtifactPresent( artifact ); - } -}
\ No newline at end of file diff --git a/framework/src/maven/apache-maven-3.3.3/maven-compat/src/test/java/org/apache/maven/artifact/metadata/TestMetadataSource.java b/framework/src/maven/apache-maven-3.3.3/maven-compat/src/test/java/org/apache/maven/artifact/metadata/TestMetadataSource.java deleted file mode 100644 index f8bb1677..00000000 --- a/framework/src/maven/apache-maven-3.3.3/maven-compat/src/test/java/org/apache/maven/artifact/metadata/TestMetadataSource.java +++ /dev/null @@ -1,102 +0,0 @@ -package org.apache.maven.artifact.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 java.util.HashSet; -import java.util.List; -import java.util.Set; - -import org.apache.maven.artifact.Artifact; -import org.apache.maven.artifact.factory.ArtifactFactory; -import org.apache.maven.artifact.repository.ArtifactRepository; -import org.apache.maven.artifact.versioning.ArtifactVersion; -import org.apache.maven.repository.legacy.metadata.MetadataResolutionRequest; -import org.codehaus.plexus.component.annotations.Component; -import org.codehaus.plexus.component.annotations.Requirement; - -@Component(role = ArtifactMetadataSource.class, hint="test") -public class TestMetadataSource - implements ArtifactMetadataSource -{ - @Requirement - private ArtifactFactory factory; - - public ResolutionGroup retrieve( Artifact artifact, ArtifactRepository localRepository, List<ArtifactRepository> remoteRepositories ) - throws ArtifactMetadataRetrievalException - { - Set dependencies = new HashSet(); - - if ( "g".equals( artifact.getArtifactId() ) ) - { - Artifact a = null; - try - { - a = factory.createBuildArtifact( "org.apache.maven", "h", "1.0", "jar" ); - dependencies.add( a ); - } - catch ( Exception e ) - { - throw new ArtifactMetadataRetrievalException( "Error retrieving metadata", e, a ); - } - } - - if ( "i".equals( artifact.getArtifactId() ) ) - { - Artifact a = null; - try - { - a = factory.createBuildArtifact( "org.apache.maven", "j", "1.0-SNAPSHOT", "jar" ); - dependencies.add( a ); - } - catch ( Exception e ) - { - throw new ArtifactMetadataRetrievalException( "Error retrieving metadata", e, a ); - } - } - - - return new ResolutionGroup( artifact, dependencies, remoteRepositories ); - } - - public List<ArtifactVersion> retrieveAvailableVersions( Artifact artifact, ArtifactRepository localRepository, List<ArtifactRepository> remoteRepositories ) - throws ArtifactMetadataRetrievalException - { - throw new UnsupportedOperationException( "Cannot get available versions in this test case" ); - } - - public List<ArtifactVersion> retrieveAvailableVersionsFromDeploymentRepository( Artifact artifact, ArtifactRepository localRepository, ArtifactRepository remoteRepository ) - throws ArtifactMetadataRetrievalException - { - throw new UnsupportedOperationException( "Cannot get available versions in this test case" ); - } - - public ResolutionGroup retrieve( MetadataResolutionRequest request ) - throws ArtifactMetadataRetrievalException - { - return retrieve( request.getArtifact(), request.getLocalRepository(), request.getRemoteRepositories() ); - } - - public List<ArtifactVersion> retrieveAvailableVersions( MetadataResolutionRequest request ) - throws ArtifactMetadataRetrievalException - { - return retrieveAvailableVersions( request.getArtifact(), request.getLocalRepository(), request.getRemoteRepositories() ); - } - -} diff --git a/framework/src/maven/apache-maven-3.3.3/maven-compat/src/test/java/org/apache/maven/artifact/repository/MavenArtifactRepositoryTest.java b/framework/src/maven/apache-maven-3.3.3/maven-compat/src/test/java/org/apache/maven/artifact/repository/MavenArtifactRepositoryTest.java deleted file mode 100644 index 533f3042..00000000 --- a/framework/src/maven/apache-maven-3.3.3/maven-compat/src/test/java/org/apache/maven/artifact/repository/MavenArtifactRepositoryTest.java +++ /dev/null @@ -1,59 +0,0 @@ -package org.apache.maven.artifact.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 junit.framework.TestCase; - -public class MavenArtifactRepositoryTest - extends TestCase -{ - private static class MavenArtifactRepositorySubclass extends MavenArtifactRepository - { - String id; - - public MavenArtifactRepositorySubclass(String id) - { - this.id = id; - } - - @Override - public String getId() - { - return id; - } - } - - public void testHashCodeEquals() - { - MavenArtifactRepositorySubclass r1 = new MavenArtifactRepositorySubclass( "foo" ); - MavenArtifactRepositorySubclass r2 = new MavenArtifactRepositorySubclass( "foo" ); - MavenArtifactRepositorySubclass r3 = new MavenArtifactRepositorySubclass( "bar" ); - - assertTrue( r1.hashCode() == r2.hashCode() ); - assertFalse( r1.hashCode() == r3.hashCode() ); - - assertTrue( r1.equals( r2 ) ); - assertTrue( r2.equals( r1 ) ); - - assertFalse( r1.equals( r3 ) ); - assertFalse( r3.equals( r1 ) ); - } -} diff --git a/framework/src/maven/apache-maven-3.3.3/maven-compat/src/test/java/org/apache/maven/artifact/resolver/ArtifactResolutionExceptionTest.java b/framework/src/maven/apache-maven-3.3.3/maven-compat/src/test/java/org/apache/maven/artifact/resolver/ArtifactResolutionExceptionTest.java deleted file mode 100644 index aeacfb81..00000000 --- a/framework/src/maven/apache-maven-3.3.3/maven-compat/src/test/java/org/apache/maven/artifact/resolver/ArtifactResolutionExceptionTest.java +++ /dev/null @@ -1,64 +0,0 @@ -package org.apache.maven.artifact.resolver; - -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -import java.util.Arrays; -import java.util.List; - -import junit.framework.TestCase; - -/** - * Test the artifact resolution exception message - * - * @author Mauro Talevi - */ -public class ArtifactResolutionExceptionTest - extends TestCase -{ - private static final String LS = System.getProperty( "line.separator" ); - - public void testMissingArtifactMessageFormat() - { - String message = "Missing artifact"; - String indentation = " "; - String groupId = "aGroupId"; - String artifactId = "anArtifactId"; - String version = "aVersion"; - String type = "jar"; - String classifier = "aClassifier"; - String downloadUrl = "http://somewhere.com/download"; - 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 ); - } -} diff --git a/framework/src/maven/apache-maven-3.3.3/maven-compat/src/test/java/org/apache/maven/artifact/resolver/ArtifactResolverTest.java b/framework/src/maven/apache-maven-3.3.3/maven-compat/src/test/java/org/apache/maven/artifact/resolver/ArtifactResolverTest.java deleted file mode 100644 index 117c0e22..00000000 --- a/framework/src/maven/apache-maven-3.3.3/maven-compat/src/test/java/org/apache/maven/artifact/resolver/ArtifactResolverTest.java +++ /dev/null @@ -1,283 +0,0 @@ -package org.apache.maven.artifact.resolver; - -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -import java.util.ArrayList; -import java.util.Collections; -import java.util.HashSet; -import java.util.Iterator; -import java.util.LinkedHashSet; -import java.util.List; -import java.util.Set; - -import org.apache.maven.artifact.AbstractArtifactComponentTestCase; -import org.apache.maven.artifact.Artifact; -import org.apache.maven.artifact.metadata.ArtifactMetadataRetrievalException; -import org.apache.maven.artifact.metadata.ArtifactMetadataSource; -import org.apache.maven.artifact.metadata.ResolutionGroup; -import org.apache.maven.artifact.repository.ArtifactRepository; -import org.apache.maven.artifact.versioning.ArtifactVersion; -import org.apache.maven.repository.legacy.metadata.MetadataResolutionRequest; -import org.codehaus.plexus.component.repository.ComponentDescriptor; - -// It would be cool if there was a hook that i could use to setup a test environment. -// I want to setup a local/remote repositories for testing but i don't want to have -// to change them when i change the layout of the repositories. So i want to generate -// the structure i want to test by using the artifact handler manager which dictates -// the layout used for a particular artifact type. - -/** - * @author Jason van Zyl - */ -public class ArtifactResolverTest - extends AbstractArtifactComponentTestCase -{ - private DefaultArtifactResolver artifactResolver; - - private Artifact projectArtifact; - - @Override - protected void setUp() - throws Exception - { - super.setUp(); - - artifactResolver = (DefaultArtifactResolver) lookup( ArtifactResolver.class ); - - projectArtifact = createLocalArtifact( "project", "3.0" ); - } - - @Override - protected void tearDown() - throws Exception - { - artifactFactory = null; - projectArtifact = null; - super.tearDown(); - } - - @Override - protected String component() - { - return "resolver"; - } - - public void testResolutionOfASingleArtifactWhereTheArtifactIsPresentInTheLocalRepository() - throws Exception - { - Artifact a = createLocalArtifact( "a", "1.0" ); - - artifactResolver.resolve( a, remoteRepositories(), localRepository() ); - - assertLocalArtifactPresent( a ); - } - - public void testResolutionOfASingleArtifactWhereTheArtifactIsNotPresentLocallyAndMustBeRetrievedFromTheRemoteRepository() - throws Exception - { - Artifact b = createRemoteArtifact( "b", "1.0-SNAPSHOT" ); - deleteLocalArtifact( b ); - artifactResolver.resolve( b, remoteRepositories(), localRepository() ); - assertLocalArtifactPresent( b ); - } - - @Override - protected Artifact createArtifact( String groupId, String artifactId, String version, String type ) - throws Exception - { - // for the anonymous classes - return super.createArtifact( groupId, artifactId, version, type ); - } - - public void testTransitiveResolutionWhereAllArtifactsArePresentInTheLocalRepository() - throws Exception - { - Artifact g = createLocalArtifact( "g", "1.0" ); - - Artifact h = createLocalArtifact( "h", "1.0" ); - - ArtifactResolutionResult result = artifactResolver.resolveTransitively( Collections.singleton( g ), projectArtifact, remoteRepositories(), localRepository(), null ); - - printErrors( result ); - - assertEquals( 2, result.getArtifacts().size() ); - - assertTrue( result.getArtifacts().contains( g ) ); - - assertTrue( result.getArtifacts().contains( h ) ); - - assertLocalArtifactPresent( g ); - - assertLocalArtifactPresent( h ); - } - - public void testTransitiveResolutionWhereAllArtifactsAreNotPresentInTheLocalRepositoryAndMustBeRetrievedFromTheRemoteRepository() - throws Exception - { - Artifact i = createRemoteArtifact( "i", "1.0-SNAPSHOT" ); - deleteLocalArtifact( i ); - - Artifact j = createRemoteArtifact( "j", "1.0-SNAPSHOT" ); - deleteLocalArtifact( j ); - - ArtifactResolutionResult result = artifactResolver.resolveTransitively( Collections.singleton( i ), projectArtifact, remoteRepositories(), localRepository(), null ); - - printErrors( result ); - - assertEquals( 2, result.getArtifacts().size() ); - - assertTrue( result.getArtifacts().contains( i ) ); - - assertTrue( result.getArtifacts().contains( j ) ); - - assertLocalArtifactPresent( i ); - - assertLocalArtifactPresent( j ); - } - - public void testResolutionFailureWhenArtifactNotPresentInRemoteRepository() - throws Exception - { - Artifact k = createArtifact( "k", "1.0" ); - - try - { - artifactResolver.resolve( k, remoteRepositories(), localRepository() ); - fail( "Resolution succeeded when it should have failed" ); - } - catch ( ArtifactNotFoundException expected ) - { - assertTrue( true ); - } - } - - public void testResolutionOfAnArtifactWhereOneRemoteRepositoryIsBadButOneIsGood() - throws Exception - { - Artifact l = createRemoteArtifact( "l", "1.0-SNAPSHOT" ); - deleteLocalArtifact( l ); - - List<ArtifactRepository> repositories = new ArrayList<ArtifactRepository>(); - repositories.add( remoteRepository() ); - repositories.add( badRemoteRepository() ); - - artifactResolver.resolve( l, repositories, localRepository() ); - - assertLocalArtifactPresent( l ); - } - - public void testTransitiveResolutionOrder() - throws Exception - { - Artifact m = createLocalArtifact( "m", "1.0" ); - - Artifact n = createLocalArtifact( "n", "1.0" ); - - ArtifactMetadataSource mds = new ArtifactMetadataSource() - { - public ResolutionGroup retrieve( Artifact artifact, ArtifactRepository localRepository, - List<ArtifactRepository> remoteRepositories ) - throws ArtifactMetadataRetrievalException - { - Set dependencies = new HashSet(); - - return new ResolutionGroup( artifact, dependencies, remoteRepositories ); - } - - public List<ArtifactVersion> retrieveAvailableVersions( Artifact artifact, - ArtifactRepository localRepository, - List<ArtifactRepository> remoteRepositories ) - throws ArtifactMetadataRetrievalException - { - throw new UnsupportedOperationException( "Cannot get available versions in this test case" ); - } - - public List<ArtifactVersion> retrieveAvailableVersionsFromDeploymentRepository( - Artifact artifact, - ArtifactRepository localRepository, - ArtifactRepository remoteRepository ) - throws ArtifactMetadataRetrievalException - { - throw new UnsupportedOperationException( "Cannot get available versions in this test case" ); - } - - public ResolutionGroup retrieve( MetadataResolutionRequest request ) - throws ArtifactMetadataRetrievalException - { - return retrieve( request.getArtifact(), request.getLocalRepository(), request.getRemoteRepositories() ); - } - - public List<ArtifactVersion> retrieveAvailableVersions( MetadataResolutionRequest request ) - throws ArtifactMetadataRetrievalException - { - return retrieveAvailableVersions( request.getArtifact(), request.getLocalRepository(), request.getRemoteRepositories() ); - } - }; - - ArtifactResolutionResult result = null; - - Set set = new LinkedHashSet(); - set.add( n ); - set.add( m ); - - result = - artifactResolver.resolveTransitively( set, projectArtifact, remoteRepositories(), localRepository(), mds ); - - printErrors( result ); - - Iterator i = result.getArtifacts().iterator(); - assertEquals( "n should be first", n, i.next() ); - assertEquals( "m should be second", m, i.next() ); - - // inverse order - set = new LinkedHashSet(); - set.add( m ); - set.add( n ); - - result = - artifactResolver.resolveTransitively( set, projectArtifact, remoteRepositories(), localRepository(), mds ); - - printErrors( result ); - - i = result.getArtifacts().iterator(); - assertEquals( "m should be first", m, i.next() ); - assertEquals( "n should be second", n, i.next() ); - } - - private void printErrors( ArtifactResolutionResult result ) - { - if ( result.hasMissingArtifacts() ) - { - for ( Artifact artifact : result.getMissingArtifacts() ) - { - System.err.println( "Missing: " + artifact ); - } - } - - if ( result.hasExceptions() ) - { - for ( Exception e : result.getExceptions() ) - { - e.printStackTrace(); - } - } - } - -} diff --git a/framework/src/maven/apache-maven-3.3.3/maven-compat/src/test/java/org/apache/maven/artifact/resolver/DefaultArtifactResolverTest.java b/framework/src/maven/apache-maven-3.3.3/maven-compat/src/test/java/org/apache/maven/artifact/resolver/DefaultArtifactResolverTest.java deleted file mode 100644 index 914d9d1c..00000000 --- a/framework/src/maven/apache-maven-3.3.3/maven-compat/src/test/java/org/apache/maven/artifact/resolver/DefaultArtifactResolverTest.java +++ /dev/null @@ -1,111 +0,0 @@ -package org.apache.maven.artifact.resolver; - -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -import java.util.Collections; - -import org.apache.maven.artifact.AbstractArtifactComponentTestCase; -import org.apache.maven.artifact.Artifact; -import org.apache.maven.artifact.resolver.DefaultArtifactResolver.DaemonThreadCreator; - -public class DefaultArtifactResolverTest - extends AbstractArtifactComponentTestCase -{ - private DefaultArtifactResolver artifactResolver; - - private Artifact projectArtifact; - - @Override - protected void setUp() - throws Exception - { - super.setUp(); - - artifactResolver = (DefaultArtifactResolver) lookup( ArtifactResolver.class ); - - projectArtifact = createLocalArtifact( "project", "3.0" ); - } - - @Override - protected void tearDown() - throws Exception - { - artifactFactory = null; - projectArtifact = null; - super.tearDown(); - } - - @Override - protected String component() - { - return "resolver"; - } - - public void testMNG4738() - throws Exception - { - Artifact g = createLocalArtifact( "g", "1.0" ); - createLocalArtifact( "h", "1.0" ); - artifactResolver.resolveTransitively( Collections.singleton( g ), projectArtifact, remoteRepositories(), - localRepository(), null ); - - // we want to see all top-level thread groups - ThreadGroup tg = Thread.currentThread().getThreadGroup(); - while ( tg.getParent() == null ) - { - tg = tg.getParent(); - } - - ThreadGroup[] tgList = new ThreadGroup[tg.activeGroupCount()]; - tg.enumerate( tgList ); - - boolean seen = false; - - for ( ThreadGroup aTgList : tgList ) - { - if ( !aTgList.getName().equals( DaemonThreadCreator.THREADGROUP_NAME ) ) - { - continue; - } - - seen = true; - - tg = aTgList; - Thread[] ts = new Thread[tg.activeCount()]; - tg.enumerate( ts ); - - for ( Thread active : ts ) - { - String name = active.getName(); - boolean daemon = active.isDaemon(); - assertTrue( name + " is no daemon Thread.", daemon ); - } - - } - - assertTrue( "Could not find ThreadGroup: " + DaemonThreadCreator.THREADGROUP_NAME, seen ); - } - - public void testLookup() - throws Exception - { - ArtifactResolver resolver = lookup( ArtifactResolver.class, "default" ); - } -} diff --git a/framework/src/maven/apache-maven-3.3.3/maven-compat/src/test/java/org/apache/maven/artifact/resolver/TestFileWagon.java b/framework/src/maven/apache-maven-3.3.3/maven-compat/src/test/java/org/apache/maven/artifact/resolver/TestFileWagon.java deleted file mode 100644 index c78c1901..00000000 --- a/framework/src/maven/apache-maven-3.3.3/maven-compat/src/test/java/org/apache/maven/artifact/resolver/TestFileWagon.java +++ /dev/null @@ -1,94 +0,0 @@ -package org.apache.maven.artifact.resolver; - -/* - * 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.io.InputStream; - -import org.apache.maven.wagon.ResourceDoesNotExistException; -import org.apache.maven.wagon.TransferFailedException; -import org.apache.maven.wagon.authorization.AuthorizationException; -import org.apache.maven.wagon.events.TransferListener; -import org.apache.maven.wagon.providers.file.FileWagon; -import org.apache.maven.wagon.resource.Resource; - -/** - * Wagon used for test cases that annotates some methods. Note that this is not a thread-safe implementation. - */ -public class TestFileWagon - extends FileWagon -{ - private TestTransferListener testTransferListener; - private boolean insideGet; - - protected void getTransfer( Resource resource, - File destination, - InputStream input, - boolean closeInput, - int maxSize ) - throws TransferFailedException - { - addTransfer( "getTransfer " + resource.getName() ); - super.getTransfer( resource, destination, input, closeInput, maxSize ); - } - - public void get( String resourceName, File destination ) - throws TransferFailedException, - ResourceDoesNotExistException, - AuthorizationException - { - addTransfer( "get " + resourceName ); - - insideGet = true; - - super.get( resourceName, destination ); - - insideGet = false; - } - - private void addTransfer( String resourceName ) - { - if ( testTransferListener != null ) - { - testTransferListener.addTransfer( resourceName ); - } - } - - public boolean getIfNewer( String resourceName, File destination, long timestamp ) - throws TransferFailedException, - ResourceDoesNotExistException, - AuthorizationException - { - if ( !insideGet ) - { - addTransfer( "getIfNewer " + resourceName ); - } - return super.getIfNewer( resourceName, destination, timestamp ); - } - - public void addTransferListener( TransferListener listener ) - { - if ( listener instanceof TestTransferListener ) - { - testTransferListener = (TestTransferListener) listener; - } - super.addTransferListener( listener ); - } -} diff --git a/framework/src/maven/apache-maven-3.3.3/maven-compat/src/test/java/org/apache/maven/artifact/resolver/TestTransferListener.java b/framework/src/maven/apache-maven-3.3.3/maven-compat/src/test/java/org/apache/maven/artifact/resolver/TestTransferListener.java deleted file mode 100644 index afec3ef5..00000000 --- a/framework/src/maven/apache-maven-3.3.3/maven-compat/src/test/java/org/apache/maven/artifact/resolver/TestTransferListener.java +++ /dev/null @@ -1,43 +0,0 @@ -package org.apache.maven.artifact.resolver; - -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -import java.util.ArrayList; -import java.util.List; - -import org.apache.maven.wagon.observers.AbstractTransferListener; - -public class TestTransferListener - extends AbstractTransferListener -{ - - private final List<String> transfers = new ArrayList<String>(); - - public List<String> getTransfers() - { - return transfers; - } - - public void addTransfer( String name ) - { - transfers.add( name ); - } - -} diff --git a/framework/src/maven/apache-maven-3.3.3/maven-compat/src/test/java/org/apache/maven/artifact/resolver/filter/AndArtifactFilterTest.java b/framework/src/maven/apache-maven-3.3.3/maven-compat/src/test/java/org/apache/maven/artifact/resolver/filter/AndArtifactFilterTest.java deleted file mode 100644 index bca112b8..00000000 --- a/framework/src/maven/apache-maven-3.3.3/maven-compat/src/test/java/org/apache/maven/artifact/resolver/filter/AndArtifactFilterTest.java +++ /dev/null @@ -1,62 +0,0 @@ -package org.apache.maven.artifact.resolver.filter; - -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -import java.util.Arrays; - -import org.apache.maven.artifact.Artifact; - -import junit.framework.TestCase; - -/** - * Tests {@link AndArtifactFilter}. - * - * @author Benjamin Bentmann - */ -public class AndArtifactFilterTest - extends TestCase -{ - - private ArtifactFilter newSubFilter() - { - return new ArtifactFilter() - { - public boolean include( Artifact artifact ) - { - return false; - } - }; - } - - public void testEquals() - { - AndArtifactFilter filter1 = new AndArtifactFilter(); - - AndArtifactFilter filter2 = new AndArtifactFilter( Arrays.asList( newSubFilter() ) ); - - assertFalse( filter1.equals( null ) ); - assertTrue( filter1.equals( filter1 ) ); - assertEquals( filter1.hashCode(), filter1.hashCode() ); - - assertFalse( filter1.equals( filter2 ) ); - assertFalse( filter2.equals( filter1 ) ); - } - -} diff --git a/framework/src/maven/apache-maven-3.3.3/maven-compat/src/test/java/org/apache/maven/artifact/resolver/filter/FilterHashEqualsTest.java b/framework/src/maven/apache-maven-3.3.3/maven-compat/src/test/java/org/apache/maven/artifact/resolver/filter/FilterHashEqualsTest.java deleted file mode 100644 index fb465663..00000000 --- a/framework/src/maven/apache-maven-3.3.3/maven-compat/src/test/java/org/apache/maven/artifact/resolver/filter/FilterHashEqualsTest.java +++ /dev/null @@ -1,50 +0,0 @@ -package org.apache.maven.artifact.resolver.filter; - -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -import java.util.Arrays; -import java.util.List; - -import junit.framework.TestCase; - -/** - * @author Igor Fedorenko - */ -public class FilterHashEqualsTest - extends TestCase -{ - - public void testIncludesExcludesArtifactFilter() - { - List<String> patterns = Arrays.asList( "c", "d", "e" ); - - IncludesArtifactFilter f1 = new IncludesArtifactFilter( patterns ); - - IncludesArtifactFilter f2 = new IncludesArtifactFilter( patterns ); - - assertTrue( f1.equals(f2) ); - assertTrue( f2.equals(f1) ); - assertTrue( f1.hashCode() == f2.hashCode() ); - - IncludesArtifactFilter f3 = new IncludesArtifactFilter( Arrays.asList( "d", "c", "e" ) ); - assertTrue( f1.equals( f3 ) ); - assertTrue( f1.hashCode() == f3.hashCode() ); - } -} diff --git a/framework/src/maven/apache-maven-3.3.3/maven-compat/src/test/java/org/apache/maven/artifact/resolver/filter/OrArtifactFilterTest.java b/framework/src/maven/apache-maven-3.3.3/maven-compat/src/test/java/org/apache/maven/artifact/resolver/filter/OrArtifactFilterTest.java deleted file mode 100644 index e161437f..00000000 --- a/framework/src/maven/apache-maven-3.3.3/maven-compat/src/test/java/org/apache/maven/artifact/resolver/filter/OrArtifactFilterTest.java +++ /dev/null @@ -1,62 +0,0 @@ -package org.apache.maven.artifact.resolver.filter; - -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -import java.util.Arrays; - -import org.apache.maven.artifact.Artifact; - -import junit.framework.TestCase; - -/** - * Tests {@link OrArtifactFilter}. - * - * @author Benjamin Bentmann - */ -public class OrArtifactFilterTest - extends TestCase -{ - - private ArtifactFilter newSubFilter() - { - return new ArtifactFilter() - { - public boolean include( Artifact artifact ) - { - return false; - } - }; - } - - public void testEquals() - { - OrArtifactFilter filter1 = new OrArtifactFilter(); - - OrArtifactFilter filter2 = new OrArtifactFilter( Arrays.asList( newSubFilter() ) ); - - assertFalse( filter1.equals( null ) ); - assertTrue( filter1.equals( filter1 ) ); - assertEquals( filter1.hashCode(), filter1.hashCode() ); - - assertFalse( filter1.equals( filter2 ) ); - assertFalse( filter2.equals( filter1 ) ); - } - -} diff --git a/framework/src/maven/apache-maven-3.3.3/maven-compat/src/test/java/org/apache/maven/artifact/resolver/filter/ScopeArtifactFilterTest.java b/framework/src/maven/apache-maven-3.3.3/maven-compat/src/test/java/org/apache/maven/artifact/resolver/filter/ScopeArtifactFilterTest.java deleted file mode 100644 index 1a65eca0..00000000 --- a/framework/src/maven/apache-maven-3.3.3/maven-compat/src/test/java/org/apache/maven/artifact/resolver/filter/ScopeArtifactFilterTest.java +++ /dev/null @@ -1,96 +0,0 @@ -package org.apache.maven.artifact.resolver.filter; - -/* - * 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.Artifact; -import org.apache.maven.artifact.DefaultArtifact; - -import junit.framework.TestCase; - -/** - * Tests {@link ScopeArtifactFilter}. - * - * @author Benjamin Bentmann - */ -public class ScopeArtifactFilterTest - extends TestCase -{ - - private Artifact newArtifact( String scope ) - { - return new DefaultArtifact( "g", "a", "1.0", scope, "jar", "", null ); - } - - public void testInclude_Compile() - { - ScopeArtifactFilter filter = new ScopeArtifactFilter( Artifact.SCOPE_COMPILE ); - - assertTrue( filter.include( newArtifact( Artifact.SCOPE_COMPILE ) ) ); - assertTrue( filter.include( newArtifact( Artifact.SCOPE_SYSTEM ) ) ); - assertTrue( filter.include( newArtifact( Artifact.SCOPE_PROVIDED ) ) ); - assertFalse( filter.include( newArtifact( Artifact.SCOPE_RUNTIME ) ) ); - assertFalse( filter.include( newArtifact( Artifact.SCOPE_TEST ) ) ); - } - - public void testInclude_CompilePlusRuntime() - { - ScopeArtifactFilter filter = new ScopeArtifactFilter( Artifact.SCOPE_COMPILE_PLUS_RUNTIME ); - - assertTrue( filter.include( newArtifact( Artifact.SCOPE_COMPILE ) ) ); - assertTrue( filter.include( newArtifact( Artifact.SCOPE_SYSTEM ) ) ); - assertTrue( filter.include( newArtifact( Artifact.SCOPE_PROVIDED ) ) ); - assertTrue( filter.include( newArtifact( Artifact.SCOPE_RUNTIME ) ) ); - assertFalse( filter.include( newArtifact( Artifact.SCOPE_TEST ) ) ); - } - - public void testInclude_Runtime() - { - ScopeArtifactFilter filter = new ScopeArtifactFilter( Artifact.SCOPE_RUNTIME ); - - assertTrue( filter.include( newArtifact( Artifact.SCOPE_COMPILE ) ) ); - assertFalse( filter.include( newArtifact( Artifact.SCOPE_SYSTEM ) ) ); - assertFalse( filter.include( newArtifact( Artifact.SCOPE_PROVIDED ) ) ); - assertTrue( filter.include( newArtifact( Artifact.SCOPE_RUNTIME ) ) ); - assertFalse( filter.include( newArtifact( Artifact.SCOPE_TEST ) ) ); - } - - public void testInclude_RuntimePlusSystem() - { - ScopeArtifactFilter filter = new ScopeArtifactFilter( Artifact.SCOPE_RUNTIME_PLUS_SYSTEM ); - - assertTrue( filter.include( newArtifact( Artifact.SCOPE_COMPILE ) ) ); - assertTrue( filter.include( newArtifact( Artifact.SCOPE_SYSTEM ) ) ); - assertFalse( filter.include( newArtifact( Artifact.SCOPE_PROVIDED ) ) ); - assertTrue( filter.include( newArtifact( Artifact.SCOPE_RUNTIME ) ) ); - assertFalse( filter.include( newArtifact( Artifact.SCOPE_TEST ) ) ); - } - - public void testInclude_Test() - { - ScopeArtifactFilter filter = new ScopeArtifactFilter( Artifact.SCOPE_TEST ); - - assertTrue( filter.include( newArtifact( Artifact.SCOPE_COMPILE ) ) ); - assertTrue( filter.include( newArtifact( Artifact.SCOPE_SYSTEM ) ) ); - assertTrue( filter.include( newArtifact( Artifact.SCOPE_PROVIDED ) ) ); - assertTrue( filter.include( newArtifact( Artifact.SCOPE_RUNTIME ) ) ); - assertTrue( filter.include( newArtifact( Artifact.SCOPE_TEST ) ) ); - } - -} diff --git a/framework/src/maven/apache-maven-3.3.3/maven-compat/src/test/java/org/apache/maven/artifact/testutils/TestFileManager.java b/framework/src/maven/apache-maven-3.3.3/maven-compat/src/test/java/org/apache/maven/artifact/testutils/TestFileManager.java deleted file mode 100644 index a9f1ab7d..00000000 --- a/framework/src/maven/apache-maven-3.3.3/maven-compat/src/test/java/org/apache/maven/artifact/testutils/TestFileManager.java +++ /dev/null @@ -1,224 +0,0 @@ -package org.apache.maven.artifact.testutils; - -/* - * 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. - */ - -/* - * 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.io.IOException; -import java.util.ArrayList; -import java.util.Iterator; -import java.util.List; - -import junit.framework.Assert; - -import org.codehaus.plexus.util.FileUtils; - -public class TestFileManager -{ - - public static final String TEMP_DIR_PATH = System.getProperty( "java.io.tmpdir" ); - - private List<File> filesToDelete = new ArrayList<File>(); - - private final String baseFilename; - - private final String fileSuffix; - - private StackTraceElement callerInfo; - - private Thread cleanupWarning; - - private boolean warnAboutCleanup = false; - - public TestFileManager( String baseFilename, String fileSuffix ) - { - this.baseFilename = baseFilename; - this.fileSuffix = fileSuffix; - - initializeCleanupMonitoring(); - } - - private void initializeCleanupMonitoring() - { - callerInfo = new NullPointerException().getStackTrace()[2]; - - Runnable warning = new Runnable() - { - - public void run() - { - maybeWarnAboutCleanUp(); - } - - }; - - cleanupWarning = new Thread( warning ); - - Runtime.getRuntime().addShutdownHook( cleanupWarning ); - } - - private void maybeWarnAboutCleanUp() - { - if ( warnAboutCleanup ) - { - System.out.println( "[WARNING] TestFileManager from: " + callerInfo.getClassName() + " not cleaned up!" ); - } - } - - public void markForDeletion( File toDelete ) - { - filesToDelete.add( toDelete ); - warnAboutCleanup = true; - } - - public synchronized File createTempDir() - { - try - { - Thread.sleep( 20 ); - } - catch ( InterruptedException e ) - { - // ignore - } - - File dir = new File( TEMP_DIR_PATH, baseFilename + System.currentTimeMillis() ); - - dir.mkdirs(); - markForDeletion( dir ); - - return dir; - } - - public synchronized File createTempFile() - throws IOException - { - File tempFile = File.createTempFile( baseFilename, fileSuffix ); - tempFile.deleteOnExit(); - markForDeletion( tempFile ); - - return tempFile; - } - - public void cleanUp() - throws IOException - { - for ( Iterator it = filesToDelete.iterator(); it.hasNext(); ) - { - File file = (File) it.next(); - - if ( file.exists() ) - { - if ( file.isDirectory() ) - { - FileUtils.deleteDirectory( file ); - } - else - { - file.delete(); - } - } - - it.remove(); - } - - warnAboutCleanup = false; - } - - public void assertFileExistence( File dir, String filename, boolean shouldExist ) - { - File file = new File( dir, filename ); - - if ( shouldExist ) - { - Assert.assertTrue( file.exists() ); - } - else - { - Assert.assertFalse( file.exists() ); - } - } - - public void assertFileContents( File dir, String filename, String contentsTest, String encoding ) - throws IOException - { - assertFileExistence( dir, filename, true ); - - File file = new File( dir, filename ); - - String contents = FileUtils.fileRead( file, encoding ); - - Assert.assertEquals( contentsTest, contents ); - } - - public File createFile( File dir, String filename, String contents, String encoding ) - throws IOException - { - File file = new File( dir, filename ); - - file.getParentFile().mkdirs(); - - FileUtils.fileWrite( file.getPath(), encoding, contents ); - - markForDeletion( file ); - - return file; - } - - public String getFileContents( File file, String encoding ) - throws IOException - { - return FileUtils.fileRead( file, encoding ); - } - - protected void finalize() - throws Throwable - { - maybeWarnAboutCleanUp(); - - super.finalize(); - } - - public File createFile( String filename, String content, String encoding ) - throws IOException - { - File dir = createTempDir(); - return createFile( dir, filename, content, encoding ); - } - -} diff --git a/framework/src/maven/apache-maven-3.3.3/maven-compat/src/test/java/org/apache/maven/artifact/transform/TransformationManagerTest.java b/framework/src/maven/apache-maven-3.3.3/maven-compat/src/test/java/org/apache/maven/artifact/transform/TransformationManagerTest.java deleted file mode 100644 index 38450929..00000000 --- a/framework/src/maven/apache-maven-3.3.3/maven-compat/src/test/java/org/apache/maven/artifact/transform/TransformationManagerTest.java +++ /dev/null @@ -1,46 +0,0 @@ -package org.apache.maven.artifact.transform; - -/* - * Licensed to the Apache Software Foundation (ASF) under one or more contributor license - * agreements. See the NOTICE file distributed with this work for additional information regarding - * copyright ownership. The ASF licenses this file to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance with the License. You may obtain a - * copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software distributed under the License - * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express - * or implied. See the License for the specific language governing permissions and limitations under - * the License. - */ - -import java.util.List; - -import org.apache.maven.repository.legacy.resolver.transform.ArtifactTransformationManager; -import org.apache.maven.repository.legacy.resolver.transform.LatestArtifactTransformation; -import org.apache.maven.repository.legacy.resolver.transform.ReleaseArtifactTransformation; -import org.apache.maven.repository.legacy.resolver.transform.SnapshotTransformation; -import org.codehaus.plexus.PlexusTestCase; - -/** @author Jason van Zyl */ -public class TransformationManagerTest - extends PlexusTestCase -{ - public void testTransformationManager() - throws Exception - { - ArtifactTransformationManager tm = lookup( ArtifactTransformationManager.class ); - - List tms = tm.getArtifactTransformations(); - - assertEquals( 3, tms.size() ); - - assertTrue( "We expected the release transformation and got " + tms.get(0), tms.get(0) instanceof ReleaseArtifactTransformation ); - - assertTrue( "We expected the latest transformation and got " + tms.get(1), tms.get(1) instanceof LatestArtifactTransformation ); - - assertTrue( "We expected the snapshot transformation and got " + tms.get(2), tms.get(2) instanceof SnapshotTransformation ); - } - -} |