Skip to content

[WIP] Migrate to JUnit 5 and away from PlexusTestCase#812

Draft
olamy wants to merge 7 commits into
masterfrom
junit5-plexus-test
Draft

[WIP] Migrate to JUnit 5 and away from PlexusTestCase#812
olamy wants to merge 7 commits into
masterfrom
junit5-plexus-test

Conversation

@olamy
Copy link
Copy Markdown
Member

@olamy olamy commented Aug 4, 2025

Signed-off-by: Olivier Lamy olamy@apache.org

Following this checklist to help us incorporate your
contribution quickly and easily:

  • Your pull request should address just one issue, without pulling in other changes.
  • Write a pull request description that is detailed enough to understand what the pull request does, how, and why.
  • Each commit in the pull request should have a meaningful subject line and body.
    Note that commits might be squashed by a maintainer on merge.
  • Write unit tests that match behavioral changes, where the tests fail if the changes to the runtime are not applied.
    This may not always be possible but is a best-practice.
  • Run mvn verify to make sure basic checks pass.
    A more thorough check will be performed on your pull request automatically.
  • You have run the integration tests successfully (mvn -Prun-its verify).

If your pull request is about ~20 lines of code you don't need to sign an
Individual Contributor License Agreement if you are unsure
please ask on the developers list.

To make clear that you license your contribution under
the Apache License Version 2.0, January 2004
you have to acknowledge this by using the following check-box.

olamy added 7 commits August 4, 2025 10:05
Signed-off-by: Olivier Lamy <olamy@apache.org>
Signed-off-by: Olivier Lamy <olamy@apache.org>
Signed-off-by: Olivier Lamy <olamy@apache.org>
Signed-off-by: Olivier Lamy <olamy@apache.org>
Signed-off-by: Olivier Lamy <olamy@apache.org>
Signed-off-by: Olivier Lamy <olamy@apache.org>
Signed-off-by: Olivier Lamy <olamy@apache.org>
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Migrates Maven Wagon’s unit and TCK tests from JUnit 4 / JUnit3-style TestCase/PlexusTestCase patterns toward JUnit 5 (Jupiter) and updates parts of the test infrastructure and DI wiring to reduce reliance on legacy Plexus metadata.

Changes:

  • Migrated many test classes from JUnit 4/JUnit3 (TestCase, @RunWith(Suite.class), @Ignore) to JUnit 5 (@Test, @Suite, @Disabled, Jupiter assertions).
  • Reworked parts of the test harness/TCK to stop extending PlexusTestCase and to adjust Wagon lookup/initialization patterns.
  • Updated multiple module POMs and the root build to swap JUnit dependencies and add/replace Plexus/Sisu-related dependencies/plugins.

Reviewed changes

Copilot reviewed 69 out of 69 changed files in this pull request and generated 15 comments.

Show a summary per file
File Description
wagon-tcks/wagon-tck-http/src/main/java/org/apache/maven/wagon/tck/http/HttpWagonTests.java Migrates lifecycle annotations to JUnit 5 and changes how Wagon/configurator are obtained.
wagon-tcks/wagon-tck-http/src/main/java/org/apache/maven/wagon/tck/http/GetWagonTests.java Migrates to JUnit 5, modernizes exception assertions, and adjusts timeout test behavior.
wagon-tcks/wagon-tck-http/src/main/java/org/apache/maven/wagon/tck/http/fixture/LatencyServlet.java Replaces manual stream closing with try-with-resources.
wagon-tcks/wagon-tck-http/src/main/java/org/apache/maven/wagon/tck/http/Assertions.java Switches assertions to JUnit 5 and adjusts assertion argument order.
wagon-tcks/wagon-tck-http/sample-tck-consumer/pom.xml Updates sample consumer to use JUnit Jupiter API.
wagon-tcks/wagon-tck-http/pom.xml Replaces Plexus container dependency and adds Awaitility/Sisu dependencies for the TCK.
wagon-providers/wagon-webdav-jackrabbit/src/test/java/org/apache/maven/wagon/providers/webdav/HttpClientWagonTest.java Converts test class to JUnit 5.
wagon-providers/wagon-webdav-jackrabbit/pom.xml Updates test dependency from JUnit 4 to JUnit Jupiter API and removes Plexus metadata plugin config.
wagon-providers/wagon-ssh/pom.xml Updates test dependencies (Sisu + JUnit Jupiter API).
wagon-providers/wagon-ssh-common/src/test/java/org/apache/maven/wagon/providers/ssh/knownhost/FileKnownHostsProviderTest.java Converts to JUnit 5 and updates assertions/lifecycle annotations.
wagon-providers/wagon-ssh-common/pom.xml Updates test dependency from JUnit 4 to JUnit Jupiter API.
wagon-providers/wagon-ssh-common-test/pom.xml Swaps Plexus container default for Sisu dependencies in test module.
wagon-providers/wagon-http/src/test/resources/META-INF/plexus/components.xml Removes test Plexus component configuration metadata.
wagon-providers/wagon-http/src/test/java/org/apache/maven/wagon/providers/http/TckTest.java Migrates JUnit 4 Suite runner to JUnit Platform Suite.
wagon-providers/wagon-http/src/test/java/org/apache/maven/wagon/providers/http/HugeFileDownloadTest.java Replaces PlexusTestCase usage with Plexus JUnit 5 annotation and updates paths/wagon creation.
wagon-providers/wagon-http/src/test/java/org/apache/maven/wagon/providers/http/HttpWagonTimeoutTest.java Migrates to JUnit 5, replaces temp file helper, updates assertions.
wagon-providers/wagon-http/src/test/java/org/apache/maven/wagon/providers/http/HttpWagonTest.java Adds explicit raw Wagon creation override for new test harness.
wagon-providers/wagon-http/src/test/java/org/apache/maven/wagon/providers/http/HttpWagonHttpServerTestCase.java Removes PlexusTestCase inheritance and switches setup to JUnit 5.
wagon-providers/wagon-http/src/test/java/org/apache/maven/wagon/providers/http/HttpWagonErrorTest.java Migrates to JUnit 5 and replaces temp file helper usage.
wagon-providers/wagon-http/src/test/java/org/apache/maven/wagon/providers/http/HttpsWagonTest.java Removes PlexusTestCase helper usage for keystore paths and updates to JUnit 5 style.
wagon-providers/wagon-http/src/test/java/org/apache/maven/wagon/providers/http/HttpsWagonPreemptiveTest.java Removes PlexusTestCase helper usage for keystore paths and updates to JUnit 5 style.
wagon-providers/wagon-http/src/test/java/org/apache/maven/wagon/providers/http/HttpClientWagonTest.java Converts test class to JUnit 5 and uses Jupiter assertions.
wagon-providers/wagon-http/src/test/java/org/apache/maven/wagon/providers/http/BasicAuthScopeTest.java Converts to JUnit 5 assertions and annotations.
wagon-providers/wagon-http/src/test/java/org/apache/maven/wagon/providers/http/AbstractHttpClientWagonTest.java Migrates to JUnit 5 and modernizes inner runnable usage.
wagon-providers/wagon-http/pom.xml Updates test dependencies to JUnit Jupiter API and adds Sisu/Plexus testing dependencies.
wagon-providers/wagon-http-shared/src/test/java/org/apache/maven/wagon/shared/http/EncodingUtilTest.java Converts JUnit3-style tests to JUnit 5.
wagon-providers/wagon-http-shared/pom.xml Updates test dependency from JUnit 4 to JUnit Jupiter API.
wagon-providers/wagon-http-lightweight/src/test/resources/META-INF/plexus/components.xml Removes test Plexus component configuration metadata.
wagon-providers/wagon-http-lightweight/src/test/java/org/apache/maven/wagon/providers/http/TckTest.java Migrates JUnit 4 Suite runner to JUnit Platform Suite.
wagon-providers/wagon-http-lightweight/src/test/java/org/apache/maven/wagon/providers/http/LightweightHttpWagonTest.java Adds explicit raw Wagon creation override and migrates assertions to JUnit 5.
wagon-providers/wagon-http-lightweight/src/test/java/org/apache/maven/wagon/providers/http/LightweightHttpsWagonTest.java Removes PlexusTestCase helper usage for keystore paths.
wagon-providers/wagon-http-lightweight/pom.xml Updates test dependency from JUnit 4 to JUnit Jupiter API and adds JUnit Platform Suite.
wagon-providers/wagon-ftp/src/test/java/org/apache/maven/wagon/providers/ftp/FtpWagonTest.java Updates tests for new harness and switches to JUnit 5 exception assertions.
wagon-providers/wagon-ftp/src/main/java/org/apache/maven/wagon/providers/ftp/FtpWagon.java Replaces Plexus metadata comments with javax.inject annotations and adds constructor-based config.
wagon-providers/wagon-ftp/src/main/java/org/apache/maven/wagon/providers/ftp/FtpsWagon.java Adds javax.inject annotations and constructor-based config for FTPS.
wagon-providers/wagon-ftp/src/main/java/org/apache/maven/wagon/providers/ftp/FtpHttpWagon.java Adds javax.inject annotations and constructor-based config for FTP-over-HTTP.
wagon-providers/wagon-ftp/pom.xml Adds javax.inject and Sisu inject dependency changes.
wagon-providers/wagon-file/src/test/java/org/apache/maven/wagon/providers/file/FileWagonTest.java Switches to JUnit 5 + Plexus injection for wagon instance.
wagon-providers/wagon-file/src/main/java/org/apache/maven/wagon/providers/file/FileWagon.java Adds javax.inject @Named in place of Plexus metadata comment.
wagon-providers/wagon-file/pom.xml Adds javax.inject and plexus-testing test dependency.
wagon-provider-test/src/main/java/org/apache/maven/wagon/WagonTestCase.java Major refactor of shared provider test harness for JUnit 5 and reduced PlexusTestCase usage.
wagon-provider-test/src/main/java/org/apache/maven/wagon/StreamingWagonTestCase.java Migrates shared streaming tests to JUnit 5 and modern I/O helpers.
wagon-provider-test/src/main/java/org/apache/maven/wagon/http/HttpWagonTestCase.java Migrates HTTP provider shared tests to JUnit 5 and modern I/O.
wagon-provider-test/src/main/java/org/apache/maven/wagon/CommandExecutorTestCase.java Migrates command executor shared tests to JUnit 5 and injection-based executor acquisition.
wagon-provider-test/pom.xml Updates dependencies for Jupiter + Sisu/Plexus testing stack.
wagon-provider-api/src/test/java/org/apache/maven/wagon/TransferFailedExceptionTest.java Converts to JUnit 5.
wagon-provider-api/src/test/java/org/apache/maven/wagon/StreamWagonTest.java Converts to JUnit 5 and updates assertion/exception patterns.
wagon-provider-api/src/test/java/org/apache/maven/wagon/ResourceDoesNotExistExceptionTest.java Converts to JUnit 5.
wagon-provider-api/src/test/java/org/apache/maven/wagon/repository/RepositoryTest.java Converts to JUnit 5.
wagon-provider-api/src/test/java/org/apache/maven/wagon/repository/RepositoryPermissionsTest.java Converts to JUnit 5.
wagon-provider-api/src/test/java/org/apache/maven/wagon/proxy/ProxyInfoUtilsTest.java Converts to JUnit 5 and updates assertions.
wagon-provider-api/src/test/java/org/apache/maven/wagon/proxy/ProxyInfoTest.java Converts to JUnit 5.
wagon-provider-api/src/test/java/org/apache/maven/wagon/PermissionModeUtilsTest.java Converts to JUnit 5.
wagon-provider-api/src/test/java/org/apache/maven/wagon/PathUtilsTest.java Converts to JUnit 5 assertions and adds explicit @Test annotations.
wagon-provider-api/src/test/java/org/apache/maven/wagon/observers/ChecksumObserverTest.java Converts to JUnit 5 and adds lifecycle annotations.
wagon-provider-api/src/test/java/org/apache/maven/wagon/NotAuthorizedExceptionTest.java Converts to JUnit 5.
wagon-provider-api/src/test/java/org/apache/maven/wagon/LazyFileOutputStreamTest.java Converts to JUnit 5 and adjusts temp file naming.
wagon-provider-api/src/test/java/org/apache/maven/wagon/events/TransferEventTest.java Converts to JUnit 5.
wagon-provider-api/src/test/java/org/apache/maven/wagon/events/TransferEventSupportTest.java Converts to JUnit 5 and adds @beforeeach.
wagon-provider-api/src/test/java/org/apache/maven/wagon/events/SessionEventTest.java Converts to JUnit 5.
wagon-provider-api/src/test/java/org/apache/maven/wagon/events/SessionEventSupportTest.java Converts to JUnit 5 and adds @beforeeach.
wagon-provider-api/src/test/java/org/apache/maven/wagon/CannotConnectExceptionTest.java Converts to JUnit 5.
wagon-provider-api/src/test/java/org/apache/maven/wagon/authentication/AuthenticationInfoTest.java Converts to JUnit 5.
wagon-provider-api/src/test/java/org/apache/maven/wagon/authentication/AuthenticationExceptionTest.java Converts to JUnit 5.
wagon-provider-api/src/test/java/org/apache/maven/wagon/AbstractWagonTest.java Converts to JUnit 5 and modernizes exception assertions.
wagon-provider-api/src/main/java/org/apache/maven/wagon/Wagon.java Removes legacy ROLE constant from public API.
wagon-provider-api/src/main/java/org/apache/maven/wagon/CommandExecutor.java Removes legacy ROLE constant from public API.
wagon-provider-api/pom.xml Updates test dependency from JUnit 4 to JUnit Jupiter API.
pom.xml Updates dependencyManagement and build plugins for the new testing/DI approach.
Comments suppressed due to low confidence (1)

wagon-tcks/wagon-tck-http/src/main/java/org/apache/maven/wagon/tck/http/HttpWagonTests.java:123

  • afterAll() calls container.release(configurator), but configurator is no longer a container-managed component (it's created via 'new'). Releasing a non-managed instance can throw ComponentLifecycleException or be a no-op depending on Plexus implementation. Either obtain configurator from the container (so release is valid) or remove the release() call.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread pom.xml
<groupId>org.junit.platform</groupId>
<artifactId>junit-platform-suite</artifactId>
<version>1.9.3</version>
</dependency>
Comment on lines 34 to 42
<dependencies>
<dependency>
<groupId>org.codehaus.plexus</groupId>
<artifactId>plexus-container-default</artifactId>
<scope>compile</scope>
<groupId>org.eclipse.sisu</groupId>
<artifactId>org.eclipse.sisu.plexus</artifactId>
</dependency>
<dependency>
<groupId>org.eclipse.sisu</groupId>
<artifactId>org.eclipse.sisu.inject</artifactId>
</dependency>
Comment on lines +66 to 71
@BeforeEach
public void beforeEach() throws Exception {
serverFixture = new ServerFixture(isSsl());
serverFixture.start();
wagon = (Wagon) container.lookup(Wagon.ROLE, configurator.getWagonHint());
wagon = container.lookup(Wagon.class);
}
Comment on lines 82 to 85
container = new DefaultPlexusContainer();

configurator = (WagonTestCaseConfigurator) container.lookup(WagonTestCaseConfigurator.class.getName());
configurator = new WagonTestCaseConfigurator();
}
Comment on lines +132 to 134
protected String getName() {
return getClass().getName();
}
Comment on lines +35 to 37
@Singleton
@Named("ftps")
public class FtpsWagon extends FtpWagon {
Comment on lines +45 to +56
@Inject
public FtpsWagon(
@Named("${passiveMode:-true}") boolean passiveMode,
@Named("${controlEncoding:-ISO-8859-1}") String controlEncoding,
@Named("${securityProtocol:-TLS}") String securityProtocol,
@Named("${implicit:-false}") boolean implicit,
@Named("${endpointChecking:-true}") boolean endpointChecking) {
super(passiveMode, controlEncoding);
this.securityProtocol = securityProtocol;
this.implicit = implicit;
this.endpointChecking = endpointChecking;
}
Comment on lines +34 to +43
@Singleton
@Named("ftph")
public class FtpHttpWagon extends FtpWagon {

private static final Logger LOG = LoggerFactory.getLogger(FtpHttpWagon.class);

public FtpHttpWagon(
@Named("${passiveMode}") boolean passiveMode, @Named("${controlEncoding}") String controlEncoding) {
super(passiveMode, controlEncoding);
}
Comment on lines +142 to +147
// try {
// logger.info("Waiting 60 seconds for wagon timeout.");
// t.join(ONE_MINUTE);
// } catch (InterruptedException e) {
// e.printStackTrace();
// }
Comment on lines 72 to 76
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-api</artifactId>
<scope>test</scope>
</dependency>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants