Remove maven-test-support in favor of plexus-testing

This commit is contained in:
rfscholte 2021-05-28 18:26:03 +02:00
parent 5c45b3fe22
commit 12f3e7e878
40 changed files with 76 additions and 587 deletions

View File

@ -66,7 +66,6 @@ under the License.
- apache-maven, as it delivers the binaries
- maven-compat, only used by apache-maven distributions to support older releases
- maven-slf4j-provider, only used by apache-maven distributions
- maven-test-support, only for internal test usage
- maven-wrapper, only used by apache-maven-wrapper distributions -->
<dependencies>
<dependency>

View File

@ -100,8 +100,8 @@ under the License.
</dependency>
<dependency>
<groupId>org.apache.maven</groupId>
<artifactId>maven-test-support</artifactId>
<groupId>org.codehaus.plexus</groupId>
<artifactId>plexus-testing</artifactId>
<scope>test</scope>
</dependency>
<dependency>

View File

@ -32,7 +32,7 @@
import javax.inject.Inject;
import javax.inject.Named;
import org.apache.maven.test.PlexusTest;
import org.codehaus.plexus.testing.PlexusTest;
import org.apache.maven.artifact.factory.ArtifactFactory;
import org.apache.maven.artifact.repository.ArtifactRepository;
import org.apache.maven.artifact.repository.ArtifactRepositoryPolicy;
@ -65,10 +65,9 @@
import org.eclipse.aether.util.graph.transformer.SimpleOptionalitySelector;
import org.eclipse.aether.util.graph.traverser.FatArtifactTraverser;
import org.eclipse.aether.util.repository.SimpleArtifactDescriptorPolicy;
import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.BeforeEach;
import static org.apache.maven.test.PlexusExtension.getBasedir;
import static org.codehaus.plexus.testing.PlexusExtension.getBasedir;
import static org.junit.jupiter.api.Assertions.assertFalse;
import static org.junit.jupiter.api.Assertions.assertTrue;

View File

@ -25,10 +25,9 @@
import org.apache.maven.artifact.Artifact;
import org.apache.maven.artifact.repository.ArtifactRepository;
import org.codehaus.plexus.util.FileUtils;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import static org.apache.maven.test.PlexusExtension.getBasedir;
import static org.codehaus.plexus.testing.PlexusExtension.getBasedir;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertTrue;

View File

@ -21,7 +21,7 @@
import javax.inject.Inject;
import org.apache.maven.test.PlexusTest;
import org.codehaus.plexus.testing.PlexusTest;
import org.apache.maven.artifact.Artifact;
import org.apache.maven.artifact.versioning.VersionRange;
import org.junit.jupiter.api.Test;

View File

@ -23,12 +23,11 @@
import org.apache.maven.artifact.AbstractArtifactComponentTestCase;
import org.apache.maven.artifact.Artifact;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import javax.inject.Inject;
import static org.apache.maven.test.PlexusExtension.getBasedir;
import static org.codehaus.plexus.testing.PlexusExtension.getBasedir;
/**
* @author <a href="mailto:jason@maven.org">Jason van Zyl</a>

View File

@ -22,7 +22,7 @@
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.apache.maven.test.PlexusTest;
import org.codehaus.plexus.testing.PlexusTest;
import org.junit.jupiter.api.Test;
import static org.junit.jupiter.api.Assertions.assertEquals;

View File

@ -24,7 +24,7 @@
import javax.inject.Inject;
import org.apache.maven.test.PlexusTest;
import org.codehaus.plexus.testing.PlexusTest;
import org.apache.maven.model.Activation;
import org.apache.maven.model.ActivationProperty;
import org.apache.maven.model.Profile;

View File

@ -24,7 +24,7 @@
import javax.inject.Inject;
import org.apache.maven.test.PlexusTest;
import org.codehaus.plexus.testing.PlexusTest;
import org.apache.maven.artifact.repository.ArtifactRepository;
import org.apache.maven.artifact.repository.layout.ArtifactRepositoryLayout;
import org.apache.maven.model.building.ModelBuildingException;
@ -33,7 +33,6 @@
import org.apache.maven.repository.internal.MavenRepositorySystemUtils;
import org.codehaus.plexus.PlexusContainer;
import org.eclipse.aether.DefaultRepositorySystemSession;
import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.BeforeEach;
import static org.junit.jupiter.api.Assertions.fail;

View File

@ -23,7 +23,7 @@
import org.apache.maven.project.AbstractMavenProjectTestCase;
import static org.apache.maven.test.PlexusExtension.getTestFile;
import static org.codehaus.plexus.testing.PlexusExtension.getTestFile;
/**
* @author Jason van Zyl

View File

@ -32,16 +32,14 @@
import org.apache.maven.model.RepositoryPolicy;
import org.apache.maven.plugin.LegacySupport;
import org.apache.maven.repository.legacy.LegacyRepositorySystem;
import org.apache.maven.test.PlexusTest;
import org.codehaus.plexus.testing.PlexusTest;
import org.codehaus.plexus.PlexusContainer;
import org.eclipse.aether.DefaultRepositorySystemSession;
import org.eclipse.aether.internal.impl.SimpleLocalRepositoryManagerFactory;
import org.eclipse.aether.repository.LocalRepository;
import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import static org.apache.maven.test.PlexusExtension.getBasedir;
import static org.codehaus.plexus.testing.PlexusExtension.getBasedir;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertFalse;
import static org.junit.jupiter.api.Assertions.assertTrue;

View File

@ -22,13 +22,11 @@
import java.util.Arrays;
import java.util.List;
import org.apache.maven.test.PlexusTest;
import org.codehaus.plexus.testing.PlexusTest;
import org.apache.maven.artifact.repository.ArtifactRepository;
import org.apache.maven.artifact.repository.layout.DefaultRepositoryLayout;
import org.apache.maven.repository.legacy.repository.ArtifactRepositoryFactory;
import org.apache.maven.settings.Mirror;
import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import static org.junit.jupiter.api.Assertions.assertFalse;

View File

@ -34,7 +34,7 @@
import org.apache.maven.artifact.repository.layout.DefaultRepositoryLayout;
import org.apache.maven.artifact.versioning.VersionRange;
import org.apache.maven.repository.legacy.repository.ArtifactRepositoryFactory;
import org.apache.maven.test.PlexusTest;
import org.codehaus.plexus.testing.PlexusTest;
import org.apache.maven.wagon.ResourceDoesNotExistException;
import org.apache.maven.wagon.TransferFailedException;
import org.apache.maven.wagon.UnsupportedProtocolException;
@ -43,14 +43,11 @@
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.PlexusContainer;
import org.codehaus.plexus.util.FileUtils;
import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Disabled;
import org.junit.jupiter.api.Test;
import static org.apache.maven.test.PlexusExtension.getTestFile;
import static org.codehaus.plexus.testing.PlexusExtension.getTestFile;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertFalse;
import static org.junit.jupiter.api.Assertions.assertNotNull;

View File

@ -22,9 +22,7 @@
import org.apache.maven.artifact.repository.Authentication;
import org.apache.maven.repository.RepositorySystem;
import org.apache.maven.settings.Server;
import org.apache.maven.test.PlexusTest;
import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.BeforeEach;
import org.codehaus.plexus.testing.PlexusTest;
import org.junit.jupiter.api.Test;
import static org.junit.jupiter.api.Assertions.assertEquals;

View File

@ -49,8 +49,7 @@
import org.apache.maven.artifact.versioning.OverConstrainedVersionException;
import org.apache.maven.artifact.versioning.VersionRange;
import org.apache.maven.repository.legacy.metadata.MetadataResolutionRequest;
import org.apache.maven.test.PlexusTest;
import org.junit.jupiter.api.AfterEach;
import org.codehaus.plexus.testing.PlexusTest;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Disabled;
import org.junit.jupiter.api.Test;

View File

@ -27,9 +27,8 @@
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.test.PlexusTest;
import org.codehaus.plexus.testing.PlexusTest;
import org.codehaus.plexus.PlexusContainer;
import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.BeforeEach;
import javax.inject.Inject;

View File

@ -18,7 +18,7 @@
import javax.inject.Inject;
import org.apache.maven.artifact.ArtifactScopeEnum;
import org.apache.maven.test.PlexusTest;
import org.codehaus.plexus.testing.PlexusTest;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.BeforeEach;

View File

@ -18,7 +18,7 @@
import javax.inject.Inject;
import org.apache.maven.artifact.ArtifactScopeEnum;
import org.apache.maven.test.PlexusTest;
import org.codehaus.plexus.testing.PlexusTest;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;

View File

@ -165,8 +165,13 @@ under the License.
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.apache.maven</groupId>
<artifactId>maven-test-support</artifactId>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-params</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.codehaus.plexus</groupId>
<artifactId>plexus-testing</artifactId>
<scope>test</scope>
</dependency>
</dependencies>

View File

@ -44,9 +44,7 @@
import org.apache.maven.project.ProjectBuildingRequest;
import org.apache.maven.repository.RepositorySystem;
import org.apache.maven.repository.internal.MavenRepositorySystemUtils;
import org.apache.maven.test.PlexusTest;
import org.codehaus.plexus.ContainerConfiguration;
import org.codehaus.plexus.PlexusConstants;
import org.codehaus.plexus.testing.PlexusTest;
import org.codehaus.plexus.PlexusContainer;
import org.codehaus.plexus.util.FileUtils;
import org.eclipse.aether.DefaultRepositorySystemSession;
@ -55,7 +53,7 @@
import javax.inject.Inject;
import static org.apache.maven.test.PlexusExtension.getBasedir;
import static org.codehaus.plexus.testing.PlexusExtension.getBasedir;
@PlexusTest
public abstract class AbstractCoreMavenComponentTestCase

View File

@ -28,7 +28,7 @@
import javax.inject.Inject;
import org.junit.jupiter.api.Test;
import static org.apache.maven.test.PlexusExtension.getBasedir;
import static org.codehaus.plexus.testing.PlexusExtension.getBasedir;
import static org.hamcrest.Matchers.endsWith;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.hamcrest.MatcherAssert.assertThat;

View File

@ -24,13 +24,12 @@
import javax.inject.Inject;
import org.apache.maven.test.PlexusExtension;
import org.apache.maven.test.PlexusTest;
import org.codehaus.plexus.testing.PlexusTest;
import org.codehaus.plexus.PlexusContainer;
import org.codehaus.plexus.util.FileUtils;
import org.junit.jupiter.api.Test;
import static org.apache.maven.test.PlexusExtension.getTestFile;
import static org.codehaus.plexus.testing.PlexusExtension.getTestFile;
import static org.junit.jupiter.api.Assertions.assertEquals;
@PlexusTest

View File

@ -1,18 +1,5 @@
package org.apache.maven.execution;
import java.util.List;
import javax.inject.Inject;
import org.apache.maven.artifact.repository.ArtifactRepository;
import org.apache.maven.settings.Profile;
import org.apache.maven.settings.Repository;
import org.apache.maven.settings.Settings;
import org.apache.maven.test.PlexusTest;
import org.junit.jupiter.api.Test;
import static org.junit.jupiter.api.Assertions.assertEquals;
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
@ -31,6 +18,20 @@
* specific language governing permissions and limitations
* under the License.
*/
import java.util.List;
import javax.inject.Inject;
import org.apache.maven.artifact.repository.ArtifactRepository;
import org.apache.maven.settings.Profile;
import org.apache.maven.settings.Repository;
import org.apache.maven.settings.Settings;
import org.codehaus.plexus.testing.PlexusTest;
import org.junit.jupiter.api.Test;
import static org.junit.jupiter.api.Assertions.assertEquals;
@PlexusTest
public class DefaultMavenExecutionRequestPopulatorTest
{

View File

@ -23,8 +23,7 @@
import javax.inject.Inject;
import org.apache.maven.test.PlexusTest;
import org.junit.jupiter.api.BeforeEach;
import org.codehaus.plexus.testing.PlexusTest;
import org.junit.jupiter.api.Test;
import static org.hamcrest.MatcherAssert.assertThat;

View File

@ -46,11 +46,9 @@
import org.codehaus.plexus.PlexusContainer;
import org.codehaus.plexus.component.configurator.expression.ExpressionEvaluator;
import org.codehaus.plexus.util.dag.CycleDetectedException;
import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import static org.apache.maven.test.PlexusExtension.getTestFile;
import static org.codehaus.plexus.testing.PlexusExtension.getTestFile;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertNotNull;
import static org.junit.jupiter.api.Assertions.assertSame;

View File

@ -27,11 +27,10 @@
import org.apache.maven.model.building.ModelProblem;
import org.apache.maven.repository.RepositorySystem;
import org.apache.maven.repository.internal.MavenRepositorySystemUtils;
import org.apache.maven.test.PlexusTest;
import org.codehaus.plexus.testing.PlexusTest;
import org.codehaus.plexus.PlexusContainer;
import org.eclipse.aether.DefaultRepositoryCache;
import org.eclipse.aether.DefaultRepositorySystemSession;
import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.BeforeEach;
import javax.inject.Inject;

View File

@ -19,7 +19,7 @@
* under the License.
*/
import static org.apache.maven.test.PlexusExtension.getTestFile;
import static org.codehaus.plexus.testing.PlexusExtension.getTestFile;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.containsString;
import static org.hamcrest.Matchers.is;

View File

@ -28,7 +28,7 @@
import javax.inject.Inject;
import org.apache.maven.test.PlexusTest;
import org.codehaus.plexus.testing.PlexusTest;
import org.apache.maven.artifact.repository.layout.DefaultRepositoryLayout;
import org.apache.maven.model.Plugin;
import org.apache.maven.model.PluginExecution;
@ -39,11 +39,10 @@
import org.eclipse.aether.DefaultRepositorySystemSession;
import org.eclipse.aether.internal.impl.SimpleLocalRepositoryManagerFactory;
import org.eclipse.aether.repository.LocalRepository;
import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import static org.apache.maven.test.PlexusExtension.getBasedir;
import static org.codehaus.plexus.testing.PlexusExtension.getBasedir;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.endsWith;
import static org.hamcrest.Matchers.lessThan;

View File

@ -35,7 +35,7 @@
import org.eclipse.aether.repository.RemoteRepository;
import org.junit.jupiter.api.Test;
import static org.apache.maven.test.PlexusExtension.getBasedir;
import static org.codehaus.plexus.testing.PlexusExtension.getBasedir;
import static org.hamcrest.Matchers.startsWith;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertNotNull;

View File

@ -22,7 +22,7 @@
import javax.inject.Inject;
import org.apache.maven.repository.RepositorySystem;
import org.apache.maven.test.PlexusTest;
import org.codehaus.plexus.testing.PlexusTest;
import org.codehaus.plexus.PlexusContainer;
import org.junit.jupiter.api.Disabled;
import org.junit.jupiter.api.Test;

View File

@ -20,10 +20,7 @@
*/
import org.apache.maven.rtinfo.RuntimeInformation;
import org.apache.maven.test.PlexusTest;
import org.codehaus.plexus.ContainerConfiguration;
import org.codehaus.plexus.PlexusConstants;
import org.junit.jupiter.api.BeforeEach;
import org.codehaus.plexus.testing.PlexusTest;
import org.junit.jupiter.api.Test;
import static org.junit.jupiter.api.Assertions.assertFalse;

View File

@ -32,7 +32,7 @@
import org.apache.maven.repository.RepositorySystem;
import org.apache.maven.repository.internal.MavenRepositorySystemUtils;
import org.apache.maven.settings.io.xpp3.SettingsXpp3Reader;
import org.apache.maven.test.PlexusTest;
import org.codehaus.plexus.testing.PlexusTest;
import org.codehaus.plexus.util.ReaderFactory;
import org.codehaus.plexus.util.xml.pull.XmlPullParserException;
import org.eclipse.aether.DefaultRepositorySystemSession;
@ -43,7 +43,7 @@
import javax.inject.Inject;
import static org.apache.maven.test.PlexusExtension.getBasedir;
import static org.codehaus.plexus.testing.PlexusExtension.getBasedir;
import static org.junit.jupiter.api.Assertions.assertEquals;
@PlexusTest

View File

@ -33,8 +33,8 @@ under the License.
<dependencies>
<dependency>
<groupId>org.apache.maven</groupId>
<artifactId>maven-test-support</artifactId>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-params</artifactId>
<scope>test</scope>
</dependency>
<dependency>

View File

@ -98,8 +98,8 @@ under the License.
</dependency>
<!-- Testing -->
<dependency>
<groupId>org.apache.maven</groupId>
<artifactId>maven-test-support</artifactId>
<groupId>org.codehaus.plexus</groupId>
<artifactId>plexus-testing</artifactId>
<scope>test</scope>
</dependency>
<dependency>

View File

@ -23,19 +23,18 @@
import javax.inject.Inject;
import org.apache.maven.test.PlexusTest;
import org.apache.maven.repository.internal.util.ConsoleRepositoryListener;
import org.apache.maven.repository.internal.util.ConsoleTransferListener;
import org.codehaus.plexus.PlexusContainer;
import org.codehaus.plexus.testing.PlexusTest;
import org.eclipse.aether.DefaultRepositorySystemSession;
import org.eclipse.aether.RepositorySystem;
import org.eclipse.aether.RepositorySystemSession;
import org.eclipse.aether.repository.LocalRepository;
import org.eclipse.aether.repository.RemoteRepository;
import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.BeforeEach;
import static org.apache.maven.test.PlexusExtension.getTestFile;
import static org.codehaus.plexus.testing.PlexusExtension.getTestFile;
@PlexusTest
public abstract class AbstractRepositoryTestCase

View File

@ -1,78 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
Licensed to the Apache Software Foundation (ASF) under one
or more contributor license agreements. See the NOTICE file
distributed with this work for additional information
regarding copyright ownership. The ASF licenses this file
to you under the Apache License, Version 2.0 (the
"License"); you may not use this file except in compliance
with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing,
software distributed under the License is distributed on an
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
KIND, either express or implied. See the License for the
specific language governing permissions and limitations
under the License.
-->
<project xmlns="http://maven.apache.org/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>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-engine</artifactId>
<version>${junitVersion}</version>
</dependency>
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-params</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>

View File

@ -1,341 +0,0 @@
package org.apache.maven.test;
/*
* 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 java.util.Collections;
import org.codehaus.plexus.ContainerConfiguration;
import org.codehaus.plexus.DefaultContainerConfiguration;
import org.codehaus.plexus.DefaultPlexusContainer;
import org.codehaus.plexus.PlexusConstants;
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.jupiter.api.extension.AfterEachCallback;
import org.junit.jupiter.api.extension.BeforeEachCallback;
import org.junit.jupiter.api.extension.ExtensionContext;
/**
* 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&oslash;l</a>
* @author <a href="mailto:michal@codehaus.org">Michal Maczka</a>
* @author Guillaume Nodet
*/
public class PlexusExtension implements BeforeEachCallback, AfterEachCallback
{
private ExtensionContext context;
private PlexusContainer container;
private static String basedir;
@Override
public void beforeEach( ExtensionContext context )
throws Exception
{
basedir = getBasedir();
this.context = context;
getContainer().addComponent( getContainer(), PlexusContainer.class.getName() );
( (DefaultPlexusContainer) getContainer() ).addPlexusInjector( Collections.emptyList(),
binder -> binder.requestInjection( context.getRequiredTestInstance() ) );
}
@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 )
{
containerConfiguration.setAutoWiring( true );
containerConfiguration.setClassPathScanning( PlexusConstants.SCANNING_INDEX );
}
protected void customizeContext( Context context )
{
}
protected PlexusConfiguration customizeComponentConfiguration()
{
return null;
}
@Override
public void afterEach( ExtensionContext context )
throws Exception
{
if ( container != null )
{
container.dispose();
container = null;
}
}
public 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 )
{
Class<?> testClass = context.getRequiredTestClass();
for ( Class<?> clazz = testClass;
clazz != null;
clazz = clazz.getSuperclass() )
{
String name = clazz.getName().replace( '.', '/' ) + ".xml";
if ( testClass.getClassLoader().getResource( name ) != null )
{
return name;
}
}
return null;
}
protected InputStream getResourceAsStream( String resource )
{
return context.getRequiredTestClass().getResourceAsStream( resource );
}
protected ClassLoader getClassLoader()
{
return context.getRequiredTestClass().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( context.getRequiredTestClass() );
}
public static String getTestConfiguration( Class<?> clazz )
{
String s = clazz.getName().replace( '.', '/' );
return s.substring( 0, s.indexOf( "$" ) ) + ".xml";
}
}

View File

@ -1,38 +0,0 @@
package org.apache.maven.test;
/*
* 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.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
import org.junit.jupiter.api.extension.ExtendWith;
/**
* Plexus test
*/
@Retention( RetentionPolicy.RUNTIME )
@ExtendWith( PlexusExtension.class )
@Target( ElementType.TYPE )
public @interface PlexusTest
{
}

View File

@ -1,38 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
Licensed to the Apache Software Foundation (ASF) under one
or more contributor license agreements. See the NOTICE file
distributed with this work for additional information
regarding copyright ownership. The ASF licenses this file
to you under the Apache License, Version 2.0 (the
"License"); you may not use this file except in compliance
with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing,
software distributed under the License is distributed on an
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
KIND, either express or implied. See the License for the
specific language governing permissions and limitations
under the License.
-->
<project xmlns="http://maven.apache.org/DECORATION/1.8.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/DECORATION/1.8.0 http://maven.apache.org/xsd/decoration-1.8.0.xsd">
<edit>${project.scm.url}</edit>
<body>
<menu name="Overview">
<item name="Introduction" href="index.html"/>
<item name="JavaDocs" href="apidocs/index.html"/>
<item name="Source Xref" href="xref/index.html"/>
<!--item name="FAQ" href="faq.html"/-->
</menu>
<menu ref="parent"/>
<menu ref="reports"/>
</body>
</project>

18
pom.xml
View File

@ -83,7 +83,6 @@ under the License.
<modules>
<module>maven-bom</module>
<module>maven-test-support</module>
<module>maven-plugin-api</module>
<module>maven-builder-support</module>
<module>maven-model</module>
@ -197,11 +196,6 @@ under the License.
<artifactId>maven-compat</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>org.apache.maven</groupId>
<artifactId>maven-test-support</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>org.apache.maven</groupId>
<artifactId>maven-slf4j-provider</artifactId>
@ -456,6 +450,18 @@ under the License.
<version>2.2</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.codehaus.plexus</groupId>
<artifactId>plexus-testing</artifactId>
<version>1.0.0</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-params</artifactId>
<version>${junitVersion}</version>
<scope>test</scope>
</dependency>
</dependencies>
<!--bootstrap-start-comment-->
</dependencyManagement>