You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@maven.apache.org by sl...@apache.org on 2021/01/08 18:42:22 UTC
[maven] 04/08: Move the 3 PlexusTestCase classes into a new test
support module
This is an automated email from the ASF dual-hosted git repository.
slachiewicz pushed a commit to branch MNG-7035-maven5
in repository https://gitbox.apache.org/repos/asf/maven.git
commit 00745c9e56707e4460a712cdb4599a188b62f56f
Author: Guillaume Nodet <gn...@gmail.com>
AuthorDate: Fri Jan 8 11:55:15 2021 +0100
Move the 3 PlexusTestCase classes into a new test support module
---
maven-compat/pom.xml | 5 +
.../AbstractArtifactComponentTestCase.java | 2 +-
.../factory/DefaultArtifactFactoryTest.java | 2 +-
.../transform/TransformationManagerTest.java | 2 +-
.../manager/DefaultProfileManagerTest.java | 2 +-
.../project/AbstractMavenProjectTestCase.java | 2 +-
.../repository/LegacyRepositorySystemTest.java | 2 +-
.../maven/repository/MirrorProcessorTest.java | 2 +-
.../repository/legacy/DefaultWagonManagerTest.java | 2 +-
.../legacy/LegacyRepositorySystemTest.java | 2 +-
.../resolver/DefaultArtifactCollectorTest.java | 2 +-
.../conflict/AbstractConflictResolverTest.java | 3 +-
.../DefaultClasspathTransformationTest.java | 2 +-
.../metadata/DefaultGraphConflictResolverTest.java | 2 +-
maven-core/pom.xml | 5 +
.../maven/AbstractCoreMavenComponentTestCase.java | 1 +
.../test/java/org/apache/maven/PlexusTestCase.java | 317 --------------------
.../artifact/handler/ArtifactHandlerTest.java | 2 +-
.../maven/lifecycle/DefaultLifecyclesTest.java | 2 +-
.../project/AbstractMavenProjectTestCase.java | 2 +-
.../apache/maven/project/PomConstructionTest.java | 2 +-
.../project/artifact/MavenMetadataSourceTest.java | 2 +-
.../internal/DefaultRuntimeInformationTest.java | 2 +-
.../settings/PomConstructionWithSettingsTest.java | 8 +-
maven-resolver-provider/pom.xml | 5 +
.../test/java/org/apache/maven/PlexusTestCase.java | 318 ---------------------
.../internal/AbstractRepositoryTestCase.java | 2 +-
maven-test-support/pom.xml | 73 +++++
.../org/apache/maven/test}/PlexusTestCase.java | 11 +-
pom.xml | 6 +
30 files changed, 123 insertions(+), 667 deletions(-)
diff --git a/maven-compat/pom.xml b/maven-compat/pom.xml
index 73d1a24..be1cd35 100644
--- a/maven-compat/pom.xml
+++ b/maven-compat/pom.xml
@@ -100,6 +100,11 @@ under the License.
</dependency>
<dependency>
+ <groupId>org.apache.maven</groupId>
+ <artifactId>maven-test-support</artifactId>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
<groupId>org.codehaus.plexus</groupId>
<artifactId>plexus-cipher</artifactId>
<scope>test</scope>
diff --git a/maven-compat/src/test/java/org/apache/maven/artifact/AbstractArtifactComponentTestCase.java b/maven-compat/src/test/java/org/apache/maven/artifact/AbstractArtifactComponentTestCase.java
index 6e6b8ca..e099f65 100644
--- a/maven-compat/src/test/java/org/apache/maven/artifact/AbstractArtifactComponentTestCase.java
+++ b/maven-compat/src/test/java/org/apache/maven/artifact/AbstractArtifactComponentTestCase.java
@@ -32,7 +32,7 @@ import java.util.List;
import javax.inject.Inject;
-import org.apache.maven.PlexusTestCase;
+import org.apache.maven.test.PlexusTestCase;
import org.apache.maven.artifact.factory.ArtifactFactory;
import org.apache.maven.artifact.repository.ArtifactRepository;
import org.apache.maven.artifact.repository.ArtifactRepositoryPolicy;
diff --git a/maven-compat/src/test/java/org/apache/maven/artifact/factory/DefaultArtifactFactoryTest.java b/maven-compat/src/test/java/org/apache/maven/artifact/factory/DefaultArtifactFactoryTest.java
index f9de70c..14721cd 100644
--- a/maven-compat/src/test/java/org/apache/maven/artifact/factory/DefaultArtifactFactoryTest.java
+++ b/maven-compat/src/test/java/org/apache/maven/artifact/factory/DefaultArtifactFactoryTest.java
@@ -23,7 +23,7 @@ import java.util.Collections;
import javax.inject.Inject;
-import org.apache.maven.PlexusTestCase;
+import org.apache.maven.test.PlexusTestCase;
import org.apache.maven.artifact.Artifact;
import org.apache.maven.artifact.versioning.VersionRange;
import org.codehaus.plexus.ContainerConfiguration;
diff --git a/maven-compat/src/test/java/org/apache/maven/artifact/transform/TransformationManagerTest.java b/maven-compat/src/test/java/org/apache/maven/artifact/transform/TransformationManagerTest.java
index 887ae05..f7072f3 100644
--- a/maven-compat/src/test/java/org/apache/maven/artifact/transform/TransformationManagerTest.java
+++ b/maven-compat/src/test/java/org/apache/maven/artifact/transform/TransformationManagerTest.java
@@ -26,7 +26,7 @@ import org.apache.maven.repository.legacy.resolver.transform.SnapshotTransformat
import org.codehaus.plexus.ContainerConfiguration;
import org.codehaus.plexus.DefaultPlexusContainer;
import org.codehaus.plexus.PlexusConstants;
-import org.apache.maven.PlexusTestCase;
+import org.apache.maven.test.PlexusTestCase;
import org.junit.Test;
import static org.junit.Assert.assertEquals;
diff --git a/maven-compat/src/test/java/org/apache/maven/profiles/manager/DefaultProfileManagerTest.java b/maven-compat/src/test/java/org/apache/maven/profiles/manager/DefaultProfileManagerTest.java
index 3951ccf..e5e5410 100644
--- a/maven-compat/src/test/java/org/apache/maven/profiles/manager/DefaultProfileManagerTest.java
+++ b/maven-compat/src/test/java/org/apache/maven/profiles/manager/DefaultProfileManagerTest.java
@@ -22,7 +22,7 @@ package org.apache.maven.profiles.manager;
import java.util.List;
import java.util.Properties;
-import org.apache.maven.PlexusTestCase;
+import org.apache.maven.test.PlexusTestCase;
import org.apache.maven.model.Activation;
import org.apache.maven.model.ActivationProperty;
import org.apache.maven.model.Profile;
diff --git a/maven-compat/src/test/java/org/apache/maven/project/AbstractMavenProjectTestCase.java b/maven-compat/src/test/java/org/apache/maven/project/AbstractMavenProjectTestCase.java
index 002ae55..5694e23 100644
--- a/maven-compat/src/test/java/org/apache/maven/project/AbstractMavenProjectTestCase.java
+++ b/maven-compat/src/test/java/org/apache/maven/project/AbstractMavenProjectTestCase.java
@@ -25,7 +25,7 @@ import java.util.Collections;
import javax.inject.Inject;
-import org.apache.maven.PlexusTestCase;
+import org.apache.maven.test.PlexusTestCase;
import org.apache.maven.artifact.repository.ArtifactRepository;
import org.apache.maven.artifact.repository.layout.ArtifactRepositoryLayout;
import org.apache.maven.model.building.ModelBuildingException;
diff --git a/maven-compat/src/test/java/org/apache/maven/repository/LegacyRepositorySystemTest.java b/maven-compat/src/test/java/org/apache/maven/repository/LegacyRepositorySystemTest.java
index b346e5e..251d116 100644
--- a/maven-compat/src/test/java/org/apache/maven/repository/LegacyRepositorySystemTest.java
+++ b/maven-compat/src/test/java/org/apache/maven/repository/LegacyRepositorySystemTest.java
@@ -36,7 +36,7 @@ import org.apache.maven.repository.legacy.LegacyRepositorySystem;
import org.codehaus.plexus.ContainerConfiguration;
import org.codehaus.plexus.DefaultPlexusContainer;
import org.codehaus.plexus.PlexusConstants;
-import org.apache.maven.PlexusTestCase;
+import org.apache.maven.test.PlexusTestCase;
import org.eclipse.aether.DefaultRepositorySystemSession;
import org.eclipse.aether.internal.impl.SimpleLocalRepositoryManagerFactory;
import org.eclipse.aether.repository.LocalRepository;
diff --git a/maven-compat/src/test/java/org/apache/maven/repository/MirrorProcessorTest.java b/maven-compat/src/test/java/org/apache/maven/repository/MirrorProcessorTest.java
index 1c40aea..7fc75c3 100644
--- a/maven-compat/src/test/java/org/apache/maven/repository/MirrorProcessorTest.java
+++ b/maven-compat/src/test/java/org/apache/maven/repository/MirrorProcessorTest.java
@@ -23,7 +23,7 @@ import java.util.Arrays;
import java.util.Collections;
import java.util.List;
-import org.apache.maven.PlexusTestCase;
+import org.apache.maven.test.PlexusTestCase;
import org.apache.maven.artifact.repository.ArtifactRepository;
import org.apache.maven.artifact.repository.layout.DefaultRepositoryLayout;
import org.apache.maven.repository.legacy.repository.ArtifactRepositoryFactory;
diff --git a/maven-compat/src/test/java/org/apache/maven/repository/legacy/DefaultWagonManagerTest.java b/maven-compat/src/test/java/org/apache/maven/repository/legacy/DefaultWagonManagerTest.java
index 1c28bd4..37aa4e7 100644
--- a/maven-compat/src/test/java/org/apache/maven/repository/legacy/DefaultWagonManagerTest.java
+++ b/maven-compat/src/test/java/org/apache/maven/repository/legacy/DefaultWagonManagerTest.java
@@ -46,7 +46,7 @@ import org.apache.maven.wagon.observers.Debug;
import org.codehaus.plexus.ContainerConfiguration;
import org.codehaus.plexus.DefaultPlexusContainer;
import org.codehaus.plexus.PlexusConstants;
-import org.apache.maven.PlexusTestCase;
+import org.apache.maven.test.PlexusTestCase;
import org.codehaus.plexus.util.FileUtils;
import org.junit.After;
import org.junit.Before;
diff --git a/maven-compat/src/test/java/org/apache/maven/repository/legacy/LegacyRepositorySystemTest.java b/maven-compat/src/test/java/org/apache/maven/repository/legacy/LegacyRepositorySystemTest.java
index 476c2cf..0499e80 100644
--- a/maven-compat/src/test/java/org/apache/maven/repository/legacy/LegacyRepositorySystemTest.java
+++ b/maven-compat/src/test/java/org/apache/maven/repository/legacy/LegacyRepositorySystemTest.java
@@ -26,7 +26,7 @@ import org.apache.maven.settings.Server;
import org.codehaus.plexus.ContainerConfiguration;
import org.codehaus.plexus.DefaultPlexusContainer;
import org.codehaus.plexus.PlexusConstants;
-import org.apache.maven.PlexusTestCase;
+import org.apache.maven.test.PlexusTestCase;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
diff --git a/maven-compat/src/test/java/org/apache/maven/repository/legacy/resolver/DefaultArtifactCollectorTest.java b/maven-compat/src/test/java/org/apache/maven/repository/legacy/resolver/DefaultArtifactCollectorTest.java
index c0e1d49..ba84b82 100644
--- a/maven-compat/src/test/java/org/apache/maven/repository/legacy/resolver/DefaultArtifactCollectorTest.java
+++ b/maven-compat/src/test/java/org/apache/maven/repository/legacy/resolver/DefaultArtifactCollectorTest.java
@@ -49,7 +49,7 @@ import org.apache.maven.artifact.versioning.VersionRange;
import org.apache.maven.repository.legacy.metadata.MetadataResolutionRequest;
import org.codehaus.plexus.ContainerConfiguration;
import org.codehaus.plexus.PlexusConstants;
-import org.apache.maven.PlexusTestCase;
+import org.apache.maven.test.PlexusTestCase;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
diff --git a/maven-compat/src/test/java/org/apache/maven/repository/legacy/resolver/conflict/AbstractConflictResolverTest.java b/maven-compat/src/test/java/org/apache/maven/repository/legacy/resolver/conflict/AbstractConflictResolverTest.java
index fd890b0..f60773f 100644
--- a/maven-compat/src/test/java/org/apache/maven/repository/legacy/resolver/conflict/AbstractConflictResolverTest.java
+++ b/maven-compat/src/test/java/org/apache/maven/repository/legacy/resolver/conflict/AbstractConflictResolverTest.java
@@ -30,12 +30,11 @@ import org.apache.maven.artifact.versioning.VersionRange;
import org.codehaus.plexus.ContainerConfiguration;
import org.codehaus.plexus.DefaultPlexusContainer;
import org.codehaus.plexus.PlexusConstants;
-import org.apache.maven.PlexusTestCase;
+import org.apache.maven.test.PlexusTestCase;
import org.junit.After;
import org.junit.Before;
import javax.inject.Inject;
-import java.util.Collections;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
diff --git a/maven-compat/src/test/java/org/apache/maven/repository/metadata/DefaultClasspathTransformationTest.java b/maven-compat/src/test/java/org/apache/maven/repository/metadata/DefaultClasspathTransformationTest.java
index c5d9d82..0da1be9 100644
--- a/maven-compat/src/test/java/org/apache/maven/repository/metadata/DefaultClasspathTransformationTest.java
+++ b/maven-compat/src/test/java/org/apache/maven/repository/metadata/DefaultClasspathTransformationTest.java
@@ -16,7 +16,7 @@ package org.apache.maven.repository.metadata;
*/
import org.apache.maven.artifact.ArtifactScopeEnum;
-import org.apache.maven.PlexusTestCase;
+import org.apache.maven.test.PlexusTestCase;
import org.junit.Before;
import org.junit.Test;
diff --git a/maven-compat/src/test/java/org/apache/maven/repository/metadata/DefaultGraphConflictResolverTest.java b/maven-compat/src/test/java/org/apache/maven/repository/metadata/DefaultGraphConflictResolverTest.java
index be09db2..cba9491 100644
--- a/maven-compat/src/test/java/org/apache/maven/repository/metadata/DefaultGraphConflictResolverTest.java
+++ b/maven-compat/src/test/java/org/apache/maven/repository/metadata/DefaultGraphConflictResolverTest.java
@@ -16,7 +16,7 @@ package org.apache.maven.repository.metadata;
*/
import org.apache.maven.artifact.ArtifactScopeEnum;
-import org.apache.maven.PlexusTestCase;
+import org.apache.maven.test.PlexusTestCase;
import org.codehaus.plexus.logging.Logger;
import org.junit.Before;
import org.junit.Test;
diff --git a/maven-core/pom.xml b/maven-core/pom.xml
index 661ae9b..4316ff7 100644
--- a/maven-core/pom.xml
+++ b/maven-core/pom.xml
@@ -156,6 +156,11 @@ under the License.
<artifactId>xmlunit-assertj</artifactId>
<scope>test</scope>
</dependency>
+ <dependency>
+ <groupId>org.apache.maven</groupId>
+ <artifactId>maven-test-support</artifactId>
+ <scope>test</scope>
+ </dependency>
</dependencies>
<build>
diff --git a/maven-core/src/test/java/org/apache/maven/AbstractCoreMavenComponentTestCase.java b/maven-core/src/test/java/org/apache/maven/AbstractCoreMavenComponentTestCase.java
index 3ae311f..edee9ca 100644
--- a/maven-core/src/test/java/org/apache/maven/AbstractCoreMavenComponentTestCase.java
+++ b/maven-core/src/test/java/org/apache/maven/AbstractCoreMavenComponentTestCase.java
@@ -45,6 +45,7 @@ import org.apache.maven.project.MavenProject;
import org.apache.maven.project.ProjectBuildingRequest;
import org.apache.maven.repository.RepositorySystem;
import org.apache.maven.repository.internal.MavenRepositorySystemUtils;
+import org.apache.maven.test.PlexusTestCase;
import org.codehaus.plexus.ContainerConfiguration;
import org.codehaus.plexus.DefaultPlexusContainer;
import org.codehaus.plexus.PlexusConstants;
diff --git a/maven-core/src/test/java/org/apache/maven/PlexusTestCase.java b/maven-core/src/test/java/org/apache/maven/PlexusTestCase.java
deleted file mode 100644
index d3801b8..0000000
--- a/maven-core/src/test/java/org/apache/maven/PlexusTestCase.java
+++ /dev/null
@@ -1,317 +0,0 @@
-package org.apache.maven;
-
-/*
- * 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.
- */
-
-/*
- * Copyright 2001-2006 Codehaus Foundation.
- *
- * Licensed 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.codehaus.plexus.ContainerConfiguration;
-import org.codehaus.plexus.DefaultContainerConfiguration;
-import org.codehaus.plexus.DefaultPlexusContainer;
-import org.codehaus.plexus.PlexusContainer;
-import org.codehaus.plexus.PlexusContainerException;
-import org.codehaus.plexus.component.repository.exception.ComponentLifecycleException;
-import org.codehaus.plexus.component.repository.exception.ComponentLookupException;
-import org.codehaus.plexus.configuration.PlexusConfiguration;
-import org.codehaus.plexus.context.Context;
-import org.codehaus.plexus.context.DefaultContext;
-import org.junit.After;
-import org.junit.Before;
-
-/**
- * This is a slightly modified version of the original plexus class
- * available at https://raw.githubusercontent.com/codehaus-plexus/plexus-containers/master/plexus-container-default/src/main/java/org/codehaus/plexus/PlexusTestCase.java
- * in order to migrate the tests to JUnit 4.
- *
- * @author Jason van Zyl
- * @author <a href="mailto:trygvis@inamo.no">Trygve Laugstøl</a>
- * @author <a href="mailto:michal@codehaus.org">Michal Maczka</a>
- * @author Guillaume Nodet
- */
-public abstract class PlexusTestCase
-{
- private PlexusContainer container;
-
- private static String basedir;
-
- @Before
- public void setUp()
- throws Exception
- {
- basedir = getBasedir();
- }
-
- @SuppressWarnings("ResultOfMethodCallIgnored")
- protected void setupContainer()
- {
- // ----------------------------------------------------------------------------
- // Context Setup
- // ----------------------------------------------------------------------------
-
- DefaultContext context = new DefaultContext();
-
- context.put( "basedir", getBasedir() );
-
- customizeContext( context );
-
- boolean hasPlexusHome = context.contains( "plexus.home" );
-
- if ( !hasPlexusHome )
- {
- File f = getTestFile( "target/plexus-home" );
-
- if ( !f.isDirectory() )
- {
- f.mkdir();
- }
-
- context.put( "plexus.home", f.getAbsolutePath() );
- }
-
- // ----------------------------------------------------------------------------
- // Configuration
- // ----------------------------------------------------------------------------
-
- String config = getCustomConfigurationName();
-
- ContainerConfiguration containerConfiguration = new DefaultContainerConfiguration()
- .setName( "test" )
- .setContext( context.getContextData() );
-
- if ( config != null )
- {
- containerConfiguration.setContainerConfiguration( config );
- }
- else
- {
- String resource = getConfigurationName( null );
-
- containerConfiguration.setContainerConfiguration( resource );
- }
-
- customizeContainerConfiguration( containerConfiguration );
-
- try
- {
- container = new DefaultPlexusContainer( containerConfiguration );
- }
- catch ( PlexusContainerException e )
- {
- throw new IllegalArgumentException( "Failed to create plexus container.", e );
- }
- }
-
- /**
- * Allow custom test case implementations do augment the default container configuration before
- * executing tests.
- *
- * @param containerConfiguration {@link ContainerConfiguration}.
- */
- protected void customizeContainerConfiguration( ContainerConfiguration containerConfiguration )
- {
- }
-
- protected void customizeContext( Context context )
- {
- }
-
- protected PlexusConfiguration customizeComponentConfiguration()
- {
- return null;
- }
-
- @After
- public void tearDown()
- throws Exception
- {
- if ( container != null )
- {
- container.dispose();
-
- container = null;
- }
- }
-
- protected PlexusContainer getContainer()
- {
- if ( container == null )
- {
- setupContainer();
- }
-
- return container;
- }
-
- protected InputStream getConfiguration()
- throws Exception
- {
- return getConfiguration( null );
- }
-
- protected InputStream getConfiguration( String subname )
- throws Exception
- {
- return getResourceAsStream( getConfigurationName( subname ) );
- }
-
- protected String getCustomConfigurationName()
- {
- return null;
- }
-
- /**
- * Allow the retrieval of a container configuration that is based on the name
- * of the test class being run. So if you have a test class called org.foo.FunTest, then
- * this will produce a resource name of org/foo/FunTest.xml which would be used to
- * configure the Plexus container before running your test.
- *
- * @param subname the subname
- * @return A configruation name
- */
- protected String getConfigurationName( String subname )
- {
- return getClass().getName().replace( '.', '/' ) + ".xml";
- }
-
- protected InputStream getResourceAsStream( String resource )
- {
- return getClass().getResourceAsStream( resource );
- }
-
- protected ClassLoader getClassLoader()
- {
- return getClass().getClassLoader();
- }
-
- // ----------------------------------------------------------------------
- // Container access
- // ----------------------------------------------------------------------
-
- @SuppressWarnings("unchecked")
- protected <T> T lookup( String componentKey )
- throws ComponentLookupException
- {
- return (T) getContainer().lookup( componentKey );
- }
-
- @SuppressWarnings("unchecked")
- protected <T> T lookup( String role,
- String roleHint )
- throws ComponentLookupException
- {
- return (T) getContainer().lookup( role, roleHint );
- }
-
- protected <T> T lookup( Class<T> componentClass )
- throws ComponentLookupException
- {
- return getContainer().lookup( componentClass );
- }
-
- protected <T> T lookup( Class<T> componentClass, String roleHint )
- throws ComponentLookupException
- {
- return getContainer().lookup( componentClass, roleHint );
- }
-
- protected void release( Object component )
- throws ComponentLifecycleException
- {
- getContainer().release( component );
- }
-
- // ----------------------------------------------------------------------
- // Helper methods for sub classes
- // ----------------------------------------------------------------------
-
- public static File getTestFile( String path )
- {
- return new File( getBasedir(), path );
- }
-
- public static File getTestFile( String basedir,
- String path )
- {
- File basedirFile = new File( basedir );
-
- if ( !basedirFile.isAbsolute() )
- {
- basedirFile = getTestFile( basedir );
- }
-
- return new File( basedirFile, path );
- }
-
- public static String getTestPath( String path )
- {
- return getTestFile( path ).getAbsolutePath();
- }
-
- public static String getTestPath( String basedir,
- String path )
- {
- return getTestFile( basedir, path ).getAbsolutePath();
- }
-
- public static String getBasedir()
- {
- if ( basedir != null )
- {
- return basedir;
- }
-
- basedir = System.getProperty( "basedir" );
-
- if ( basedir == null )
- {
- basedir = new File( "" ).getAbsolutePath();
- }
-
- return basedir;
- }
-
- public String getTestConfiguration()
- {
- return getTestConfiguration( getClass() );
- }
-
- public static String getTestConfiguration( Class<?> clazz )
- {
- String s = clazz.getName().replace( '.', '/' );
-
- return s.substring( 0, s.indexOf( "$" ) ) + ".xml";
- }
-}
diff --git a/maven-core/src/test/java/org/apache/maven/artifact/handler/ArtifactHandlerTest.java b/maven-core/src/test/java/org/apache/maven/artifact/handler/ArtifactHandlerTest.java
index 180e6ff..5290780 100644
--- a/maven-core/src/test/java/org/apache/maven/artifact/handler/ArtifactHandlerTest.java
+++ b/maven-core/src/test/java/org/apache/maven/artifact/handler/ArtifactHandlerTest.java
@@ -22,7 +22,7 @@ package org.apache.maven.artifact.handler;
import java.io.File;
import java.util.List;
-import org.apache.maven.PlexusTestCase;
+import org.apache.maven.test.PlexusTestCase;
import org.codehaus.plexus.util.FileUtils;
import org.junit.Test;
diff --git a/maven-core/src/test/java/org/apache/maven/lifecycle/DefaultLifecyclesTest.java b/maven-core/src/test/java/org/apache/maven/lifecycle/DefaultLifecyclesTest.java
index 1e131ab..02ac4dc 100644
--- a/maven-core/src/test/java/org/apache/maven/lifecycle/DefaultLifecyclesTest.java
+++ b/maven-core/src/test/java/org/apache/maven/lifecycle/DefaultLifecyclesTest.java
@@ -23,7 +23,7 @@ import java.util.stream.Collectors;
import javax.inject.Inject;
-import org.apache.maven.PlexusTestCase;
+import org.apache.maven.test.PlexusTestCase;
import org.codehaus.plexus.ContainerConfiguration;
import org.codehaus.plexus.DefaultPlexusContainer;
import org.codehaus.plexus.PlexusConstants;
diff --git a/maven-core/src/test/java/org/apache/maven/project/AbstractMavenProjectTestCase.java b/maven-core/src/test/java/org/apache/maven/project/AbstractMavenProjectTestCase.java
index 18a5812..d93c0f3 100644
--- a/maven-core/src/test/java/org/apache/maven/project/AbstractMavenProjectTestCase.java
+++ b/maven-core/src/test/java/org/apache/maven/project/AbstractMavenProjectTestCase.java
@@ -31,7 +31,7 @@ import org.apache.maven.repository.internal.MavenRepositorySystemUtils;
import org.codehaus.plexus.ContainerConfiguration;
import org.codehaus.plexus.DefaultPlexusContainer;
import org.codehaus.plexus.PlexusConstants;
-import org.apache.maven.PlexusTestCase;
+import org.apache.maven.test.PlexusTestCase;
import org.eclipse.aether.DefaultRepositorySystemSession;
import org.junit.After;
import org.junit.Before;
diff --git a/maven-core/src/test/java/org/apache/maven/project/PomConstructionTest.java b/maven-core/src/test/java/org/apache/maven/project/PomConstructionTest.java
index c5d76bd..0f02d80 100644
--- a/maven-core/src/test/java/org/apache/maven/project/PomConstructionTest.java
+++ b/maven-core/src/test/java/org/apache/maven/project/PomConstructionTest.java
@@ -29,7 +29,7 @@ import java.util.Properties;
import javax.inject.Inject;
-import org.apache.maven.PlexusTestCase;
+import org.apache.maven.test.PlexusTestCase;
import org.apache.maven.artifact.repository.layout.DefaultRepositoryLayout;
import org.apache.maven.model.Plugin;
import org.apache.maven.model.PluginExecution;
diff --git a/maven-core/src/test/java/org/apache/maven/project/artifact/MavenMetadataSourceTest.java b/maven-core/src/test/java/org/apache/maven/project/artifact/MavenMetadataSourceTest.java
index 5b3beac..f79b596 100644
--- a/maven-core/src/test/java/org/apache/maven/project/artifact/MavenMetadataSourceTest.java
+++ b/maven-core/src/test/java/org/apache/maven/project/artifact/MavenMetadataSourceTest.java
@@ -19,7 +19,7 @@ package org.apache.maven.project.artifact;
* under the License.
*/
-import org.apache.maven.PlexusTestCase;
+import org.apache.maven.test.PlexusTestCase;
import org.apache.maven.repository.RepositorySystem;
import org.codehaus.plexus.DefaultPlexusContainer;
import org.junit.After;
diff --git a/maven-core/src/test/java/org/apache/maven/rtinfo/internal/DefaultRuntimeInformationTest.java b/maven-core/src/test/java/org/apache/maven/rtinfo/internal/DefaultRuntimeInformationTest.java
index 09fbb4d..22dbe89 100644
--- a/maven-core/src/test/java/org/apache/maven/rtinfo/internal/DefaultRuntimeInformationTest.java
+++ b/maven-core/src/test/java/org/apache/maven/rtinfo/internal/DefaultRuntimeInformationTest.java
@@ -23,7 +23,7 @@ import org.apache.maven.rtinfo.RuntimeInformation;
import org.codehaus.plexus.ContainerConfiguration;
import org.codehaus.plexus.DefaultPlexusContainer;
import org.codehaus.plexus.PlexusConstants;
-import org.apache.maven.PlexusTestCase;
+import org.apache.maven.test.PlexusTestCase;
import org.junit.Before;
import org.junit.Test;
diff --git a/maven-core/src/test/java/org/apache/maven/settings/PomConstructionWithSettingsTest.java b/maven-core/src/test/java/org/apache/maven/settings/PomConstructionWithSettingsTest.java
index db75136..ae61c63 100644
--- a/maven-core/src/test/java/org/apache/maven/settings/PomConstructionWithSettingsTest.java
+++ b/maven-core/src/test/java/org/apache/maven/settings/PomConstructionWithSettingsTest.java
@@ -32,24 +32,20 @@ import org.apache.maven.project.harness.PomTestWrapper;
import org.apache.maven.repository.RepositorySystem;
import org.apache.maven.repository.internal.MavenRepositorySystemUtils;
import org.apache.maven.settings.io.xpp3.SettingsXpp3Reader;
-import org.checkerframework.checker.units.qual.A;
import org.codehaus.plexus.ContainerConfiguration;
import org.codehaus.plexus.DefaultPlexusContainer;
import org.codehaus.plexus.PlexusConstants;
-import org.apache.maven.PlexusTestCase;
+import org.apache.maven.test.PlexusTestCase;
import org.codehaus.plexus.util.ReaderFactory;
import org.codehaus.plexus.util.xml.pull.XmlPullParserException;
import org.eclipse.aether.DefaultRepositorySystemSession;
import org.eclipse.aether.internal.impl.SimpleLocalRepositoryManagerFactory;
import org.eclipse.aether.repository.LocalRepository;
-import org.junit.After;
import org.junit.Before;
import org.junit.Test;
import javax.inject.Inject;
-import java.io.File;
-import java.io.IOException;
-import java.io.Reader;
+
import java.util.Collections;
import static org.junit.Assert.assertEquals;
diff --git a/maven-resolver-provider/pom.xml b/maven-resolver-provider/pom.xml
index de33876..5bbeb84 100644
--- a/maven-resolver-provider/pom.xml
+++ b/maven-resolver-provider/pom.xml
@@ -84,6 +84,11 @@ under the License.
</dependency>
<!-- Testing -->
<dependency>
+ <groupId>org.apache.maven</groupId>
+ <artifactId>maven-test-support</artifactId>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
<groupId>org.apache.maven.resolver</groupId>
<artifactId>maven-resolver-connector-basic</artifactId>
<scope>test</scope>
diff --git a/maven-resolver-provider/src/test/java/org/apache/maven/PlexusTestCase.java b/maven-resolver-provider/src/test/java/org/apache/maven/PlexusTestCase.java
deleted file mode 100644
index 64dbfe5..0000000
--- a/maven-resolver-provider/src/test/java/org/apache/maven/PlexusTestCase.java
+++ /dev/null
@@ -1,318 +0,0 @@
-package org.apache.maven;
-
-/*
- * 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.
- */
-
-/*
- * Copyright 2001-2006 Codehaus Foundation.
- *
- * Licensed 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.codehaus.plexus.ContainerConfiguration;
-import org.codehaus.plexus.DefaultContainerConfiguration;
-import org.codehaus.plexus.DefaultPlexusContainer;
-import org.codehaus.plexus.PlexusContainer;
-import org.codehaus.plexus.PlexusContainerException;
-import org.codehaus.plexus.component.repository.exception.ComponentLifecycleException;
-import org.codehaus.plexus.component.repository.exception.ComponentLookupException;
-import org.codehaus.plexus.configuration.PlexusConfiguration;
-import org.codehaus.plexus.context.Context;
-import org.codehaus.plexus.context.DefaultContext;
-import org.junit.After;
-import org.junit.Before;
-
-/**
- * This is a slightly modified version of the original plexus class
- * available at https://raw.githubusercontent.com/codehaus-plexus/plexus-containers/master/plexus-container-default/src/main/java/org/codehaus/plexus/PlexusTestCase.java
- * in order to migrate the tests to JUnit 4.
- *
- * @author Jason van Zyl
- * @author <a href="mailto:trygvis@inamo.no">Trygve Laugstøl</a>
- * @author <a href="mailto:michal@codehaus.org">Michal Maczka</a>
- * @author Guillaume Nodet
- */
-public abstract class PlexusTestCase
-{
- private PlexusContainer container;
-
- private static String basedir;
-
- @Before
- public void setUp()
- throws Exception
- {
- basedir = getBasedir();
- }
-
- @SuppressWarnings("ResultOfMethodCallIgnored")
- protected void setupContainer()
- {
- // ----------------------------------------------------------------------------
- // Context Setup
- // ----------------------------------------------------------------------------
-
- DefaultContext context = new DefaultContext();
-
- context.put( "basedir", getBasedir() );
-
- customizeContext( context );
-
- boolean hasPlexusHome = context.contains( "plexus.home" );
-
- if ( !hasPlexusHome )
- {
- File f = getTestFile( "target/plexus-home" );
-
- if ( !f.isDirectory() )
- {
- f.mkdir();
- }
-
- context.put( "plexus.home", f.getAbsolutePath() );
- }
-
- // ----------------------------------------------------------------------------
- // Configuration
- // ----------------------------------------------------------------------------
-
- String config = getCustomConfigurationName();
-
- ContainerConfiguration containerConfiguration = new DefaultContainerConfiguration()
- .setName( "test" )
- .setContext( context.getContextData() );
-
- if ( config != null )
- {
- containerConfiguration.setContainerConfiguration( config );
- }
- else
- {
- String resource = getConfigurationName( null );
-
- containerConfiguration.setContainerConfiguration( resource );
- }
-
- customizeContainerConfiguration( containerConfiguration );
-
- try
- {
- container = new DefaultPlexusContainer( containerConfiguration );
- }
- catch ( PlexusContainerException e )
- {
- throw new IllegalArgumentException( "Failed to create plexus container.", e );
- }
- }
-
- /**
- * Allow custom test case implementations do augment the default container configuration before
- * executing tests.
- *
- * @param containerConfiguration {@link ContainerConfiguration}.
- */
- protected void customizeContainerConfiguration( ContainerConfiguration containerConfiguration )
- {
- }
-
- protected void customizeContext( Context context )
- {
- }
-
- protected PlexusConfiguration customizeComponentConfiguration()
- {
- return null;
- }
-
- @After
- public void tearDown()
- throws Exception
- {
- if ( container != null )
- {
- container.dispose();
-
- container = null;
- }
- }
-
- protected PlexusContainer getContainer()
- {
- if ( container == null )
- {
- setupContainer();
- }
-
- return container;
- }
-
- protected InputStream getConfiguration()
- throws Exception
- {
- return getConfiguration( null );
- }
-
- protected InputStream getConfiguration( String subname )
- throws Exception
- {
- return getResourceAsStream( getConfigurationName( subname ) );
- }
-
- protected String getCustomConfigurationName()
- {
- return null;
- }
-
- /**
- * Allow the retrieval of a container configuration that is based on the name
- * of the test class being run. So if you have a test class called org.foo.FunTest, then
- * this will produce a resource name of org/foo/FunTest.xml which would be used to
- * configure the Plexus container before running your test.
- *
- * @param subname the subname
- * @return A configruation name
- */
- protected String getConfigurationName( String subname )
- {
- return getClass().getName().replace( '.', '/' ) + ".xml";
- }
-
- protected InputStream getResourceAsStream( String resource )
- {
- return getClass().getResourceAsStream( resource );
- }
-
- protected ClassLoader getClassLoader()
- {
- return getClass().getClassLoader();
- }
-
- // ----------------------------------------------------------------------
- // Container access
- // ----------------------------------------------------------------------
-
- @SuppressWarnings("unchecked")
- protected <T> T lookup( String componentKey )
- throws ComponentLookupException
- {
- return (T) getContainer().lookup( componentKey );
- }
-
- @SuppressWarnings("unchecked")
- protected <T> T lookup( String role,
- String roleHint )
- throws ComponentLookupException
- {
- return (T) getContainer().lookup( role, roleHint );
- }
-
- protected <T> T lookup( Class<T> componentClass )
- throws ComponentLookupException
- {
- return getContainer().lookup( componentClass );
- }
-
- protected <T> T lookup( Class<T> componentClass, String roleHint )
- throws ComponentLookupException
- {
- return getContainer().lookup( componentClass, roleHint );
- }
-
- protected void release( Object component )
- throws ComponentLifecycleException
- {
- getContainer().release( component );
- }
-
- // ----------------------------------------------------------------------
- // Helper methods for sub classes
- // ----------------------------------------------------------------------
-
- public static File getTestFile( String path )
- {
- return new File( getBasedir(), path );
- }
-
- public static File getTestFile( String basedir,
- String path )
- {
- File basedirFile = new File( basedir );
-
- if ( !basedirFile.isAbsolute() )
- {
- basedirFile = getTestFile( basedir );
- }
-
- return new File( basedirFile, path );
- }
-
- public static String getTestPath( String path )
- {
- return getTestFile( path ).getAbsolutePath();
- }
-
- public static String getTestPath( String basedir,
- String path )
- {
- return getTestFile( basedir, path ).getAbsolutePath();
- }
-
- public static String getBasedir()
- {
- if ( basedir != null )
- {
- return basedir;
- }
-
- basedir = System.getProperty( "basedir" );
-
- if ( basedir == null )
- {
- basedir = new File( "" ).getAbsolutePath();
- }
-
- return basedir;
- }
-
- public String getTestConfiguration()
- {
- return getTestConfiguration( getClass() );
- }
-
- public static String getTestConfiguration( Class<?> clazz )
- {
- String s = clazz.getName().replace( '.', '/' );
-
- return s.substring( 0, s.indexOf( "$" ) ) + ".xml";
- }
-}
diff --git a/maven-resolver-provider/src/test/java/org/apache/maven/repository/internal/AbstractRepositoryTestCase.java b/maven-resolver-provider/src/test/java/org/apache/maven/repository/internal/AbstractRepositoryTestCase.java
index 825d5c5..d872e16 100644
--- a/maven-resolver-provider/src/test/java/org/apache/maven/repository/internal/AbstractRepositoryTestCase.java
+++ b/maven-resolver-provider/src/test/java/org/apache/maven/repository/internal/AbstractRepositoryTestCase.java
@@ -21,7 +21,7 @@ package org.apache.maven.repository.internal;
import java.net.MalformedURLException;
-import org.apache.maven.PlexusTestCase;
+import org.apache.maven.test.PlexusTestCase;
import org.apache.maven.repository.internal.util.ConsoleRepositoryListener;
import org.apache.maven.repository.internal.util.ConsoleTransferListener;
import org.codehaus.plexus.ContainerConfiguration;
diff --git a/maven-test-support/pom.xml b/maven-test-support/pom.xml
new file mode 100644
index 0000000..8a5821c
--- /dev/null
+++ b/maven-test-support/pom.xml
@@ -0,0 +1,73 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<!--
+Licensed to the Apache Software Foundation (ASF) under one
+or more contributor license agreements. See the NOTICE file
+distributed with this work for additional information
+regarding copyright ownership. The ASF licenses this file
+to you under the Apache License, Version 2.0 (the
+"License"); you may not use this file except in compliance
+with the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+Unless required by applicable law or agreed to in writing,
+software distributed under the License is distributed on an
+"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+KIND, either express or implied. See the License for the
+specific language governing permissions and limitations
+under the License.
+-->
+
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+
+ <parent>
+ <groupId>org.apache.maven</groupId>
+ <artifactId>maven</artifactId>
+ <version>4.0.0-alpha-1-SNAPSHOT</version>
+ </parent>
+
+ <artifactId>maven-test-support</artifactId>
+
+ <name>Maven Test Support</name>
+ <description>Test support classes for maven.</description>
+
+ <dependencies>
+ <dependency>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ <version>${junitVersion}</version>
+ </dependency>
+ <dependency>
+ <groupId>com.google.inject</groupId>
+ <artifactId>guice</artifactId>
+ <classifier>no_aop</classifier>
+ </dependency>
+ <dependency>
+ <groupId>javax.inject</groupId>
+ <artifactId>javax.inject</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.codehaus.plexus</groupId>
+ <artifactId>plexus-utils</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.codehaus.plexus</groupId>
+ <artifactId>plexus-interpolation</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.codehaus.plexus</groupId>
+ <artifactId>plexus-cipher</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.eclipse.sisu</groupId>
+ <artifactId>org.eclipse.sisu.plexus</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.codehaus.plexus</groupId>
+ <artifactId>plexus-component-annotations</artifactId>
+ </dependency>
+ </dependencies>
+
+</project>
diff --git a/maven-compat/src/test/java/org/apache/maven/PlexusTestCase.java b/maven-test-support/src/main/java/org/apache/maven/test/PlexusTestCase.java
similarity index 97%
rename from maven-compat/src/test/java/org/apache/maven/PlexusTestCase.java
rename to maven-test-support/src/main/java/org/apache/maven/test/PlexusTestCase.java
index d3801b8..0187ce1 100644
--- a/maven-compat/src/test/java/org/apache/maven/PlexusTestCase.java
+++ b/maven-test-support/src/main/java/org/apache/maven/test/PlexusTestCase.java
@@ -1,4 +1,4 @@
-package org.apache.maven;
+package org.apache.maven.test;
/*
* Licensed to the Apache Software Foundation (ASF) under one
@@ -53,7 +53,8 @@ import org.junit.Before;
/**
* This is a slightly modified version of the original plexus class
- * available at https://raw.githubusercontent.com/codehaus-plexus/plexus-containers/master/plexus-container-default/src/main/java/org/codehaus/plexus/PlexusTestCase.java
+ * available at https://raw.githubusercontent.com/codehaus-plexus/plexus-containers/master/plexus-container-default/
+ * src/main/java/org/codehaus/plexus/PlexusTestCase.java
* in order to migrate the tests to JUnit 4.
*
* @author Jason van Zyl
@@ -74,7 +75,7 @@ public abstract class PlexusTestCase
basedir = getBasedir();
}
- @SuppressWarnings("ResultOfMethodCallIgnored")
+ @SuppressWarnings( "ResultOfMethodCallIgnored" )
protected void setupContainer()
{
// ----------------------------------------------------------------------------
@@ -220,14 +221,14 @@ public abstract class PlexusTestCase
// Container access
// ----------------------------------------------------------------------
- @SuppressWarnings("unchecked")
+ @SuppressWarnings( "unchecked" )
protected <T> T lookup( String componentKey )
throws ComponentLookupException
{
return (T) getContainer().lookup( componentKey );
}
- @SuppressWarnings("unchecked")
+ @SuppressWarnings( "unchecked" )
protected <T> T lookup( String role,
String roleHint )
throws ComponentLookupException
diff --git a/pom.xml b/pom.xml
index 23f976f..6c90fb2 100644
--- a/pom.xml
+++ b/pom.xml
@@ -80,6 +80,7 @@ under the License.
</properties>
<modules>
+ <module>maven-test-support</module>
<module>maven-plugin-api</module>
<module>maven-builder-support</module>
<module>maven-model</module>
@@ -183,6 +184,11 @@ under the License.
<!--bootstrap-start-comment-->
<dependency>
<groupId>org.apache.maven</groupId>
+ <artifactId>maven-test-support</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.maven</groupId>
<artifactId>maven-model</artifactId>
<version>${project.version}</version>
</dependency>