aboutsummaryrefslogtreecommitdiffstats
path: root/framework/src/maven/apache-maven-3.3.3/maven-compat/src/test/java/org
diff options
context:
space:
mode:
Diffstat (limited to 'framework/src/maven/apache-maven-3.3.3/maven-compat/src/test/java/org')
-rw-r--r--framework/src/maven/apache-maven-3.3.3/maven-compat/src/test/java/org/apache/maven/artifact/AbstractArtifactComponentTestCase.java371
-rw-r--r--framework/src/maven/apache-maven-3.3.3/maven-compat/src/test/java/org/apache/maven/artifact/ArtifactUtilsTest.java79
-rw-r--r--framework/src/maven/apache-maven-3.3.3/maven-compat/src/test/java/org/apache/maven/artifact/DefaultArtifactTest.java140
-rw-r--r--framework/src/maven/apache-maven-3.3.3/maven-compat/src/test/java/org/apache/maven/artifact/deployer/ArtifactDeployerTest.java67
-rw-r--r--framework/src/maven/apache-maven-3.3.3/maven-compat/src/test/java/org/apache/maven/artifact/deployer/SimpleArtifactMetadataSource.java66
-rw-r--r--framework/src/maven/apache-maven-3.3.3/maven-compat/src/test/java/org/apache/maven/artifact/factory/DefaultArtifactFactoryTest.java49
-rw-r--r--framework/src/maven/apache-maven-3.3.3/maven-compat/src/test/java/org/apache/maven/artifact/handler/ArtifactHandlerMock.java100
-rw-r--r--framework/src/maven/apache-maven-3.3.3/maven-compat/src/test/java/org/apache/maven/artifact/installer/ArtifactInstallerTest.java61
-rw-r--r--framework/src/maven/apache-maven-3.3.3/maven-compat/src/test/java/org/apache/maven/artifact/metadata/TestMetadataSource.java102
-rw-r--r--framework/src/maven/apache-maven-3.3.3/maven-compat/src/test/java/org/apache/maven/artifact/repository/MavenArtifactRepositoryTest.java59
-rw-r--r--framework/src/maven/apache-maven-3.3.3/maven-compat/src/test/java/org/apache/maven/artifact/resolver/ArtifactResolutionExceptionTest.java64
-rw-r--r--framework/src/maven/apache-maven-3.3.3/maven-compat/src/test/java/org/apache/maven/artifact/resolver/ArtifactResolverTest.java283
-rw-r--r--framework/src/maven/apache-maven-3.3.3/maven-compat/src/test/java/org/apache/maven/artifact/resolver/DefaultArtifactResolverTest.java111
-rw-r--r--framework/src/maven/apache-maven-3.3.3/maven-compat/src/test/java/org/apache/maven/artifact/resolver/TestFileWagon.java94
-rw-r--r--framework/src/maven/apache-maven-3.3.3/maven-compat/src/test/java/org/apache/maven/artifact/resolver/TestTransferListener.java43
-rw-r--r--framework/src/maven/apache-maven-3.3.3/maven-compat/src/test/java/org/apache/maven/artifact/resolver/filter/AndArtifactFilterTest.java62
-rw-r--r--framework/src/maven/apache-maven-3.3.3/maven-compat/src/test/java/org/apache/maven/artifact/resolver/filter/FilterHashEqualsTest.java50
-rw-r--r--framework/src/maven/apache-maven-3.3.3/maven-compat/src/test/java/org/apache/maven/artifact/resolver/filter/OrArtifactFilterTest.java62
-rw-r--r--framework/src/maven/apache-maven-3.3.3/maven-compat/src/test/java/org/apache/maven/artifact/resolver/filter/ScopeArtifactFilterTest.java96
-rw-r--r--framework/src/maven/apache-maven-3.3.3/maven-compat/src/test/java/org/apache/maven/artifact/testutils/TestFileManager.java224
-rw-r--r--framework/src/maven/apache-maven-3.3.3/maven-compat/src/test/java/org/apache/maven/artifact/transform/TransformationManagerTest.java46
-rw-r--r--framework/src/maven/apache-maven-3.3.3/maven-compat/src/test/java/org/apache/maven/profiles/manager/DefaultProfileManagerTest.java232
-rw-r--r--framework/src/maven/apache-maven-3.3.3/maven-compat/src/test/java/org/apache/maven/project/AbstractMavenProjectTestCase.java185
-rw-r--r--framework/src/maven/apache-maven-3.3.3/maven-compat/src/test/java/org/apache/maven/project/ClasspathArtifactResolver.java89
-rw-r--r--framework/src/maven/apache-maven-3.3.3/maven-compat/src/test/java/org/apache/maven/project/EmptyLifecycleExecutor.java110
-rw-r--r--framework/src/maven/apache-maven-3.3.3/maven-compat/src/test/java/org/apache/maven/project/EmptyLifecyclePluginAnalyzer.java78
-rw-r--r--framework/src/maven/apache-maven-3.3.3/maven-compat/src/test/java/org/apache/maven/project/LegacyLocalRepositoryManager.java192
-rw-r--r--framework/src/maven/apache-maven-3.3.3/maven-compat/src/test/java/org/apache/maven/project/ModelUtilsTest.java616
-rw-r--r--framework/src/maven/apache-maven-3.3.3/maven-compat/src/test/java/org/apache/maven/project/ProjectClasspathTest.java149
-rw-r--r--framework/src/maven/apache-maven-3.3.3/maven-compat/src/test/java/org/apache/maven/project/TestArtifactResolver.java30
-rw-r--r--framework/src/maven/apache-maven-3.3.3/maven-compat/src/test/java/org/apache/maven/project/TestMavenRepositorySystem.java30
-rw-r--r--framework/src/maven/apache-maven-3.3.3/maven-compat/src/test/java/org/apache/maven/project/TestProjectBuilder.java68
-rw-r--r--framework/src/maven/apache-maven-3.3.3/maven-compat/src/test/java/org/apache/maven/project/inheritance/AbstractProjectInheritanceTestCase.java57
-rw-r--r--framework/src/maven/apache-maven-3.3.3/maven-compat/src/test/java/org/apache/maven/project/inheritance/t00/ProjectInheritanceTest.java93
-rw-r--r--framework/src/maven/apache-maven-3.3.3/maven-compat/src/test/java/org/apache/maven/project/inheritance/t01/ProjectInheritanceTest.java92
-rw-r--r--framework/src/maven/apache-maven-3.3.3/maven-compat/src/test/java/org/apache/maven/project/inheritance/t02/ProjectInheritanceTest.java169
-rw-r--r--framework/src/maven/apache-maven-3.3.3/maven-compat/src/test/java/org/apache/maven/project/inheritance/t03/ProjectInheritanceTest.java68
-rw-r--r--framework/src/maven/apache-maven-3.3.3/maven-compat/src/test/java/org/apache/maven/project/inheritance/t04/ProjectInheritanceTest.java86
-rw-r--r--framework/src/maven/apache-maven-3.3.3/maven-compat/src/test/java/org/apache/maven/project/inheritance/t05/ProjectInheritanceTest.java79
-rw-r--r--framework/src/maven/apache-maven-3.3.3/maven-compat/src/test/java/org/apache/maven/project/inheritance/t06/ProjectInheritanceTest.java80
-rw-r--r--framework/src/maven/apache-maven-3.3.3/maven-compat/src/test/java/org/apache/maven/project/inheritance/t07/ProjectInheritanceTest.java82
-rw-r--r--framework/src/maven/apache-maven-3.3.3/maven-compat/src/test/java/org/apache/maven/project/inheritance/t08/ProjectInheritanceTest.java81
-rw-r--r--framework/src/maven/apache-maven-3.3.3/maven-compat/src/test/java/org/apache/maven/project/inheritance/t09/ProjectInheritanceTest.java119
-rw-r--r--framework/src/maven/apache-maven-3.3.3/maven-compat/src/test/java/org/apache/maven/project/inheritance/t10/ProjectInheritanceTest.java94
-rw-r--r--framework/src/maven/apache-maven-3.3.3/maven-compat/src/test/java/org/apache/maven/project/inheritance/t11/ProjectInheritanceTest.java64
-rw-r--r--framework/src/maven/apache-maven-3.3.3/maven-compat/src/test/java/org/apache/maven/project/inheritance/t12/ProjectInheritanceTest.java65
-rw-r--r--framework/src/maven/apache-maven-3.3.3/maven-compat/src/test/java/org/apache/maven/project/inheritance/t12scm/ProjectInheritanceTest.java125
-rw-r--r--framework/src/maven/apache-maven-3.3.3/maven-compat/src/test/java/org/apache/maven/project/path/DefaultPathTranslatorTest.java58
-rw-r--r--framework/src/maven/apache-maven-3.3.3/maven-compat/src/test/java/org/apache/maven/repository/DefaultMirrorSelectorTest.java38
-rw-r--r--framework/src/maven/apache-maven-3.3.3/maven-compat/src/test/java/org/apache/maven/repository/LegacyRepositoryLayout.java89
-rw-r--r--framework/src/maven/apache-maven-3.3.3/maven-compat/src/test/java/org/apache/maven/repository/LegacyRepositorySystemTest.java206
-rw-r--r--framework/src/maven/apache-maven-3.3.3/maven-compat/src/test/java/org/apache/maven/repository/MirrorProcessorTest.java259
-rw-r--r--framework/src/maven/apache-maven-3.3.3/maven-compat/src/test/java/org/apache/maven/repository/legacy/DefaultUpdateCheckManagerTest.java240
-rw-r--r--framework/src/maven/apache-maven-3.3.3/maven-compat/src/test/java/org/apache/maven/repository/legacy/DefaultWagonManagerTest.java422
-rw-r--r--framework/src/maven/apache-maven-3.3.3/maven-compat/src/test/java/org/apache/maven/repository/legacy/LegacyRepositorySystemTest.java88
-rw-r--r--framework/src/maven/apache-maven-3.3.3/maven-compat/src/test/java/org/apache/maven/repository/legacy/PerLookupWagon.java38
-rw-r--r--framework/src/maven/apache-maven-3.3.3/maven-compat/src/test/java/org/apache/maven/repository/legacy/StringWagon.java107
-rw-r--r--framework/src/maven/apache-maven-3.3.3/maven-compat/src/test/java/org/apache/maven/repository/legacy/WagonA.java39
-rw-r--r--framework/src/maven/apache-maven-3.3.3/maven-compat/src/test/java/org/apache/maven/repository/legacy/WagonB.java39
-rw-r--r--framework/src/maven/apache-maven-3.3.3/maven-compat/src/test/java/org/apache/maven/repository/legacy/WagonC.java39
-rw-r--r--framework/src/maven/apache-maven-3.3.3/maven-compat/src/test/java/org/apache/maven/repository/legacy/WagonMock.java50
-rw-r--r--framework/src/maven/apache-maven-3.3.3/maven-compat/src/test/java/org/apache/maven/repository/legacy/resolver/DefaultArtifactCollectorTest.java984
-rw-r--r--framework/src/maven/apache-maven-3.3.3/maven-compat/src/test/java/org/apache/maven/repository/legacy/resolver/conflict/AbstractConflictResolverTest.java143
-rw-r--r--framework/src/maven/apache-maven-3.3.3/maven-compat/src/test/java/org/apache/maven/repository/legacy/resolver/conflict/FarthestConflictResolverTest.java107
-rw-r--r--framework/src/maven/apache-maven-3.3.3/maven-compat/src/test/java/org/apache/maven/repository/legacy/resolver/conflict/NearestConflictResolverTest.java107
-rw-r--r--framework/src/maven/apache-maven-3.3.3/maven-compat/src/test/java/org/apache/maven/repository/legacy/resolver/conflict/NewestConflictResolverTest.java107
-rw-r--r--framework/src/maven/apache-maven-3.3.3/maven-compat/src/test/java/org/apache/maven/repository/legacy/resolver/conflict/OldestConflictResolverTest.java107
-rw-r--r--framework/src/maven/apache-maven-3.3.3/maven-compat/src/test/java/org/apache/maven/repository/metadata/DefaultClasspathTransformationTest.java120
-rw-r--r--framework/src/maven/apache-maven-3.3.3/maven-compat/src/test/java/org/apache/maven/repository/metadata/DefaultGraphConflictResolutionPolicyTest.java59
-rw-r--r--framework/src/maven/apache-maven-3.3.3/maven-compat/src/test/java/org/apache/maven/repository/metadata/DefaultGraphConflictResolverTest.java153
-rw-r--r--framework/src/maven/apache-maven-3.3.3/maven-compat/src/test/java/org/apache/maven/repository/metadata/TestMetadataSource.java99
71 files changed, 9060 insertions, 0 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
new file mode 100644
index 00000000..010c566b
--- /dev/null
+++ b/framework/src/maven/apache-maven-3.3.3/maven-compat/src/test/java/org/apache/maven/artifact/AbstractArtifactComponentTestCase.java
@@ -0,0 +1,371 @@
+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
new file mode 100644
index 00000000..7b20eb5d
--- /dev/null
+++ b/framework/src/maven/apache-maven-3.3.3/maven-compat/src/test/java/org/apache/maven/artifact/ArtifactUtilsTest.java
@@ -0,0 +1,79 @@
+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
new file mode 100644
index 00000000..fbd01191
--- /dev/null
+++ b/framework/src/maven/apache-maven-3.3.3/maven-compat/src/test/java/org/apache/maven/artifact/DefaultArtifactTest.java
@@ -0,0 +1,140 @@
+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
new file mode 100644
index 00000000..f929f480
--- /dev/null
+++ b/framework/src/maven/apache-maven-3.3.3/maven-compat/src/test/java/org/apache/maven/artifact/deployer/ArtifactDeployerTest.java
@@ -0,0 +1,67 @@
+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
new file mode 100644
index 00000000..f6bebcba
--- /dev/null
+++ b/framework/src/maven/apache-maven-3.3.3/maven-compat/src/test/java/org/apache/maven/artifact/deployer/SimpleArtifactMetadataSource.java
@@ -0,0 +1,66 @@
+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
new file mode 100644
index 00000000..0d109acb
--- /dev/null
+++ b/framework/src/maven/apache-maven-3.3.3/maven-compat/src/test/java/org/apache/maven/artifact/factory/DefaultArtifactFactoryTest.java
@@ -0,0 +1,49 @@
+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
new file mode 100644
index 00000000..a9f335e6
--- /dev/null
+++ b/framework/src/maven/apache-maven-3.3.3/maven-compat/src/test/java/org/apache/maven/artifact/handler/ArtifactHandlerMock.java
@@ -0,0 +1,100 @@
+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
new file mode 100644
index 00000000..21bfb2b7
--- /dev/null
+++ b/framework/src/maven/apache-maven-3.3.3/maven-compat/src/test/java/org/apache/maven/artifact/installer/ArtifactInstallerTest.java
@@ -0,0 +1,61 @@
+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
new file mode 100644
index 00000000..f8bb1677
--- /dev/null
+++ b/framework/src/maven/apache-maven-3.3.3/maven-compat/src/test/java/org/apache/maven/artifact/metadata/TestMetadataSource.java
@@ -0,0 +1,102 @@
+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
new file mode 100644
index 00000000..533f3042
--- /dev/null
+++ b/framework/src/maven/apache-maven-3.3.3/maven-compat/src/test/java/org/apache/maven/artifact/repository/MavenArtifactRepositoryTest.java
@@ -0,0 +1,59 @@
+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
new file mode 100644
index 00000000..aeacfb81
--- /dev/null
+++ b/framework/src/maven/apache-maven-3.3.3/maven-compat/src/test/java/org/apache/maven/artifact/resolver/ArtifactResolutionExceptionTest.java
@@ -0,0 +1,64 @@
+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
new file mode 100644
index 00000000..117c0e22
--- /dev/null
+++ b/framework/src/maven/apache-maven-3.3.3/maven-compat/src/test/java/org/apache/maven/artifact/resolver/ArtifactResolverTest.java
@@ -0,0 +1,283 @@
+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
new file mode 100644
index 00000000..914d9d1c
--- /dev/null
+++ b/framework/src/maven/apache-maven-3.3.3/maven-compat/src/test/java/org/apache/maven/artifact/resolver/DefaultArtifactResolverTest.java
@@ -0,0 +1,111 @@
+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
new file mode 100644
index 00000000..c78c1901
--- /dev/null
+++ b/framework/src/maven/apache-maven-3.3.3/maven-compat/src/test/java/org/apache/maven/artifact/resolver/TestFileWagon.java
@@ -0,0 +1,94 @@
+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
new file mode 100644
index 00000000..afec3ef5
--- /dev/null
+++ b/framework/src/maven/apache-maven-3.3.3/maven-compat/src/test/java/org/apache/maven/artifact/resolver/TestTransferListener.java
@@ -0,0 +1,43 @@
+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
new file mode 100644
index 00000000..bca112b8
--- /dev/null
+++ b/framework/src/maven/apache-maven-3.3.3/maven-compat/src/test/java/org/apache/maven/artifact/resolver/filter/AndArtifactFilterTest.java
@@ -0,0 +1,62 @@
+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
new file mode 100644
index 00000000..fb465663
--- /dev/null
+++ b/framework/src/maven/apache-maven-3.3.3/maven-compat/src/test/java/org/apache/maven/artifact/resolver/filter/FilterHashEqualsTest.java
@@ -0,0 +1,50 @@
+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
new file mode 100644
index 00000000..e161437f
--- /dev/null
+++ b/framework/src/maven/apache-maven-3.3.3/maven-compat/src/test/java/org/apache/maven/artifact/resolver/filter/OrArtifactFilterTest.java
@@ -0,0 +1,62 @@
+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
new file mode 100644
index 00000000..1a65eca0
--- /dev/null
+++ b/framework/src/maven/apache-maven-3.3.3/maven-compat/src/test/java/org/apache/maven/artifact/resolver/filter/ScopeArtifactFilterTest.java
@@ -0,0 +1,96 @@
+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
new file mode 100644
index 00000000..a9f1ab7d
--- /dev/null
+++ b/framework/src/maven/apache-maven-3.3.3/maven-compat/src/test/java/org/apache/maven/artifact/testutils/TestFileManager.java
@@ -0,0 +1,224 @@
+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
new file mode 100644
index 00000000..38450929
--- /dev/null
+++ b/framework/src/maven/apache-maven-3.3.3/maven-compat/src/test/java/org/apache/maven/artifact/transform/TransformationManagerTest.java
@@ -0,0 +1,46 @@
+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 );
+ }
+
+}
diff --git a/framework/src/maven/apache-maven-3.3.3/maven-compat/src/test/java/org/apache/maven/profiles/manager/DefaultProfileManagerTest.java b/framework/src/maven/apache-maven-3.3.3/maven-compat/src/test/java/org/apache/maven/profiles/manager/DefaultProfileManagerTest.java
new file mode 100644
index 00000000..8e3b86a6
--- /dev/null
+++ b/framework/src/maven/apache-maven-3.3.3/maven-compat/src/test/java/org/apache/maven/profiles/manager/DefaultProfileManagerTest.java
@@ -0,0 +1,232 @@
+package org.apache.maven.profiles.manager;
+
+/*
+ * 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 java.util.Properties;
+
+import org.apache.maven.model.Activation;
+import org.apache.maven.model.ActivationProperty;
+import org.apache.maven.model.Profile;
+import org.apache.maven.profiles.DefaultProfileManager;
+import org.apache.maven.profiles.ProfileManager;
+import org.codehaus.plexus.PlexusTestCase;
+
+public class DefaultProfileManagerTest
+ extends PlexusTestCase
+{
+
+ public void setUp()
+ throws Exception
+ {
+ super.setUp();
+ }
+
+ public void testShouldActivateDefaultProfile()
+ throws Exception
+ {
+ Profile notActivated = new Profile();
+ notActivated.setId( "notActivated" );
+
+ Activation nonActivation = new Activation();
+
+ nonActivation.setJdk( "19.2" );
+
+ notActivated.setActivation( nonActivation );
+
+ Profile defaultActivated = new Profile();
+ defaultActivated.setId( "defaultActivated" );
+
+ Activation defaultActivation = new Activation();
+
+ defaultActivation.setActiveByDefault( true );
+
+ defaultActivated.setActivation( defaultActivation );
+
+ Properties props = System.getProperties();
+
+ ProfileManager profileManager = new DefaultProfileManager( getContainer(), props );
+
+ profileManager.addProfile( notActivated );
+ profileManager.addProfile( defaultActivated );
+
+ List active = profileManager.getActiveProfiles();
+
+ assertNotNull( active );
+ assertEquals( 1, active.size() );
+ assertEquals( "defaultActivated", ( (Profile) active.get( 0 ) ).getId() );
+ }
+
+ public void testShouldNotActivateDefaultProfile()
+ throws Exception
+ {
+ Profile syspropActivated = new Profile();
+ syspropActivated.setId( "syspropActivated" );
+
+ Activation syspropActivation = new Activation();
+
+ ActivationProperty syspropProperty = new ActivationProperty();
+ syspropProperty.setName( "java.version" );
+
+ syspropActivation.setProperty( syspropProperty );
+
+ syspropActivated.setActivation( syspropActivation );
+
+ Profile defaultActivated = new Profile();
+ defaultActivated.setId( "defaultActivated" );
+
+ Activation defaultActivation = new Activation();
+
+ defaultActivation.setActiveByDefault( true );
+
+ defaultActivated.setActivation( defaultActivation );
+
+ Properties props = System.getProperties();
+
+ ProfileManager profileManager = new DefaultProfileManager( getContainer(), props );
+
+ profileManager.addProfile( syspropActivated );
+ profileManager.addProfile( defaultActivated );
+
+ List active = profileManager.getActiveProfiles();
+
+ assertNotNull( active );
+ assertEquals( 1, active.size() );
+ assertEquals( "syspropActivated", ( (Profile) active.get( 0 ) ).getId() );
+ }
+
+
+ public void testShouldNotActivateReversalOfPresentSystemProperty()
+ throws Exception
+ {
+ Profile syspropActivated = new Profile();
+ syspropActivated.setId( "syspropActivated" );
+
+ Activation syspropActivation = new Activation();
+
+ ActivationProperty syspropProperty = new ActivationProperty();
+ syspropProperty.setName( "!java.version" );
+
+ syspropActivation.setProperty( syspropProperty );
+
+ syspropActivated.setActivation( syspropActivation );
+
+ Properties props = System.getProperties();
+
+ ProfileManager profileManager = new DefaultProfileManager( getContainer(), props );
+
+ profileManager.addProfile( syspropActivated );
+
+ List active = profileManager.getActiveProfiles();
+
+ assertNotNull( active );
+ assertEquals( 0, active.size() );
+ }
+
+ public void testShouldOverrideAndActivateInactiveProfile()
+ throws Exception
+ {
+ Profile syspropActivated = new Profile();
+ syspropActivated.setId( "syspropActivated" );
+
+ Activation syspropActivation = new Activation();
+
+ ActivationProperty syspropProperty = new ActivationProperty();
+ syspropProperty.setName( "!java.version" );
+
+ syspropActivation.setProperty( syspropProperty );
+
+ syspropActivated.setActivation( syspropActivation );
+
+ Properties props = System.getProperties();
+
+ ProfileManager profileManager = new DefaultProfileManager( getContainer(), props );
+
+ profileManager.addProfile( syspropActivated );
+
+ profileManager.explicitlyActivate( "syspropActivated" );
+
+ List active = profileManager.getActiveProfiles();
+
+ assertNotNull( active );
+ assertEquals( 1, active.size() );
+ assertEquals( "syspropActivated", ( (Profile) active.get( 0 ) ).getId() );
+ }
+
+ public void testShouldOverrideAndDeactivateActiveProfile()
+ throws Exception
+ {
+ Profile syspropActivated = new Profile();
+ syspropActivated.setId( "syspropActivated" );
+
+ Activation syspropActivation = new Activation();
+
+ ActivationProperty syspropProperty = new ActivationProperty();
+ syspropProperty.setName( "java.version" );
+
+ syspropActivation.setProperty( syspropProperty );
+
+ syspropActivated.setActivation( syspropActivation );
+
+ Properties props = System.getProperties();
+
+ ProfileManager profileManager = new DefaultProfileManager( getContainer(), props );
+
+ profileManager.addProfile( syspropActivated );
+
+ profileManager.explicitlyDeactivate( "syspropActivated" );
+
+ List active = profileManager.getActiveProfiles();
+
+ assertNotNull( active );
+ assertEquals( 0, active.size() );
+ }
+/*
+ public void testOsActivationProfile()
+ throws Exception
+ {
+ Profile osActivated = new Profile();
+ osActivated.setId( "os-profile" );
+
+ Activation osActivation = new Activation();
+
+ ActivationOS activationOS = new ActivationOS();
+
+ activationOS.setName( "!dddd" );
+
+ osActivation.setOs( activationOS );
+
+ osActivated.setActivation( osActivation );
+
+ Properties props = System.getProperties();
+ ProfileActivationContext ctx = new ProfileActivationContext( props, false );
+
+ ProfileManager profileManager = new DefaultProfileManager( getContainer(), props );
+
+ profileManager.addProfile( osActivated );
+
+ List active = profileManager.getActiveProfiles( null );
+
+ assertNotNull( active );
+ assertEquals( 1, active.size() );
+ }
+ */
+
+}
diff --git a/framework/src/maven/apache-maven-3.3.3/maven-compat/src/test/java/org/apache/maven/project/AbstractMavenProjectTestCase.java b/framework/src/maven/apache-maven-3.3.3/maven-compat/src/test/java/org/apache/maven/project/AbstractMavenProjectTestCase.java
new file mode 100644
index 00000000..7e3f7e6b
--- /dev/null
+++ b/framework/src/maven/apache-maven-3.3.3/maven-compat/src/test/java/org/apache/maven/project/AbstractMavenProjectTestCase.java
@@ -0,0 +1,185 @@
+package org.apache.maven.project;
+
+/*
+ * 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.FileNotFoundException;
+import java.net.URI;
+import java.net.URISyntaxException;
+import java.net.URL;
+import java.util.Arrays;
+
+import org.apache.maven.artifact.repository.ArtifactRepository;
+import org.apache.maven.artifact.repository.layout.ArtifactRepositoryLayout;
+import org.apache.maven.model.building.ModelBuildingException;
+import org.apache.maven.model.building.ModelProblem;
+import org.apache.maven.repository.RepositorySystem;
+import org.apache.maven.repository.internal.MavenRepositorySystemUtils;
+import org.codehaus.plexus.ContainerConfiguration;
+import org.codehaus.plexus.PlexusConstants;
+import org.codehaus.plexus.PlexusTestCase;
+import org.eclipse.aether.DefaultRepositorySystemSession;
+
+/**
+ * @author Jason van Zyl
+ */
+public abstract class AbstractMavenProjectTestCase
+ extends PlexusTestCase
+{
+ protected ProjectBuilder projectBuilder;
+
+ protected RepositorySystem repositorySystem;
+
+ @Override
+ protected void customizeContainerConfiguration( ContainerConfiguration containerConfiguration )
+ {
+ super.customizeContainerConfiguration( containerConfiguration );
+ containerConfiguration.setAutoWiring( true );
+ containerConfiguration.setClassPathScanning( PlexusConstants.SCANNING_INDEX );
+ }
+
+ protected void setUp()
+ throws Exception
+ {
+ super.setUp();
+
+ if ( getContainer().hasComponent( ProjectBuilder.class, "test" ) )
+ {
+ projectBuilder = lookup( ProjectBuilder.class, "test" );
+ }
+ else
+ {
+ // default over to the main project builder...
+ projectBuilder = lookup( ProjectBuilder.class );
+ }
+
+ repositorySystem = lookup( RepositorySystem.class );
+ }
+
+ @Override
+ protected void tearDown()
+ throws Exception
+ {
+ projectBuilder = null;
+
+ super.tearDown();
+ }
+
+ protected ProjectBuilder getProjectBuilder()
+ {
+ return projectBuilder;
+ }
+
+ @Override
+ protected String getCustomConfigurationName()
+ {
+ String name = AbstractMavenProjectTestCase.class.getName().replace( '.', '/' ) + ".xml";
+ System.out.println( name );
+ return name;
+ }
+
+ // ----------------------------------------------------------------------
+ // Local repository
+ // ----------------------------------------------------------------------
+
+ protected File getLocalRepositoryPath()
+ throws FileNotFoundException, URISyntaxException
+ {
+ File markerFile = getFileForClasspathResource( "local-repo/marker.txt" );
+
+ return markerFile.getAbsoluteFile().getParentFile();
+ }
+
+ protected static File getFileForClasspathResource( String resource )
+ throws FileNotFoundException
+ {
+ ClassLoader cloader = Thread.currentThread().getContextClassLoader();
+
+ URL resourceUrl = cloader.getResource( resource );
+
+ if ( resourceUrl == null )
+ {
+ throw new FileNotFoundException( "Unable to find: " + resource );
+ }
+
+ return new File( URI.create( resourceUrl.toString().replaceAll( " ", "%20" ) ) );
+ }
+
+ protected ArtifactRepository getLocalRepository()
+ throws Exception
+ {
+ ArtifactRepositoryLayout repoLayout = lookup( ArtifactRepositoryLayout.class, "legacy" );
+
+ ArtifactRepository r = repositorySystem.createArtifactRepository( "local", "file://" + getLocalRepositoryPath().getAbsolutePath(), repoLayout, null, null );
+
+ return r;
+ }
+
+ // ----------------------------------------------------------------------
+ // Project building
+ // ----------------------------------------------------------------------
+
+ protected MavenProject getProjectWithDependencies( File pom )
+ throws Exception
+ {
+ ProjectBuildingRequest configuration = new DefaultProjectBuildingRequest();
+ configuration.setLocalRepository( getLocalRepository() );
+ configuration.setRemoteRepositories( Arrays.asList( new ArtifactRepository[] {} ) );
+ configuration.setProcessPlugins( false );
+ configuration.setResolveDependencies( true );
+ initRepoSession( configuration );
+
+ try
+ {
+ return projectBuilder.build( pom, configuration ).getProject();
+ }
+ catch ( Exception e )
+ {
+ Throwable cause = e.getCause();
+ if ( cause instanceof ModelBuildingException )
+ {
+ String message = "In: " + pom + "\n\n";
+ for ( ModelProblem problem : ( (ModelBuildingException) cause ).getProblems() )
+ {
+ message += problem + "\n";
+ }
+ System.out.println( message );
+ fail( message );
+ }
+
+ throw e;
+ }
+ }
+
+ protected MavenProject getProject( File pom )
+ throws Exception
+ {
+ ProjectBuildingRequest configuration = new DefaultProjectBuildingRequest();
+ configuration.setLocalRepository( getLocalRepository() );
+ initRepoSession( configuration );
+
+ return projectBuilder.build( pom, configuration ).getProject();
+ }
+
+ protected void initRepoSession( ProjectBuildingRequest request )
+ {
+ File localRepo = new File( request.getLocalRepository().getBasedir() );
+ DefaultRepositorySystemSession session = MavenRepositorySystemUtils.newSession();
+ session.setLocalRepositoryManager( new LegacyLocalRepositoryManager( localRepo ) );
+ request.setRepositorySession( session );
+ }
+
+}
diff --git a/framework/src/maven/apache-maven-3.3.3/maven-compat/src/test/java/org/apache/maven/project/ClasspathArtifactResolver.java b/framework/src/maven/apache-maven-3.3.3/maven-compat/src/test/java/org/apache/maven/project/ClasspathArtifactResolver.java
new file mode 100644
index 00000000..36eaee8f
--- /dev/null
+++ b/framework/src/maven/apache-maven-3.3.3/maven-compat/src/test/java/org/apache/maven/project/ClasspathArtifactResolver.java
@@ -0,0 +1,89 @@
+package org.apache.maven.project;
+
+/*
+ * 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.FileNotFoundException;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.List;
+
+import org.codehaus.plexus.component.annotations.Component;
+import org.eclipse.aether.RepositorySystemSession;
+import org.eclipse.aether.artifact.Artifact;
+import org.eclipse.aether.impl.ArtifactResolver;
+import org.eclipse.aether.resolution.ArtifactRequest;
+import org.eclipse.aether.resolution.ArtifactResolutionException;
+import org.eclipse.aether.resolution.ArtifactResult;
+import org.eclipse.aether.transfer.ArtifactNotFoundException;
+
+/**
+ * @author Benjamin Bentmann
+ */
+@Component( role = ArtifactResolver.class, hint = "classpath" )
+public class ClasspathArtifactResolver
+ implements ArtifactResolver
+{
+
+ public List<ArtifactResult> resolveArtifacts( RepositorySystemSession session,
+ Collection<? extends ArtifactRequest> requests )
+ throws ArtifactResolutionException
+ {
+ List<ArtifactResult> results = new ArrayList<ArtifactResult>();
+
+ for ( ArtifactRequest request : requests )
+ {
+ ArtifactResult result = new ArtifactResult( request );
+ results.add( result );
+
+ Artifact artifact = request.getArtifact();
+ if ( "maven-test".equals( artifact.getGroupId() ) )
+ {
+ String scope = artifact.getArtifactId().substring( "scope-".length() );
+
+ try
+ {
+ artifact =
+ artifact.setFile( ProjectClasspathTest.getFileForClasspathResource( ProjectClasspathTest.dir
+ + "transitive-" + scope + "-dep.xml" ) );
+ result.setArtifact( artifact );
+ }
+ catch ( FileNotFoundException e )
+ {
+ throw new IllegalStateException( "Missing test POM for " + artifact );
+ }
+ }
+ else
+ {
+ result.addException( new ArtifactNotFoundException( artifact, null ) );
+ throw new ArtifactResolutionException( results );
+ }
+ }
+
+ return results;
+ }
+
+ public ArtifactResult resolveArtifact( RepositorySystemSession session, ArtifactRequest request )
+ throws ArtifactResolutionException
+ {
+ return resolveArtifacts( session, Collections.singleton( request ) ).get( 0 );
+ }
+
+}
diff --git a/framework/src/maven/apache-maven-3.3.3/maven-compat/src/test/java/org/apache/maven/project/EmptyLifecycleExecutor.java b/framework/src/maven/apache-maven-3.3.3/maven-compat/src/test/java/org/apache/maven/project/EmptyLifecycleExecutor.java
new file mode 100644
index 00000000..024917de
--- /dev/null
+++ b/framework/src/maven/apache-maven-3.3.3/maven-compat/src/test/java/org/apache/maven/project/EmptyLifecycleExecutor.java
@@ -0,0 +1,110 @@
+package org.apache.maven.project;
+
+/*
+ * 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.LinkedHashSet;
+import java.util.List;
+import java.util.Set;
+
+import org.apache.maven.execution.MavenSession;
+import org.apache.maven.lifecycle.DefaultLifecycles;
+import org.apache.maven.lifecycle.LifecycleExecutor;
+import org.apache.maven.lifecycle.MavenExecutionPlan;
+import org.apache.maven.model.Plugin;
+import org.apache.maven.model.PluginExecution;
+import org.apache.maven.plugin.MojoExecution;
+
+/**
+ * A stub implementation that assumes an empty lifecycle to bypass interaction with the plugin manager and to avoid
+ * plugin artifact resolution from repositories.
+ *
+ * @author Benjamin Bentmann
+ */
+public class EmptyLifecycleExecutor
+ implements LifecycleExecutor
+{
+
+ public MavenExecutionPlan calculateExecutionPlan( MavenSession session, String... tasks )
+ {
+ return new MavenExecutionPlan( null, new DefaultLifecycles() );
+ }
+
+ public MavenExecutionPlan calculateExecutionPlan( MavenSession session, boolean setup, String... tasks )
+ {
+ return new MavenExecutionPlan( null, new DefaultLifecycles() );
+ }
+
+ public void execute( MavenSession session )
+ {
+ }
+
+ public Set<Plugin> getPluginsBoundByDefaultToAllLifecycles( String packaging )
+ {
+ Set<Plugin> plugins;
+
+ // NOTE: The upper-case packaging name is intentional, that's a special hinting mode used for certain tests
+ if ( "JAR".equals( packaging ) )
+ {
+ plugins = new LinkedHashSet<Plugin>();
+
+ plugins.add( newPlugin( "maven-compiler-plugin", "compile", "testCompile" ) );
+ plugins.add( newPlugin( "maven-resources-plugin", "resources", "testResources" ) );
+ plugins.add( newPlugin( "maven-surefire-plugin", "test" ) );
+ plugins.add( newPlugin( "maven-jar-plugin", "jar" ) );
+ plugins.add( newPlugin( "maven-install-plugin", "install" ) );
+ plugins.add( newPlugin( "maven-deploy-plugin", "deploy" ) );
+ }
+ else
+ {
+ plugins = Collections.emptySet();
+ }
+
+ return plugins;
+ }
+
+ private Plugin newPlugin( String artifactId, String... goals )
+ {
+ Plugin plugin = new Plugin();
+
+ plugin.setGroupId( "org.apache.maven.plugins" );
+ plugin.setArtifactId( artifactId );
+
+ for ( String goal : goals )
+ {
+ PluginExecution pluginExecution = new PluginExecution();
+ pluginExecution.setId( "default-" + goal );
+ pluginExecution.addGoal( goal );
+ plugin.addExecution( pluginExecution );
+ }
+
+ return plugin;
+ }
+
+ public void calculateForkedExecutions( MojoExecution mojoExecution, MavenSession session )
+ {
+ }
+
+ public List<MavenProject> executeForkedExecutions( MojoExecution mojoExecution, MavenSession session )
+ {
+ return Collections.emptyList();
+ }
+
+}
diff --git a/framework/src/maven/apache-maven-3.3.3/maven-compat/src/test/java/org/apache/maven/project/EmptyLifecyclePluginAnalyzer.java b/framework/src/maven/apache-maven-3.3.3/maven-compat/src/test/java/org/apache/maven/project/EmptyLifecyclePluginAnalyzer.java
new file mode 100644
index 00000000..5a78a7e5
--- /dev/null
+++ b/framework/src/maven/apache-maven-3.3.3/maven-compat/src/test/java/org/apache/maven/project/EmptyLifecyclePluginAnalyzer.java
@@ -0,0 +1,78 @@
+package org.apache.maven.project;
+
+/*
+ * 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.LinkedHashSet;
+import java.util.Set;
+
+import org.apache.maven.lifecycle.LifeCyclePluginAnalyzer;
+import org.apache.maven.model.Plugin;
+import org.apache.maven.model.PluginExecution;
+
+/**
+ * @author Benjamin Bentmann
+ */
+public class EmptyLifecyclePluginAnalyzer
+ implements LifeCyclePluginAnalyzer
+{
+ public Set<Plugin> getPluginsBoundByDefaultToAllLifecycles( String packaging )
+ {
+ Set<Plugin> plugins;
+
+ // NOTE: The upper-case packaging name is intentional, that's a special hinting mode used for certain tests
+ if ( "JAR".equals( packaging ) )
+ {
+ plugins = new LinkedHashSet<Plugin>();
+
+ plugins.add( newPlugin( "maven-compiler-plugin", "compile", "testCompile" ) );
+ plugins.add( newPlugin( "maven-resources-plugin", "resources", "testResources" ) );
+ plugins.add( newPlugin( "maven-surefire-plugin", "test" ) );
+ plugins.add( newPlugin( "maven-jar-plugin", "jar" ) );
+ plugins.add( newPlugin( "maven-install-plugin", "install" ) );
+ plugins.add( newPlugin( "maven-deploy-plugin", "deploy" ) );
+ }
+ else
+ {
+ plugins = Collections.emptySet();
+ }
+
+ return plugins;
+ }
+
+ private Plugin newPlugin( String artifactId, String... goals )
+ {
+ Plugin plugin = new Plugin();
+
+ plugin.setGroupId( "org.apache.maven.plugins" );
+ plugin.setArtifactId( artifactId );
+
+ for ( String goal : goals )
+ {
+ PluginExecution pluginExecution = new PluginExecution();
+ pluginExecution.setId( "default-" + goal );
+ pluginExecution.addGoal( goal );
+ plugin.addExecution( pluginExecution );
+ }
+
+ return plugin;
+ }
+
+}
diff --git a/framework/src/maven/apache-maven-3.3.3/maven-compat/src/test/java/org/apache/maven/project/LegacyLocalRepositoryManager.java b/framework/src/maven/apache-maven-3.3.3/maven-compat/src/test/java/org/apache/maven/project/LegacyLocalRepositoryManager.java
new file mode 100644
index 00000000..52fdd804
--- /dev/null
+++ b/framework/src/maven/apache-maven-3.3.3/maven-compat/src/test/java/org/apache/maven/project/LegacyLocalRepositoryManager.java
@@ -0,0 +1,192 @@
+package org.apache.maven.project;
+
+/*
+ * 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.eclipse.aether.RepositorySystemSession;
+import org.eclipse.aether.artifact.Artifact;
+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;
+
+/**
+ * @author Benjamin Bentmann
+ */
+public class LegacyLocalRepositoryManager
+ implements LocalRepositoryManager
+{
+
+ private final LocalRepository repository;
+
+ public LegacyLocalRepositoryManager( File basedir )
+ {
+ this.repository = new LocalRepository( basedir.getAbsoluteFile(), "legacy" );
+ }
+
+ public LocalRepository getRepository()
+ {
+ return repository;
+ }
+
+ public String getPathForLocalArtifact( Artifact artifact )
+ {
+ StringBuilder path = new StringBuilder( 128 );
+
+ path.append( artifact.getGroupId() ).append( '/' );
+
+ path.append( artifact.getExtension() ).append( 's' ).append( '/' );
+
+ path.append( artifact.getArtifactId() ).append( '-' ).append( artifact.getVersion() );
+
+ if ( artifact.getClassifier().length() > 0 )
+ {
+ path.append( '-' ).append( artifact.getClassifier() );
+ }
+
+ path.append( '.' ).append( artifact.getExtension() );
+
+ return path.toString();
+ }
+
+ public String getPathForRemoteArtifact( Artifact artifact, RemoteRepository repository, String context )
+ {
+ return getPathForLocalArtifact( artifact );
+ }
+
+ public String getPathForLocalMetadata( Metadata metadata )
+ {
+ return getPath( metadata, "local" );
+ }
+
+ public String getPathForRemoteMetadata( Metadata metadata, RemoteRepository repository, String context )
+ {
+ return getPath( metadata, getRepositoryKey( repository, context ) );
+ }
+
+ String getRepositoryKey( RemoteRepository repository, String context )
+ {
+ return repository.getId();
+ }
+
+ private String getPath( Metadata metadata, String repositoryKey )
+ {
+ StringBuilder path = new StringBuilder( 128 );
+
+ if ( metadata.getGroupId().length() > 0 )
+ {
+ path.append( metadata.getGroupId().replace( '.', '/' ) ).append( '/' );
+
+ if ( metadata.getArtifactId().length() > 0 )
+ {
+ path.append( metadata.getArtifactId() ).append( '/' );
+
+ if ( metadata.getVersion().length() > 0 )
+ {
+ path.append( metadata.getVersion() ).append( '/' );
+ }
+ }
+ }
+
+ path.append( insertRepositoryKey( metadata.getType(), repositoryKey ) );
+
+ return path.toString();
+ }
+
+ private String insertRepositoryKey( String filename, String repositoryKey )
+ {
+ String result;
+ int idx = filename.indexOf( '.' );
+ if ( idx < 0 )
+ {
+ result = filename + '-' + repositoryKey;
+ }
+ else
+ {
+ result = filename.substring( 0, idx ) + '-' + repositoryKey + filename.substring( idx );
+ }
+ return result;
+ }
+
+ public LocalArtifactResult find( RepositorySystemSession session, LocalArtifactRequest request )
+ {
+ String path = getPathForLocalArtifact( request.getArtifact() );
+ File file = new File( getRepository().getBasedir(), path );
+
+ LocalArtifactResult result = new LocalArtifactResult( request );
+ if ( file.isFile() )
+ {
+ result.setFile( file );
+ result.setAvailable( true );
+ }
+
+ return result;
+ }
+
+ public void add( RepositorySystemSession session, LocalArtifactRegistration request )
+ {
+ // noop
+ }
+
+ public LocalMetadataResult find( RepositorySystemSession session, LocalMetadataRequest request )
+ {
+ LocalMetadataResult result = new LocalMetadataResult( request );
+
+ String path;
+
+ Metadata metadata = request.getMetadata();
+ String context = request.getContext();
+ RemoteRepository remote = request.getRepository();
+
+ if ( remote != null )
+ {
+ path = getPathForRemoteMetadata( metadata, remote, context );
+ }
+ else
+ {
+ path = getPathForLocalMetadata( metadata );
+ }
+
+ File file = new File( getRepository().getBasedir(), path );
+ if ( file.isFile() )
+ {
+ result.setFile( file );
+ }
+
+ return result;
+ }
+
+ public void add( RepositorySystemSession session, LocalMetadataRegistration request )
+ {
+ // noop
+ }
+
+ public String toString()
+ {
+ return String.valueOf( getRepository() );
+ }
+}
diff --git a/framework/src/maven/apache-maven-3.3.3/maven-compat/src/test/java/org/apache/maven/project/ModelUtilsTest.java b/framework/src/maven/apache-maven-3.3.3/maven-compat/src/test/java/org/apache/maven/project/ModelUtilsTest.java
new file mode 100644
index 00000000..6c3df9a0
--- /dev/null
+++ b/framework/src/maven/apache-maven-3.3.3/maven-compat/src/test/java/org/apache/maven/project/ModelUtilsTest.java
@@ -0,0 +1,616 @@
+package org.apache.maven.project;
+
+/*
+ * 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.IOException;
+import java.io.StringReader;
+import java.util.Arrays;
+import java.util.Collections;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+
+import junit.framework.TestCase;
+
+import org.apache.maven.model.Build;
+import org.apache.maven.model.Dependency;
+import org.apache.maven.model.Plugin;
+import org.apache.maven.model.PluginContainer;
+import org.apache.maven.model.PluginExecution;
+import org.codehaus.plexus.util.xml.Xpp3Dom;
+import org.codehaus.plexus.util.xml.Xpp3DomBuilder;
+import org.codehaus.plexus.util.xml.pull.XmlPullParserException;
+
+public class ModelUtilsTest
+ extends TestCase
+{
+
+ public void testShouldUseMainPluginDependencyVersionOverManagedDepVersion()
+ {
+ Plugin mgtPlugin = createPlugin( "group", "artifact", "1", Collections.EMPTY_MAP );
+ Dependency mgtDep = createDependency( "g", "a", "2" );
+ mgtPlugin.addDependency( mgtDep );
+
+ Plugin plugin = createPlugin( "group", "artifact", "1", Collections.EMPTY_MAP );
+ Dependency dep = createDependency( "g", "a", "1" );
+ plugin.addDependency( dep );
+
+ ModelUtils.mergePluginDefinitions( plugin, mgtPlugin, false );
+
+ assertEquals( dep.getVersion(), plugin.getDependencies().get( 0 ).getVersion() );
+ }
+
+ private Dependency createDependency( String gid,
+ String aid,
+ String ver )
+ {
+ Dependency dep = new Dependency();
+ dep.setGroupId( gid );
+ dep.setArtifactId( aid );
+ dep.setVersion( ver );
+
+ return dep;
+ }
+
+ public void testShouldNotInheritPluginWithInheritanceSetToFalse()
+ {
+ PluginContainer parent = new PluginContainer();
+
+ Plugin parentPlugin = createPlugin( "group", "artifact", "1.0", Collections.EMPTY_MAP );
+ parentPlugin.setInherited( "false" );
+
+ parent.addPlugin( parentPlugin );
+
+ PluginContainer child = new PluginContainer();
+
+ child.addPlugin( createPlugin( "group3", "artifact3", "1.0", Collections.EMPTY_MAP ) );
+
+ ModelUtils.mergePluginLists( child, parent, true );
+
+ List results = child.getPlugins();
+
+ assertEquals( 1, results.size() );
+
+ Plugin result1 = (Plugin) results.get( 0 );
+ assertEquals( "group3", result1.getGroupId() );
+ assertEquals( "artifact3", result1.getArtifactId() );
+ }
+
+ /**
+ * Test that this is the resulting ordering of plugins after merging:
+ *
+ * Given:
+ *
+ * parent: X -> A -> B -> D -> E
+ * child: Y -> A -> C -> D -> F
+ *
+ * Result:
+ *
+ * X -> Y -> A -> B -> C -> D -> E -> F
+ */
+ public void testShouldPreserveChildOrderingOfPluginsAfterParentMerge()
+ {
+ PluginContainer parent = new PluginContainer();
+
+ parent.addPlugin( createPlugin( "group", "artifact", "1.0", Collections.EMPTY_MAP ) );
+ parent.addPlugin( createPlugin( "group2", "artifact2", "1.0", Collections.singletonMap( "key", "value" ) ) );
+
+ PluginContainer child = new PluginContainer();
+
+ child.addPlugin( createPlugin( "group3", "artifact3", "1.0", Collections.EMPTY_MAP ) );
+ child.addPlugin( createPlugin( "group2", "artifact2", "1.0", Collections.singletonMap( "key2", "value2" ) ) );
+
+ ModelUtils.mergePluginLists( child, parent, true );
+
+ List results = child.getPlugins();
+
+ assertEquals( 3, results.size() );
+
+ Plugin result1 = (Plugin) results.get( 0 );
+
+ assertEquals( "group", result1.getGroupId() );
+ assertEquals( "artifact", result1.getArtifactId() );
+
+ Plugin result2 = (Plugin) results.get( 1 );
+
+ assertEquals( "group3", result2.getGroupId() );
+ assertEquals( "artifact3", result2.getArtifactId() );
+
+ Plugin result3 = (Plugin) results.get( 2 );
+
+ assertEquals( "group2", result3.getGroupId() );
+ assertEquals( "artifact2", result3.getArtifactId() );
+
+ Xpp3Dom result3Config = (Xpp3Dom) result3.getConfiguration();
+
+ assertNotNull( result3Config );
+
+ assertEquals( "value", result3Config.getChild( "key" ).getValue() );
+ assertEquals( "value2", result3Config.getChild( "key2" ).getValue() );
+ }
+
+ private Plugin createPlugin( String groupId, String artifactId, String version, Map configuration )
+ {
+ Plugin plugin = new Plugin();
+ plugin.setGroupId( groupId );
+ plugin.setArtifactId( artifactId );
+ plugin.setVersion( version );
+
+ Xpp3Dom config = new Xpp3Dom( "configuration" );
+
+ if( configuration != null )
+ {
+ for ( Object o : configuration.entrySet() )
+ {
+ Map.Entry entry = (Map.Entry) o;
+
+ Xpp3Dom param = new Xpp3Dom( String.valueOf( entry.getKey() ) );
+ param.setValue( String.valueOf( entry.getValue() ) );
+
+ config.addChild( param );
+ }
+ }
+
+ plugin.setConfiguration( config );
+
+ return plugin;
+ }
+
+ public void testShouldInheritOnePluginWithExecution()
+ {
+ Plugin parent = new Plugin();
+ parent.setArtifactId( "testArtifact" );
+ parent.setGroupId( "testGroup" );
+ parent.setVersion( "1.0" );
+
+ PluginExecution parentExecution = new PluginExecution();
+ parentExecution.setId( "testExecution" );
+
+ parent.addExecution( parentExecution );
+
+ Plugin child = new Plugin();
+ child.setArtifactId( "testArtifact" );
+ child.setGroupId( "testGroup" );
+ child.setVersion( "1.0" );
+
+ ModelUtils.mergePluginDefinitions( child, parent, false );
+
+ assertEquals( 1, child.getExecutions().size() );
+ }
+
+ public void testShouldMergeInheritedPluginHavingExecutionWithLocalPlugin()
+ {
+ Plugin parent = new Plugin();
+ parent.setArtifactId( "testArtifact" );
+ parent.setGroupId( "testGroup" );
+ parent.setVersion( "1.0" );
+
+ PluginExecution parentExecution = new PluginExecution();
+ parentExecution.setId( "testExecution" );
+
+ parent.addExecution( parentExecution );
+
+ Plugin child = new Plugin();
+ child.setArtifactId( "testArtifact" );
+ child.setGroupId( "testGroup" );
+ child.setVersion( "1.0" );
+
+ PluginExecution childExecution = new PluginExecution();
+ childExecution.setId( "testExecution2" );
+
+ child.addExecution( childExecution );
+
+ ModelUtils.mergePluginDefinitions( child, parent, false );
+
+ assertEquals( 2, child.getExecutions().size() );
+ }
+
+ public void testShouldMergeOnePluginWithInheritExecutionWithoutDuplicatingPluginInList()
+ {
+ Plugin parent = new Plugin();
+ parent.setArtifactId( "testArtifact" );
+ parent.setGroupId( "testGroup" );
+ parent.setVersion( "1.0" );
+
+ PluginExecution parentExecution = new PluginExecution();
+ parentExecution.setId( "testExecution" );
+
+ parent.addExecution( parentExecution );
+
+ Build parentContainer = new Build();
+ parentContainer.addPlugin( parent );
+
+ Plugin child = new Plugin();
+ child.setArtifactId( "testArtifact" );
+ child.setGroupId( "testGroup" );
+ child.setVersion( "1.0" );
+
+ Build childContainer = new Build();
+ childContainer.addPlugin( child );
+
+ ModelUtils.mergePluginLists( childContainer, parentContainer, true );
+
+ List plugins = childContainer.getPlugins();
+
+ assertEquals( 1, plugins.size() );
+
+ Plugin plugin = (Plugin) plugins.get( 0 );
+
+ assertEquals( 1, plugin.getExecutions().size() );
+ }
+
+ public void testShouldMergePluginWithDifferentExecutionFromParentWithoutDuplicatingPluginInList()
+ {
+ Plugin parent = new Plugin();
+ parent.setArtifactId( "testArtifact" );
+ parent.setGroupId( "testGroup" );
+ parent.setVersion( "1.0" );
+
+ PluginExecution parentExecution = new PluginExecution();
+ parentExecution.setId( "testExecution" );
+
+ parent.addExecution( parentExecution );
+
+ Build parentContainer = new Build();
+ parentContainer.addPlugin( parent );
+
+ Plugin child = new Plugin();
+ child.setArtifactId( "testArtifact" );
+ child.setGroupId( "testGroup" );
+ child.setVersion( "1.0" );
+
+ PluginExecution childExecution = new PluginExecution();
+ childExecution.setId( "testExecution2" );
+
+ child.addExecution( childExecution );
+
+
+ Build childContainer = new Build();
+ childContainer.addPlugin( child );
+
+ ModelUtils.mergePluginLists( childContainer, parentContainer, true );
+
+ List plugins = childContainer.getPlugins();
+
+ assertEquals( 1, plugins.size() );
+
+ Plugin plugin = (Plugin) plugins.get( 0 );
+
+ assertEquals( 2, plugin.getExecutions().size() );
+ }
+
+ public void testShouldNOTMergeInheritedPluginHavingInheritEqualFalse()
+ {
+ Plugin parent = new Plugin();
+ parent.setArtifactId( "testArtifact" );
+ parent.setGroupId( "testGroup" );
+ parent.setVersion( "1.0" );
+ parent.setInherited( "false" );
+
+ PluginExecution parentExecution = new PluginExecution();
+ parentExecution.setId( "testExecution" );
+
+ parent.addExecution( parentExecution );
+
+ Plugin child = new Plugin();
+ child.setArtifactId( "testArtifact" );
+ child.setGroupId( "testGroup" );
+ child.setVersion( "1.0" );
+
+ ModelUtils.mergePluginDefinitions( child, parent, true );
+
+ assertEquals( 0, child.getExecutions().size() );
+ }
+
+ /**
+ * Verifies MNG-1499: The order of the merged list should be the plugins specified by the parent followed by the
+ * child list.
+ */
+ public void testShouldKeepOriginalPluginOrdering()
+ {
+ Plugin parentPlugin1 = new Plugin();
+ parentPlugin1.setArtifactId( "testArtifact" );
+ parentPlugin1.setGroupId( "zzz" ); // This will put this plugin last in the sorted map
+ parentPlugin1.setVersion( "1.0" );
+
+ PluginExecution parentExecution1 = new PluginExecution();
+ parentExecution1.setId( "testExecution" );
+
+ parentPlugin1.addExecution( parentExecution1 );
+
+ Plugin parentPlugin2 = new Plugin();
+ parentPlugin2.setArtifactId( "testArtifact" );
+ parentPlugin2.setGroupId( "yyy" );
+ parentPlugin2.setVersion( "1.0" );
+
+ PluginExecution parentExecution2 = new PluginExecution();
+ parentExecution2.setId( "testExecution" );
+
+ parentPlugin2.addExecution( parentExecution2 );
+
+ PluginContainer parentContainer = new PluginContainer();
+ parentContainer.addPlugin(parentPlugin1);
+ parentContainer.addPlugin(parentPlugin2);
+
+
+ Plugin childPlugin1 = new Plugin();
+ childPlugin1.setArtifactId( "testArtifact" );
+ childPlugin1.setGroupId( "bbb" );
+ childPlugin1.setVersion( "1.0" );
+
+ PluginExecution childExecution1 = new PluginExecution();
+ childExecution1.setId( "testExecution" );
+
+ childPlugin1.addExecution( childExecution1 );
+
+ Plugin childPlugin2 = new Plugin();
+ childPlugin2.setArtifactId( "testArtifact" );
+ childPlugin2.setGroupId( "aaa" );
+ childPlugin2.setVersion( "1.0" );
+
+ PluginExecution childExecution2 = new PluginExecution();
+ childExecution2.setId( "testExecution" );
+
+ childPlugin2.addExecution( childExecution2 );
+
+ PluginContainer childContainer = new PluginContainer();
+ childContainer.addPlugin(childPlugin1);
+ childContainer.addPlugin(childPlugin2);
+
+
+ ModelUtils.mergePluginLists(childContainer, parentContainer, true);
+
+ assertEquals( 4, childContainer.getPlugins().size() );
+ assertSame(parentPlugin1, childContainer.getPlugins().get(0));
+ assertSame(parentPlugin2, childContainer.getPlugins().get(1));
+ assertSame(childPlugin1, childContainer.getPlugins().get(2));
+ assertSame(childPlugin2, childContainer.getPlugins().get(3));
+ }
+
+ /**
+ * Verifies MNG-1499: The ordering of plugin executions should also be in the specified order.
+ */
+ public void testShouldKeepOriginalPluginExecutionOrdering()
+ {
+ Plugin parent = new Plugin();
+ parent.setArtifactId( "testArtifact" );
+ parent.setGroupId( "testGroup" );
+ parent.setVersion( "1.0" );
+
+ PluginExecution parentExecution1 = new PluginExecution();
+ parentExecution1.setId( "zzz" ); // Will show up last in the sorted map
+ PluginExecution parentExecution2 = new PluginExecution();
+ parentExecution2.setId( "yyy" ); // Will show up last in the sorted map
+
+ parent.addExecution( parentExecution1 );
+ parent.addExecution( parentExecution2 );
+
+ // this block verifies MNG-1703
+ Dependency dep = new Dependency();
+ dep.setGroupId( "depGroupId" );
+ dep.setArtifactId( "depArtifactId" );
+ dep.setVersion( "depVersion" );
+ parent.setDependencies( Collections.singletonList( dep ) );
+
+ Plugin child = new Plugin();
+ child.setArtifactId( "testArtifact" );
+ child.setGroupId( "testGroup" );
+ child.setVersion( "1.0" );
+
+ PluginExecution childExecution1 = new PluginExecution();
+ childExecution1.setId( "bbb" );
+ PluginExecution childExecution2 = new PluginExecution();
+ childExecution2.setId( "aaa" );
+
+ child.addExecution( childExecution1 );
+ child.addExecution( childExecution2 );
+
+ ModelUtils.mergePluginDefinitions( child, parent, false );
+
+ assertEquals( 4, child.getExecutions().size() );
+ assertSame(parentExecution1, child.getExecutions().get(0));
+ assertSame(parentExecution2, child.getExecutions().get(1));
+ assertSame(childExecution1, child.getExecutions().get(2));
+ assertSame(childExecution2, child.getExecutions().get(3));
+
+ // this block prevents MNG-1703
+ assertEquals( 1, child.getDependencies().size() );
+ Dependency dep2 = child.getDependencies().get( 0 );
+ assertEquals( dep.getManagementKey(), dep2.getManagementKey() );
+ }
+
+ public void testShouldOverwritePluginConfigurationSubItemsByDefault()
+ throws XmlPullParserException, IOException
+ {
+ String parentConfigStr = "<configuration><items><item>one</item><item>two</item></items></configuration>";
+ Xpp3Dom parentConfig = Xpp3DomBuilder.build( new StringReader( parentConfigStr ) );
+
+ Plugin parentPlugin = createPlugin( "group", "artifact", "1", null );
+ parentPlugin.setConfiguration( parentConfig );
+
+ String childConfigStr = "<configuration><items><item>three</item></items></configuration>";
+ Xpp3Dom childConfig = Xpp3DomBuilder.build( new StringReader( childConfigStr ) );
+
+ Plugin childPlugin = createPlugin( "group", "artifact", "1", null );
+ childPlugin.setConfiguration( childConfig );
+
+ ModelUtils.mergePluginDefinitions( childPlugin, parentPlugin, true );
+
+ Xpp3Dom result = (Xpp3Dom) childPlugin.getConfiguration();
+ Xpp3Dom items = result.getChild( "items" );
+
+ assertEquals( 1, items.getChildCount() );
+
+ Xpp3Dom item = items.getChild( 0 );
+ assertEquals( "three", item.getValue() );
+ }
+
+ public void testShouldMergePluginConfigurationSubItemsWithMergeAttributeSet()
+ throws XmlPullParserException, IOException
+ {
+ String parentConfigStr = "<configuration><items><item>one</item><item>two</item></items></configuration>";
+ Xpp3Dom parentConfig = Xpp3DomBuilder.build( new StringReader( parentConfigStr ) );
+
+ Plugin parentPlugin = createPlugin( "group", "artifact", "1", null );
+ parentPlugin.setConfiguration( parentConfig );
+
+ String childConfigStr = "<configuration><items combine.children=\"append\"><item>three</item></items></configuration>";
+ Xpp3Dom childConfig = Xpp3DomBuilder.build( new StringReader( childConfigStr ) );
+
+ Plugin childPlugin = createPlugin( "group", "artifact", "1", null );
+ childPlugin.setConfiguration( childConfig );
+
+ ModelUtils.mergePluginDefinitions( childPlugin, parentPlugin, true );
+
+ Xpp3Dom result = (Xpp3Dom) childPlugin.getConfiguration();
+ Xpp3Dom items = result.getChild( "items" );
+
+ assertEquals( 3, items.getChildCount() );
+
+ Xpp3Dom[] item = items.getChildren();
+
+ List<String> actual = Arrays.asList( item[0].getValue(), item[1].getValue(), item[2].getValue() );
+ List<String> expected = Arrays.asList( "one", "two", "three" );
+ Collections.sort( actual );
+ Collections.sort( expected );
+ assertEquals( expected, actual );
+ }
+
+ public void testShouldNotMergePluginExecutionWhenExecInheritedIsFalseAndTreatAsInheritanceIsTrue()
+ {
+ String gid = "group";
+ String aid = "artifact";
+ String ver = "1";
+
+ PluginContainer parent = new PluginContainer();
+ Plugin pParent = createPlugin( gid, aid, ver, Collections.EMPTY_MAP );
+
+ pParent.setInherited( Boolean.toString( true ) );
+
+ PluginExecution eParent = new PluginExecution();
+
+ String testId = "test";
+
+ eParent.setId( testId );
+ eParent.addGoal( "run" );
+ eParent.setPhase( "initialize" );
+ eParent.setInherited( Boolean.toString( false ) );
+
+ pParent.addExecution( eParent );
+ parent.addPlugin( pParent );
+
+ PluginContainer child = new PluginContainer();
+ Plugin pChild = createPlugin( gid, aid, ver, Collections.EMPTY_MAP );
+ PluginExecution eChild = new PluginExecution();
+
+ eChild.setId( "child-specified" );
+ eChild.addGoal( "child" );
+ eChild.setPhase( "compile" );
+
+ pChild.addExecution( eChild );
+ child.addPlugin( pChild );
+
+ ModelUtils.mergePluginDefinitions( pChild, pParent, true );
+
+ Map executionMap = pChild.getExecutionsAsMap();
+ assertNull( "test execution should not be inherited from parent.", executionMap.get( testId ) );
+ }
+
+ public void testShouldNotMergePluginExecutionWhenPluginInheritedIsFalseAndTreatAsInheritanceIsTrue()
+ {
+ String gid = "group";
+ String aid = "artifact";
+ String ver = "1";
+
+ PluginContainer parent = new PluginContainer();
+ Plugin pParent = createPlugin( gid, aid, ver, Collections.EMPTY_MAP );
+
+ pParent.setInherited( Boolean.toString( false ) );
+
+ PluginExecution eParent = new PluginExecution();
+
+ String testId = "test";
+
+ eParent.setId( testId );
+ eParent.addGoal( "run" );
+ eParent.setPhase( "initialize" );
+ eParent.setInherited( Boolean.toString( true ) );
+
+ pParent.addExecution( eParent );
+ parent.addPlugin( pParent );
+
+ PluginContainer child = new PluginContainer();
+ Plugin pChild = createPlugin( gid, aid, ver, Collections.EMPTY_MAP );
+ PluginExecution eChild = new PluginExecution();
+
+ eChild.setId( "child-specified" );
+ eChild.addGoal( "child" );
+ eChild.setPhase( "compile" );
+
+ pChild.addExecution( eChild );
+ child.addPlugin( pChild );
+
+ ModelUtils.mergePluginDefinitions( pChild, pParent, true );
+
+ Map executionMap = pChild.getExecutionsAsMap();
+ assertNull( "test execution should not be inherited from parent.", executionMap.get( testId ) );
+ }
+
+ public void testShouldMergePluginExecutionWhenExecInheritedIsTrueAndTreatAsInheritanceIsTrue()
+ {
+ String gid = "group";
+ String aid = "artifact";
+ String ver = "1";
+
+ PluginContainer parent = new PluginContainer();
+ Plugin pParent = createPlugin( gid, aid, ver, Collections.EMPTY_MAP );
+
+ pParent.setInherited( Boolean.toString( true ) );
+
+ PluginExecution eParent = new PluginExecution();
+
+ String testId = "test";
+
+ eParent.setId( testId );
+ eParent.addGoal( "run" );
+ eParent.setPhase( "initialize" );
+ eParent.setInherited( Boolean.toString( true ) );
+
+ pParent.addExecution( eParent );
+ parent.addPlugin( pParent );
+
+ PluginContainer child = new PluginContainer();
+ Plugin pChild = createPlugin( gid, aid, ver, Collections.EMPTY_MAP );
+ PluginExecution eChild = new PluginExecution();
+
+ eChild.setId( "child-specified" );
+ eChild.addGoal( "child" );
+ eChild.setPhase( "compile" );
+
+ pChild.addExecution( eChild );
+ child.addPlugin( pChild );
+
+ ModelUtils.mergePluginDefinitions( pChild, pParent, true );
+
+ Map executionMap = pChild.getExecutionsAsMap();
+ assertNotNull( "test execution should be inherited from parent.", executionMap.get( testId ) );
+ }
+
+}
diff --git a/framework/src/maven/apache-maven-3.3.3/maven-compat/src/test/java/org/apache/maven/project/ProjectClasspathTest.java b/framework/src/maven/apache-maven-3.3.3/maven-compat/src/test/java/org/apache/maven/project/ProjectClasspathTest.java
new file mode 100644
index 00000000..d9e7beb2
--- /dev/null
+++ b/framework/src/maven/apache-maven-3.3.3/maven-compat/src/test/java/org/apache/maven/project/ProjectClasspathTest.java
@@ -0,0 +1,149 @@
+package org.apache.maven.project;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+import java.io.File;
+import java.util.Iterator;
+
+import org.apache.maven.artifact.Artifact;
+import org.apache.maven.repository.RepositorySystem;
+import org.apache.maven.repository.internal.DefaultArtifactDescriptorReader;
+import org.eclipse.aether.impl.ArtifactDescriptorReader;
+import org.eclipse.aether.impl.ArtifactResolver;
+
+public class ProjectClasspathTest
+ extends AbstractMavenProjectTestCase
+{
+ static final String dir = "projects/scope/";
+
+ public void setUp()
+ throws Exception
+ {
+ ArtifactResolver resolver = lookup( ArtifactResolver.class, "classpath" );
+ DefaultArtifactDescriptorReader pomReader = (DefaultArtifactDescriptorReader)lookup(ArtifactDescriptorReader.class);
+ pomReader.setArtifactResolver( resolver );
+
+ projectBuilder = lookup( ProjectBuilder.class, "classpath" );
+
+ // the metadata source looks up the default impl, so we have to trick it
+ getContainer().addComponent( projectBuilder, ProjectBuilder.class, "default" );
+
+ repositorySystem = lookup( RepositorySystem.class );
+ }
+
+ @Override
+ protected String getCustomConfigurationName()
+ {
+ return null;
+ }
+
+ public void testProjectClasspath()
+ throws Exception
+ {
+ File f = getFileForClasspathResource( dir + "project-with-scoped-dependencies.xml" );
+
+ MavenProject project = getProjectWithDependencies( f );
+
+ Artifact artifact;
+
+ assertNotNull( "Test project can't be null!", project );
+
+ checkArtifactIdScope( project, "provided", "provided" );
+ checkArtifactIdScope( project, "test", "test" );
+ checkArtifactIdScope( project, "compile", "compile" );
+ checkArtifactIdScope( project, "runtime", "runtime" );
+ checkArtifactIdScope( project, "default", "compile" );
+
+ // check all transitive deps of a test dependency are test, except test and provided which is skipped
+ artifact = getArtifact( project, "maven-test-test", "scope-provided" );
+ assertNull( "Check no provided dependencies are transitive", artifact );
+ artifact = getArtifact( project, "maven-test-test", "scope-test" );
+ assertNull( "Check no test dependencies are transitive", artifact );
+
+ artifact = getArtifact( project, "maven-test-test", "scope-compile" );
+ assertNotNull( artifact );
+
+ System.out.println( "a = " + artifact );
+ System.out.println( "b = " + artifact.getScope() );
+ assertEquals( "Check scope", "test", artifact.getScope() );
+ artifact = getArtifact( project, "maven-test-test", "scope-default" );
+ assertEquals( "Check scope", "test", artifact.getScope() );
+ artifact = getArtifact( project, "maven-test-test", "scope-runtime" );
+ assertEquals( "Check scope", "test", artifact.getScope() );
+
+ // check all transitive deps of a provided dependency are provided scope, except for test
+ checkGroupIdScope( project, "provided", "maven-test-provided" );
+ artifact = getArtifact( project, "maven-test-provided", "scope-runtime" );
+ assertEquals( "Check scope", "provided", artifact.getScope() );
+
+ // check all transitive deps of a runtime dependency are runtime scope, except for test
+ checkGroupIdScope( project, "runtime", "maven-test-runtime" );
+ artifact = getArtifact( project, "maven-test-runtime", "scope-runtime" );
+ assertEquals( "Check scope", "runtime", artifact.getScope() );
+
+ // check all transitive deps of a compile dependency are compile scope, except for runtime and test
+ checkGroupIdScope( project, "compile", "maven-test-compile" );
+ artifact = getArtifact( project, "maven-test-compile", "scope-runtime" );
+ assertEquals( "Check scope", "runtime", artifact.getScope() );
+
+ // check all transitive deps of a default dependency are compile scope, except for runtime and test
+ checkGroupIdScope( project, "compile", "maven-test-default" );
+ artifact = getArtifact( project, "maven-test-default", "scope-runtime" );
+ assertEquals( "Check scope", "runtime", artifact.getScope() );
+ }
+
+ private void checkGroupIdScope( MavenProject project, String scopeValue, String groupId )
+ {
+ Artifact artifact;
+ artifact = getArtifact( project, groupId, "scope-compile" );
+ assertEquals( "Check scope", scopeValue, artifact.getScope() );
+ artifact = getArtifact( project, groupId, "scope-test" );
+ assertNull( "Check test dependency is not transitive", artifact );
+ artifact = getArtifact( project, groupId, "scope-provided" );
+ assertNull( "Check provided dependency is not transitive", artifact );
+ artifact = getArtifact( project, groupId, "scope-default" );
+ assertEquals( "Check scope", scopeValue, artifact.getScope() );
+ }
+
+ private void checkArtifactIdScope( MavenProject project, String scope, String scopeValue )
+ {
+ String artifactId = "scope-" + scope;
+ Artifact artifact = getArtifact( project, "maven-test", artifactId );
+ assertNotNull( artifact );
+ assertEquals( "Check scope", scopeValue, artifact.getScope() );
+ }
+
+ private Artifact getArtifact( MavenProject project, String groupId, String artifactId )
+ {
+ System.out.println( "[ Looking for " + groupId + ":" + artifactId + " ]" );
+ for ( Artifact a : project.getArtifacts() )
+ {
+ System.out.println( a.toString() );
+ if ( artifactId.equals( a.getArtifactId() ) && a.getGroupId().equals( groupId ) )
+ {
+ System.out.println( "RETURN" );
+ return a;
+ }
+ }
+ System.out.println( "Return null" );
+ return null;
+ }
+
+}
diff --git a/framework/src/maven/apache-maven-3.3.3/maven-compat/src/test/java/org/apache/maven/project/TestArtifactResolver.java b/framework/src/maven/apache-maven-3.3.3/maven-compat/src/test/java/org/apache/maven/project/TestArtifactResolver.java
new file mode 100644
index 00000000..9f389d6d
--- /dev/null
+++ b/framework/src/maven/apache-maven-3.3.3/maven-compat/src/test/java/org/apache/maven/project/TestArtifactResolver.java
@@ -0,0 +1,30 @@
+package org.apache.maven.project;
+
+/*
+ * 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.metadata.ArtifactMetadataSource;
+import org.apache.maven.artifact.resolver.ArtifactResolver;
+import org.apache.maven.artifact.resolver.DefaultArtifactResolver;
+import org.codehaus.plexus.component.annotations.Component;
+import org.codehaus.plexus.component.annotations.Requirement;
+
+@Component(role=ArtifactResolver.class,hint="classpath")
+public class TestArtifactResolver
+ extends DefaultArtifactResolver
+{
+ @Requirement(hint="classpath")
+ private ArtifactMetadataSource source;
+}
diff --git a/framework/src/maven/apache-maven-3.3.3/maven-compat/src/test/java/org/apache/maven/project/TestMavenRepositorySystem.java b/framework/src/maven/apache-maven-3.3.3/maven-compat/src/test/java/org/apache/maven/project/TestMavenRepositorySystem.java
new file mode 100644
index 00000000..2818df06
--- /dev/null
+++ b/framework/src/maven/apache-maven-3.3.3/maven-compat/src/test/java/org/apache/maven/project/TestMavenRepositorySystem.java
@@ -0,0 +1,30 @@
+package org.apache.maven.project;
+
+/*
+ * 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.resolver.ArtifactResolver;
+import org.apache.maven.repository.RepositorySystem;
+import org.apache.maven.repository.legacy.LegacyRepositorySystem;
+import org.codehaus.plexus.component.annotations.Component;
+import org.codehaus.plexus.component.annotations.Requirement;
+
+@Component(role = RepositorySystem.class, hint = "classpath")
+public class TestMavenRepositorySystem
+ extends LegacyRepositorySystem
+{
+ @Requirement(hint="classpath")
+ private ArtifactResolver artifactResolver;
+}
diff --git a/framework/src/maven/apache-maven-3.3.3/maven-compat/src/test/java/org/apache/maven/project/TestProjectBuilder.java b/framework/src/maven/apache-maven-3.3.3/maven-compat/src/test/java/org/apache/maven/project/TestProjectBuilder.java
new file mode 100644
index 00000000..754487f4
--- /dev/null
+++ b/framework/src/maven/apache-maven-3.3.3/maven-compat/src/test/java/org/apache/maven/project/TestProjectBuilder.java
@@ -0,0 +1,68 @@
+package org.apache.maven.project;
+
+/*
+ * 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.FileNotFoundException;
+import java.util.Collections;
+
+import org.apache.maven.artifact.Artifact;
+import org.apache.maven.artifact.repository.ArtifactRepository;
+import org.codehaus.plexus.component.annotations.Component;
+
+@Component(role=ProjectBuilder.class,hint="classpath")
+public class TestProjectBuilder
+ extends DefaultProjectBuilder
+{
+
+ @Override
+ public ProjectBuildingResult build( Artifact artifact, ProjectBuildingRequest request )
+ throws ProjectBuildingException
+ {
+ if ( "maven-test".equals( artifact.getGroupId() ) )
+ {
+ String scope = artifact.getArtifactId().substring( "scope-".length() );
+
+ try
+ {
+ artifact.setFile( ProjectClasspathTest.getFileForClasspathResource( ProjectClasspathTest.dir + "transitive-" + scope + "-dep.xml" ) );
+ }
+ catch ( FileNotFoundException e )
+ {
+ throw new IllegalStateException( "Missing test POM for " + artifact );
+ }
+ }
+ if ( artifact.getFile() == null )
+ {
+ MavenProject project = new MavenProject();
+ project.setArtifact( artifact );
+ return new DefaultProjectBuildingResult( project, null, null );
+ }
+ return build( artifact.getFile(), request );
+ }
+
+ @Override
+ public ProjectBuildingResult build( File pomFile, ProjectBuildingRequest configuration )
+ throws ProjectBuildingException
+ {
+ ProjectBuildingResult result = super.build( pomFile, configuration );
+
+ result.getProject().setRemoteArtifactRepositories( Collections.<ArtifactRepository> emptyList() );
+
+ return result;
+ }
+
+} \ 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/project/inheritance/AbstractProjectInheritanceTestCase.java b/framework/src/maven/apache-maven-3.3.3/maven-compat/src/test/java/org/apache/maven/project/inheritance/AbstractProjectInheritanceTestCase.java
new file mode 100644
index 00000000..413d6fea
--- /dev/null
+++ b/framework/src/maven/apache-maven-3.3.3/maven-compat/src/test/java/org/apache/maven/project/inheritance/AbstractProjectInheritanceTestCase.java
@@ -0,0 +1,57 @@
+package org.apache.maven.project.inheritance;
+
+/*
+ * 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.project.AbstractMavenProjectTestCase;
+
+/**
+ * @author Jason van Zyl
+ */
+public abstract class AbstractProjectInheritanceTestCase
+ extends AbstractMavenProjectTestCase
+{
+ protected String getTestSeries()
+ {
+ String className = getClass().getPackage().getName();
+
+ return className.substring( className.lastIndexOf( "." ) + 1 );
+ }
+
+ protected File projectFile( String name )
+ {
+ return projectFile( "maven", name );
+ }
+
+ protected File projectFile( String groupId, String artifactId )
+ {
+ return new File( getLocalRepositoryPath(), "/" + groupId + "/poms/" + artifactId + "-1.0.pom" );
+ }
+
+ // ----------------------------------------------------------------------
+ // The local repository for this category of tests
+ // ----------------------------------------------------------------------
+
+ protected File getLocalRepositoryPath()
+ {
+ return getTestFile("src/test/resources/inheritance-repo/" + getTestSeries() );
+ }
+}
diff --git a/framework/src/maven/apache-maven-3.3.3/maven-compat/src/test/java/org/apache/maven/project/inheritance/t00/ProjectInheritanceTest.java b/framework/src/maven/apache-maven-3.3.3/maven-compat/src/test/java/org/apache/maven/project/inheritance/t00/ProjectInheritanceTest.java
new file mode 100644
index 00000000..0ee79807
--- /dev/null
+++ b/framework/src/maven/apache-maven-3.3.3/maven-compat/src/test/java/org/apache/maven/project/inheritance/t00/ProjectInheritanceTest.java
@@ -0,0 +1,93 @@
+package org.apache.maven.project.inheritance.t00;
+
+/*
+ * 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.model.MailingList;
+import org.apache.maven.project.MavenProject;
+import org.apache.maven.project.inheritance.AbstractProjectInheritanceTestCase;
+
+/**
+ * A test which demonstrates maven's recursive inheritance where
+ * a distinct value is taken from each parent contributing to the
+ * the final model of the project being assembled. There is no
+ * overriding going on amongst the models being used in this test:
+ * each model in the lineage is providing a value that is not present
+ * anywhere else in the lineage. We are just making sure that values
+ * down in the lineage are bubbling up where they should.
+ *
+ * @author Jason van Zyl
+ */
+public class ProjectInheritanceTest
+ extends AbstractProjectInheritanceTestCase
+{
+ // ----------------------------------------------------------------------
+ //
+ // p4 inherits from p3
+ // p3 inherits from p2
+ // p2 inherits from p1
+ // p1 inherits from p0
+ // p0 inhertis from super model
+ //
+ // or we can show it graphically as:
+ //
+ // p4 ---> p3 ---> p2 ---> p1 ---> p0 --> super model
+ //
+ // ----------------------------------------------------------------------
+
+ public void testProjectInheritance()
+ throws Exception
+ {
+ MavenProject p4 = getProject( projectFile( "p4" ) );
+
+ assertEquals( "p4", p4.getName() );
+
+ // ----------------------------------------------------------------------
+ // Value inherited from p3
+ // ----------------------------------------------------------------------
+
+ assertEquals( "2000", p4.getInceptionYear() );
+
+ // ----------------------------------------------------------------------
+ // Value taken from p2
+ // ----------------------------------------------------------------------
+
+ assertEquals( "mailing-list", p4.getMailingLists().get( 0 ).getName() );
+
+ // ----------------------------------------------------------------------
+ // Value taken from p1
+ // ----------------------------------------------------------------------
+
+ assertEquals( "scm-url/p2/p3/p4", p4.getScm().getUrl() );
+
+ // ----------------------------------------------------------------------
+ // Value taken from p4
+ // ----------------------------------------------------------------------
+
+ assertEquals( "Codehaus", p4.getOrganization().getName() );
+
+ // ----------------------------------------------------------------------
+ // Value taken from super model
+ // ----------------------------------------------------------------------
+
+ assertEquals( "4.0.0", p4.getModelVersion() );
+
+ assertEquals( "4.0.0", p4.getModelVersion() );
+ }
+}
diff --git a/framework/src/maven/apache-maven-3.3.3/maven-compat/src/test/java/org/apache/maven/project/inheritance/t01/ProjectInheritanceTest.java b/framework/src/maven/apache-maven-3.3.3/maven-compat/src/test/java/org/apache/maven/project/inheritance/t01/ProjectInheritanceTest.java
new file mode 100644
index 00000000..e6efcc4d
--- /dev/null
+++ b/framework/src/maven/apache-maven-3.3.3/maven-compat/src/test/java/org/apache/maven/project/inheritance/t01/ProjectInheritanceTest.java
@@ -0,0 +1,92 @@
+package org.apache.maven.project.inheritance.t01;
+
+/*
+ * 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.project.MavenProject;
+import org.apache.maven.project.inheritance.AbstractProjectInheritanceTestCase;
+
+/**
+ * A test which demonstrates maven's recursive inheritance where
+ * we are testing to make sure that elements stated in a model are
+ * not clobbered by the same elements elsewhere in the lineage.
+ *
+ * @author Jason van Zyl
+ */
+public class ProjectInheritanceTest
+ extends AbstractProjectInheritanceTestCase
+{
+ // ----------------------------------------------------------------------
+ //
+ // p4 inherits from p3
+ // p3 inherits from p2
+ // p2 inherits from p1
+ // p1 inherits from p0
+ // p0 inhertis from super model
+ //
+ // or we can show it graphically as:
+ //
+ // p4 ---> p3 ---> p2 ---> p1 ---> p0 --> super model
+ //
+ // ----------------------------------------------------------------------
+
+ public void testProjectInheritance()
+ throws Exception
+ {
+ // ----------------------------------------------------------------------
+ // Check p0 value for org name
+ // ----------------------------------------------------------------------
+
+ MavenProject p0 = getProject( projectFile( "maven.t01", "p0" ) );
+
+ assertEquals( "p0-org", p0.getOrganization().getName() );
+
+ // ----------------------------------------------------------------------
+ // Check p1 value for org name
+ // ----------------------------------------------------------------------
+
+ MavenProject p1 = getProject( projectFile( "maven.t01", "p1" ) );
+
+ assertEquals( "p1-org", p1.getOrganization().getName() );
+
+ // ----------------------------------------------------------------------
+ // Check p2 value for org name
+ // ----------------------------------------------------------------------
+
+ MavenProject p2 = getProject( projectFile( "maven.t01", "p2" ) );
+
+ assertEquals( "p2-org", p2.getOrganization().getName() );
+
+ // ----------------------------------------------------------------------
+ // Check p2 value for org name
+ // ----------------------------------------------------------------------
+
+ MavenProject p3 = getProject( projectFile( "maven.t01", "p3" ) );
+
+ assertEquals( "p3-org", p3.getOrganization().getName() );
+
+ // ----------------------------------------------------------------------
+ // Check p4 value for org name
+ // ----------------------------------------------------------------------
+
+ MavenProject p4 = getProject( projectFile( "maven.t01", "p4" ) );
+
+ assertEquals( "p4-org", p4.getOrganization().getName() );
+ }
+}
diff --git a/framework/src/maven/apache-maven-3.3.3/maven-compat/src/test/java/org/apache/maven/project/inheritance/t02/ProjectInheritanceTest.java b/framework/src/maven/apache-maven-3.3.3/maven-compat/src/test/java/org/apache/maven/project/inheritance/t02/ProjectInheritanceTest.java
new file mode 100644
index 00000000..339c81ff
--- /dev/null
+++ b/framework/src/maven/apache-maven-3.3.3/maven-compat/src/test/java/org/apache/maven/project/inheritance/t02/ProjectInheritanceTest.java
@@ -0,0 +1,169 @@
+package org.apache.maven.project.inheritance.t02;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+import java.io.File;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+
+import org.apache.maven.model.Build;
+import org.apache.maven.model.MailingList;
+import org.apache.maven.model.Plugin;
+import org.apache.maven.project.MavenProject;
+import org.apache.maven.project.inheritance.AbstractProjectInheritanceTestCase;
+
+/**
+ * A test which demonstrates maven's recursive inheritance where
+ * a distinct value is taken from each parent contributing to the
+ * the final model of the project being assembled. There is no
+ * overriding going on amongst the models being used in this test:
+ * each model in the lineage is providing a value that is not present
+ * anywhere else in the lineage. We are just making sure that values
+ * down in the lineage are bubbling up where they should.
+ *
+ * @author Jason van Zyl
+ */
+public class ProjectInheritanceTest
+ extends AbstractProjectInheritanceTestCase
+{
+ // ----------------------------------------------------------------------
+ //
+ // p4 inherits from p3
+ // p3 inherits from p2
+ // p2 inherits from p1
+ // p1 inherits from p0
+ // p0 inhertis from super model
+ //
+ // or we can show it graphically as:
+ //
+ // p4 ---> p3 ---> p2 ---> p1 ---> p0 --> super model
+ //
+ // ----------------------------------------------------------------------
+
+ public void testProjectInheritance()
+ throws Exception
+ {
+ File localRepo = getLocalRepositoryPath();
+
+ System.out.println( "Local repository is at: " + localRepo.getAbsolutePath() );
+
+ File pom0 = new File( localRepo, "p0/pom.xml" );
+ File pom1 = new File( pom0.getParentFile(), "p1/pom.xml" );
+ File pom2 = new File( pom1.getParentFile(), "p2/pom.xml" );
+ File pom3 = new File( pom2.getParentFile(), "p3/pom.xml" );
+ File pom4 = new File( pom3.getParentFile(), "p4/pom.xml" );
+ File pom5 = new File( pom4.getParentFile(), "p5/pom.xml" );
+
+ System.out.println( "Location of project-4's POM: " + pom4.getPath() );
+
+ // load everything...
+ MavenProject project0 = getProject( pom0 );
+ MavenProject project1 = getProject( pom1 );
+ MavenProject project2 = getProject( pom2 );
+ MavenProject project3 = getProject( pom3 );
+ MavenProject project4 = getProject( pom4 );
+ MavenProject project5 = getProject( pom5 );
+
+ assertEquals( "p4", project4.getName() );
+
+ // ----------------------------------------------------------------------
+ // Value inherited from p3
+ // ----------------------------------------------------------------------
+
+ assertEquals( "2000", project4.getInceptionYear() );
+
+ // ----------------------------------------------------------------------
+ // Value taken from p2
+ // ----------------------------------------------------------------------
+
+ assertEquals( "mailing-list", project4.getMailingLists().get( 0 ).getName() );
+
+ // ----------------------------------------------------------------------
+ // Value taken from p1
+ // ----------------------------------------------------------------------
+
+ assertEquals( "scm-url/p2/p3/p4", project4.getScm().getUrl() );
+
+ // ----------------------------------------------------------------------
+ // Value taken from p4
+ // ----------------------------------------------------------------------
+
+ assertEquals( "Codehaus", project4.getOrganization().getName() );
+
+ // ----------------------------------------------------------------------
+ // Value taken from super model
+ // ----------------------------------------------------------------------
+
+ assertEquals( "4.0.0", project4.getModelVersion() );
+
+ Build build = project4.getBuild();
+ List<Plugin> plugins = build.getPlugins();
+
+ Map validPluginCounts = new HashMap();
+
+ String testPluginArtifactId = "maven-compiler-plugin";
+
+ // this is the plugin we're looking for.
+ validPluginCounts.put( testPluginArtifactId, 0 );
+
+ // these are injected if -DperformRelease=true
+ validPluginCounts.put( "maven-deploy-plugin", 0 );
+ validPluginCounts.put( "maven-javadoc-plugin", 0 );
+ validPluginCounts.put( "maven-source-plugin", 0 );
+
+ Plugin testPlugin = null;
+
+ for ( Plugin plugin : plugins )
+ {
+ String pluginArtifactId = plugin.getArtifactId();
+
+ if ( !validPluginCounts.containsKey( pluginArtifactId ) )
+ {
+ fail( "Illegal plugin found: " + pluginArtifactId );
+ }
+ else
+ {
+ if ( pluginArtifactId.equals( testPluginArtifactId ) )
+ {
+ testPlugin = plugin;
+ }
+
+ Integer count = (Integer) validPluginCounts.get( pluginArtifactId );
+
+ if ( count > 0 )
+ {
+ fail( "Multiple copies of plugin: " + pluginArtifactId + " found in POM." );
+ }
+ else
+ {
+ count = count + 1;
+
+ validPluginCounts.put( pluginArtifactId, count );
+ }
+ }
+ }
+
+ List executions = testPlugin.getExecutions();
+
+ assertEquals( 1, executions.size() );
+ }
+}
diff --git a/framework/src/maven/apache-maven-3.3.3/maven-compat/src/test/java/org/apache/maven/project/inheritance/t03/ProjectInheritanceTest.java b/framework/src/maven/apache-maven-3.3.3/maven-compat/src/test/java/org/apache/maven/project/inheritance/t03/ProjectInheritanceTest.java
new file mode 100644
index 00000000..73f518e4
--- /dev/null
+++ b/framework/src/maven/apache-maven-3.3.3/maven-compat/src/test/java/org/apache/maven/project/inheritance/t03/ProjectInheritanceTest.java
@@ -0,0 +1,68 @@
+package org.apache.maven.project.inheritance.t03;
+
+/*
+ * 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.project.MavenProject;
+import org.apache.maven.project.inheritance.AbstractProjectInheritanceTestCase;
+
+/**
+ * A test which demonstrates maven's recursive inheritance where
+ * a distinct value is taken from each parent contributing to the
+ * the final model of the project being assembled. There is no
+ * overriding going on amongst the models being used in this test:
+ * each model in the lineage is providing a value that is not present
+ * anywhere else in the lineage. We are just making sure that values
+ * down in the lineage are bubbling up where they should.
+ *
+ * @author Jason van Zyl
+ */
+public class ProjectInheritanceTest
+ extends AbstractProjectInheritanceTestCase
+{
+ // ----------------------------------------------------------------------
+ //
+ // p1 inherits from p0
+ // p0 inhertis from super model
+ //
+ // or we can show it graphically as:
+ //
+ // p1 ---> p0 --> super model
+ //
+ // ----------------------------------------------------------------------
+
+ public void testProjectInheritance()
+ throws Exception
+ {
+ File localRepo = getLocalRepositoryPath();
+ File pom0 = new File( localRepo, "p0/pom.xml" );
+
+ File pom0Basedir = pom0.getParentFile();
+
+ File pom1 = new File( pom0Basedir, "p1/pom.xml" );
+
+ // load everything...
+ MavenProject project0 = getProject( pom0 );
+ MavenProject project1 = getProject( pom1 );
+
+ assertEquals( pom0Basedir, project1.getParent().getBasedir() );
+ }
+}
diff --git a/framework/src/maven/apache-maven-3.3.3/maven-compat/src/test/java/org/apache/maven/project/inheritance/t04/ProjectInheritanceTest.java b/framework/src/maven/apache-maven-3.3.3/maven-compat/src/test/java/org/apache/maven/project/inheritance/t04/ProjectInheritanceTest.java
new file mode 100644
index 00000000..e24262f1
--- /dev/null
+++ b/framework/src/maven/apache-maven-3.3.3/maven-compat/src/test/java/org/apache/maven/project/inheritance/t04/ProjectInheritanceTest.java
@@ -0,0 +1,86 @@
+package org.apache.maven.project.inheritance.t04;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+import java.io.File;
+import java.util.Iterator;
+import java.util.Set;
+
+import org.apache.maven.artifact.Artifact;
+import org.apache.maven.project.MavenProject;
+import org.apache.maven.project.inheritance.AbstractProjectInheritanceTestCase;
+
+/**
+ * Verifies the version of a dependency listed in a parent's
+ * dependencyManagement section is chosen over another version of the same
+ * dependency, listed transitively.
+ *
+ * @author <a href="mailto:pschneider@gmail.com">Patrick Schneider</a>
+ */
+public class ProjectInheritanceTest
+ extends AbstractProjectInheritanceTestCase
+{
+ // ----------------------------------------------------------------------
+ //
+ // p1 inherits from p0
+ // p0 inhertis from super model
+ //
+ // or we can show it graphically as:
+ //
+ // p1 ---> p0 --> super model
+ //
+ // p1 has a depMgmt section that specifies versions 1.0 of jars "a" & "b"
+ // jar "a" has a transitive dependency on 2.0 of jar "b", but maven should
+ // prefer to use version 1.0.
+ //
+ // ----------------------------------------------------------------------
+
+ public void testDependencyManagementOverridesTransitiveDependencyVersion()
+ throws Exception
+ {
+ File localRepo = getLocalRepositoryPath();
+ File pom0 = new File( localRepo, "p0/pom.xml" );
+ File pom0Basedir = pom0.getParentFile();
+ File pom1 = new File( pom0Basedir, "p1/pom.xml" );
+
+ // load the child project, which inherits from p0...
+ MavenProject project0 = getProjectWithDependencies( pom0 );
+ MavenProject project1 = getProjectWithDependencies( pom1 );
+
+ assertEquals( pom0Basedir, project1.getParent().getBasedir() );
+ Set set = project1.getArtifacts();
+ assertNotNull( "No artifacts", set );
+ assertTrue( "No Artifacts", set.size() > 0 );
+ assertTrue( "Set size should be 3, is " + set.size(), set.size() == 3 );
+
+ for ( Object aSet : set )
+ {
+ Artifact artifact = (Artifact) aSet;
+ System.out.println(
+ "Artifact: " + artifact.getDependencyConflictId() + " " + artifact.getVersion() + " Optional=" + (
+ artifact.isOptional()
+ ? "true"
+ : "false" ) );
+ assertTrue( "Incorrect version for " + artifact.getDependencyConflictId(),
+ artifact.getVersion().equals( "1.0" ) );
+ }
+
+ }
+} \ 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/project/inheritance/t05/ProjectInheritanceTest.java b/framework/src/maven/apache-maven-3.3.3/maven-compat/src/test/java/org/apache/maven/project/inheritance/t05/ProjectInheritanceTest.java
new file mode 100644
index 00000000..1d2bd182
--- /dev/null
+++ b/framework/src/maven/apache-maven-3.3.3/maven-compat/src/test/java/org/apache/maven/project/inheritance/t05/ProjectInheritanceTest.java
@@ -0,0 +1,79 @@
+package org.apache.maven.project.inheritance.t05;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+import java.io.File;
+import java.util.Iterator;
+import java.util.Set;
+
+import org.apache.maven.artifact.Artifact;
+import org.apache.maven.project.MavenProject;
+import org.apache.maven.project.inheritance.AbstractProjectInheritanceTestCase;
+
+/**
+ * A test which demonstrates maven's dependency management
+ *
+ * @author <a href="rgoers@apache.org">Ralph Goers</a>
+ */
+public class ProjectInheritanceTest
+ extends AbstractProjectInheritanceTestCase
+{
+ // ----------------------------------------------------------------------
+ //
+ // p1 inherits from p0
+ // p0 inhertis from super model
+ //
+ // or we can show it graphically as:
+ //
+ // p1 ---> p0 --> super model
+ //
+ // ----------------------------------------------------------------------
+
+ public void testDependencyManagement()
+ throws Exception
+ {
+ File localRepo = getLocalRepositoryPath();
+ File pom0 = new File( localRepo, "p0/pom.xml" );
+
+ File pom0Basedir = pom0.getParentFile();
+
+ File pom1 = new File( pom0Basedir, "p1/pom.xml" );
+
+ // load everything...
+ MavenProject project0 = getProjectWithDependencies( pom0 );
+ MavenProject project1 = getProjectWithDependencies( pom1 );
+
+ assertEquals( pom0Basedir, project1.getParent().getBasedir() );
+ Set set = project1.getArtifacts();
+ assertNotNull( "No artifacts", set );
+ assertTrue( "No Artifacts", set.size() > 0 );
+
+ for ( Object aSet : set )
+ {
+ Artifact artifact = (Artifact) aSet;
+ System.out.println(
+ "Artifact: " + artifact.getDependencyConflictId() + " " + artifact.getVersion() + " Scope: "
+ + artifact.getScope() );
+ assertTrue( "Incorrect version for " + artifact.getDependencyConflictId(),
+ artifact.getVersion().equals( "1.0" ) );
+ }
+
+ }
+}
diff --git a/framework/src/maven/apache-maven-3.3.3/maven-compat/src/test/java/org/apache/maven/project/inheritance/t06/ProjectInheritanceTest.java b/framework/src/maven/apache-maven-3.3.3/maven-compat/src/test/java/org/apache/maven/project/inheritance/t06/ProjectInheritanceTest.java
new file mode 100644
index 00000000..1b80dfeb
--- /dev/null
+++ b/framework/src/maven/apache-maven-3.3.3/maven-compat/src/test/java/org/apache/maven/project/inheritance/t06/ProjectInheritanceTest.java
@@ -0,0 +1,80 @@
+package org.apache.maven.project.inheritance.t06;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+import java.io.File;
+import java.util.Iterator;
+import java.util.Set;
+
+import org.apache.maven.artifact.Artifact;
+import org.apache.maven.project.MavenProject;
+import org.apache.maven.project.inheritance.AbstractProjectInheritanceTestCase;
+
+/**
+ * A test which demonstrates maven's dependency management
+ *
+ * @author <a href="rgoers@apache.org">Ralph Goers</a>
+ */
+public class ProjectInheritanceTest
+ extends AbstractProjectInheritanceTestCase
+{
+ // ----------------------------------------------------------------------
+ //
+ // p1 inherits from p0
+ // p0 inhertis from super model
+ //
+ // or we can show it graphically as:
+ //
+ // p1 ---> p0 --> super model
+ //
+ // ----------------------------------------------------------------------
+
+ public void testDependencyManagement()
+ throws Exception
+ {
+ File localRepo = getLocalRepositoryPath();
+ File pom0 = new File( localRepo, "p0/pom.xml" );
+
+ File pom0Basedir = pom0.getParentFile();
+
+ File pom1 = new File( pom0Basedir, "p1/pom.xml" );
+
+ // load everything...
+ MavenProject project0 = getProjectWithDependencies( pom0 );
+ MavenProject project1 = getProjectWithDependencies( pom1 );
+
+ assertEquals( pom0Basedir, project1.getParent().getBasedir() );
+ Set set = project1.getArtifacts();
+ assertNotNull( "No artifacts", set );
+ assertTrue( "No Artifacts", set.size() > 0 );
+ Iterator iter = set.iterator();
+ assertTrue( "Set size should be 4, is " + set.size(), set.size() == 4 );
+
+ while ( iter.hasNext() )
+ {
+ Artifact artifact = (Artifact) iter.next();
+ System.out.println( "Artifact: " + artifact.getDependencyConflictId() + " " + artifact.getVersion()
+ + " Optional=" + ( artifact.isOptional() ? "true" : "false" ) );
+ assertTrue( "Incorrect version for " + artifact.getDependencyConflictId(),
+ artifact.getVersion().equals( "1.0" ) );
+ }
+
+ }
+}
diff --git a/framework/src/maven/apache-maven-3.3.3/maven-compat/src/test/java/org/apache/maven/project/inheritance/t07/ProjectInheritanceTest.java b/framework/src/maven/apache-maven-3.3.3/maven-compat/src/test/java/org/apache/maven/project/inheritance/t07/ProjectInheritanceTest.java
new file mode 100644
index 00000000..68586aaf
--- /dev/null
+++ b/framework/src/maven/apache-maven-3.3.3/maven-compat/src/test/java/org/apache/maven/project/inheritance/t07/ProjectInheritanceTest.java
@@ -0,0 +1,82 @@
+package org.apache.maven.project.inheritance.t07;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+import java.io.File;
+import java.util.Iterator;
+import java.util.Set;
+
+import org.apache.maven.artifact.Artifact;
+import org.apache.maven.project.MavenProject;
+import org.apache.maven.project.inheritance.AbstractProjectInheritanceTestCase;
+
+/**
+ * A test which demonstrates maven's dependency management
+ *
+ * @author Jason van Zyl
+ */
+public class ProjectInheritanceTest
+ extends AbstractProjectInheritanceTestCase
+{
+ // ----------------------------------------------------------------------
+ //
+ // p1 inherits from p0
+ // p0 inhertis from super model
+ //
+ // or we can show it graphically as:
+ //
+ // p1 ---> p0 --> super model
+ //
+ // ----------------------------------------------------------------------
+
+ public void testDependencyManagement()
+ throws Exception
+ {
+ File localRepo = getLocalRepositoryPath();
+ File pom0 = new File( localRepo, "p0/pom.xml" );
+
+ File pom0Basedir = pom0.getParentFile();
+
+ File pom1 = new File( pom0Basedir, "p1/pom.xml" );
+
+ // load everything...
+ MavenProject project1 = getProjectWithDependencies( pom1 );
+
+ assertEquals( pom0Basedir, project1.getParent().getBasedir() );
+ System.out.println("Project " + project1.getId() + " " + project1);
+ Set set = project1.getArtifacts();
+ assertNotNull("No artifacts", set);
+ assertTrue("No Artifacts", set.size() > 0);
+ assertTrue("Set size should be 3, is " + set.size(), set.size() == 3 );
+
+ for ( Object aSet : set )
+ {
+ Artifact artifact = (Artifact) aSet;
+ assertFalse( "", artifact.getArtifactId().equals( "t07-d" ) );
+ System.out.println(
+ "Artifact: " + artifact.getDependencyConflictId() + " " + artifact.getVersion() + " Optional=" + (
+ artifact.isOptional()
+ ? "true"
+ : "false" ) );
+ assertTrue( "Incorrect version for " + artifact.getDependencyConflictId(),
+ artifact.getVersion().equals( "1.0" ) );
+ }
+ }
+}
diff --git a/framework/src/maven/apache-maven-3.3.3/maven-compat/src/test/java/org/apache/maven/project/inheritance/t08/ProjectInheritanceTest.java b/framework/src/maven/apache-maven-3.3.3/maven-compat/src/test/java/org/apache/maven/project/inheritance/t08/ProjectInheritanceTest.java
new file mode 100644
index 00000000..1afb8e8e
--- /dev/null
+++ b/framework/src/maven/apache-maven-3.3.3/maven-compat/src/test/java/org/apache/maven/project/inheritance/t08/ProjectInheritanceTest.java
@@ -0,0 +1,81 @@
+package org.apache.maven.project.inheritance.t08;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+import java.io.File;
+import java.util.Iterator;
+import java.util.Set;
+
+import org.apache.maven.artifact.Artifact;
+import org.apache.maven.project.MavenProject;
+import org.apache.maven.project.inheritance.AbstractProjectInheritanceTestCase;
+
+/**
+ * A test which demonstrates maven's dependency management
+ *
+ * @author <a href="rgoers@apache.org">Ralph Goers</a>
+ */
+public class ProjectInheritanceTest
+ extends AbstractProjectInheritanceTestCase
+{
+ // ----------------------------------------------------------------------
+ //
+ // p1 inherits from p0
+ // p0 inhertis from super model
+ //
+ // or we can show it graphically as:
+ //
+ // p1 ---> p0 --> super model
+ //
+ // ----------------------------------------------------------------------
+
+ public void testDependencyManagement()
+ throws Exception
+ {
+ File localRepo = getLocalRepositoryPath();
+ File pom0 = new File( localRepo, "p0/pom.xml" );
+
+ File pom0Basedir = pom0.getParentFile();
+
+ File pom1 = new File( pom0Basedir, "p1/pom.xml" );
+
+ // load everything...
+ MavenProject project0 = getProjectWithDependencies( pom0 );
+ MavenProject project1 = getProjectWithDependencies( pom1 );
+
+ assertEquals( pom0Basedir, project1.getParent().getBasedir() );
+ System.out.println( "Project " + project1.getId() + " " + project1 );
+ Set set = project1.getArtifacts();
+ assertNotNull( "No artifacts", set );
+ assertTrue( "No Artifacts", set.size() > 0 );
+ Iterator iter = set.iterator();
+ assertTrue( "Set size should be 4, is " + set.size(), set.size() == 4 );
+
+ while ( iter.hasNext() )
+ {
+ Artifact artifact = (Artifact) iter.next();
+ System.out.println( "Artifact: " + artifact.getDependencyConflictId() + " " + artifact.getVersion()
+ + " Optional=" + ( artifact.isOptional() ? "true" : "false" ) );
+ assertTrue( "Incorrect version for " + artifact.getDependencyConflictId(),
+ artifact.getVersion().equals( "1.0" ) );
+ }
+
+ }
+}
diff --git a/framework/src/maven/apache-maven-3.3.3/maven-compat/src/test/java/org/apache/maven/project/inheritance/t09/ProjectInheritanceTest.java b/framework/src/maven/apache-maven-3.3.3/maven-compat/src/test/java/org/apache/maven/project/inheritance/t09/ProjectInheritanceTest.java
new file mode 100644
index 00000000..6a29b732
--- /dev/null
+++ b/framework/src/maven/apache-maven-3.3.3/maven-compat/src/test/java/org/apache/maven/project/inheritance/t09/ProjectInheritanceTest.java
@@ -0,0 +1,119 @@
+package org.apache.maven.project.inheritance.t09;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+import java.io.File;
+import java.util.Map;
+
+import org.apache.maven.project.MavenProject;
+import org.apache.maven.project.inheritance.AbstractProjectInheritanceTestCase;
+
+/**
+ * Verifies exclusions listed in dependencyManagement are valid for
+ * transitive dependencies.
+ *
+ * @author <a href="mailto:pschneider@gmail.com">Patrick Schneider</a>
+ */
+public class ProjectInheritanceTest
+ extends AbstractProjectInheritanceTestCase
+{
+ // ----------------------------------------------------------------------
+ //
+ // p1 inherits from p0
+ // p0 inhertis from super model
+ //
+ // or we can show it graphically as:
+ //
+ // p1 ---> p0 --> super model
+ //
+ // ----------------------------------------------------------------------
+
+ /**
+ * How the test project is set up:
+ *
+ * 1. dependencyManagement lists dependencies on a & b,
+ * with an exclusion on c in b.
+ * 2. the child project lists a dependency on project a only
+ * 3. a depends on b (which is transitive to the child project),
+ * and b depends on c.
+ *
+ * We should see that the resulting size of collected artifacts is two:
+ * a & b only.
+ */
+ public void testDependencyManagementExclusionsExcludeTransitively()
+ throws Exception
+ {
+ File localRepo = getLocalRepositoryPath();
+
+ File pom0 = new File( localRepo, "p0/pom.xml" );
+ File pom0Basedir = pom0.getParentFile();
+ File pom1 = new File( pom0Basedir, "p1/pom.xml" );
+
+ // load the child project, which inherits from p0...
+ MavenProject project0 = getProjectWithDependencies( pom0 );
+ MavenProject project1 = getProjectWithDependencies( pom1 );
+
+ assertNotNull("Parent is null", project1.getParent());
+ assertEquals( pom0Basedir, project1.getParent().getBasedir() );
+ Map map = project1.getArtifactMap();
+
+ assertNotNull("No artifacts", map);
+ assertTrue("No Artifacts", map.size() > 0);
+ assertTrue("Set size should be 2, is " + map.size(), map.size() == 2);
+
+ assertTrue("maven-test:t09-a is not in the project", map.containsKey( "maven-test:t09-a" ));
+ assertTrue("maven-test:t09-b is not in the project", map.containsKey( "maven-test:t09-b" ));
+ assertFalse("maven-test:t09-c is in the project", map.containsKey( "maven-test:t09-c" ));
+ }
+
+ /**
+ * Setup exactly the same as the above test, except that the child project
+ * now depends upon d, which has a transitive dependency on c. Even though
+ * we did list an exclusion on c, it was only from within the context of
+ * project b. We will pick up project c in this case because no
+ * restrictions were placed on d. This demonstrates that a, b, c, & d will
+ * all be collected.
+ *
+ * @throws Exception
+ */
+ public void testDependencyManagementExclusionDoesNotOverrideGloballyForTransitives()
+ throws Exception
+ {
+ File localRepo = getLocalRepositoryPath();
+
+ File pom0 = new File( localRepo, "p0/pom.xml" );
+ File pom0Basedir = pom0.getParentFile();
+ File pom2 = new File( pom0Basedir, "p2/pom.xml" );
+
+ // load the child project, which inherits from p0...
+ MavenProject project0 = getProjectWithDependencies( pom0 );
+ MavenProject project2 = getProjectWithDependencies( pom2 );
+
+ assertEquals( pom0Basedir, project2.getParent().getBasedir() );
+ Map map = project2.getArtifactMap();
+ assertNotNull( "No artifacts", map );
+ assertTrue( "No Artifacts", map.size() > 0 );
+ assertTrue( "Set size should be 4, is " + map.size(), map.size() == 4 );
+
+ assertTrue( "maven-test:t09-a is not in the project", map.containsKey( "maven-test:t09-a" ) );
+ assertTrue( "maven-test:t09-b is not in the project", map.containsKey( "maven-test:t09-b" ) );
+ assertTrue( "maven-test:t09-c is not in the project", map.containsKey( "maven-test:t09-c" ) );
+ assertTrue( "maven-test:t09-d is not in the project", map.containsKey( "maven-test:t09-d" ) );
+ }
+} \ 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/project/inheritance/t10/ProjectInheritanceTest.java b/framework/src/maven/apache-maven-3.3.3/maven-compat/src/test/java/org/apache/maven/project/inheritance/t10/ProjectInheritanceTest.java
new file mode 100644
index 00000000..9e5137f2
--- /dev/null
+++ b/framework/src/maven/apache-maven-3.3.3/maven-compat/src/test/java/org/apache/maven/project/inheritance/t10/ProjectInheritanceTest.java
@@ -0,0 +1,94 @@
+package org.apache.maven.project.inheritance.t10;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+import java.io.File;
+import java.util.Map;
+
+import org.apache.maven.artifact.Artifact;
+import org.apache.maven.project.MavenProject;
+import org.apache.maven.project.inheritance.AbstractProjectInheritanceTestCase;
+
+/**
+ * Verifies scope inheritence of direct and transitive dependencies.
+ *
+ * Should show three behaviors:
+ *
+ * 1. dependencyManagement should override the scope of transitive dependencies.
+ * 2. Direct dependencies should override the scope of dependencyManagement.
+ * 3. Direct dependencies should inherit scope from dependencyManagement when
+ * they do not explicitly state a scope.
+ *
+ * @author <a href="mailto:pschneider@gmail.com">Patrick Schneider</a>
+ */
+public class ProjectInheritanceTest
+ extends AbstractProjectInheritanceTestCase
+{
+ // ----------------------------------------------------------------------
+ //
+ // p1 inherits from p0
+ // p0 inhertis from super model
+ //
+ // or we can show it graphically as:
+ //
+ // p1 ---> p0 --> super model
+ //
+ // ----------------------------------------------------------------------
+
+ public void testDependencyManagementOverridesTransitiveDependencyVersion()
+ throws Exception
+ {
+ File localRepo = getLocalRepositoryPath();
+
+ File pom0 = new File( localRepo, "p0/pom.xml" );
+ File pom0Basedir = pom0.getParentFile();
+ File pom1 = new File( pom0Basedir, "p1/pom.xml" );
+
+ // load the child project, which inherits from p0...
+ MavenProject project0 = getProjectWithDependencies( pom0 );
+ MavenProject project1 = getProjectWithDependencies( pom1 );
+
+ assertEquals( pom0Basedir, project1.getParent().getBasedir() );
+ System.out.println("Project " + project1.getId() + " " + project1);
+ Map map = project1.getArtifactMap();
+ assertNotNull("No artifacts", map);
+ assertTrue("No Artifacts", map.size() > 0);
+ assertTrue("Set size should be 3, is " + map.size(), map.size() == 3);
+
+ Artifact a = (Artifact) map.get("maven-test:t10-a");
+ Artifact b = (Artifact) map.get("maven-test:t10-b");
+ Artifact c = (Artifact) map.get("maven-test:t10-c");
+
+ assertNotNull( a );
+ assertNotNull( b );
+ assertNotNull( c );
+
+ // inherited from depMgmt
+ System.out.println(a.getScope());
+ assertTrue("Incorrect scope for " + a.getDependencyConflictId(), a.getScope().equals("test"));
+
+ // transitive dep, overridden b depMgmt
+ assertTrue("Incorrect scope for " + b.getDependencyConflictId(), b.getScope().equals("runtime"));
+
+ // direct dep, overrides depMgmt
+ assertTrue("Incorrect scope for " + c.getDependencyConflictId(), c.getScope().equals("runtime"));
+
+ }
+} \ 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/project/inheritance/t11/ProjectInheritanceTest.java b/framework/src/maven/apache-maven-3.3.3/maven-compat/src/test/java/org/apache/maven/project/inheritance/t11/ProjectInheritanceTest.java
new file mode 100644
index 00000000..bbdecd7a
--- /dev/null
+++ b/framework/src/maven/apache-maven-3.3.3/maven-compat/src/test/java/org/apache/maven/project/inheritance/t11/ProjectInheritanceTest.java
@@ -0,0 +1,64 @@
+package org.apache.maven.project.inheritance.t11;
+
+/*
+ * 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.project.MavenProject;
+import org.apache.maven.project.inheritance.AbstractProjectInheritanceTestCase;
+
+/**
+ * Verifies scope of root project is preserved regardless of parent depenedency management.
+ *
+ * @author <a href="mailto:pschneider@gmail.com">Patrick Schneider</a>
+ * @see <a href="http://jira.codehaus.org/browse/MNG-2919">MNG-2919</a>
+ */
+public class ProjectInheritanceTest
+ extends AbstractProjectInheritanceTestCase
+{
+ // ----------------------------------------------------------------------
+ //
+ // p1 inherits from p0
+ // p0 inhertis from super model
+ //
+ // or we can show it graphically as:
+ //
+ // p1 ---> p0 --> super model
+ //
+ // ----------------------------------------------------------------------
+
+ public void testDependencyManagementDoesNotOverrideScopeOfCurrentArtifact()
+ throws Exception
+ {
+ File localRepo = getLocalRepositoryPath();
+
+ File pom0 = new File( localRepo, "p0/pom.xml" );
+ File pom0Basedir = pom0.getParentFile();
+ File pom1 = new File( pom0Basedir, "p1/pom.xml" );
+
+ // load the child project, which inherits from p0...
+ MavenProject project0 = getProjectWithDependencies( pom0 );
+ MavenProject project1 = getProjectWithDependencies( pom1 );
+
+ assertEquals( pom0Basedir, project1.getParent().getBasedir() );
+ assertNull( "dependencyManagement has overwritten the scope of the currently building child project",
+ project1.getArtifact().getScope() );
+ }
+}
diff --git a/framework/src/maven/apache-maven-3.3.3/maven-compat/src/test/java/org/apache/maven/project/inheritance/t12/ProjectInheritanceTest.java b/framework/src/maven/apache-maven-3.3.3/maven-compat/src/test/java/org/apache/maven/project/inheritance/t12/ProjectInheritanceTest.java
new file mode 100644
index 00000000..814e4871
--- /dev/null
+++ b/framework/src/maven/apache-maven-3.3.3/maven-compat/src/test/java/org/apache/maven/project/inheritance/t12/ProjectInheritanceTest.java
@@ -0,0 +1,65 @@
+package org.apache.maven.project.inheritance.t12;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+import java.io.File;
+import java.util.Map;
+
+import org.apache.maven.model.Plugin;
+import org.apache.maven.project.MavenProject;
+import org.apache.maven.project.inheritance.AbstractProjectInheritanceTestCase;
+
+/**
+ * Verifies that plugin execution sections in the parent POM that have
+ * inherit == false are not inherited to the child POM.
+ */
+public class ProjectInheritanceTest extends AbstractProjectInheritanceTestCase
+{
+ // ----------------------------------------------------------------------
+ //
+ // p1 inherits from p0
+ // p0 inherits from super model
+ //
+ // or we can show it graphically as:
+ //
+ // p1 ---> p0 --> super model
+ //
+ // ----------------------------------------------------------------------
+
+ public void testFalsePluginExecutionInheritValue() throws Exception
+ {
+ File localRepo = getLocalRepositoryPath();
+
+ File pom0 = new File( localRepo, "p0/pom.xml" );
+ File pom0Basedir = pom0.getParentFile();
+ File pom1 = new File( pom0Basedir, "p1/pom.xml" );
+
+ getProjectWithDependencies( pom0 );
+ MavenProject project1 = getProjectWithDependencies( pom1 );
+
+ Map pluginMap = project1.getBuild().getPluginsAsMap();
+ Plugin compilerPlugin = (Plugin) pluginMap.get( "org.apache.maven.plugins:maven-compiler-plugin" );
+
+ assertNotNull( compilerPlugin );
+
+ Map executionMap = compilerPlugin.getExecutionsAsMap();
+ assertNull( "Plugin execution: \'test\' should NOT exist in the compiler plugin specification for the child project!", executionMap.get( "test" ) );
+ }
+} \ 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/project/inheritance/t12scm/ProjectInheritanceTest.java b/framework/src/maven/apache-maven-3.3.3/maven-compat/src/test/java/org/apache/maven/project/inheritance/t12scm/ProjectInheritanceTest.java
new file mode 100644
index 00000000..3b086624
--- /dev/null
+++ b/framework/src/maven/apache-maven-3.3.3/maven-compat/src/test/java/org/apache/maven/project/inheritance/t12scm/ProjectInheritanceTest.java
@@ -0,0 +1,125 @@
+package org.apache.maven.project.inheritance.t12scm;
+
+/*
+ * 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.project.MavenProject;
+import org.apache.maven.project.inheritance.AbstractProjectInheritanceTestCase;
+
+/**
+ * Verifies SCM inheritance uses modules statement from parent.
+ *
+ * @author jdcasey
+ */
+public class ProjectInheritanceTest
+ extends AbstractProjectInheritanceTestCase
+{
+ // ----------------------------------------------------------------------
+ //
+ // p1 inherits from p0
+ // p0 inhertis from super model
+ //
+ // or we can show it graphically as:
+ //
+ // p1 ---> p0 --> super model
+ //
+ // ----------------------------------------------------------------------
+
+ public void testScmInfoCalculatedCorrectlyOnParentAndChildRead()
+ throws Exception
+ {
+ File localRepo = getLocalRepositoryPath();
+
+ File pom0 = new File( localRepo, "p0/pom.xml" );
+ File pom0Basedir = pom0.getParentFile();
+ File pom1 = new File( pom0Basedir, "modules/p1/pom.xml" );
+
+ // load the child project, which inherits from p0...
+ MavenProject project0 = getProject( pom0 );
+ MavenProject project1 = getProject( pom1 );
+
+ System.out.println( "\n\n" );
+ System.out.println( "Parent SCM URL is: " + project0.getScm().getUrl() );
+ System.out.println( "Child SCM URL is: " + project1.getScm().getUrl() );
+ System.out.println();
+ System.out.println( "Parent SCM connection is: " + project0.getScm().getConnection() );
+ System.out.println( "Child SCM connection is: " + project1.getScm().getConnection() );
+ System.out.println();
+ System.out.println( "Parent SCM developer connection is: "
+ + project0.getScm().getDeveloperConnection() );
+ System.out.println( "Child SCM developer connection is: "
+ + project1.getScm().getDeveloperConnection() );
+
+ assertEquals( project1.getScm().getUrl(), project0.getScm().getUrl() + "/modules/p1" );
+ assertEquals( project1.getScm().getConnection(), project0.getScm().getConnection()
+ + "/modules/p1" );
+ assertEquals( project1.getScm().getDeveloperConnection(), project0.getScm()
+ .getDeveloperConnection()
+ + "/modules/p1" );
+ }
+
+ public void testScmInfoCalculatedCorrectlyOnChildOnlyRead()
+ throws Exception
+ {
+ File localRepo = getLocalRepositoryPath();
+
+ File pom1 = new File( localRepo, "p0/modules/p1/pom.xml" );
+
+ // load the child project, which inherits from p0...
+ MavenProject project1 = getProject( pom1 );
+
+ System.out.println( "\n\n" );
+ System.out.println( "Child SCM URL is: " + project1.getScm().getUrl() );
+ System.out.println( "Child SCM connection is: " + project1.getScm().getConnection() );
+ System.out.println( "Child SCM developer connection is: "
+ + project1.getScm().getDeveloperConnection() );
+
+ assertEquals( "http://host/viewer?path=/p0/modules/p1", project1.getScm().getUrl() );
+ assertEquals( "scm:svn:http://host/p0/modules/p1", project1.getScm().getConnection() );
+ assertEquals( "scm:svn:https://host/p0/modules/p1", project1.getScm().getDeveloperConnection() );
+ }
+
+// public void testScmInfoCalculatedCorrectlyOnChildReadFromLocalRepository()
+// throws Exception
+// {
+// File localRepo = getLocalRepositoryPath();
+//
+// ArtifactFactory factory = (ArtifactFactory) lookup( ArtifactFactory.class );
+// Artifact artifact = factory.createProjectArtifact( "maven", "p1", "1.0" );
+//
+// ArtifactRepositoryFactory repoFactory = (ArtifactRepositoryFactory) lookup( ArtifactRepositoryFactory.class );
+// ArtifactRepository localArtifactRepo = repoFactory.createLocalRepository( localRepo );
+//
+// MavenProject project1 = getProjectBuilder().buildFromRepository( artifact, Collections.EMPTY_LIST, localArtifactRepo );
+//
+// System.out.println( "\n\n" );
+// System.out.println( "Child SCM URL is: " + project1.getScm().getUrl() );
+// System.out.println( "Child SCM connection is: " + project1.getScm().getConnection() );
+// System.out.println( "Child SCM developer connection is: "
+// + project1.getScm().getDeveloperConnection() );
+//
+// assertEquals( project1.getScm().getUrl(), "http://host/viewer?path=/p0/modules/p1" );
+// assertEquals( project1.getScm().getConnection(), "scm:svn:http://host/p0/modules/p1" );
+// assertEquals( project1.getScm().getDeveloperConnection(),
+// "scm:svn:https://host/p0/modules/p1" );
+// }
+
+}
diff --git a/framework/src/maven/apache-maven-3.3.3/maven-compat/src/test/java/org/apache/maven/project/path/DefaultPathTranslatorTest.java b/framework/src/maven/apache-maven-3.3.3/maven-compat/src/test/java/org/apache/maven/project/path/DefaultPathTranslatorTest.java
new file mode 100644
index 00000000..b19ef996
--- /dev/null
+++ b/framework/src/maven/apache-maven-3.3.3/maven-compat/src/test/java/org/apache/maven/project/path/DefaultPathTranslatorTest.java
@@ -0,0 +1,58 @@
+package org.apache.maven.project.path;
+
+/*
+ * 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 junit.framework.TestCase;
+
+@SuppressWarnings( "deprecation" )
+public class DefaultPathTranslatorTest
+ extends TestCase
+{
+
+ public void testAlignToBasedirWhereBasedirExpressionIsTheCompleteValue()
+ {
+ File basedir = new File( System.getProperty( "java.io.tmpdir" ), "test" ).getAbsoluteFile();
+
+ String aligned = new DefaultPathTranslator().alignToBaseDirectory( "${basedir}", basedir );
+
+ assertEquals( basedir.getAbsolutePath(), aligned );
+ }
+
+ public void testAlignToBasedirWhereBasedirExpressionIsTheValuePrefix()
+ {
+ File basedir = new File( System.getProperty( "java.io.tmpdir" ), "test" ).getAbsoluteFile();
+
+ String aligned = new DefaultPathTranslator().alignToBaseDirectory( "${basedir}/dir", basedir );
+
+ assertEquals( new File( basedir, "dir" ).getAbsolutePath(), aligned );
+ }
+
+ public void testUnalignToBasedirWherePathEqualsBasedir()
+ {
+ File basedir = new File( System.getProperty( "java.io.tmpdir" ), "test" ).getAbsoluteFile();
+
+ String unaligned = new DefaultPathTranslator().unalignFromBaseDirectory( basedir.getAbsolutePath(), basedir );
+
+ assertEquals( ".", unaligned );
+ }
+
+}
diff --git a/framework/src/maven/apache-maven-3.3.3/maven-compat/src/test/java/org/apache/maven/repository/DefaultMirrorSelectorTest.java b/framework/src/maven/apache-maven-3.3.3/maven-compat/src/test/java/org/apache/maven/repository/DefaultMirrorSelectorTest.java
new file mode 100644
index 00000000..fb32f0f2
--- /dev/null
+++ b/framework/src/maven/apache-maven-3.3.3/maven-compat/src/test/java/org/apache/maven/repository/DefaultMirrorSelectorTest.java
@@ -0,0 +1,38 @@
+package org.apache.maven.repository;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+import org.apache.maven.artifact.repository.ArtifactRepository;
+import org.apache.maven.artifact.repository.DefaultArtifactRepository;
+import org.codehaus.plexus.PlexusTestCase;
+
+public class DefaultMirrorSelectorTest
+ extends PlexusTestCase
+{
+
+ public void testMirrorWithMirroOfPatternContainingANegationIsNotSelected()
+ {
+ ArtifactRepository repository = new DefaultArtifactRepository( "snapshots.repo", "http://whatever", null );
+ String pattern = "external:*, !snapshots.repo";
+ boolean matches = DefaultMirrorSelector.matchPattern( repository, pattern );
+ System.out.println( matches );
+ assertFalse( matches );
+ }
+}
diff --git a/framework/src/maven/apache-maven-3.3.3/maven-compat/src/test/java/org/apache/maven/repository/LegacyRepositoryLayout.java b/framework/src/maven/apache-maven-3.3.3/maven-compat/src/test/java/org/apache/maven/repository/LegacyRepositoryLayout.java
new file mode 100644
index 00000000..77a6baef
--- /dev/null
+++ b/framework/src/maven/apache-maven-3.3.3/maven-compat/src/test/java/org/apache/maven/repository/LegacyRepositoryLayout.java
@@ -0,0 +1,89 @@
+package org.apache.maven.repository;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+import org.apache.maven.artifact.Artifact;
+import org.apache.maven.artifact.handler.ArtifactHandler;
+import org.apache.maven.artifact.metadata.ArtifactMetadata;
+import org.apache.maven.artifact.repository.ArtifactRepository;
+import org.apache.maven.artifact.repository.layout.ArtifactRepositoryLayout;
+import org.codehaus.plexus.component.annotations.Component;
+
+/**
+ * @author jdcasey
+ */
+@Component(role=ArtifactRepositoryLayout.class, hint="legacy")
+public class LegacyRepositoryLayout
+ implements ArtifactRepositoryLayout
+{
+ private static final String PATH_SEPARATOR = "/";
+
+ public String getId()
+ {
+ return "legacy";
+ }
+
+ public String pathOf( Artifact artifact )
+ {
+ ArtifactHandler artifactHandler = artifact.getArtifactHandler();
+
+ StringBuilder path = new StringBuilder( 128 );
+
+ path.append( artifact.getGroupId() ).append( '/' );
+ path.append( artifactHandler.getDirectory() ).append( '/' );
+ path.append( artifact.getArtifactId() ).append( '-' ).append( artifact.getVersion() );
+
+ if ( artifact.hasClassifier() )
+ {
+ path.append( '-' ).append( artifact.getClassifier() );
+ }
+
+ if ( artifactHandler.getExtension() != null && artifactHandler.getExtension().length() > 0 )
+ {
+ path.append( '.' ).append( artifactHandler.getExtension() );
+ }
+
+ return path.toString();
+ }
+
+ public String pathOfLocalRepositoryMetadata( ArtifactMetadata metadata,
+ ArtifactRepository repository )
+ {
+ return pathOfRepositoryMetadata( metadata, metadata.getLocalFilename( repository ) );
+ }
+
+ private String pathOfRepositoryMetadata( ArtifactMetadata metadata,
+ String filename )
+ {
+ StringBuilder path = new StringBuilder( 128 );
+
+ path.append( metadata.getGroupId() ).append( PATH_SEPARATOR ).append( "poms" ).append( PATH_SEPARATOR );
+
+ path.append( filename );
+
+ return path.toString();
+ }
+
+ public String pathOfRemoteRepositoryMetadata( ArtifactMetadata metadata )
+ {
+ return pathOfRepositoryMetadata( metadata, metadata.getRemoteFilename() );
+ }
+
+}
diff --git a/framework/src/maven/apache-maven-3.3.3/maven-compat/src/test/java/org/apache/maven/repository/LegacyRepositorySystemTest.java b/framework/src/maven/apache-maven-3.3.3/maven-compat/src/test/java/org/apache/maven/repository/LegacyRepositorySystemTest.java
new file mode 100644
index 00000000..96af590c
--- /dev/null
+++ b/framework/src/maven/apache-maven-3.3.3/maven-compat/src/test/java/org/apache/maven/repository/LegacyRepositorySystemTest.java
@@ -0,0 +1,206 @@
+package org.apache.maven.repository;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more contributor license
+ * agreements. See the NOTICE file distributed with this work for additional information regarding
+ * copyright ownership. The ASF licenses this file to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance with the License. You may obtain a
+ * copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software distributed under the License
+ * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
+ * or implied. See the License for the specific language governing permissions and limitations under
+ * the License.
+ */
+
+import java.io.File;
+import java.util.Arrays;
+import java.util.List;
+
+import org.apache.maven.artifact.Artifact;
+import org.apache.maven.artifact.repository.ArtifactRepository;
+import org.apache.maven.artifact.resolver.ArtifactResolutionRequest;
+import org.apache.maven.artifact.resolver.ArtifactResolutionResult;
+import org.apache.maven.artifact.resolver.ResolutionErrorHandler;
+import org.apache.maven.execution.DefaultMavenExecutionRequest;
+import org.apache.maven.execution.DefaultMavenExecutionResult;
+import org.apache.maven.execution.MavenSession;
+import org.apache.maven.model.Dependency;
+import org.apache.maven.model.Repository;
+import org.apache.maven.model.RepositoryPolicy;
+import org.apache.maven.plugin.LegacySupport;
+import org.apache.maven.repository.RepositorySystem;
+import org.codehaus.plexus.ContainerConfiguration;
+import org.codehaus.plexus.PlexusConstants;
+import org.codehaus.plexus.PlexusTestCase;
+import org.eclipse.aether.DefaultRepositorySystemSession;
+import org.eclipse.aether.internal.impl.SimpleLocalRepositoryManagerFactory;
+import org.eclipse.aether.repository.LocalRepository;
+
+/**
+ * Tests {@link LegacyRepositorySystem}.
+ *
+ * @author Benjamin Bentmann
+ */
+public class LegacyRepositorySystemTest
+ extends PlexusTestCase
+{
+ private RepositorySystem repositorySystem;
+
+ private ResolutionErrorHandler resolutionErrorHandler;
+
+ @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();
+ repositorySystem = lookup( RepositorySystem.class, "default" );
+ resolutionErrorHandler = lookup( ResolutionErrorHandler.class );
+ }
+
+ @Override
+ protected void tearDown()
+ throws Exception
+ {
+ repositorySystem = null;
+ resolutionErrorHandler = null;
+ super.tearDown();
+ }
+
+ protected List<ArtifactRepository> getRemoteRepositories()
+ throws Exception
+ {
+ File repoDir = new File( getBasedir(), "src/test/remote-repo" ).getAbsoluteFile();
+
+ RepositoryPolicy policy = new RepositoryPolicy();
+ policy.setEnabled( true );
+ policy.setChecksumPolicy( "ignore" );
+ policy.setUpdatePolicy( "always" );
+
+ Repository repository = new Repository();
+ repository.setId( RepositorySystem.DEFAULT_REMOTE_REPO_ID );
+ repository.setUrl( "file://" + repoDir.toURI().getPath() );
+ repository.setReleases( policy );
+ repository.setSnapshots( policy );
+
+ return Arrays.asList( repositorySystem.buildArtifactRepository( repository ) );
+ }
+
+ protected ArtifactRepository getLocalRepository()
+ throws Exception
+ {
+ File repoDir = new File( getBasedir(), "target/local-repo" ).getAbsoluteFile();
+
+ return repositorySystem.createLocalRepository( repoDir );
+ }
+
+ public void testThatASystemScopedDependencyIsNotResolvedFromRepositories()
+ throws Exception
+ {
+ //
+ // We should get a whole slew of dependencies resolving this artifact transitively
+ //
+ Dependency d = new Dependency();
+ d.setGroupId( "org.apache.maven.its" );
+ d.setArtifactId( "b" );
+ d.setVersion( "0.1" );
+ d.setScope( Artifact.SCOPE_COMPILE );
+ Artifact artifact = repositorySystem.createDependencyArtifact( d );
+
+ ArtifactResolutionRequest request = new ArtifactResolutionRequest()
+ .setArtifact( artifact )
+ .setResolveRoot( true )
+ .setResolveTransitively( true )
+ .setRemoteRepositories( getRemoteRepositories() )
+ .setLocalRepository( getLocalRepository() );
+
+ DefaultRepositorySystemSession session = new DefaultRepositorySystemSession();
+ LocalRepository localRepo = new LocalRepository( request.getLocalRepository().getBasedir() );
+ session.setLocalRepositoryManager( new SimpleLocalRepositoryManagerFactory().newInstance( session, localRepo ) );
+ LegacySupport legacySupport = lookup( LegacySupport.class );
+ legacySupport.setSession( new MavenSession( getContainer(), session, new DefaultMavenExecutionRequest(),
+ new DefaultMavenExecutionResult() ) );
+
+ ArtifactResolutionResult result = repositorySystem.resolve( request );
+ resolutionErrorHandler.throwErrors( request, result );
+ assertEquals( 2, result.getArtifacts().size() );
+
+ //
+ // System scoped version which should
+ //
+ d.setScope( Artifact.SCOPE_SYSTEM );
+ File file = new File( getBasedir(), "src/test/repository-system/maven-core-2.1.0.jar" );
+ assertTrue( file.exists() );
+ d.setSystemPath( file.getCanonicalPath() );
+
+ artifact = repositorySystem.createDependencyArtifact( d );
+
+ //
+ // The request has not set any local or remote repositories as the system scoped dependency being resolved should only
+ // give us the dependency off the disk and nothing more.
+ //
+ request = new ArtifactResolutionRequest()
+ .setArtifact( artifact )
+ .setResolveRoot( true )
+ .setResolveTransitively( true );
+
+ result = repositorySystem.resolve( request );
+ resolutionErrorHandler.throwErrors( request, result );
+ assertEquals( 1, result.getArtifacts().size() );
+
+ //
+ // Put in a bogus file to make sure missing files cause the resolution to fail.
+ //
+ file = new File( getBasedir(), "src/test/repository-system/maven-monkey-2.1.0.jar" );
+ assertFalse( file.exists() );
+ d.setSystemPath( file.getCanonicalPath() );
+ artifact = repositorySystem.createDependencyArtifact( d );
+
+ //
+ // The request has not set any local or remote repositories as the system scoped dependency being resolved should only
+ // give us the dependency off the disk and nothing more.
+ //
+ request = new ArtifactResolutionRequest()
+ .setArtifact( artifact )
+ .setResolveRoot( true )
+ .setResolveTransitively( true );
+
+ try
+ {
+ result = repositorySystem.resolve( request );
+ resolutionErrorHandler.throwErrors( request, result );
+ }
+ catch( Exception e )
+ {
+ assertTrue( result.hasMissingArtifacts() );
+ }
+ }
+
+ public void testLocalRepositoryBasedir()
+ throws Exception
+ {
+ File localRepoDir = new File( "" ).getAbsoluteFile();
+
+ ArtifactRepository localRepo = repositorySystem.createLocalRepository( localRepoDir );
+
+ String basedir = localRepo.getBasedir();
+
+ assertFalse( basedir.endsWith( "/" ) );
+ assertFalse( basedir.endsWith( "\\" ) );
+
+ assertEquals( localRepoDir, new File( basedir ) );
+
+ assertEquals( localRepoDir.getPath(), basedir );
+ }
+
+}
diff --git a/framework/src/maven/apache-maven-3.3.3/maven-compat/src/test/java/org/apache/maven/repository/MirrorProcessorTest.java b/framework/src/maven/apache-maven-3.3.3/maven-compat/src/test/java/org/apache/maven/repository/MirrorProcessorTest.java
new file mode 100644
index 00000000..57645750
--- /dev/null
+++ b/framework/src/maven/apache-maven-3.3.3/maven-compat/src/test/java/org/apache/maven/repository/MirrorProcessorTest.java
@@ -0,0 +1,259 @@
+package org.apache.maven.repository;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+import java.util.Arrays;
+import java.util.List;
+
+import org.apache.maven.artifact.repository.ArtifactRepository;
+import org.apache.maven.repository.legacy.repository.ArtifactRepositoryFactory;
+import org.apache.maven.artifact.repository.layout.DefaultRepositoryLayout;
+import org.apache.maven.settings.Mirror;
+import org.codehaus.plexus.PlexusTestCase;
+
+public class MirrorProcessorTest
+ extends PlexusTestCase
+{
+ private DefaultMirrorSelector mirrorSelector;
+ private ArtifactRepositoryFactory repositorySystem;
+
+ protected void setUp()
+ throws Exception
+ {
+ mirrorSelector = (DefaultMirrorSelector) lookup( MirrorSelector.class );
+ repositorySystem = lookup( ArtifactRepositoryFactory.class );
+ }
+
+ @Override
+ protected void tearDown()
+ throws Exception
+ {
+ mirrorSelector = null;
+ repositorySystem = null;
+
+ super.tearDown();
+ }
+
+ public void testExternalURL()
+ {
+ assertTrue( DefaultMirrorSelector.isExternalRepo( getRepo( "foo", "http://somehost" ) ) );
+ assertTrue( DefaultMirrorSelector.isExternalRepo( getRepo( "foo", "http://somehost:9090/somepath" ) ) );
+ assertTrue( DefaultMirrorSelector.isExternalRepo( getRepo( "foo", "ftp://somehost" ) ) );
+ assertTrue( DefaultMirrorSelector.isExternalRepo( getRepo( "foo", "http://192.168.101.1" ) ) );
+ assertTrue( DefaultMirrorSelector.isExternalRepo( getRepo( "foo", "http://" ) ) );
+ // these are local
+ assertFalse( DefaultMirrorSelector.isExternalRepo( getRepo( "foo", "http://localhost:8080" ) ) );
+ assertFalse( DefaultMirrorSelector.isExternalRepo( getRepo( "foo", "http://127.0.0.1:9090" ) ) );
+ assertFalse( DefaultMirrorSelector.isExternalRepo( getRepo( "foo", "file://localhost/somepath" ) ) );
+ assertFalse( DefaultMirrorSelector.isExternalRepo( getRepo( "foo", "file://localhost/D:/somepath" ) ) );
+ assertFalse( DefaultMirrorSelector.isExternalRepo( getRepo( "foo", "http://localhost" ) ) );
+ assertFalse( DefaultMirrorSelector.isExternalRepo( getRepo( "foo", "http://127.0.0.1" ) ) );
+ assertFalse( DefaultMirrorSelector.isExternalRepo( getRepo( "foo", "file:///somepath" ) ) );
+ assertFalse( DefaultMirrorSelector.isExternalRepo( getRepo( "foo", "file://D:/somepath" ) ) );
+
+ // not a proper url so returns false;
+ assertFalse( DefaultMirrorSelector.isExternalRepo( getRepo( "foo", "192.168.101.1" ) ) );
+ assertFalse( DefaultMirrorSelector.isExternalRepo( getRepo( "foo", "" ) ) );
+ }
+
+ public void testMirrorLookup()
+ {
+ Mirror mirrorA = newMirror( "a", "a", "http://a" );
+ Mirror mirrorB = newMirror( "b", "b", "http://b" );
+
+ List<Mirror> mirrors = Arrays.asList( mirrorA, mirrorB );
+
+ assertSame( mirrorA, mirrorSelector.getMirror( getRepo( "a", "http://a.a" ), mirrors ) );
+
+ assertSame( mirrorB, mirrorSelector.getMirror( getRepo( "b", "http://a.a" ), mirrors ) );
+
+ assertNull( mirrorSelector.getMirror( getRepo( "c", "http://c.c" ), mirrors ) );
+ }
+
+ public void testMirrorWildcardLookup()
+ {
+ Mirror mirrorA = newMirror( "a", "a", "http://a" );
+ Mirror mirrorB = newMirror( "b", "b", "http://b" );
+ Mirror mirrorC = newMirror( "c", "*", "http://wildcard" );
+
+ List<Mirror> mirrors = Arrays.asList( mirrorA, mirrorB, mirrorC );
+
+ assertSame( mirrorA, mirrorSelector.getMirror( getRepo( "a", "http://a.a" ), mirrors ) );
+
+ assertSame( mirrorB, mirrorSelector.getMirror( getRepo( "b", "http://a.a" ), mirrors ) );
+
+ assertSame( mirrorC, mirrorSelector.getMirror( getRepo( "c", "http://c.c" ), mirrors ) );
+ }
+
+ public void testMirrorStopOnFirstMatch()
+ {
+ // exact matches win first
+ Mirror mirrorA2 = newMirror( "a2", "a,b", "http://a2" );
+ Mirror mirrorA = newMirror( "a", "a", "http://a" );
+ // make sure repeated entries are skipped
+ Mirror mirrorA3 = newMirror( "a", "a", "http://a3" );
+
+ Mirror mirrorB = newMirror( "b", "b", "http://b" );
+ Mirror mirrorC = newMirror( "c", "d,e", "http://de" );
+ Mirror mirrorC2 = newMirror( "c", "*", "http://wildcard" );
+ Mirror mirrorC3 = newMirror( "c", "e,f", "http://ef" );
+
+ List<Mirror> mirrors = Arrays.asList( mirrorA2, mirrorA, mirrorA3, mirrorB, mirrorC, mirrorC2, mirrorC3 );
+
+ assertSame( mirrorA, mirrorSelector.getMirror( getRepo( "a", "http://a.a" ), mirrors ) );
+
+ assertSame( mirrorB, mirrorSelector.getMirror( getRepo( "b", "http://a.a" ), mirrors ) );
+
+ assertSame( mirrorC2, mirrorSelector.getMirror( getRepo( "c", "http://c.c" ), mirrors ) );
+
+ assertSame( mirrorC, mirrorSelector.getMirror( getRepo( "d", "http://d" ), mirrors ) );
+
+ assertSame( mirrorC, mirrorSelector.getMirror( getRepo( "e", "http://e" ), mirrors ) );
+
+ assertSame( mirrorC2, mirrorSelector.getMirror( getRepo( "f", "http://f" ), mirrors ) );
+ }
+
+ public void testPatterns()
+ {
+ assertTrue( DefaultMirrorSelector.matchPattern( getRepo( "a" ), "*" ) );
+ assertTrue( DefaultMirrorSelector.matchPattern( getRepo( "a" ), "*," ) );
+ assertTrue( DefaultMirrorSelector.matchPattern( getRepo( "a" ), ",*," ) );
+ assertTrue( DefaultMirrorSelector.matchPattern( getRepo( "a" ), "*," ) );
+
+ assertTrue( DefaultMirrorSelector.matchPattern( getRepo( "a" ), "a" ) );
+ assertTrue( DefaultMirrorSelector.matchPattern( getRepo( "a" ), "a," ) );
+ assertTrue( DefaultMirrorSelector.matchPattern( getRepo( "a" ), ",a," ) );
+ assertTrue( DefaultMirrorSelector.matchPattern( getRepo( "a" ), "a," ) );
+
+ assertFalse( DefaultMirrorSelector.matchPattern( getRepo( "b" ), "a" ) );
+ assertFalse( DefaultMirrorSelector.matchPattern( getRepo( "b" ), "a," ) );
+ assertFalse( DefaultMirrorSelector.matchPattern( getRepo( "b" ), ",a" ) );
+ assertFalse( DefaultMirrorSelector.matchPattern( getRepo( "b" ), ",a," ) );
+
+ assertTrue( DefaultMirrorSelector.matchPattern( getRepo( "a" ), "a,b" ) );
+ assertTrue( DefaultMirrorSelector.matchPattern( getRepo( "b" ), "a,b" ) );
+
+ assertFalse( DefaultMirrorSelector.matchPattern( getRepo( "c" ), "a,b" ) );
+
+ assertTrue( DefaultMirrorSelector.matchPattern( getRepo( "a" ), "*" ) );
+ assertTrue( DefaultMirrorSelector.matchPattern( getRepo( "a" ), "*,b" ) );
+ assertTrue( DefaultMirrorSelector.matchPattern( getRepo( "a" ), "*,!b" ) );
+
+ assertFalse( DefaultMirrorSelector.matchPattern( getRepo( "a" ), "*,!a" ) );
+ assertFalse( DefaultMirrorSelector.matchPattern( getRepo( "a" ), "!a,*" ) );
+
+ assertTrue( DefaultMirrorSelector.matchPattern( getRepo( "c" ), "*,!a" ) );
+ assertTrue( DefaultMirrorSelector.matchPattern( getRepo( "c" ), "!a,*" ) );
+
+ assertFalse( DefaultMirrorSelector.matchPattern( getRepo( "c" ), "!a,!c" ) );
+ assertFalse( DefaultMirrorSelector.matchPattern( getRepo( "d" ), "!a,!c*" ) );
+ }
+
+ public void testPatternsWithExternal()
+ {
+ assertTrue( DefaultMirrorSelector.matchPattern( getRepo( "a", "http://localhost" ), "*" ) );
+ assertFalse( DefaultMirrorSelector.matchPattern( getRepo( "a", "http://localhost" ), "external:*" ) );
+
+ assertTrue( DefaultMirrorSelector.matchPattern( getRepo( "a", "http://localhost" ), "external:*,a" ) );
+ assertFalse( DefaultMirrorSelector.matchPattern( getRepo( "a", "http://localhost" ), "external:*,!a" ) );
+ assertTrue( DefaultMirrorSelector.matchPattern( getRepo( "a", "http://localhost" ), "a,external:*" ) );
+ assertFalse( DefaultMirrorSelector.matchPattern( getRepo( "a", "http://localhost" ), "!a,external:*" ) );
+
+ assertFalse( DefaultMirrorSelector.matchPattern( getRepo( "c", "http://localhost" ), "!a,external:*" ) );
+ assertTrue( DefaultMirrorSelector.matchPattern( getRepo( "c", "http://somehost" ), "!a,external:*" ) );
+ }
+
+ public void testLayoutPattern()
+ {
+ assertTrue( DefaultMirrorSelector.matchesLayout( "default", null ) );
+ assertTrue( DefaultMirrorSelector.matchesLayout( "default", "" ) );
+ assertTrue( DefaultMirrorSelector.matchesLayout( "default", "*" ) );
+
+ assertTrue( DefaultMirrorSelector.matchesLayout( "default", "default" ) );
+ assertFalse( DefaultMirrorSelector.matchesLayout( "default", "legacy" ) );
+
+ assertTrue( DefaultMirrorSelector.matchesLayout( "default", "legacy,default" ) );
+ assertTrue( DefaultMirrorSelector.matchesLayout( "default", "default,legacy" ) );
+
+ assertFalse( DefaultMirrorSelector.matchesLayout( "default", "legacy,!default" ) );
+ assertFalse( DefaultMirrorSelector.matchesLayout( "default", "!default,legacy" ) );
+
+ assertFalse( DefaultMirrorSelector.matchesLayout( "default", "*,!default" ) );
+ assertFalse( DefaultMirrorSelector.matchesLayout( "default", "!default,*" ) );
+ }
+
+ public void testMirrorLayoutConsideredForMatching()
+ {
+ ArtifactRepository repo = getRepo( "a" );
+
+ Mirror mirrorA = newMirror( "a", "a", null, "http://a" );
+ Mirror mirrorB = newMirror( "b", "a", "p2", "http://b" );
+
+ Mirror mirrorC = newMirror( "c", "*", null, "http://c" );
+ Mirror mirrorD = newMirror( "d", "*", "p2", "http://d" );
+
+ assertSame( mirrorA, mirrorSelector.getMirror( repo, Arrays.asList( mirrorA ) ) );
+ assertNull( mirrorSelector.getMirror( repo, Arrays.asList( mirrorB ) ) );
+
+ assertSame( mirrorC, mirrorSelector.getMirror( repo, Arrays.asList( mirrorC ) ) );
+ assertNull( mirrorSelector.getMirror( repo, Arrays.asList( mirrorD ) ) );
+ }
+
+ /**
+ * Build an ArtifactRepository object.
+ *
+ * @param id
+ * @param url
+ * @return
+ */
+ private ArtifactRepository getRepo( String id, String url )
+ {
+ return repositorySystem.createArtifactRepository( id, url, new DefaultRepositoryLayout(), null, null );
+ }
+
+ /**
+ * Build an ArtifactRepository object.
+ *
+ * @param id
+ * @return
+ */
+ private ArtifactRepository getRepo( String id )
+ {
+ return getRepo( id, "http://something" );
+ }
+
+ private Mirror newMirror( String id, String mirrorOf, String url )
+ {
+ return newMirror( id, mirrorOf, null, url );
+ }
+
+ private Mirror newMirror( String id, String mirrorOf, String layouts, String url )
+ {
+ Mirror mirror = new Mirror();
+
+ mirror.setId( id );
+ mirror.setMirrorOf( mirrorOf );
+ mirror.setMirrorOfLayouts( layouts );
+ mirror.setUrl( url );
+
+ return mirror;
+ }
+
+}
diff --git a/framework/src/maven/apache-maven-3.3.3/maven-compat/src/test/java/org/apache/maven/repository/legacy/DefaultUpdateCheckManagerTest.java b/framework/src/maven/apache-maven-3.3.3/maven-compat/src/test/java/org/apache/maven/repository/legacy/DefaultUpdateCheckManagerTest.java
new file mode 100644
index 00000000..1c5f34c3
--- /dev/null
+++ b/framework/src/maven/apache-maven-3.3.3/maven-compat/src/test/java/org/apache/maven/repository/legacy/DefaultUpdateCheckManagerTest.java
@@ -0,0 +1,240 @@
+package org.apache.maven.repository.legacy;
+
+/*
+ * 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.factory.ArtifactFactory;
+import org.apache.maven.artifact.repository.ArtifactRepository;
+import org.apache.maven.artifact.repository.metadata.ArtifactRepositoryMetadata;
+import org.apache.maven.artifact.repository.metadata.RepositoryMetadata;
+import org.apache.maven.repository.legacy.DefaultUpdateCheckManager;
+import org.codehaus.plexus.logging.Logger;
+import org.codehaus.plexus.logging.console.ConsoleLogger;
+
+public class DefaultUpdateCheckManagerTest
+ extends AbstractArtifactComponentTestCase
+{
+
+ DefaultUpdateCheckManager updateCheckManager;
+
+ @Override
+ protected String component()
+ {
+ return "updateCheckManager";
+ }
+
+ @Override
+ protected void setUp()
+ throws Exception
+ {
+ super.setUp();
+
+ updateCheckManager = new DefaultUpdateCheckManager( new ConsoleLogger( Logger.LEVEL_DEBUG, "test" ) );
+ }
+
+ public void testArtifact() throws Exception
+ {
+ ArtifactRepository remoteRepository = remoteRepository();
+
+ ArtifactRepository localRepository = localRepository();
+
+ Artifact a = createArtifact( "a", "0.0.1-SNAPSHOT" );
+ File file = new File( localRepository.getBasedir(),
+ localRepository.pathOf( a ) );
+ file.delete();
+ a.setFile( file );
+
+ File touchFile = updateCheckManager.getTouchfile( a );
+ touchFile.delete();
+
+ assertTrue( updateCheckManager.isUpdateRequired( a, remoteRepository ) );
+
+ file.getParentFile().mkdirs();
+ file.createNewFile();
+ updateCheckManager.touch( a, remoteRepository, null );
+
+ assertFalse( updateCheckManager.isUpdateRequired( a, remoteRepository ) );
+
+ assertNull( updateCheckManager.readLastUpdated( touchFile,
+ updateCheckManager.getRepositoryKey( remoteRepository ) ) );
+
+ assertFalse( updateCheckManager.getTouchfile( a ).exists() );
+ }
+
+ public void testMissingArtifact()
+ throws Exception
+ {
+ ArtifactRepository remoteRepository = remoteRepository();
+
+ ArtifactRepository localRepository = localRepository();
+
+ Artifact a = createArtifact( "a", "0.0.1-SNAPSHOT" );
+ File file = new File( localRepository.getBasedir(),
+ localRepository.pathOf( a ) );
+ file.delete();
+ a.setFile( file );
+
+ File touchFile = updateCheckManager.getTouchfile( a );
+ touchFile.delete();
+
+ assertTrue( updateCheckManager.isUpdateRequired( a, remoteRepository ) );
+
+ updateCheckManager.touch( a, remoteRepository, null );
+
+ assertFalse( updateCheckManager.isUpdateRequired( a, remoteRepository ) );
+
+ assertFalse( file.exists() );
+ assertNotNull( updateCheckManager.readLastUpdated( touchFile,
+ updateCheckManager.getRepositoryKey( remoteRepository ) ) );
+ }
+
+ public void testPom() throws Exception
+ {
+ ArtifactRepository remoteRepository = remoteRepository();
+
+ ArtifactRepository localRepository = localRepository();
+
+ Artifact a = createArtifact( "a", "0.0.1", "pom" );
+ File file = new File( localRepository.getBasedir(),
+ localRepository.pathOf( a ) );
+ file.delete();
+ a.setFile( file );
+
+ File touchFile = updateCheckManager.getTouchfile( a );
+ touchFile.delete();
+
+ assertTrue( updateCheckManager.isUpdateRequired( a, remoteRepository ) );
+
+ file.getParentFile().mkdirs();
+ file.createNewFile();
+ updateCheckManager.touch( a, remoteRepository, null );
+
+ assertFalse( updateCheckManager.isUpdateRequired( a, remoteRepository ) );
+
+ assertNull( updateCheckManager.readLastUpdated( touchFile,
+ updateCheckManager.getRepositoryKey( remoteRepository ) ) );
+
+ assertFalse( updateCheckManager.getTouchfile( a ).exists() );
+ }
+
+ public void testMissingPom()
+ throws Exception
+ {
+ ArtifactRepository remoteRepository = remoteRepository();
+
+ ArtifactRepository localRepository = localRepository();
+
+ Artifact a = createArtifact( "a", "0.0.1", "pom" );
+ File file = new File( localRepository.getBasedir(),
+ localRepository.pathOf( a ) );
+ file.delete();
+ a.setFile( file );
+
+ File touchFile = updateCheckManager.getTouchfile( a );
+ touchFile.delete();
+
+ assertTrue( updateCheckManager.isUpdateRequired( a, remoteRepository ) );
+
+ updateCheckManager.touch( a, remoteRepository, null );
+
+ assertFalse( updateCheckManager.isUpdateRequired( a, remoteRepository ) );
+
+ assertFalse( file.exists() );
+ assertNotNull( updateCheckManager.readLastUpdated( touchFile,
+ updateCheckManager.getRepositoryKey( remoteRepository ) ) );
+ }
+
+ public void testMetadata() throws Exception
+ {
+ ArtifactRepository remoteRepository = remoteRepository();
+
+ ArtifactRepository localRepository = localRepository();
+
+ Artifact a = createRemoteArtifact( "a", "0.0.1-SNAPSHOT" );
+ RepositoryMetadata metadata = new ArtifactRepositoryMetadata( a );
+
+ File file = new File( localRepository.getBasedir(),
+ localRepository.pathOfLocalRepositoryMetadata( metadata, localRepository ) );
+ file.delete();
+
+ File touchFile = updateCheckManager.getTouchfile( metadata, file );
+ touchFile.delete();
+
+ assertTrue( updateCheckManager.isUpdateRequired( metadata, remoteRepository, file ) );
+
+ file.getParentFile().mkdirs();
+ file.createNewFile();
+ updateCheckManager.touch( metadata, remoteRepository, file );
+
+ assertFalse( updateCheckManager.isUpdateRequired( metadata, remoteRepository, file ) );
+
+ assertNotNull( updateCheckManager.readLastUpdated( touchFile, updateCheckManager.getMetadataKey( remoteRepository, file ) ) );
+ }
+
+ public void testMissingMetadata() throws Exception
+ {
+ ArtifactRepository remoteRepository = remoteRepository();
+
+ ArtifactRepository localRepository = localRepository();
+
+ Artifact a = createRemoteArtifact( "a", "0.0.1-SNAPSHOT" );
+ RepositoryMetadata metadata = new ArtifactRepositoryMetadata( a );
+
+ File file = new File( localRepository.getBasedir(),
+ localRepository.pathOfLocalRepositoryMetadata( metadata, localRepository ) );
+ file.delete();
+
+ File touchFile = updateCheckManager.getTouchfile( metadata, file );
+ touchFile.delete();
+
+ assertTrue( updateCheckManager.isUpdateRequired( metadata, remoteRepository, file ) );
+
+ updateCheckManager.touch( metadata, remoteRepository, file );
+
+ assertFalse( updateCheckManager.isUpdateRequired( metadata, remoteRepository, file ) );
+
+ assertNotNull( updateCheckManager.readLastUpdated( touchFile, updateCheckManager.getMetadataKey( remoteRepository, file ) ) );
+ }
+
+ public void testArtifactTouchFileName() throws Exception
+ {
+ ArtifactFactory artifactFactory = (ArtifactFactory) lookup( ArtifactFactory.ROLE );
+
+ ArtifactRepository localRepository = localRepository();
+
+ Artifact a = artifactFactory.createArtifactWithClassifier( "groupdId", "a", "0.0.1-SNAPSHOT", "jar", null );
+ File file = new File( localRepository.getBasedir(),
+ localRepository.pathOf( a ) );
+ a.setFile( file );
+
+ assertEquals( "a-0.0.1-SNAPSHOT.jar.lastUpdated", updateCheckManager.getTouchfile( a ).getName() );
+
+ a = artifactFactory.createArtifactWithClassifier( "groupdId", "a", "0.0.1-SNAPSHOT", "jar", "classifier" );
+ file = new File( localRepository.getBasedir(),
+ localRepository.pathOf( a ) );
+ a.setFile( file );
+
+ assertEquals( "a-0.0.1-SNAPSHOT-classifier.jar.lastUpdated", updateCheckManager.getTouchfile( a ).getName() );
+ }
+
+}
diff --git a/framework/src/maven/apache-maven-3.3.3/maven-compat/src/test/java/org/apache/maven/repository/legacy/DefaultWagonManagerTest.java b/framework/src/maven/apache-maven-3.3.3/maven-compat/src/test/java/org/apache/maven/repository/legacy/DefaultWagonManagerTest.java
new file mode 100644
index 00000000..068c0e0a
--- /dev/null
+++ b/framework/src/maven/apache-maven-3.3.3/maven-compat/src/test/java/org/apache/maven/repository/legacy/DefaultWagonManagerTest.java
@@ -0,0 +1,422 @@
+package org.apache.maven.repository.legacy;
+
+/*
+ * 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.List;
+
+import org.apache.maven.artifact.Artifact;
+import org.apache.maven.artifact.DefaultArtifact;
+import org.apache.maven.artifact.factory.ArtifactFactory;
+import org.apache.maven.artifact.metadata.ArtifactMetadata;
+import org.apache.maven.artifact.repository.ArtifactRepository;
+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.artifact.repository.layout.DefaultRepositoryLayout;
+import org.apache.maven.artifact.versioning.VersionRange;
+import org.apache.maven.wagon.ResourceDoesNotExistException;
+import org.apache.maven.wagon.TransferFailedException;
+import org.apache.maven.wagon.UnsupportedProtocolException;
+import org.apache.maven.wagon.Wagon;
+import org.apache.maven.wagon.authorization.AuthorizationException;
+import org.apache.maven.wagon.events.TransferEvent;
+import org.apache.maven.wagon.events.TransferListener;
+import org.apache.maven.wagon.observers.AbstractTransferListener;
+import org.apache.maven.wagon.observers.Debug;
+import org.codehaus.plexus.PlexusTestCase;
+import org.codehaus.plexus.util.FileUtils;
+
+/**
+ * @author <a href="michal.maczka@dimatics.com">Michal Maczka</a>
+ */
+public class DefaultWagonManagerTest
+ extends PlexusTestCase
+{
+ private DefaultWagonManager wagonManager;
+
+ private TransferListener transferListener = new Debug();
+
+ private ArtifactFactory artifactFactory;
+
+ private ArtifactRepositoryFactory artifactRepositoryFactory;
+
+ protected void setUp()
+ throws Exception
+ {
+ super.setUp();
+ wagonManager = (DefaultWagonManager) lookup( WagonManager.class );
+ artifactFactory = lookup( ArtifactFactory.class );
+ artifactRepositoryFactory = lookup( ArtifactRepositoryFactory.class );
+ }
+
+ @Override
+ protected void tearDown()
+ throws Exception
+ {
+ wagonManager = null;
+ artifactFactory = null;
+ super.tearDown();
+ }
+
+ public void testUnnecessaryRepositoryLookup()
+ throws Exception
+ {
+ Artifact artifact = createTestPomArtifact( "target/test-data/get-missing-pom" );
+
+ List<ArtifactRepository> repos = new ArrayList<ArtifactRepository>();
+ repos.add( artifactRepositoryFactory.createArtifactRepository( "repo1", "string://url1",
+ new ArtifactRepositoryLayoutStub(), null, null ) );
+ repos.add( artifactRepositoryFactory.createArtifactRepository( "repo2", "string://url2",
+ new ArtifactRepositoryLayoutStub(), null, null ) );
+
+ StringWagon wagon = (StringWagon) wagonManager.getWagon( "string" );
+ wagon.addExpectedContent( repos.get( 0 ).getLayout().pathOf( artifact ), "expected" );
+ wagon.addExpectedContent( repos.get( 1 ).getLayout().pathOf( artifact ), "expected" );
+
+ class TransferListener
+ extends AbstractTransferListener
+ {
+ public List<TransferEvent> events = new ArrayList<TransferEvent>();
+
+ @Override
+ public void transferInitiated( TransferEvent transferEvent )
+ {
+ events.add( transferEvent );
+ }
+ }
+
+ TransferListener listener = new TransferListener();
+ wagonManager.getArtifact( artifact, repos, listener, false );
+ assertEquals( 1, listener.events.size() );
+ }
+
+ public void testGetMissingJar() throws TransferFailedException, UnsupportedProtocolException, IOException
+ {
+ Artifact artifact = createTestArtifact( "target/test-data/get-missing-jar", "jar" );
+
+ ArtifactRepository repo = createStringRepo();
+
+ try
+ {
+ wagonManager.getArtifact( artifact, repo, null, false );
+
+ fail();
+ }
+ catch ( ResourceDoesNotExistException e )
+ {
+ assertTrue( true );
+ }
+
+ assertFalse( artifact.getFile().exists() );
+ }
+
+ public void testGetMissingJarForced() throws TransferFailedException, UnsupportedProtocolException, IOException
+ {
+ Artifact artifact = createTestArtifact( "target/test-data/get-missing-jar", "jar" );
+
+ ArtifactRepository repo = createStringRepo();
+
+ try
+ {
+ wagonManager.getArtifact( artifact, repo, null, false );
+
+ fail();
+ }
+ catch ( ResourceDoesNotExistException e )
+ {
+ assertTrue( true );
+ }
+
+ assertFalse( artifact.getFile().exists() );
+ }
+
+ public void testGetRemoteJar()
+ throws TransferFailedException, ResourceDoesNotExistException, UnsupportedProtocolException, IOException,
+ AuthorizationException
+ {
+ Artifact artifact = createTestArtifact( "target/test-data/get-remote-jar", "jar" );
+
+ ArtifactRepository repo = createStringRepo();
+
+ StringWagon wagon = (StringWagon) wagonManager.getWagon( "string" );
+ wagon.addExpectedContent( repo.getLayout().pathOf( artifact ), "expected" );
+
+ wagonManager.getArtifact( artifact, repo, null, false );
+
+ assertTrue( artifact.getFile().exists() );
+ assertEquals( "expected", FileUtils.fileRead( artifact.getFile(), "UTF-8" ) );
+ }
+
+ private Artifact createTestPomArtifact( String directory )
+ throws IOException
+ {
+ File testData = getTestFile( directory );
+ FileUtils.deleteDirectory( testData );
+ testData.mkdirs();
+
+ Artifact artifact = artifactFactory.createProjectArtifact( "test", "test", "1.0" );
+ artifact.setFile( new File( testData, "test-1.0.pom" ) );
+ assertFalse( artifact.getFile().exists() );
+ return artifact;
+ }
+
+ private Artifact createTestArtifact( String directory, String type )
+ throws IOException
+ {
+ return createTestArtifact( directory, "1.0", type );
+ }
+
+ private Artifact createTestArtifact( String directory, String version, String type )
+ throws IOException
+ {
+ File testData = getTestFile( directory );
+ FileUtils.deleteDirectory( testData );
+ testData.mkdirs();
+
+ Artifact artifact = artifactFactory.createBuildArtifact( "test", "test", version, type );
+ artifact.setFile( new File( testData, "test-" + version + "." + artifact.getArtifactHandler().getExtension() ) );
+ assertFalse( artifact.getFile().exists() );
+ return artifact;
+ }
+
+ private ArtifactRepository createStringRepo()
+ {
+ return artifactRepositoryFactory.createArtifactRepository( "id", "string://url", new ArtifactRepositoryLayoutStub(), null, null );
+ }
+
+ /**
+ * Build an ArtifactRepository object.
+ *
+ * @param id
+ * @param url
+ * @return
+ */
+ private ArtifactRepository getRepo( String id, String url )
+ {
+ return artifactRepositoryFactory.createArtifactRepository( id, url, new DefaultRepositoryLayout(), null, null );
+ }
+
+ /**
+ * Build an ArtifactRepository object.
+ *
+ * @param id
+ * @return
+ */
+ private ArtifactRepository getRepo( String id )
+ {
+ return getRepo( id, "http://something" );
+ }
+
+ public void testDefaultWagonManager()
+ throws Exception
+ {
+ assertWagon( "a" );
+
+ assertWagon( "b" );
+
+ assertWagon( "c" );
+
+ assertWagon( "string" );
+
+ try
+ {
+ assertWagon( "d" );
+
+ fail( "Expected :" + UnsupportedProtocolException.class.getName() );
+ }
+ catch ( UnsupportedProtocolException e )
+ {
+ // ok
+ assertTrue( true );
+ }
+ }
+
+ /**
+ * Check that transfer listeners are properly removed after getArtifact and putArtifact
+ */
+ public void testWagonTransferListenerRemovedAfterGetArtifactAndPutArtifact()
+ throws Exception
+ {
+ Artifact artifact = createTestArtifact( "target/test-data/transfer-listener", "jar" );
+ ArtifactRepository repo = createStringRepo();
+ StringWagon wagon = (StringWagon) wagonManager.getWagon( "string" );
+ wagon.addExpectedContent( repo.getLayout().pathOf( artifact ), "expected" );
+
+ /* getArtifact */
+ assertFalse( "Transfer listener is registered before test",
+ wagon.getTransferEventSupport().hasTransferListener( transferListener ) );
+ wagonManager.getArtifact( artifact, repo, transferListener, false );
+ assertFalse( "Transfer listener still registered after getArtifact",
+ wagon.getTransferEventSupport().hasTransferListener( transferListener ) );
+
+ /* putArtifact */
+ File sampleFile = getTestFile( "target/test-file" );
+ FileUtils.fileWrite( sampleFile.getAbsolutePath(), "sample file" );
+
+ assertFalse( "Transfer listener is registered before test", wagon.getTransferEventSupport().hasTransferListener( transferListener ) );
+ wagonManager.putArtifact( sampleFile, artifact, repo, transferListener );
+ assertFalse( "Transfer listener still registered after putArtifact", wagon.getTransferEventSupport().hasTransferListener( transferListener ) );
+ }
+
+ /**
+ * Checks the verification of checksums.
+ */
+ public void xtestChecksumVerification()
+ throws Exception
+ {
+ ArtifactRepositoryPolicy policy = new ArtifactRepositoryPolicy( true, ArtifactRepositoryPolicy.UPDATE_POLICY_ALWAYS, ArtifactRepositoryPolicy.CHECKSUM_POLICY_FAIL );
+
+ ArtifactRepository repo = artifactRepositoryFactory.createArtifactRepository( "id", "string://url", new ArtifactRepositoryLayoutStub(), policy, policy );
+
+ Artifact artifact =
+ new DefaultArtifact( "sample.group", "sample-art", VersionRange.createFromVersion( "1.0" ), "scope",
+ "jar", "classifier", null );
+ artifact.setFile( getTestFile( "target/sample-art" ) );
+
+ StringWagon wagon = (StringWagon) wagonManager.getWagon( "string" );
+
+ wagon.clearExpectedContent();
+ wagon.addExpectedContent( "path", "lower-case-checksum" );
+ wagon.addExpectedContent( "path.sha1", "2a25dc564a3b34f68237fc849066cbc7bb7a36a1" );
+
+ try
+ {
+ wagonManager.getArtifact( artifact, repo, null, false );
+ }
+ catch ( ChecksumFailedException e )
+ {
+ fail( "Checksum verification did not pass: " + e.getMessage() );
+ }
+
+ wagon.clearExpectedContent();
+ wagon.addExpectedContent( "path", "upper-case-checksum" );
+ wagon.addExpectedContent( "path.sha1", "B7BB97D7D0B9244398D9B47296907F73313663E6" );
+
+ try
+ {
+ wagonManager.getArtifact( artifact, repo, null, false );
+ }
+ catch ( ChecksumFailedException e )
+ {
+ fail( "Checksum verification did not pass: " + e.getMessage() );
+ }
+
+ wagon.clearExpectedContent();
+ wagon.addExpectedContent( "path", "expected-failure" );
+ wagon.addExpectedContent( "path.sha1", "b7bb97d7d0b9244398d9b47296907f73313663e6" );
+
+ try
+ {
+ wagonManager.getArtifact( artifact, repo, null, false );
+ fail( "Checksum verification did not fail" );
+ }
+ catch ( ChecksumFailedException e )
+ {
+ // expected
+ }
+
+ wagon.clearExpectedContent();
+ wagon.addExpectedContent( "path", "lower-case-checksum" );
+ wagon.addExpectedContent( "path.md5", "50b2cf50a103a965efac62b983035cac" );
+
+ try
+ {
+ wagonManager.getArtifact( artifact, repo, null, false );
+ }
+ catch ( ChecksumFailedException e )
+ {
+ fail( "Checksum verification did not pass: " + e.getMessage() );
+ }
+
+ wagon.clearExpectedContent();
+ wagon.addExpectedContent( "path", "upper-case-checksum" );
+ wagon.addExpectedContent( "path.md5", "842F568FCCFEB7E534DC72133D42FFDC" );
+
+ try
+ {
+ wagonManager.getArtifact( artifact, repo, null, false );
+ }
+ catch ( ChecksumFailedException e )
+ {
+ fail( "Checksum verification did not pass: " + e.getMessage() );
+ }
+
+ wagon.clearExpectedContent();
+ wagon.addExpectedContent( "path", "expected-failure" );
+ wagon.addExpectedContent( "path.md5", "b7bb97d7d0b9244398d9b47296907f73313663e6" );
+
+ try
+ {
+ wagonManager.getArtifact( artifact, repo, null, false );
+ fail( "Checksum verification did not fail" );
+ }
+ catch ( ChecksumFailedException e )
+ {
+ // expected
+ }
+ }
+
+ public void testPerLookupInstantiation()
+ throws Exception
+ {
+ String protocol = "perlookup";
+
+ Wagon one = wagonManager.getWagon( protocol );
+ Wagon two = wagonManager.getWagon( protocol );
+
+ assertNotSame( one, two );
+ }
+
+ private void assertWagon( String protocol )
+ throws Exception
+ {
+ Wagon wagon = wagonManager.getWagon( protocol );
+
+ assertNotNull( "Check wagon, protocol=" + protocol, wagon );
+ }
+
+ private final class ArtifactRepositoryLayoutStub
+ implements ArtifactRepositoryLayout
+ {
+ public String getId()
+ {
+ return "test";
+ }
+
+ public String pathOfRemoteRepositoryMetadata( ArtifactMetadata metadata )
+ {
+ return "path";
+ }
+
+ public String pathOfLocalRepositoryMetadata( ArtifactMetadata metadata, ArtifactRepository repository )
+ {
+ return "path";
+ }
+
+ public String pathOf( Artifact artifact )
+ {
+ return "path";
+ }
+ }
+
+}
diff --git a/framework/src/maven/apache-maven-3.3.3/maven-compat/src/test/java/org/apache/maven/repository/legacy/LegacyRepositorySystemTest.java b/framework/src/maven/apache-maven-3.3.3/maven-compat/src/test/java/org/apache/maven/repository/legacy/LegacyRepositorySystemTest.java
new file mode 100644
index 00000000..f34c05fb
--- /dev/null
+++ b/framework/src/maven/apache-maven-3.3.3/maven-compat/src/test/java/org/apache/maven/repository/legacy/LegacyRepositorySystemTest.java
@@ -0,0 +1,88 @@
+package org.apache.maven.repository.legacy;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more contributor license
+ * agreements. See the NOTICE file distributed with this work for additional information regarding
+ * copyright ownership. The ASF licenses this file to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance with the License. You may obtain a
+ * copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software distributed under the License
+ * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
+ * or implied. See the License for the specific language governing permissions and limitations under
+ * the License.
+ */
+
+import java.io.File;
+import java.util.Arrays;
+
+import org.apache.maven.artifact.repository.ArtifactRepository;
+import org.apache.maven.artifact.repository.Authentication;
+import org.apache.maven.repository.RepositorySystem;
+import org.apache.maven.settings.Server;
+import org.codehaus.plexus.ContainerConfiguration;
+import org.codehaus.plexus.PlexusConstants;
+import org.codehaus.plexus.PlexusTestCase;
+
+/**
+ * Tests {@link LegacyRepositorySystem}.
+ *
+ * @author Benjamin Bentmann
+ */
+public class LegacyRepositorySystemTest
+ extends PlexusTestCase
+{
+ private RepositorySystem repositorySystem;
+
+ @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();
+ repositorySystem = lookup( RepositorySystem.class, "default" );
+ }
+
+ @Override
+ protected void tearDown()
+ throws Exception
+ {
+ repositorySystem = null;
+ super.tearDown();
+ }
+
+ public void testThatLocalRepositoryWithSpacesIsProperlyHandled()
+ throws Exception
+ {
+ File basedir = new File( "target/spacy path" ).getAbsoluteFile();
+ ArtifactRepository repo = repositorySystem.createLocalRepository( basedir );
+ assertEquals( basedir, new File( repo.getBasedir() ) );
+ }
+
+ public void testAuthenticationHandling()
+ throws Exception
+ {
+ Server server = new Server();
+ server.setId( "repository" );
+ server.setUsername( "jason" );
+ server.setPassword( "abc123" );
+
+ ArtifactRepository repository =
+ repositorySystem.createArtifactRepository( "repository", "http://foo", null, null, null );
+ repositorySystem.injectAuthentication( Arrays.asList( repository ), Arrays.asList( server ) );
+ Authentication authentication = repository.getAuthentication();
+ assertNotNull( authentication );
+ assertEquals( "jason", authentication.getUsername() );
+ assertEquals( "abc123", authentication.getPassword() );
+ }
+
+}
diff --git a/framework/src/maven/apache-maven-3.3.3/maven-compat/src/test/java/org/apache/maven/repository/legacy/PerLookupWagon.java b/framework/src/maven/apache-maven-3.3.3/maven-compat/src/test/java/org/apache/maven/repository/legacy/PerLookupWagon.java
new file mode 100644
index 00000000..051f3e46
--- /dev/null
+++ b/framework/src/maven/apache-maven-3.3.3/maven-compat/src/test/java/org/apache/maven/repository/legacy/PerLookupWagon.java
@@ -0,0 +1,38 @@
+package org.apache.maven.repository.legacy;
+
+/*
+ * 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.wagon.Wagon;
+import org.codehaus.plexus.component.annotations.Component;
+
+/**
+ * Wagon with per-lookup instantiation strategy.
+ */
+@Component( role = Wagon.class, hint = "perlookup", instantiationStrategy = "per-lookup" )
+public class PerLookupWagon
+ extends WagonMock
+{
+
+ public String[] getSupportedProtocols()
+ {
+ return new String[] { "perlookup" };
+ }
+
+}
diff --git a/framework/src/maven/apache-maven-3.3.3/maven-compat/src/test/java/org/apache/maven/repository/legacy/StringWagon.java b/framework/src/maven/apache-maven-3.3.3/maven-compat/src/test/java/org/apache/maven/repository/legacy/StringWagon.java
new file mode 100644
index 00000000..d0325db4
--- /dev/null
+++ b/framework/src/maven/apache-maven-3.3.3/maven-compat/src/test/java/org/apache/maven/repository/legacy/StringWagon.java
@@ -0,0 +1,107 @@
+package org.apache.maven.repository.legacy;
+
+/*
+ * 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.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
+import java.io.UnsupportedEncodingException;
+import java.util.HashMap;
+import java.util.Map;
+
+import org.apache.maven.wagon.ConnectionException;
+import org.apache.maven.wagon.InputData;
+import org.apache.maven.wagon.OutputData;
+import org.apache.maven.wagon.ResourceDoesNotExistException;
+import org.apache.maven.wagon.StreamWagon;
+import org.apache.maven.wagon.TransferFailedException;
+import org.apache.maven.wagon.Wagon;
+import org.apache.maven.wagon.authentication.AuthenticationException;
+import org.apache.maven.wagon.authorization.AuthorizationException;
+import org.apache.maven.wagon.resource.Resource;
+import org.codehaus.plexus.component.annotations.Component;
+
+@Component(role=Wagon.class,hint="string")
+public class StringWagon
+ extends StreamWagon
+{
+ private Map<String, String> expectedContent = new HashMap<String, String>();
+
+ public void addExpectedContent( String resourceName, String expectedContent )
+ {
+ this.expectedContent.put( resourceName, expectedContent );
+ }
+
+ public String[] getSupportedProtocols()
+ {
+ return new String[] { "string" };
+ }
+
+ @Override
+ public void closeConnection()
+ throws ConnectionException
+ {
+ }
+
+ @Override
+ public void fillInputData( InputData inputData )
+ throws TransferFailedException, ResourceDoesNotExistException, AuthorizationException
+ {
+ Resource resource = inputData.getResource();
+
+ String content = expectedContent.get( resource.getName() );
+
+ if ( content != null )
+ {
+ resource.setContentLength( content.length() );
+ resource.setLastModified( System.currentTimeMillis() );
+
+ try
+ {
+ inputData.setInputStream( new ByteArrayInputStream( content.getBytes( "UTF-8" ) ) );
+ }
+ catch ( UnsupportedEncodingException e )
+ {
+ throw new Error( "broken JVM", e );
+ }
+ }
+ else
+ {
+ throw new ResourceDoesNotExistException( "No content provided for " + resource.getName() );
+ }
+ }
+
+ @Override
+ public void fillOutputData( OutputData outputData )
+ throws TransferFailedException
+ {
+ outputData.setOutputStream( new ByteArrayOutputStream() );
+ }
+
+ @Override
+ protected void openConnectionInternal()
+ throws ConnectionException, AuthenticationException
+ {
+ }
+
+ public void clearExpectedContent()
+ {
+ expectedContent.clear();
+ }
+}
diff --git a/framework/src/maven/apache-maven-3.3.3/maven-compat/src/test/java/org/apache/maven/repository/legacy/WagonA.java b/framework/src/maven/apache-maven-3.3.3/maven-compat/src/test/java/org/apache/maven/repository/legacy/WagonA.java
new file mode 100644
index 00000000..601eefac
--- /dev/null
+++ b/framework/src/maven/apache-maven-3.3.3/maven-compat/src/test/java/org/apache/maven/repository/legacy/WagonA.java
@@ -0,0 +1,39 @@
+package org.apache.maven.repository.legacy;
+
+import org.apache.maven.wagon.Wagon;
+import org.codehaus.plexus.component.annotations.Component;
+
+/*
+ * 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.
+ */
+
+/**
+ * Wagon for testing, for protocol <code>a</code>
+ *
+ * @author <a href="mailto:carlos@apache.org">Carlos Sanchez</a>
+ * @author <a href="mailto:jason@maven.org">Jason van Zyl</a>
+ */
+@Component(role=Wagon.class,hint="a")
+public class WagonA
+ extends WagonMock
+{
+ public String[] getSupportedProtocols()
+ {
+ return new String[]{ "a" };
+ }
+}
diff --git a/framework/src/maven/apache-maven-3.3.3/maven-compat/src/test/java/org/apache/maven/repository/legacy/WagonB.java b/framework/src/maven/apache-maven-3.3.3/maven-compat/src/test/java/org/apache/maven/repository/legacy/WagonB.java
new file mode 100644
index 00000000..ecaef642
--- /dev/null
+++ b/framework/src/maven/apache-maven-3.3.3/maven-compat/src/test/java/org/apache/maven/repository/legacy/WagonB.java
@@ -0,0 +1,39 @@
+package org.apache.maven.repository.legacy;
+
+import org.apache.maven.wagon.Wagon;
+import org.codehaus.plexus.component.annotations.Component;
+
+/*
+ * 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.
+ */
+
+/**
+ * Wagon for testing, for protocols <code>b1</code> and <code>b2</code>
+ *
+ * @author <a href="mailto:carlos@apache.org">Carlos Sanchez</a>
+ * @author <a href="mailto:jason@maven.org">Jason van Zyl</a>
+ */
+@Component(role=Wagon.class,hint="b")
+public class WagonB
+ extends WagonMock
+{
+ public String[] getSupportedProtocols()
+ {
+ return new String[]{ "b1", "b2" };
+ }
+}
diff --git a/framework/src/maven/apache-maven-3.3.3/maven-compat/src/test/java/org/apache/maven/repository/legacy/WagonC.java b/framework/src/maven/apache-maven-3.3.3/maven-compat/src/test/java/org/apache/maven/repository/legacy/WagonC.java
new file mode 100644
index 00000000..29316ed5
--- /dev/null
+++ b/framework/src/maven/apache-maven-3.3.3/maven-compat/src/test/java/org/apache/maven/repository/legacy/WagonC.java
@@ -0,0 +1,39 @@
+package org.apache.maven.repository.legacy;
+
+import org.apache.maven.wagon.Wagon;
+import org.codehaus.plexus.component.annotations.Component;
+
+/*
+ * 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.
+ */
+
+/**
+ * Wagon for testing, for protocol <code>c</code>
+ *
+ * @author <a href="mailto:carlos@apache.org">Carlos Sanchez</a>
+ * @author <a href="mailto:jason@maven.org">Jason van Zyl</a>
+ */
+@Component(role=Wagon.class,hint="c")
+public class WagonC
+ extends WagonMock
+{
+ public String[] getSupportedProtocols()
+ {
+ return new String[]{ "c" };
+ }
+}
diff --git a/framework/src/maven/apache-maven-3.3.3/maven-compat/src/test/java/org/apache/maven/repository/legacy/WagonMock.java b/framework/src/maven/apache-maven-3.3.3/maven-compat/src/test/java/org/apache/maven/repository/legacy/WagonMock.java
new file mode 100644
index 00000000..c5163609
--- /dev/null
+++ b/framework/src/maven/apache-maven-3.3.3/maven-compat/src/test/java/org/apache/maven/repository/legacy/WagonMock.java
@@ -0,0 +1,50 @@
+package org.apache.maven.repository.legacy;
+
+/*
+ * 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.wagon.providers.file.FileWagon;
+
+/**
+ * Mock of a Wagon for testing
+ *
+ * @author <a href="mailto:carlos@apache.org">Carlos Sanchez</a>
+ */
+public class WagonMock
+ extends FileWagon
+{
+
+ /**
+ * A field that can be configured in the Wagon
+ *
+ * @component.configuration default="configurableField"
+ */
+ private String configurableField = null;
+
+ public void setConfigurableField( String configurableField )
+ {
+ this.configurableField = configurableField;
+ }
+
+ public String getConfigurableField()
+ {
+ return configurableField;
+ }
+
+}
diff --git a/framework/src/maven/apache-maven-3.3.3/maven-compat/src/test/java/org/apache/maven/repository/legacy/resolver/DefaultArtifactCollectorTest.java b/framework/src/maven/apache-maven-3.3.3/maven-compat/src/test/java/org/apache/maven/repository/legacy/resolver/DefaultArtifactCollectorTest.java
new file mode 100644
index 00000000..58dd3fa2
--- /dev/null
+++ b/framework/src/maven/apache-maven-3.3.3/maven-compat/src/test/java/org/apache/maven/repository/legacy/resolver/DefaultArtifactCollectorTest.java
@@ -0,0 +1,984 @@
+package org.apache.maven.repository.legacy.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.Arrays;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.Iterator;
+import java.util.LinkedHashSet;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+
+import org.apache.maven.artifact.Artifact;
+import org.apache.maven.artifact.factory.ArtifactFactory;
+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.resolver.ArtifactResolutionException;
+import org.apache.maven.artifact.resolver.ArtifactResolutionResult;
+import org.apache.maven.artifact.resolver.CyclicDependencyException;
+import org.apache.maven.artifact.resolver.filter.ArtifactFilter;
+import org.apache.maven.artifact.resolver.filter.ExclusionSetFilter;
+import org.apache.maven.artifact.resolver.filter.ScopeArtifactFilter;
+import org.apache.maven.artifact.versioning.ArtifactVersion;
+import org.apache.maven.artifact.versioning.DefaultArtifactVersion;
+import org.apache.maven.artifact.versioning.InvalidVersionSpecificationException;
+import org.apache.maven.artifact.versioning.OverConstrainedVersionException;
+import org.apache.maven.artifact.versioning.VersionRange;
+import org.apache.maven.repository.legacy.metadata.MetadataResolutionRequest;
+import org.codehaus.plexus.PlexusTestCase;
+
+/**
+ * Test the default artifact collector.
+ *
+ * @author <a href="mailto:brett@apache.org">Brett Porter</a>
+ */
+public class DefaultArtifactCollectorTest
+ extends PlexusTestCase
+{
+ private LegacyArtifactCollector artifactCollector;
+
+ private ArtifactFactory artifactFactory;
+
+ private ArtifactSpec projectArtifact;
+
+ private Source source;
+
+ private static final String GROUP_ID = "test";
+
+ @Override
+ protected void setUp()
+ throws Exception
+ {
+ super.setUp();
+
+ source = new Source();
+ artifactFactory = (ArtifactFactory) lookup( ArtifactFactory.ROLE );
+ artifactCollector = lookup( LegacyArtifactCollector.class );
+
+ projectArtifact = createArtifactSpec( "project", "1.0", null );
+ }
+
+ @Override
+ protected void tearDown()
+ throws Exception
+ {
+ artifactCollector = null;
+ artifactFactory = null;
+ super.tearDown();
+ }
+
+ // works, but we don't fail on cycles presently
+ public void disabledtestCircularDependencyNotIncludingCurrentProject()
+ throws ArtifactResolutionException, InvalidVersionSpecificationException
+ {
+ ArtifactSpec a = createArtifactSpec( "a", "1.0" );
+ ArtifactSpec b = a.addDependency( "b", "1.0" );
+ b.addDependency( "a", "1.0" );
+ try
+ {
+ collect( a );
+ fail( "Should have failed on cyclic dependency not involving project" );
+ }
+ catch ( CyclicDependencyException expected )
+ {
+ assertTrue( true );
+ }
+ }
+
+ // works, but we don't fail on cycles presently
+ public void disabledtestCircularDependencyIncludingCurrentProject()
+ throws ArtifactResolutionException, InvalidVersionSpecificationException
+ {
+ ArtifactSpec a = createArtifactSpec( "a", "1.0" );
+ ArtifactSpec b = a.addDependency( "b", "1.0" );
+ b.addDependency( "project", "1.0" );
+ try
+ {
+ collect( a );
+ fail( "Should have failed on cyclic dependency involving project" );
+ }
+ catch ( CyclicDependencyException expected )
+ {
+ assertTrue( true );
+ }
+ }
+
+ public void testResolveWithFilter()
+ throws ArtifactResolutionException, InvalidVersionSpecificationException
+ {
+ ArtifactSpec a = createArtifactSpec( "a", "1.0" );
+ ArtifactSpec b = a.addDependency( "b", "1.0" );
+ ArtifactSpec c = a.addDependency( "c", "3.0" );
+
+ b.addDependency( "c", "2.0" );
+ ArtifactSpec d = b.addDependency( "d", "4.0" );
+
+ ArtifactResolutionResult res = collect( a );
+ assertEquals( "Check artifact list",
+ createSet( new Object[] { a.artifact, b.artifact, c.artifact, d.artifact } ), res.getArtifacts() );
+
+ ArtifactFilter filter = new ExclusionSetFilter( new String[] { "b" } );
+ res = collect( a, filter );
+ assertEquals( "Check artifact list", createSet( new Object[] { a.artifact, c.artifact } ), res.getArtifacts() );
+ }
+
+ public void testResolveCorrectDependenciesWhenDifferentDependenciesOnNearest()
+ throws ArtifactResolutionException, InvalidVersionSpecificationException
+ {
+ ArtifactSpec a = createArtifactSpec( "a", "1.0" );
+ ArtifactSpec b = a.addDependency( "b", "1.0" );
+ ArtifactSpec c2 = b.addDependency( "c", "2.0" );
+ c2.addDependency( "d", "1.0" );
+
+ ArtifactSpec e = createArtifactSpec( "e", "1.0" );
+ ArtifactSpec c1 = e.addDependency( "c", "1.0" );
+ ArtifactSpec f = c1.addDependency( "f", "1.0" );
+
+ ArtifactResolutionResult res = collect( createSet( new Object[] { a.artifact, e.artifact } ) );
+ assertEquals( "Check artifact list", createSet( new Object[] { a.artifact, b.artifact, e.artifact, c1.artifact,
+ f.artifact } ), res.getArtifacts() );
+ assertEquals( "Check version", "1.0", getArtifact( "c", res.getArtifacts() ).getVersion() );
+ }
+
+ public void disabledtestResolveCorrectDependenciesWhenDifferentDependenciesOnNewest()
+ throws ArtifactResolutionException, InvalidVersionSpecificationException
+ {
+ // TODO: use newest conflict resolver
+ ArtifactSpec a = createArtifactSpec( "a", "1.0" );
+ ArtifactSpec b = a.addDependency( "b", "1.0" );
+ ArtifactSpec c2 = b.addDependency( "c", "2.0" );
+ ArtifactSpec d = c2.addDependency( "d", "1.0" );
+
+ ArtifactSpec e = createArtifactSpec( "e", "1.0" );
+ ArtifactSpec c1 = e.addDependency( "c", "1.0" );
+ c1.addDependency( "f", "1.0" );
+
+ ArtifactResolutionResult res = collect( createSet( new Object[] { a.artifact, e.artifact } ) );
+ assertEquals( "Check artifact list", createSet( new Object[] { a.artifact, b.artifact, e.artifact, c2.artifact,
+ d.artifact } ), res.getArtifacts() );
+ assertEquals( "Check version", "2.0", getArtifact( "c", res.getArtifacts() ).getVersion() );
+ }
+
+ public void disabledtestResolveCorrectDependenciesWhenDifferentDependenciesOnNewestVersionReplaced()
+ throws ArtifactResolutionException, InvalidVersionSpecificationException
+ {
+ // TODO: use newest conflict resolver
+ ArtifactSpec a = createArtifactSpec( "a", "1.0" );
+ ArtifactSpec b1 = a.addDependency( "b", "1.0" );
+ ArtifactSpec c = a.addDependency( "c", "1.0" );
+ ArtifactSpec d2 = b1.addDependency( "d", "2.0" );
+ d2.addDependency( "h", "1.0" );
+ ArtifactSpec d1 = c.addDependency( "d", "1.0" );
+ ArtifactSpec b2 = c.addDependency( "b", "2.0" );
+ ArtifactSpec e = b2.addDependency( "e", "1.0" );
+ ArtifactSpec g = d1.addDependency( "g", "1.0" );
+
+ ArtifactResolutionResult res = collect( createSet( new Object[] { a.artifact } ) );
+ Object[] artifacts = new Object[] { a.artifact, c.artifact, d1.artifact, b2.artifact, e.artifact, g.artifact };
+ assertEquals( "Check artifact list", createSet( artifacts ), res.getArtifacts() );
+ assertEquals( "Check version", "1.0", getArtifact( "d", res.getArtifacts() ).getVersion() );
+ assertEquals( "Check version", "2.0", getArtifact( "b", res.getArtifacts() ).getVersion() );
+ }
+
+ public void testResolveNearestNewestIsNearest()
+ throws ArtifactResolutionException, InvalidVersionSpecificationException
+ {
+ ArtifactSpec a = createArtifactSpec( "a", "1.0" );
+ ArtifactSpec b = a.addDependency( "b", "1.0" );
+ ArtifactSpec c = a.addDependency( "c", "3.0" );
+
+ b.addDependency( "c", "2.0" );
+
+ ArtifactResolutionResult res = collect( a );
+ assertEquals( "Check artifact list", createSet( new Object[] { a.artifact, b.artifact, c.artifact } ),
+ res.getArtifacts() );
+ assertEquals( "Check version", "3.0", getArtifact( "c", res.getArtifacts() ).getVersion() );
+ }
+
+ public void testResolveNearestOldestIsNearest()
+ throws ArtifactResolutionException, InvalidVersionSpecificationException
+ {
+ ArtifactSpec a = createArtifactSpec( "a", "1.0" );
+ ArtifactSpec b = a.addDependency( "b", "1.0" );
+ ArtifactSpec c = a.addDependency( "c", "2.0" );
+
+ b.addDependency( "c", "3.0" );
+
+ ArtifactResolutionResult res = collect( a );
+ assertEquals( "Check artifact list", createSet( new Object[] { a.artifact, b.artifact, c.artifact } ),
+ res.getArtifacts() );
+ assertEquals( "Check version", "2.0", getArtifact( "c", res.getArtifacts() ).getVersion() );
+ }
+
+ public void testResolveLocalNewestIsLocal()
+ throws ArtifactResolutionException, InvalidVersionSpecificationException
+ {
+ ArtifactSpec a = createArtifactSpec( "a", "1.0" );
+ a.addDependency( "b", "2.0" );
+ ArtifactSpec b = createArtifactSpec( "b", "3.0" );
+
+ ArtifactResolutionResult res = collect( createSet( new Object[] { a.artifact, b.artifact } ) );
+ assertEquals( "Check artifact list", createSet( new Object[] { a.artifact, b.artifact } ), res.getArtifacts() );
+ assertEquals( "Check version", "3.0", getArtifact( "b", res.getArtifacts() ).getVersion() );
+ }
+
+ public void testResolveLocalOldestIsLocal()
+ throws ArtifactResolutionException, InvalidVersionSpecificationException
+ {
+ ArtifactSpec a = createArtifactSpec( "a", "1.0" );
+ a.addDependency( "b", "3.0" );
+ ArtifactSpec b = createArtifactSpec( "b", "2.0" );
+
+ ArtifactResolutionResult res = collect( createSet( new Object[] { a.artifact, b.artifact } ) );
+ assertEquals( "Check artifact list", createSet( new Object[] { a.artifact, b.artifact } ), res.getArtifacts() );
+ assertEquals( "Check version", "2.0", getArtifact( "b", res.getArtifacts() ).getVersion() );
+ }
+
+ public void testResolveLocalWithNewerVersionButLesserScope()
+ throws ArtifactResolutionException, InvalidVersionSpecificationException
+ {
+ ArtifactSpec a = createArtifactSpec( "commons-logging", "1.0" );
+ a.addDependency( "junit", "3.7" );
+ ArtifactSpec b = createArtifactSpec( "junit", "3.8.1", Artifact.SCOPE_TEST );
+
+ ArtifactResolutionResult res = collect( createSet( new Object[] { a.artifact, b.artifact } ) );
+ assertEquals( "Check artifact list", createSet( new Object[] { a.artifact, b.artifact } ), res.getArtifacts() );
+ assertEquals( "Check version", "3.8.1", getArtifact( "junit", res.getArtifacts() ).getVersion() );
+ assertEquals( "Check artifactScope", Artifact.SCOPE_TEST, getArtifact( "junit", res.getArtifacts() ).getScope() );
+ }
+
+ public void testResolveLocalWithNewerVersionButLesserScopeResolvedFirst()
+ throws ArtifactResolutionException, InvalidVersionSpecificationException
+ {
+ ArtifactSpec b = createArtifactSpec( "junit", "3.8.1", Artifact.SCOPE_TEST );
+ ArtifactSpec a = createArtifactSpec( "commons-logging", "1.0" );
+ a.addDependency( "junit", "3.7" );
+
+ ArtifactResolutionResult res = collect( createSet( new Object[] { a.artifact, b.artifact } ) );
+ assertEquals( "Check artifact list", createSet( new Object[] { a.artifact, b.artifact } ), res.getArtifacts() );
+ assertEquals( "Check version", "3.8.1", getArtifact( "junit", res.getArtifacts() ).getVersion() );
+ assertEquals( "Check artifactScope", Artifact.SCOPE_TEST, getArtifact( "junit", res.getArtifacts() ).getScope() );
+ }
+
+ public void testResolveNearestWithRanges()
+ throws ArtifactResolutionException, InvalidVersionSpecificationException
+ {
+ ArtifactSpec a = createArtifactSpec( "a", "1.0" );
+ ArtifactSpec b = a.addDependency( "b", "1.0" );
+ ArtifactSpec c = a.addDependency( "c", "2.0" );
+
+ b.addDependency( "c", "[1.0,3.0]" );
+
+ ArtifactResolutionResult res = collect( a );
+ assertEquals( "Check artifact list", createSet( new Object[] { a.artifact, b.artifact, c.artifact } ),
+ res.getArtifacts() );
+ assertEquals( "Check version", "2.0", getArtifact( "c", res.getArtifacts() ).getVersion() );
+ }
+
+ public void testResolveRangeWithManagedVersion()
+ throws ArtifactResolutionException, InvalidVersionSpecificationException
+ {
+ ArtifactSpec a = createArtifactSpec( "a", "1.0" );
+ ArtifactSpec b = a.addDependency( "b", "[1.0,3.0]" );
+
+ ArtifactSpec managedB = createArtifactSpec( "b", "5.0" );
+
+ ArtifactResolutionResult res = collect( a, managedB.artifact );
+ assertEquals( "Check artifact list", createSet( new Object[] { a.artifact, managedB.artifact } ),
+ res.getArtifacts() );
+ assertEquals( "Check version", "5.0", getArtifact( "b", res.getArtifacts() ).getVersion() );
+ }
+
+ public void testCompatibleRanges()
+ throws ArtifactResolutionException, InvalidVersionSpecificationException
+ {
+ ArtifactSpec a = createArtifactSpec( "a", "1.0" );
+ ArtifactSpec b = a.addDependency( "b", "1.0" );
+ a.addDependency( "c", "[2.0,2.5]" );
+ b.addDependency( "c", "[1.0,3.0]" );
+ ArtifactSpec c = createArtifactSpec( "c", "2.5" );
+
+ ArtifactResolutionResult res = collect( a );
+
+ assertEquals( "Check artifact list", createSet( new Object[] { a.artifact, b.artifact, c.artifact } ),
+ res.getArtifacts() );
+ assertEquals( "Check version", "2.5", getArtifact( "c", res.getArtifacts() ).getVersion() );
+ }
+
+ public void testIncompatibleRanges()
+ throws ArtifactResolutionException, InvalidVersionSpecificationException
+ {
+ ArtifactSpec a = createArtifactSpec( "a", "1.0" );
+ ArtifactSpec b = a.addDependency( "b", "1.0" );
+ a.addDependency( "c", "[2.4,3.0]" );
+
+ b.addDependency( "c", "[1.0,2.0]" );
+
+ ArtifactResolutionResult res = collect( a );
+
+ assertTrue( res.hasVersionRangeViolations() );
+ }
+
+ public void testUnboundedRangeWhenVersionUnavailable()
+ throws ArtifactResolutionException, InvalidVersionSpecificationException
+ {
+ ArtifactSpec a = createArtifactSpec( "a", "1.0" );
+ ArtifactSpec b = a.addDependency( "b", "1.0" );
+ a.addDependency( "c", "[2.0,]" );
+ b.addDependency( "c", "[1.0,]" );
+
+ ArtifactResolutionResult res = collect( a );
+
+ assertTrue( res.hasVersionRangeViolations() );
+ }
+
+ public void testUnboundedRangeBelowLastRelease()
+ throws ArtifactResolutionException, InvalidVersionSpecificationException
+ {
+ ArtifactSpec a = createArtifactSpec( "a", "1.0" );
+ createArtifactSpec( "c", "1.5" );
+ ArtifactSpec c = createArtifactSpec( "c", "2.0" );
+ createArtifactSpec( "c", "1.1" );
+ a.addDependency( "c", "[1.0,)" );
+
+ ArtifactResolutionResult res = collect( a );
+
+ assertEquals( "Check artifact list", createSet( new Object[] { a.artifact, c.artifact } ), res.getArtifacts() );
+ assertEquals( "Check version", "2.0", getArtifact( "c", res.getArtifacts() ).getVersion() );
+ }
+
+ public void testUnboundedRangeAboveLastRelease()
+ throws ArtifactResolutionException, InvalidVersionSpecificationException
+ {
+ ArtifactSpec a = createArtifactSpec( "a", "1.0" );
+ createArtifactSpec( "c", "2.0" );
+ a.addDependency( "c", "[10.0,)" );
+
+ ArtifactResolutionResult res = collect( a );
+
+ assertTrue( res.hasVersionRangeViolations() );
+ }
+
+ public void testResolveManagedVersion()
+ throws ArtifactResolutionException, InvalidVersionSpecificationException
+ {
+ ArtifactSpec a = createArtifactSpec( "a", "1.0" );
+ a.addDependency( "b", "3.0", Artifact.SCOPE_RUNTIME );
+
+ Artifact managedVersion = createArtifactSpec( "b", "5.0" ).artifact;
+ Artifact modifiedB = createArtifactSpec( "b", "5.0", Artifact.SCOPE_RUNTIME ).artifact;
+
+ ArtifactResolutionResult res = collect( a, managedVersion );
+ assertEquals( "Check artifact list", createSet( new Object[] { a.artifact, modifiedB } ), res.getArtifacts() );
+ }
+
+ public void testCollectChangesVersionOfOriginatingArtifactIfInDependencyManagementHasDifferentVersion()
+ throws ArtifactResolutionException, InvalidVersionSpecificationException
+ {
+ ArtifactSpec a = createArtifactSpec( "a", "1.0" );
+
+ Artifact artifact = projectArtifact.artifact;
+ Artifact managedVersion = createArtifactSpec( artifact.getArtifactId(), "2.0" ).artifact;
+
+ ArtifactResolutionResult result = collect( a, managedVersion );
+
+ assertEquals( "collect has modified version in originating artifact", "1.0", artifact.getVersion() );
+
+ Artifact resolvedArtifact = result.getArtifacts().iterator().next();
+
+ assertEquals( "Resolved version don't match original artifact version", "1.0", resolvedArtifact.getVersion() );
+ }
+
+ public void testResolveCompileScopeOverTestScope()
+ throws ArtifactResolutionException, InvalidVersionSpecificationException
+ {
+ ArtifactSpec a = createArtifactSpec( "a", "1.0" );
+ ArtifactSpec c = createArtifactSpec( "c", "3.0", Artifact.SCOPE_TEST );
+
+ a.addDependency( "c", "2.0", Artifact.SCOPE_COMPILE );
+
+ Artifact modifiedC = createArtifactSpec( "c", "3.0", Artifact.SCOPE_COMPILE ).artifact;
+
+ ArtifactResolutionResult res = collect( createSet( new Object[] { a.artifact, c.artifact } ) );
+ assertEquals( "Check artifact list", createSet( new Object[] { a.artifact, modifiedC } ), res.getArtifacts() );
+ Artifact artifact = getArtifact( "c", res.getArtifacts() );
+ // local wins now, and irrelevant if not local as test/provided aren't transitive
+ // assertEquals( "Check artifactScope", Artifact.SCOPE_COMPILE, artifact.getArtifactScope() );
+ assertEquals( "Check artifactScope", Artifact.SCOPE_TEST, artifact.getScope() );
+ }
+
+ public void testResolveRuntimeScopeOverTestScope()
+ throws ArtifactResolutionException, InvalidVersionSpecificationException
+ {
+ ArtifactSpec a = createArtifactSpec( "a", "1.0" );
+ ArtifactSpec c = createArtifactSpec( "c", "3.0", Artifact.SCOPE_TEST );
+
+ a.addDependency( "c", "2.0", Artifact.SCOPE_RUNTIME );
+
+ Artifact modifiedC = createArtifactSpec( "c", "3.0", Artifact.SCOPE_RUNTIME ).artifact;
+
+ ArtifactResolutionResult res = collect( createSet( new Object[] { a.artifact, c.artifact } ) );
+ assertEquals( "Check artifact list", createSet( new Object[] { a.artifact, modifiedC } ), res.getArtifacts() );
+ Artifact artifact = getArtifact( "c", res.getArtifacts() );
+ // local wins now, and irrelevant if not local as test/provided aren't transitive
+ // assertEquals( "Check artifactScope", Artifact.SCOPE_RUNTIME, artifact.getArtifactScope() );
+ assertEquals( "Check artifactScope", Artifact.SCOPE_TEST, artifact.getScope() );
+ }
+
+ public void testResolveCompileScopeOverRuntimeScope()
+ throws ArtifactResolutionException, InvalidVersionSpecificationException
+ {
+ ArtifactSpec root = createArtifactSpec( "root", "1.0" );
+ ArtifactSpec a = root.addDependency( "a", "1.0" );
+ root.addDependency( "c", "3.0", Artifact.SCOPE_RUNTIME );
+
+ a.addDependency( "c", "2.0", Artifact.SCOPE_COMPILE );
+
+ Artifact modifiedC = createArtifactSpec( "c", "3.0", Artifact.SCOPE_COMPILE ).artifact;
+
+ ArtifactResolutionResult res = collect( createSet( new Object[] { root.artifact } ) );
+ assertEquals( "Check artifact list", createSet( new Object[] { a.artifact, root.artifact, modifiedC } ),
+ res.getArtifacts() );
+ Artifact artifact = getArtifact( "c", res.getArtifacts() );
+ assertEquals( "Check artifactScope", Artifact.SCOPE_COMPILE, artifact.getScope() );
+ }
+
+ public void testResolveCompileScopeOverProvidedScope()
+ throws ArtifactResolutionException, InvalidVersionSpecificationException
+ {
+ ArtifactSpec a = createArtifactSpec( "a", "1.0" );
+ ArtifactSpec c = createArtifactSpec( "c", "3.0", Artifact.SCOPE_PROVIDED );
+
+ a.addDependency( "c", "2.0", Artifact.SCOPE_COMPILE );
+
+ Artifact modifiedC = createArtifactSpec( "c", "3.0", Artifact.SCOPE_COMPILE ).artifact;
+
+ ArtifactResolutionResult res = collect( createSet( new Object[] { a.artifact, c.artifact } ) );
+ assertEquals( "Check artifact list", createSet( new Object[] { a.artifact, modifiedC } ), res.getArtifacts() );
+ Artifact artifact = getArtifact( "c", res.getArtifacts() );
+ // local wins now, and irrelevant if not local as test/provided aren't transitive
+ // assertEquals( "Check artifactScope", Artifact.SCOPE_COMPILE, artifact.getArtifactScope() );
+ assertEquals( "Check artifactScope", Artifact.SCOPE_PROVIDED, artifact.getScope() );
+ }
+
+ public void testResolveRuntimeScopeOverProvidedScope()
+ throws ArtifactResolutionException, InvalidVersionSpecificationException
+ {
+ ArtifactSpec a = createArtifactSpec( "a", "1.0" );
+ ArtifactSpec c = createArtifactSpec( "c", "3.0", Artifact.SCOPE_PROVIDED );
+
+ a.addDependency( "c", "2.0", Artifact.SCOPE_RUNTIME );
+
+ Artifact modifiedC = createArtifactSpec( "c", "3.0", Artifact.SCOPE_RUNTIME ).artifact;
+
+ ArtifactResolutionResult res = collect( createSet( new Object[] { a.artifact, c.artifact } ) );
+ assertEquals( "Check artifact list", createSet( new Object[] { a.artifact, modifiedC } ), res.getArtifacts() );
+ Artifact artifact = getArtifact( "c", res.getArtifacts() );
+ // local wins now, and irrelevant if not local as test/provided aren't transitive
+ // assertEquals( "Check artifactScope", Artifact.SCOPE_RUNTIME, artifact.getArtifactScope() );
+ assertEquals( "Check artifactScope", Artifact.SCOPE_PROVIDED, artifact.getScope() );
+ }
+
+ public void testProvidedScopeNotTransitive()
+ throws ArtifactResolutionException, InvalidVersionSpecificationException
+ {
+ ArtifactSpec a = createArtifactSpec( "a", "1.0", Artifact.SCOPE_PROVIDED );
+ ArtifactSpec b = createArtifactSpec( "b", "1.0" );
+ b.addDependency( "c", "3.0", Artifact.SCOPE_PROVIDED );
+
+ ArtifactResolutionResult res = collect( createSet( new Object[] { a.artifact, b.artifact } ) );
+ assertEquals( "Check artifact list", createSet( new Object[] { a.artifact, b.artifact } ), res.getArtifacts() );
+ }
+
+ public void testOptionalNotTransitive()
+ throws ArtifactResolutionException, InvalidVersionSpecificationException
+ {
+ ArtifactSpec a = createArtifactSpec( "a", "1.0" );
+ ArtifactSpec b = createArtifactSpec( "b", "1.0" );
+ b.addDependency( "c", "3.0", true );
+
+ ArtifactResolutionResult res = collect( createSet( new Object[] { a.artifact, b.artifact } ) );
+ assertEquals( "Check artifact list", createSet( new Object[] { a.artifact, b.artifact } ), res.getArtifacts() );
+ }
+
+ public void testOptionalIncludedAtRoot()
+ throws ArtifactResolutionException, InvalidVersionSpecificationException
+ {
+ ArtifactSpec a = createArtifactSpec( "a", "1.0" );
+
+ ArtifactSpec b = createArtifactSpec( "b", "1.0", true );
+
+ ArtifactResolutionResult res = collect( createSet( new Object[] { a.artifact, b.artifact } ) );
+ assertEquals( "Check artifact list", createSet( new Object[] { a.artifact, b.artifact } ), res.getArtifacts() );
+ }
+
+ public void testScopeUpdate()
+ throws InvalidVersionSpecificationException, ArtifactResolutionException
+ {
+ /* farthest = compile */
+ checkScopeUpdate( Artifact.SCOPE_COMPILE, Artifact.SCOPE_COMPILE, Artifact.SCOPE_COMPILE );
+ checkScopeUpdate( Artifact.SCOPE_COMPILE, Artifact.SCOPE_PROVIDED, Artifact.SCOPE_COMPILE );
+ checkScopeUpdate( Artifact.SCOPE_COMPILE, Artifact.SCOPE_RUNTIME, Artifact.SCOPE_COMPILE );
+ checkScopeUpdate( Artifact.SCOPE_COMPILE, Artifact.SCOPE_SYSTEM, Artifact.SCOPE_COMPILE );
+ checkScopeUpdate( Artifact.SCOPE_COMPILE, Artifact.SCOPE_TEST, Artifact.SCOPE_COMPILE );
+
+ /* farthest = provided */
+ checkScopeUpdate( Artifact.SCOPE_PROVIDED, Artifact.SCOPE_COMPILE, Artifact.SCOPE_COMPILE );
+ checkScopeUpdate( Artifact.SCOPE_PROVIDED, Artifact.SCOPE_PROVIDED, Artifact.SCOPE_PROVIDED );
+ checkScopeUpdate( Artifact.SCOPE_PROVIDED, Artifact.SCOPE_RUNTIME, Artifact.SCOPE_RUNTIME );
+ checkScopeUpdate( Artifact.SCOPE_PROVIDED, Artifact.SCOPE_SYSTEM, Artifact.SCOPE_SYSTEM );
+ checkScopeUpdate( Artifact.SCOPE_PROVIDED, Artifact.SCOPE_TEST, Artifact.SCOPE_TEST );
+
+ /* farthest = runtime */
+ checkScopeUpdate( Artifact.SCOPE_RUNTIME, Artifact.SCOPE_COMPILE, Artifact.SCOPE_COMPILE );
+ checkScopeUpdate( Artifact.SCOPE_RUNTIME, Artifact.SCOPE_PROVIDED, Artifact.SCOPE_RUNTIME );
+ checkScopeUpdate( Artifact.SCOPE_RUNTIME, Artifact.SCOPE_RUNTIME, Artifact.SCOPE_RUNTIME );
+ checkScopeUpdate( Artifact.SCOPE_RUNTIME, Artifact.SCOPE_SYSTEM, Artifact.SCOPE_SYSTEM );
+ checkScopeUpdate( Artifact.SCOPE_RUNTIME, Artifact.SCOPE_TEST, Artifact.SCOPE_RUNTIME );
+
+ /* farthest = system */
+ checkScopeUpdate( Artifact.SCOPE_SYSTEM, Artifact.SCOPE_COMPILE, Artifact.SCOPE_COMPILE );
+ checkScopeUpdate( Artifact.SCOPE_SYSTEM, Artifact.SCOPE_PROVIDED, Artifact.SCOPE_PROVIDED );
+ checkScopeUpdate( Artifact.SCOPE_SYSTEM, Artifact.SCOPE_RUNTIME, Artifact.SCOPE_RUNTIME );
+ checkScopeUpdate( Artifact.SCOPE_SYSTEM, Artifact.SCOPE_SYSTEM, Artifact.SCOPE_SYSTEM );
+ checkScopeUpdate( Artifact.SCOPE_SYSTEM, Artifact.SCOPE_TEST, Artifact.SCOPE_TEST );
+
+ /* farthest = test */
+ checkScopeUpdate( Artifact.SCOPE_TEST, Artifact.SCOPE_COMPILE, Artifact.SCOPE_COMPILE );
+ checkScopeUpdate( Artifact.SCOPE_TEST, Artifact.SCOPE_PROVIDED, Artifact.SCOPE_PROVIDED );
+ checkScopeUpdate( Artifact.SCOPE_TEST, Artifact.SCOPE_RUNTIME, Artifact.SCOPE_RUNTIME );
+ checkScopeUpdate( Artifact.SCOPE_TEST, Artifact.SCOPE_SYSTEM, Artifact.SCOPE_SYSTEM );
+ checkScopeUpdate( Artifact.SCOPE_TEST, Artifact.SCOPE_TEST, Artifact.SCOPE_TEST );
+ }
+
+ private void checkScopeUpdate( String farthestScope, String nearestScope, String expectedScope )
+ throws ArtifactResolutionException, InvalidVersionSpecificationException
+ {
+ checkScopeUpdateDirect( farthestScope, nearestScope, expectedScope );
+ checkScopeUpdateTransitively( farthestScope, nearestScope, expectedScope );
+ }
+
+ private void checkScopeUpdateTransitively( String farthestScope, String nearestScope, String expectedScope )
+ throws ArtifactResolutionException, InvalidVersionSpecificationException
+ {
+ ArtifactSpec a = createArtifactSpec( "a", "1.0" );
+ ArtifactSpec b = createArtifactSpec( "b", "1.0", nearestScope );
+ ArtifactSpec c = createArtifactSpec( "c", "1.0" );
+ a.addDependency( c );
+ ArtifactSpec dNearest = createArtifactSpec( "d", "2.0" );
+ b.addDependency( dNearest );
+ ArtifactSpec dFarthest = createArtifactSpec( "d", "3.0", farthestScope );
+ c.addDependency( dFarthest );
+
+ /* system and provided dependencies are not transitive */
+ if ( !Artifact.SCOPE_SYSTEM.equals( nearestScope ) && !Artifact.SCOPE_PROVIDED.equals( nearestScope ) )
+ {
+ checkScopeUpdate( a, b, expectedScope, "2.0" );
+ }
+ }
+
+ private void checkScopeUpdateDirect( String farthestScope, String nearestScope, String expectedScope )
+ throws ArtifactResolutionException, InvalidVersionSpecificationException
+ {
+ ArtifactSpec a = createArtifactSpec( "a", "1.0" );
+ ArtifactSpec b = createArtifactSpec( "b", "1.0" );
+ ArtifactSpec c = createArtifactSpec( "c", "1.0" );
+ a.addDependency( c );
+ ArtifactSpec dNearest = createArtifactSpec( "d", "2.0", nearestScope );
+ b.addDependency( dNearest );
+ ArtifactSpec dFarthest = createArtifactSpec( "d", "3.0", farthestScope );
+ c.addDependency( dFarthest );
+
+ checkScopeUpdate( a, b, expectedScope, "2.0" );
+ }
+
+ private void checkScopeUpdate( ArtifactSpec a, ArtifactSpec b, String expectedScope, String expectedVersion )
+ throws ArtifactResolutionException, InvalidVersionSpecificationException
+ {
+ ScopeArtifactFilter filter;
+ if ( Artifact.SCOPE_PROVIDED.equals( expectedScope ) )
+ {
+ filter = new ScopeArtifactFilter( Artifact.SCOPE_COMPILE );
+ }
+ else if ( Artifact.SCOPE_SYSTEM.equals( expectedScope ) )
+ {
+ filter = new ScopeArtifactFilter( Artifact.SCOPE_COMPILE );
+ }
+ else
+ {
+ filter = new ScopeArtifactFilter( expectedScope );
+ }
+
+ ArtifactResolutionResult res = collect( createSet( new Object[] { a.artifact, b.artifact } ), filter );
+ Artifact artifact = getArtifact( "d", res.getArtifacts() );
+ assertNotNull( "MNG-1895 Dependency was not added to resolution", artifact );
+ assertEquals( "Check artifactScope", expectedScope, artifact.getScope() );
+ assertEquals( "Check version", expectedVersion, artifact.getVersion() );
+
+ ArtifactSpec d = createArtifactSpec( "d", "1.0" );
+ res = collect( createSet( new Object[] { a.artifact, b.artifact, d.artifact } ), filter );
+ artifact = getArtifact( "d", res.getArtifacts() );
+ assertNotNull( "MNG-1895 Dependency was not added to resolution", artifact );
+ assertEquals( "Check artifactScope", d.artifact.getScope(), artifact.getScope() );
+ assertEquals( "Check version", "1.0", artifact.getVersion() );
+ }
+
+ public void disabledtestOptionalNotTransitiveButVersionIsInfluential()
+ throws ArtifactResolutionException, InvalidVersionSpecificationException
+ {
+ ArtifactSpec a = createArtifactSpec( "a", "1.0" );
+ ArtifactSpec b = createArtifactSpec( "b", "1.0" );
+ b.addDependency( "c", "3.0", true );
+ ArtifactSpec d = a.addDependency( "d", "1.0" );
+ ArtifactSpec e = d.addDependency( "e", "1.0" );
+ e.addDependency( "c", "2.0" );
+
+ ArtifactSpec c = createArtifactSpec( "c", "3.0" );
+
+ ArtifactResolutionResult res = collect( createSet( new Object[] { a.artifact, b.artifact } ) );
+ assertEquals( "Check artifact list", createSet( new Object[] { a.artifact, b.artifact, c.artifact, d.artifact,
+ e.artifact } ), res.getArtifacts() );
+ Artifact artifact = getArtifact( "c", res.getArtifacts() );
+ assertEquals( "Check version", "3.0", artifact.getVersion() );
+ }
+
+ public void testTestScopeNotTransitive()
+ throws ArtifactResolutionException, InvalidVersionSpecificationException
+ {
+ ArtifactSpec a = createArtifactSpec( "a", "1.0", Artifact.SCOPE_TEST );
+ ArtifactSpec b = createArtifactSpec( "b", "1.0" );
+ b.addDependency( "c", "3.0", Artifact.SCOPE_TEST );
+
+ ArtifactResolutionResult res = collect( createSet( new Object[] { a.artifact, b.artifact } ) );
+ assertEquals( "Check artifact list", createSet( new Object[] { a.artifact, b.artifact } ), res.getArtifacts() );
+ }
+
+ public void testSnapshotNotIncluded()
+ throws ArtifactResolutionException, InvalidVersionSpecificationException
+ {
+ ArtifactSpec a = createArtifactSpec( "a", "1.0" );
+ a.addDependency( "b", "[1.0,)" );
+ createArtifactSpec( "b", "1.0-SNAPSHOT" );
+
+ ArtifactResolutionResult res = collect( a );
+
+ assertTrue( res.hasVersionRangeViolations() );
+
+ /*
+ * try { ArtifactResolutionResult res = collect( a ); fail( "Expected b not to resolve: " + res ); } catch (
+ * OverConstrainedVersionException e ) { assertTrue( e.getMessage().indexOf( "[1.0-SNAPSHOT]" ) <
+ * e.getMessage().indexOf( "[1.0,)" ) ); }
+ */
+ }
+
+ public void testOverConstrainedVersionException()
+ throws ArtifactResolutionException, InvalidVersionSpecificationException
+ {
+ ArtifactSpec a = createArtifactSpec( "a", "1.0" );
+ a.addDependency( "b", "[1.0, 2.0)" );
+ a.addDependency( "c", "[3.3.0,4.0.0)" );
+
+ ArtifactSpec b = createArtifactSpec( "b", "1.0.0" );
+ b.addDependency( "c", "3.3.0-v3346" );
+
+ ArtifactSpec c = createArtifactSpec( "c", "3.2.1-v3235e" );
+
+ try
+ {
+ ArtifactResolutionResult res = collect( createSet( new Object[] { a.artifact } ) );
+ }
+ catch ( OverConstrainedVersionException e )
+ {
+ assertTrue( "Versions unordered", e.getMessage().contains( "[3.2.1-v3235e, 3.3.0-v3346]" ) );
+ assertTrue( "DependencyTrail unresolved", e.getMessage().contains( "Path to dependency:" ) );
+ }
+ }
+
+ private Artifact getArtifact( String id, Set artifacts )
+ {
+ for ( Object artifact : artifacts )
+ {
+ Artifact a = (Artifact) artifact;
+ if ( a.getArtifactId().equals( id ) && a.getGroupId().equals( GROUP_ID ) )
+ {
+ return a;
+ }
+ }
+ return null;
+ }
+
+ private ArtifactResolutionResult collect( Set artifacts )
+ throws ArtifactResolutionException
+ {
+ return collect( artifacts, null );
+ }
+
+ private ArtifactResolutionResult collect( Set artifacts, ArtifactFilter filter )
+ throws ArtifactResolutionException
+ {
+ return artifactCollector.collect( artifacts, projectArtifact.artifact, null, null, null, source, filter,
+ Collections.EMPTY_LIST, null );
+ }
+
+ private ArtifactResolutionResult collect( ArtifactSpec a )
+ throws ArtifactResolutionException
+ {
+ return artifactCollector.collect( Collections.singleton( a.artifact ), projectArtifact.artifact, null, null,
+ null, source, null, Collections.EMPTY_LIST, null );
+ }
+
+ private ArtifactResolutionResult collect( ArtifactSpec a, ArtifactFilter filter )
+ throws ArtifactResolutionException
+ {
+ return artifactCollector.collect( Collections.singleton( a.artifact ), projectArtifact.artifact, null, null,
+ null, source, filter, Collections.EMPTY_LIST, null );
+ }
+
+ private ArtifactResolutionResult collect( ArtifactSpec a, Artifact managedVersion )
+ throws ArtifactResolutionException
+ {
+ Map managedVersions = Collections.singletonMap( managedVersion.getDependencyConflictId(), managedVersion );
+ return artifactCollector.collect( Collections.singleton( a.artifact ), projectArtifact.artifact,
+ managedVersions, null, null, source, null, Collections.EMPTY_LIST, null );
+ }
+
+ private ArtifactSpec createArtifactSpec( String id, String version )
+ throws InvalidVersionSpecificationException
+ {
+ return createArtifactSpec( id, version, Artifact.SCOPE_COMPILE );
+ }
+
+ private ArtifactSpec createArtifactSpec( String id, String version, boolean optional )
+ throws InvalidVersionSpecificationException
+ {
+ return createArtifactSpec( id, version, Artifact.SCOPE_COMPILE, null, optional );
+ }
+
+ private ArtifactSpec createArtifactSpec( String id, String version, String scope )
+ throws InvalidVersionSpecificationException
+ {
+ return createArtifactSpec( id, version, scope, null, false );
+ }
+
+ private ArtifactSpec createArtifactSpec( String id, String version, String scope, String inheritedScope,
+ boolean optional )
+ throws InvalidVersionSpecificationException
+ {
+ VersionRange versionRange = VersionRange.createFromVersionSpec( version );
+ Artifact artifact =
+ artifactFactory.createDependencyArtifact( GROUP_ID, id, versionRange, "jar", null, scope, inheritedScope,
+ optional );
+ ArtifactSpec spec = null;
+ if ( artifact != null )
+ {
+ spec = new ArtifactSpec();
+ spec.artifact = artifact;
+ source.addArtifact( spec );
+ }
+ return spec;
+ }
+
+ private static Set createSet( Object[] x )
+ {
+ return new LinkedHashSet( Arrays.asList( x ) );
+ }
+
+ private class ArtifactSpec
+ {
+ private Artifact artifact;
+
+ private Set dependencies = new HashSet();
+
+ public ArtifactSpec addDependency( String id, String version )
+ throws InvalidVersionSpecificationException
+ {
+ return addDependency( id, version, Artifact.SCOPE_COMPILE );
+ }
+
+ public ArtifactSpec addDependency( String id, String version, String scope )
+ throws InvalidVersionSpecificationException
+ {
+ return addDependency( id, version, scope, false );
+ }
+
+ private ArtifactSpec addDependency( ArtifactSpec dep )
+ throws InvalidVersionSpecificationException
+ {
+ if ( dep != null )
+ {
+ dependencies.add( dep.artifact );
+ }
+ return dep;
+ }
+
+ private ArtifactSpec addDependency( String id, String version, String scope, boolean optional )
+ throws InvalidVersionSpecificationException
+ {
+ ArtifactSpec dep = createArtifactSpec( id, version, scope, artifact.getScope(), optional );
+ return addDependency( dep );
+ }
+
+ public ArtifactSpec addDependency( String id, String version, boolean optional )
+ throws InvalidVersionSpecificationException
+ {
+ return addDependency( id, version, Artifact.SCOPE_COMPILE, optional );
+ }
+ }
+
+ private class Source
+ implements ArtifactMetadataSource
+ {
+ private Map artifacts = new HashMap();
+
+ private Map versions = new HashMap();
+
+ public ResolutionGroup retrieve( Artifact artifact, ArtifactRepository localRepository,
+ List<ArtifactRepository> remoteRepositories )
+ throws ArtifactMetadataRetrievalException
+ {
+ String key = getKey( artifact );
+
+ ArtifactSpec a = (ArtifactSpec) artifacts.get( key );
+ try
+ {
+ return new ResolutionGroup( artifact, createArtifacts( artifactFactory, a.dependencies,
+ artifact.getScope(),
+ artifact.getDependencyFilter() ),
+ Collections.EMPTY_LIST );
+ }
+ catch ( InvalidVersionSpecificationException e )
+ {
+ throw new ArtifactMetadataRetrievalException( "Invalid version creating artifacts", e, artifact );
+ }
+ }
+
+ private String getKey( Artifact artifact )
+ {
+ return artifact.getDependencyConflictId();
+ }
+
+ private Set createArtifacts( ArtifactFactory artifactFactory, Set dependencies, String inheritedScope,
+ ArtifactFilter dependencyFilter )
+ throws InvalidVersionSpecificationException
+ {
+ Set projectArtifacts = new HashSet();
+
+ for ( Object dependency : dependencies )
+ {
+ Artifact d = (Artifact) dependency;
+
+ VersionRange versionRange;
+ if ( d.getVersionRange() != null )
+ {
+ versionRange = d.getVersionRange();
+ }
+ else
+ {
+ versionRange = VersionRange.createFromVersionSpec( d.getVersion() );
+ }
+ Artifact artifact;
+ if ( d.getScope().equals( Artifact.SCOPE_TEST ) || d.getScope().equals( Artifact.SCOPE_PROVIDED ) )
+ {
+ /* don't call createDependencyArtifact as it'll ignore test and provided scopes */
+ artifact =
+ artifactFactory.createArtifact( d.getGroupId(), d.getArtifactId(), d.getVersion(), d.getScope(),
+ d.getType() );
+ }
+ else
+ {
+ artifact =
+ artifactFactory.createDependencyArtifact( d.getGroupId(), d.getArtifactId(), versionRange,
+ d.getType(), d.getClassifier(), d.getScope(),
+ inheritedScope, d.isOptional() );
+ }
+
+ if ( artifact != null && ( dependencyFilter == null || dependencyFilter.include( artifact ) ) )
+ {
+ artifact.setDependencyFilter( dependencyFilter );
+
+ projectArtifacts.add( artifact );
+ }
+ }
+
+ return projectArtifacts;
+ }
+
+ public void addArtifact( ArtifactSpec spec )
+ {
+ artifacts.put( getKey( spec.artifact ), spec );
+
+ String key = spec.artifact.getDependencyConflictId();
+ List artifactVersions = (List) versions.get( key );
+ if ( artifactVersions == null )
+ {
+ artifactVersions = new ArrayList();
+ versions.put( key, artifactVersions );
+ }
+ if ( spec.artifact.getVersion() != null )
+ {
+ artifactVersions.add( new DefaultArtifactVersion( spec.artifact.getVersion() ) );
+ }
+ }
+
+ public List<ArtifactVersion> retrieveAvailableVersions( Artifact artifact, ArtifactRepository localRepository,
+ List<ArtifactRepository> remoteRepositories )
+ throws ArtifactMetadataRetrievalException
+ {
+ return retrieveAvailableVersions( artifact );
+ }
+
+ public List<ArtifactVersion> retrieveAvailableVersionsFromDeploymentRepository(
+ Artifact artifact,
+ ArtifactRepository localRepository,
+ ArtifactRepository remoteRepository )
+ throws ArtifactMetadataRetrievalException
+ {
+ return retrieveAvailableVersions( artifact );
+ }
+
+ private List<ArtifactVersion> retrieveAvailableVersions( Artifact artifact )
+ {
+ List artifactVersions = (List) versions.get( artifact.getDependencyConflictId() );
+ if ( artifactVersions == null )
+ {
+ artifactVersions = Collections.EMPTY_LIST;
+ }
+ return artifactVersions;
+ }
+
+ 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/repository/legacy/resolver/conflict/AbstractConflictResolverTest.java b/framework/src/maven/apache-maven-3.3.3/maven-compat/src/test/java/org/apache/maven/repository/legacy/resolver/conflict/AbstractConflictResolverTest.java
new file mode 100644
index 00000000..bfab0d26
--- /dev/null
+++ b/framework/src/maven/apache-maven-3.3.3/maven-compat/src/test/java/org/apache/maven/repository/legacy/resolver/conflict/AbstractConflictResolverTest.java
@@ -0,0 +1,143 @@
+package org.apache.maven.repository.legacy.resolver.conflict;
+
+/*
+ * 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.factory.ArtifactFactory;
+import org.apache.maven.artifact.resolver.ResolutionNode;
+import org.apache.maven.artifact.versioning.InvalidVersionSpecificationException;
+import org.apache.maven.artifact.versioning.VersionRange;
+import org.apache.maven.repository.legacy.resolver.conflict.ConflictResolver;
+import org.codehaus.plexus.PlexusTestCase;
+
+/**
+ * Provides a basis for testing conflict resolvers.
+ *
+ * @author <a href="mailto:markhobson@gmail.com">Mark Hobson</a>
+ */
+public abstract class AbstractConflictResolverTest
+ extends PlexusTestCase
+{
+ // constants --------------------------------------------------------------
+
+ private static final String GROUP_ID = "test";
+
+ // fields -----------------------------------------------------------------
+
+ protected Artifact a1;
+
+ protected Artifact a2;
+
+ protected Artifact b1;
+
+ private final String roleHint;
+
+ private ArtifactFactory artifactFactory;
+
+ private ConflictResolver conflictResolver;
+
+ // constructors -----------------------------------------------------------
+
+ public AbstractConflictResolverTest( String roleHint )
+ throws Exception
+ {
+ this.roleHint = roleHint;
+ }
+
+ // TestCase methods -------------------------------------------------------
+
+ /*
+ * @see junit.framework.TestCase#setUp()
+ */
+ protected void setUp() throws Exception
+ {
+ super.setUp();
+
+ artifactFactory = (ArtifactFactory) lookup( ArtifactFactory.ROLE );
+ conflictResolver = (ConflictResolver) lookup( ConflictResolver.ROLE, roleHint );
+
+ a1 = createArtifact( "a", "1.0" );
+ a2 = createArtifact( "a", "2.0" );
+ b1 = createArtifact( "b", "1.0" );
+ }
+
+ /*
+ * @see org.codehaus.plexus.PlexusTestCase#tearDown()
+ */
+ protected void tearDown() throws Exception
+ {
+ a1 = null;
+ a2 = null;
+ b1 = null;
+
+ artifactFactory = null;
+ conflictResolver = null;
+
+ super.tearDown();
+ }
+
+ // protected methods ------------------------------------------------------
+
+ protected ConflictResolver getConflictResolver()
+ {
+ return conflictResolver;
+ }
+
+ protected void assertResolveConflict( ResolutionNode expectedNode, ResolutionNode actualNode1, ResolutionNode actualNode2 )
+ {
+ ResolutionNode resolvedNode = getConflictResolver().resolveConflict( actualNode1, actualNode2 );
+
+ assertNotNull( "Expected resolvable", resolvedNode );
+ assertEquals( "Resolution node", expectedNode, resolvedNode );
+ }
+
+ protected void assertUnresolvableConflict( ResolutionNode actualNode1, ResolutionNode actualNode2 )
+ {
+ ResolutionNode resolvedNode = getConflictResolver().resolveConflict( actualNode1, actualNode2 );
+
+ assertNull( "Expected unresolvable", resolvedNode );
+ }
+
+ protected Artifact createArtifact( String id, String version ) throws InvalidVersionSpecificationException
+ {
+ return createArtifact( id, version, Artifact.SCOPE_COMPILE );
+ }
+
+ protected Artifact createArtifact( String id, String version, boolean optional )
+ throws InvalidVersionSpecificationException
+ {
+ return createArtifact( id, version, Artifact.SCOPE_COMPILE, null, optional );
+ }
+
+ protected Artifact createArtifact( String id, String version, String scope )
+ throws InvalidVersionSpecificationException
+ {
+ return createArtifact( id, version, scope, null, false );
+ }
+
+ protected Artifact createArtifact( String id, String version, String scope, String inheritedScope, boolean optional )
+ throws InvalidVersionSpecificationException
+ {
+ VersionRange versionRange = VersionRange.createFromVersionSpec( version );
+
+ return artifactFactory.createDependencyArtifact( GROUP_ID, id, versionRange, "jar", null, scope,
+ inheritedScope, optional );
+ }
+}
diff --git a/framework/src/maven/apache-maven-3.3.3/maven-compat/src/test/java/org/apache/maven/repository/legacy/resolver/conflict/FarthestConflictResolverTest.java b/framework/src/maven/apache-maven-3.3.3/maven-compat/src/test/java/org/apache/maven/repository/legacy/resolver/conflict/FarthestConflictResolverTest.java
new file mode 100644
index 00000000..96e283df
--- /dev/null
+++ b/framework/src/maven/apache-maven-3.3.3/maven-compat/src/test/java/org/apache/maven/repository/legacy/resolver/conflict/FarthestConflictResolverTest.java
@@ -0,0 +1,107 @@
+package org.apache.maven.repository.legacy.resolver.conflict;
+
+/*
+ * 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.resolver.ResolutionNode;
+import org.apache.maven.repository.legacy.resolver.conflict.FarthestConflictResolver;
+
+/**
+ * Tests <code>FarthestConflictResolver</code>.
+ *
+ * @author <a href="mailto:markhobson@gmail.com">Mark Hobson</a>
+ * @see FarthestConflictResolver
+ */
+public class FarthestConflictResolverTest
+ extends AbstractConflictResolverTest
+{
+ // constructors -----------------------------------------------------------
+
+ public FarthestConflictResolverTest()
+ throws Exception
+ {
+ super("farthest");
+ }
+
+ // tests ------------------------------------------------------------------
+
+ /**
+ * Tests that <code>a:2.0</code> wins in the scenario:
+ * <pre>
+ * a:1.0
+ * b:1.0 -> a:2.0
+ * </pre>
+ */
+ public void testDepth()
+ {
+ ResolutionNode a1n = new ResolutionNode( a1, Collections.EMPTY_LIST );
+ ResolutionNode b1n = new ResolutionNode( b1, Collections.EMPTY_LIST );
+ ResolutionNode a2n = new ResolutionNode( a2, Collections.EMPTY_LIST, b1n );
+
+ assertResolveConflict( a2n, a1n, a2n );
+ }
+
+ /**
+ * Tests that <code>a:2.0</code> wins in the scenario:
+ * <pre>
+ * b:1.0 -> a:2.0
+ * a:1.0
+ * </pre>
+ */
+ public void testDepthReversed()
+ {
+ ResolutionNode b1n = new ResolutionNode( b1, Collections.EMPTY_LIST );
+ ResolutionNode a2n = new ResolutionNode( a2, Collections.EMPTY_LIST, b1n );
+ ResolutionNode a1n = new ResolutionNode( a1, Collections.EMPTY_LIST );
+
+ assertResolveConflict( a2n, a2n, a1n );
+ }
+
+ /**
+ * Tests that <code>a:1.0</code> wins in the scenario:
+ * <pre>
+ * a:1.0
+ * a:2.0
+ * </pre>
+ */
+ public void testEqual()
+ {
+ ResolutionNode a1n = new ResolutionNode( a1, Collections.EMPTY_LIST );
+ ResolutionNode a2n = new ResolutionNode( a2, Collections.EMPTY_LIST );
+
+ assertResolveConflict( a1n, a1n, a2n );
+ }
+
+ /**
+ * Tests that <code>a:2.0</code> wins in the scenario:
+ * <pre>
+ * a:2.0
+ * a:1.0
+ * </pre>
+ */
+ public void testEqualReversed()
+ {
+ ResolutionNode a2n = new ResolutionNode( a2, Collections.EMPTY_LIST );
+ ResolutionNode a1n = new ResolutionNode( a1, Collections.EMPTY_LIST );
+
+ assertResolveConflict( a2n, a2n, a1n );
+ }
+}
diff --git a/framework/src/maven/apache-maven-3.3.3/maven-compat/src/test/java/org/apache/maven/repository/legacy/resolver/conflict/NearestConflictResolverTest.java b/framework/src/maven/apache-maven-3.3.3/maven-compat/src/test/java/org/apache/maven/repository/legacy/resolver/conflict/NearestConflictResolverTest.java
new file mode 100644
index 00000000..0c7b035f
--- /dev/null
+++ b/framework/src/maven/apache-maven-3.3.3/maven-compat/src/test/java/org/apache/maven/repository/legacy/resolver/conflict/NearestConflictResolverTest.java
@@ -0,0 +1,107 @@
+package org.apache.maven.repository.legacy.resolver.conflict;
+
+/*
+ * 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.resolver.ResolutionNode;
+import org.apache.maven.repository.legacy.resolver.conflict.NearestConflictResolver;
+
+/**
+ * Tests <code>NearestConflictResolver</code>.
+ *
+ * @author <a href="mailto:markhobson@gmail.com">Mark Hobson</a>
+ * @see NearestConflictResolver
+ */
+public class NearestConflictResolverTest
+ extends AbstractConflictResolverTest
+{
+ // constructors -----------------------------------------------------------
+
+ public NearestConflictResolverTest()
+ throws Exception
+ {
+ super("nearest");
+ }
+
+ // tests ------------------------------------------------------------------
+
+ /**
+ * Tests that <code>a:1.0</code> wins in the scenario:
+ * <pre>
+ * a:1.0
+ * b:1.0 -> a:2.0
+ * </pre>
+ */
+ public void testDepth()
+ {
+ ResolutionNode a1n = new ResolutionNode( a1, Collections.EMPTY_LIST );
+ ResolutionNode b1n = new ResolutionNode( b1, Collections.EMPTY_LIST );
+ ResolutionNode a2n = new ResolutionNode( a2, Collections.EMPTY_LIST, b1n );
+
+ assertResolveConflict( a1n, a1n, a2n );
+ }
+
+ /**
+ * Tests that <code>a:1.0</code> wins in the scenario:
+ * <pre>
+ * b:1.0 -> a:2.0
+ * a:1.0
+ * </pre>
+ */
+ public void testDepthReversed()
+ {
+ ResolutionNode b1n = new ResolutionNode( b1, Collections.EMPTY_LIST );
+ ResolutionNode a2n = new ResolutionNode( a2, Collections.EMPTY_LIST, b1n );
+ ResolutionNode a1n = new ResolutionNode( a1, Collections.EMPTY_LIST );
+
+ assertResolveConflict( a1n, a2n, a1n );
+ }
+
+ /**
+ * Tests that <code>a:1.0</code> wins in the scenario:
+ * <pre>
+ * a:1.0
+ * a:2.0
+ * </pre>
+ */
+ public void testEqual()
+ {
+ ResolutionNode a1n = new ResolutionNode( a1, Collections.EMPTY_LIST );
+ ResolutionNode a2n = new ResolutionNode( a2, Collections.EMPTY_LIST );
+
+ assertResolveConflict( a1n, a1n, a2n );
+ }
+
+ /**
+ * Tests that <code>a:2.0</code> wins in the scenario:
+ * <pre>
+ * a:2.0
+ * a:1.0
+ * </pre>
+ */
+ public void testEqualReversed()
+ {
+ ResolutionNode a2n = new ResolutionNode( a2, Collections.EMPTY_LIST );
+ ResolutionNode a1n = new ResolutionNode( a1, Collections.EMPTY_LIST );
+
+ assertResolveConflict( a2n, a2n, a1n );
+ }
+}
diff --git a/framework/src/maven/apache-maven-3.3.3/maven-compat/src/test/java/org/apache/maven/repository/legacy/resolver/conflict/NewestConflictResolverTest.java b/framework/src/maven/apache-maven-3.3.3/maven-compat/src/test/java/org/apache/maven/repository/legacy/resolver/conflict/NewestConflictResolverTest.java
new file mode 100644
index 00000000..68d19d6c
--- /dev/null
+++ b/framework/src/maven/apache-maven-3.3.3/maven-compat/src/test/java/org/apache/maven/repository/legacy/resolver/conflict/NewestConflictResolverTest.java
@@ -0,0 +1,107 @@
+package org.apache.maven.repository.legacy.resolver.conflict;
+
+/*
+ * 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.resolver.ResolutionNode;
+import org.apache.maven.repository.legacy.resolver.conflict.NewestConflictResolver;
+
+/**
+ * Tests <code>NewestConflictResolver</code>.
+ *
+ * @author <a href="mailto:markhobson@gmail.com">Mark Hobson</a>
+ * @see NewestConflictResolver
+ */
+public class NewestConflictResolverTest
+ extends AbstractConflictResolverTest
+{
+ // constructors -----------------------------------------------------------
+
+ public NewestConflictResolverTest()
+ throws Exception
+ {
+ super("newest");
+ }
+
+ // tests ------------------------------------------------------------------
+
+ /**
+ * Tests that <code>a:2.0</code> wins in the scenario:
+ * <pre>
+ * a:1.0
+ * b:1.0 -> a:2.0
+ * </pre>
+ */
+ public void testDepth()
+ {
+ ResolutionNode a1n = new ResolutionNode( a1, Collections.EMPTY_LIST );
+ ResolutionNode b1n = new ResolutionNode( b1, Collections.EMPTY_LIST );
+ ResolutionNode a2n = new ResolutionNode( a2, Collections.EMPTY_LIST, b1n );
+
+ assertResolveConflict( a2n, a1n, a2n );
+ }
+
+ /**
+ * Tests that <code>a:2.0</code> wins in the scenario:
+ * <pre>
+ * b:1.0 -> a:2.0
+ * a:1.0
+ * </pre>
+ */
+ public void testDepthReversed()
+ {
+ ResolutionNode b1n = new ResolutionNode( b1, Collections.EMPTY_LIST );
+ ResolutionNode a2n = new ResolutionNode( a2, Collections.EMPTY_LIST, b1n );
+ ResolutionNode a1n = new ResolutionNode( a1, Collections.EMPTY_LIST );
+
+ assertResolveConflict( a2n, a2n, a1n );
+ }
+
+ /**
+ * Tests that <code>a:2.0</code> wins in the scenario:
+ * <pre>
+ * a:1.0
+ * a:2.0
+ * </pre>
+ */
+ public void testEqual()
+ {
+ ResolutionNode a1n = new ResolutionNode( a1, Collections.EMPTY_LIST );
+ ResolutionNode a2n = new ResolutionNode( a2, Collections.EMPTY_LIST );
+
+ assertResolveConflict( a2n, a1n, a2n );
+ }
+
+ /**
+ * Tests that <code>a:2.0</code> wins in the scenario:
+ * <pre>
+ * a:2.0
+ * a:1.0
+ * </pre>
+ */
+ public void testEqualReversed()
+ {
+ ResolutionNode a2n = new ResolutionNode( a2, Collections.EMPTY_LIST );
+ ResolutionNode a1n = new ResolutionNode( a1, Collections.EMPTY_LIST );
+
+ assertResolveConflict( a2n, a2n, a1n );
+ }
+}
diff --git a/framework/src/maven/apache-maven-3.3.3/maven-compat/src/test/java/org/apache/maven/repository/legacy/resolver/conflict/OldestConflictResolverTest.java b/framework/src/maven/apache-maven-3.3.3/maven-compat/src/test/java/org/apache/maven/repository/legacy/resolver/conflict/OldestConflictResolverTest.java
new file mode 100644
index 00000000..6b06d34e
--- /dev/null
+++ b/framework/src/maven/apache-maven-3.3.3/maven-compat/src/test/java/org/apache/maven/repository/legacy/resolver/conflict/OldestConflictResolverTest.java
@@ -0,0 +1,107 @@
+package org.apache.maven.repository.legacy.resolver.conflict;
+
+/*
+ * 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.resolver.ResolutionNode;
+import org.apache.maven.repository.legacy.resolver.conflict.OldestConflictResolver;
+
+/**
+ * Tests <code>OldestConflictResolver</code>.
+ *
+ * @author <a href="mailto:markhobson@gmail.com">Mark Hobson</a>
+ * @see OldestConflictResolver
+ */
+public class OldestConflictResolverTest
+ extends AbstractConflictResolverTest
+{
+ // constructors -----------------------------------------------------------
+
+ public OldestConflictResolverTest()
+ throws Exception
+ {
+ super("oldest");
+ }
+
+ // tests ------------------------------------------------------------------
+
+ /**
+ * Tests that <code>a:1.0</code> wins in the scenario:
+ * <pre>
+ * a:1.0
+ * b:1.0 -> a:2.0
+ * </pre>
+ */
+ public void testDepth()
+ {
+ ResolutionNode a1n = new ResolutionNode( a1, Collections.EMPTY_LIST );
+ ResolutionNode b1n = new ResolutionNode( b1, Collections.EMPTY_LIST );
+ ResolutionNode a2n = new ResolutionNode( a2, Collections.EMPTY_LIST, b1n );
+
+ assertResolveConflict( a1n, a1n, a2n );
+ }
+
+ /**
+ * Tests that <code>a:1.0</code> wins in the scenario:
+ * <pre>
+ * b:1.0 -> a:2.0
+ * a:1.0
+ * </pre>
+ */
+ public void testDepthReversed()
+ {
+ ResolutionNode b1n = new ResolutionNode( b1, Collections.EMPTY_LIST );
+ ResolutionNode a2n = new ResolutionNode( a2, Collections.EMPTY_LIST, b1n );
+ ResolutionNode a1n = new ResolutionNode( a1, Collections.EMPTY_LIST );
+
+ assertResolveConflict( a1n, a2n, a1n );
+ }
+
+ /**
+ * Tests that <code>a:1.0</code> wins in the scenario:
+ * <pre>
+ * a:1.0
+ * a:2.0
+ * </pre>
+ */
+ public void testEqual()
+ {
+ ResolutionNode a1n = new ResolutionNode( a1, Collections.EMPTY_LIST );
+ ResolutionNode a2n = new ResolutionNode( a2, Collections.EMPTY_LIST );
+
+ assertResolveConflict( a1n, a1n, a2n );
+ }
+
+ /**
+ * Tests that <code>a:1.0</code> wins in the scenario:
+ * <pre>
+ * a:2.0
+ * a:1.0
+ * </pre>
+ */
+ public void testEqualReversed()
+ {
+ ResolutionNode a2n = new ResolutionNode( a2, Collections.EMPTY_LIST );
+ ResolutionNode a1n = new ResolutionNode( a1, Collections.EMPTY_LIST );
+
+ assertResolveConflict( a1n, a2n, a1n );
+ }
+}
diff --git a/framework/src/maven/apache-maven-3.3.3/maven-compat/src/test/java/org/apache/maven/repository/metadata/DefaultClasspathTransformationTest.java b/framework/src/maven/apache-maven-3.3.3/maven-compat/src/test/java/org/apache/maven/repository/metadata/DefaultClasspathTransformationTest.java
new file mode 100644
index 00000000..4f40516c
--- /dev/null
+++ b/framework/src/maven/apache-maven-3.3.3/maven-compat/src/test/java/org/apache/maven/repository/metadata/DefaultClasspathTransformationTest.java
@@ -0,0 +1,120 @@
+package org.apache.maven.repository.metadata;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more contributor license
+ * agreements. See the NOTICE file distributed with this work for additional information regarding
+ * copyright ownership. The ASF licenses this file to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance with the License. You may obtain a
+ * copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software distributed under the License
+ * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
+ * or implied. See the License for the specific language governing permissions and limitations under
+ * the License.
+ */
+
+import org.apache.maven.artifact.ArtifactScopeEnum;
+import org.apache.maven.repository.metadata.ArtifactMetadata;
+import org.apache.maven.repository.metadata.ClasspathContainer;
+import org.apache.maven.repository.metadata.ClasspathTransformation;
+import org.apache.maven.repository.metadata.MetadataGraph;
+import org.apache.maven.repository.metadata.MetadataGraphEdge;
+import org.apache.maven.repository.metadata.MetadataGraphVertex;
+import org.codehaus.plexus.PlexusTestCase;
+
+/**
+ *
+ * @author <a href="mailto:oleg@codehaus.org">Oleg Gusakov</a>
+ *
+ */
+
+public class DefaultClasspathTransformationTest
+extends PlexusTestCase
+{
+ ClasspathTransformation transform;
+
+ MetadataGraph graph;
+
+ MetadataGraphVertex v1;
+ MetadataGraphVertex v2;
+ MetadataGraphVertex v3;
+ MetadataGraphVertex v4;
+ //------------------------------------------------------------------------------------------
+ @Override
+ protected void setUp() throws Exception
+ {
+ super.setUp();
+ transform = (ClasspathTransformation) lookup( ClasspathTransformation.ROLE, "default" );
+
+ graph = new MetadataGraph( 4, 3 );
+ /*
+ * v2
+ * v1<
+ * v3-v4
+ *
+ */
+ v1 = graph.addVertex(new ArtifactMetadata("g","a1","1.0"));
+ graph.setEntry(v1);
+ v2 = graph.addVertex(new ArtifactMetadata("g","a2","1.0"));
+ v3 = graph.addVertex(new ArtifactMetadata("g","a3","1.0"));
+ v4 = graph.addVertex(new ArtifactMetadata("g","a4","1.0"));
+
+ // v1-->v2
+ graph.addEdge(v1, v2, new MetadataGraphEdge( "1.1", true, null, null, 2, 1 ) );
+ graph.addEdge(v1, v2, new MetadataGraphEdge( "1.2", true, null, null, 2, 2 ) );
+
+ // v1-->v3
+ graph.addEdge(v1, v3, new MetadataGraphEdge( "1.1", true, null, null, 2, 1 ) );
+ graph.addEdge(v1, v3, new MetadataGraphEdge( "1.2", true, null, null, 4, 2 ) );
+
+ // v3-->v4
+ graph.addEdge(v3, v4, new MetadataGraphEdge( "1.1", true, ArtifactScopeEnum.runtime, null, 2, 2 ) );
+ graph.addEdge(v3, v4, new MetadataGraphEdge( "1.2", true, ArtifactScopeEnum.test, null, 2, 2 ) );
+ }
+ //------------------------------------------------------------------------------------------
+ public void testCompileClasspathTransform()
+ throws Exception
+ {
+ ClasspathContainer res;
+
+ res = transform.transform( graph, ArtifactScopeEnum.compile, false );
+
+ assertNotNull("null classpath container after compile transform", res );
+ assertNotNull("null classpath after compile transform", res.getClasspath() );
+ assertEquals("compile classpath should have 3 entries", 3, res.getClasspath().size() );
+ }
+ //------------------------------------------------------------------------------------------
+ public void testRuntimeClasspathTransform()
+ throws Exception
+ {
+ ClasspathContainer res;
+
+ res = transform.transform( graph, ArtifactScopeEnum.runtime, false );
+
+ assertNotNull("null classpath container after runtime transform", res );
+ assertNotNull("null classpath after runtime transform", res.getClasspath() );
+ assertEquals("runtime classpath should have 4 entries", 4, res.getClasspath().size() );
+
+ ArtifactMetadata md = res.getClasspath().get(3);
+ assertEquals("runtime artifact version should be 1.1", "1.1", md.getVersion() );
+ }
+ //------------------------------------------------------------------------------------------
+ public void testTestClasspathTransform()
+ throws Exception
+ {
+ ClasspathContainer res;
+
+ res = transform.transform( graph, ArtifactScopeEnum.test, false );
+
+ assertNotNull("null classpath container after runtime transform", res );
+ assertNotNull("null classpath after runtime transform", res.getClasspath() );
+ assertEquals("runtime classpath should have 4 entries", 4, res.getClasspath().size() );
+
+ ArtifactMetadata md = res.getClasspath().get(3);
+ assertEquals("test artifact version should be 1.2", "1.2", md.getVersion() );
+ }
+ //------------------------------------------------------------------------------------------
+ //------------------------------------------------------------------------------------------
+}
diff --git a/framework/src/maven/apache-maven-3.3.3/maven-compat/src/test/java/org/apache/maven/repository/metadata/DefaultGraphConflictResolutionPolicyTest.java b/framework/src/maven/apache-maven-3.3.3/maven-compat/src/test/java/org/apache/maven/repository/metadata/DefaultGraphConflictResolutionPolicyTest.java
new file mode 100644
index 00000000..31832c33
--- /dev/null
+++ b/framework/src/maven/apache-maven-3.3.3/maven-compat/src/test/java/org/apache/maven/repository/metadata/DefaultGraphConflictResolutionPolicyTest.java
@@ -0,0 +1,59 @@
+package org.apache.maven.repository.metadata;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more contributor license
+ * agreements. See the NOTICE file distributed with this work for additional information regarding
+ * copyright ownership. The ASF licenses this file to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance with the License. You may obtain a
+ * copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software distributed under the License
+ * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
+ * or implied. See the License for the specific language governing permissions and limitations under
+ * the License.
+ */
+
+import org.apache.maven.repository.metadata.GraphConflictResolutionPolicy;
+import org.apache.maven.repository.metadata.MetadataGraphEdge;
+import org.codehaus.plexus.PlexusTestCase;
+
+/**
+ *
+ * @author <a href="mailto:oleg@codehaus.org">Oleg Gusakov</a>
+ *
+ */
+
+public class DefaultGraphConflictResolutionPolicyTest
+extends PlexusTestCase
+{
+ GraphConflictResolutionPolicy policy;
+ MetadataGraphEdge e1;
+ MetadataGraphEdge e2;
+ MetadataGraphEdge e3;
+ //------------------------------------------------------------------------------------------
+ @Override
+ protected void setUp() throws Exception
+ {
+ super.setUp();
+ policy = (GraphConflictResolutionPolicy) lookup( GraphConflictResolutionPolicy.ROLE, "default" );
+ e1 = new MetadataGraphEdge( "1.1", true, null, null, 2, 1 );
+ e2 = new MetadataGraphEdge( "1.2", true, null, null, 3, 2 );
+ e3 = new MetadataGraphEdge( "1.2", true, null, null, 2, 3 );
+ }
+ //------------------------------------------------------------------------------------------
+ public void testDefaultPolicy()
+ throws Exception
+ {
+ MetadataGraphEdge res;
+
+ res = policy.apply( e1, e2 );
+ assertEquals( "Wrong depth edge selected", "1.1", res.getVersion() );
+
+ res = policy.apply( e1, e3 );
+ assertEquals( "Wrong version edge selected", "1.2", res.getVersion() );
+ }
+ //------------------------------------------------------------------------------------------
+ //------------------------------------------------------------------------------------------
+}
diff --git a/framework/src/maven/apache-maven-3.3.3/maven-compat/src/test/java/org/apache/maven/repository/metadata/DefaultGraphConflictResolverTest.java b/framework/src/maven/apache-maven-3.3.3/maven-compat/src/test/java/org/apache/maven/repository/metadata/DefaultGraphConflictResolverTest.java
new file mode 100644
index 00000000..4fba8f54
--- /dev/null
+++ b/framework/src/maven/apache-maven-3.3.3/maven-compat/src/test/java/org/apache/maven/repository/metadata/DefaultGraphConflictResolverTest.java
@@ -0,0 +1,153 @@
+package org.apache.maven.repository.metadata;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more contributor license
+ * agreements. See the NOTICE file distributed with this work for additional information regarding
+ * copyright ownership. The ASF licenses this file to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance with the License. You may obtain a
+ * copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software distributed under the License
+ * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
+ * or implied. See the License for the specific language governing permissions and limitations under
+ * the License.
+ */
+
+import org.apache.maven.artifact.ArtifactScopeEnum;
+import org.apache.maven.repository.metadata.ArtifactMetadata;
+import org.apache.maven.repository.metadata.GraphConflictResolver;
+import org.apache.maven.repository.metadata.MetadataGraph;
+import org.apache.maven.repository.metadata.MetadataGraphEdge;
+import org.apache.maven.repository.metadata.MetadataGraphVertex;
+import org.codehaus.plexus.PlexusTestCase;
+import org.codehaus.plexus.logging.Logger;
+
+/**
+ *
+ * @author <a href="mailto:oleg@codehaus.org">Oleg Gusakov</a>
+ *
+ */
+
+public class DefaultGraphConflictResolverTest
+extends PlexusTestCase
+{
+ Logger log;
+
+ GraphConflictResolver resolver;
+
+ MetadataGraph graph;
+
+ MetadataGraphVertex v1;
+ MetadataGraphVertex v2;
+ MetadataGraphVertex v3;
+ MetadataGraphVertex v4;
+ //------------------------------------------------------------------------------------------
+ @Override
+ protected void setUp() throws Exception
+ {
+ super.setUp();
+ resolver = (GraphConflictResolver) lookup( GraphConflictResolver.ROLE, "default" );
+
+ /*
+ * v2
+ * v1<
+ * v3-v4
+ *
+ */
+ graph = new MetadataGraph( 4, 3 );
+ v1 = graph.addVertex(new ArtifactMetadata("g","a1","1.0"));
+ graph.setEntry(v1);
+ v2 = graph.addVertex(new ArtifactMetadata("g","a2","1.0"));
+ v3 = graph.addVertex(new ArtifactMetadata("g","a3","1.0"));
+ v4 = graph.addVertex(new ArtifactMetadata("g","a4","1.0"));
+
+ // v1-->v2
+ graph.addEdge(v1, v2, new MetadataGraphEdge( "1.1", true, null, null, 2, 1 ) );
+ graph.addEdge(v1, v2, new MetadataGraphEdge( "1.2", true, null, null, 2, 2 ) );
+
+ // v1-->v3
+ graph.addEdge(v1, v3, new MetadataGraphEdge( "1.1", true, null, null, 2, 1 ) );
+ graph.addEdge(v1, v3, new MetadataGraphEdge( "1.2", true, null, null, 4, 2 ) );
+
+ // v3-->v4
+ graph.addEdge(v3, v4, new MetadataGraphEdge( "1.1", true, ArtifactScopeEnum.runtime, null, 2, 1 ) );
+ graph.addEdge(v3, v4, new MetadataGraphEdge( "1.2", true, ArtifactScopeEnum.provided, null, 2, 2 ) );
+ }
+ //------------------------------------------------------------------------------------------
+ public void testCompileResolution()
+ throws Exception
+ {
+ MetadataGraph res;
+
+ res = resolver.resolveConflicts( graph, ArtifactScopeEnum.compile );
+
+ assertNotNull("null graph after resolver", res );
+ assertNotNull("no vertices in the resulting graph after resolver", res.getVertices() );
+
+ assertNotNull("no edges in the resulting graph after resolver", res.getExcidentEdges(v1) );
+
+ assertEquals( "wrong # of vertices in the resulting graph after resolver", 4, res.getVertices().size() );
+ assertEquals( "wrong # of excident edges in the resulting graph entry after resolver", 2, res.getExcidentEdges(v1).size() );
+
+ assertEquals( "wrong # of v2 incident edges in the resulting graph after resolver", 1, res.getIncidentEdges(v2).size() );
+ assertEquals( "wrong edge v1-v2 in the resulting graph after resolver", "1.2", res.getIncidentEdges(v2).get(0).getVersion() );
+
+ assertEquals( "wrong # of edges v1-v3 in the resulting graph after resolver", 1, res.getIncidentEdges(v3).size() );
+ assertEquals( "wrong edge v1-v3 in the resulting graph after resolver", "1.1", res.getIncidentEdges(v3).get(0).getVersion() );
+
+ assertEquals( "wrong # of edges v3-v4 in the resulting graph after resolver", 1, res.getIncidentEdges(v4).size() );
+ assertEquals( "wrong edge v3-v4 in the resulting graph after resolver", "1.2", res.getIncidentEdges(v4).get(0).getVersion() );
+ }
+ //------------------------------------------------------------------------------------------
+ public void testRuntimeResolution()
+ throws Exception
+ {
+ MetadataGraph res;
+
+ res = resolver.resolveConflicts( graph, ArtifactScopeEnum.runtime );
+
+ assertNotNull("null graph after resolver", res );
+ assertNotNull("no vertices in the resulting graph after resolver", res.getVertices() );
+ assertNotNull("no edges in the resulting graph after resolver", res.getExcidentEdges(v1) );
+
+ assertEquals( "wrong # of vertices in the resulting graph after resolver", 4, res.getVertices().size() );
+ assertEquals( "wrong # of excident edges in the resulting graph entry after resolver", 2, res.getExcidentEdges(v1).size() );
+
+ assertEquals( "wrong # of v2 incident edges in the resulting graph after resolver", 1, res.getIncidentEdges(v2).size() );
+ assertEquals( "wrong edge v1-v2 in the resulting graph after resolver", "1.2", res.getIncidentEdges(v2).get(0).getVersion() );
+
+ assertEquals( "wrong # of edges v1-v3 in the resulting graph after resolver", 1, res.getIncidentEdges(v3).size() );
+ assertEquals( "wrong edge v1-v3 in the resulting graph after resolver", "1.1", res.getIncidentEdges(v3).get(0).getVersion() );
+
+ assertEquals( "wrong # of edges v3-v4 in the resulting graph after resolver", 1, res.getIncidentEdges(v4).size() );
+ assertEquals( "wrong edge v3-v4 in the resulting graph after resolver", "1.1", res.getIncidentEdges(v4).get(0).getVersion() );
+ }
+ //------------------------------------------------------------------------------------------
+ public void testTestResolution()
+ throws Exception
+ {
+ MetadataGraph res;
+
+ res = resolver.resolveConflicts( graph, ArtifactScopeEnum.test );
+
+ assertNotNull("null graph after resolver", res );
+ assertNotNull("no vertices in the resulting graph after resolver", res.getVertices() );
+ assertNotNull("no edges in the resulting graph after resolver", res.getExcidentEdges(v1) );
+
+ assertEquals( "wrong # of vertices in the resulting graph after resolver", 4, res.getVertices().size() );
+ assertEquals( "wrong # of excident edges in the resulting graph entry after resolver", 2, res.getExcidentEdges(v1).size() );
+
+ assertEquals( "wrong # of v2 incident edges in the resulting graph after resolver", 1, res.getIncidentEdges(v2).size() );
+ assertEquals( "wrong edge v1-v2 in the resulting graph after resolver", "1.2", res.getIncidentEdges(v2).get(0).getVersion() );
+
+ assertEquals( "wrong # of edges v1-v3 in the resulting graph after resolver", 1, res.getIncidentEdges(v3).size() );
+ assertEquals( "wrong edge v1-v3 in the resulting graph after resolver", "1.1", res.getIncidentEdges(v3).get(0).getVersion() );
+
+ assertEquals( "wrong # of edges v3-v4 in the resulting graph after resolver", 1, res.getIncidentEdges(v4).size() );
+ assertEquals( "wrong edge v3-v4 in the resulting graph after resolver", "1.2", res.getIncidentEdges(v4).get(0).getVersion() );
+ }
+ //------------------------------------------------------------------------------------------
+ //------------------------------------------------------------------------------------------
+}
diff --git a/framework/src/maven/apache-maven-3.3.3/maven-compat/src/test/java/org/apache/maven/repository/metadata/TestMetadataSource.java b/framework/src/maven/apache-maven-3.3.3/maven-compat/src/test/java/org/apache/maven/repository/metadata/TestMetadataSource.java
new file mode 100644
index 00000000..dd9a9001
--- /dev/null
+++ b/framework/src/maven/apache-maven-3.3.3/maven-compat/src/test/java/org/apache/maven/repository/metadata/TestMetadataSource.java
@@ -0,0 +1,99 @@
+package org.apache.maven.repository.metadata;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+import 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.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;
+import org.codehaus.plexus.component.annotations.Component;
+import org.codehaus.plexus.component.annotations.Requirement;
+
+@Component(role = ArtifactMetadataSource.class)
+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() );
+ }
+
+}