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 2026/08/18 09:40:15 UTC

(maven-wagon) 01/01: Migrate ScpWagonWithProxyTest off PlexusTestCase

This is an automated email from the ASF dual-hosted git repository.

slachiewicz pushed a commit to branch junit5-scp-proxy-test-3x
in repository https://gitbox.apache.org/repos/asf/maven-wagon.git

commit 69a1d028b0991a5fd0014bcb660de0c2e5aba006
Author: Sylwester Lachiewicz <sl...@apache.org>
AuthorDate: Tue Aug 18 11:40:05 2026 +0200

    Migrate ScpWagonWithProxyTest off PlexusTestCase
    
    Backport of the same change on master; this branch's copy was
    byte-identical to master's before its migration.
    
    This one needs a real container, unlike the other providers:
    AbstractJschWagon declares knownHostsProvider, interactiveUserInfo and
    uIKeyboardInteractive with @Inject, so constructing the wagon directly
    would leave them null and the test would keep passing while exercising
    something else.
    
    wagon-ssh also gains junit-vintage-engine: five tests here still inherit
    their methods from the published WagonTestCase.
---
 wagon-providers/wagon-ssh/pom.xml                  | 17 +++++++++++++++
 .../providers/ssh/jsch/ScpWagonWithProxyTest.java  | 25 +++++++++++++++++-----
 2 files changed, 37 insertions(+), 5 deletions(-)

diff --git a/wagon-providers/wagon-ssh/pom.xml b/wagon-providers/wagon-ssh/pom.xml
index 189d0a3f..5f4a2ce1 100644
--- a/wagon-providers/wagon-ssh/pom.xml
+++ b/wagon-providers/wagon-ssh/pom.xml
@@ -92,6 +92,23 @@ under the License.
       <classifier>classes</classifier>
       <scope>test</scope>
     </dependency>
+    <dependency>
+      <groupId>org.junit.jupiter</groupId>
+      <artifactId>junit-jupiter</artifactId>
+      <scope>test</scope>
+    </dependency>
+    <dependency>
+      <groupId>org.codehaus.plexus</groupId>
+      <artifactId>plexus-testing</artifactId>
+      <version>2.1.0</version>
+      <scope>test</scope>
+    </dependency>
+    <!-- ScpWagonTest and its siblings inherit JUnit 4 tests from the published WagonTestCase -->
+    <dependency>
+      <groupId>org.junit.vintage</groupId>
+      <artifactId>junit-vintage-engine</artifactId>
+      <scope>test</scope>
+    </dependency>
     <dependency>
       <groupId>junit</groupId>
       <artifactId>junit</artifactId>
diff --git a/wagon-providers/wagon-ssh/src/test/java/org/apache/maven/wagon/providers/ssh/jsch/ScpWagonWithProxyTest.java b/wagon-providers/wagon-ssh/src/test/java/org/apache/maven/wagon/providers/ssh/jsch/ScpWagonWithProxyTest.java
index c524bc2c..b231cc89 100644
--- a/wagon-providers/wagon-ssh/src/test/java/org/apache/maven/wagon/providers/ssh/jsch/ScpWagonWithProxyTest.java
+++ b/wagon-providers/wagon-ssh/src/test/java/org/apache/maven/wagon/providers/ssh/jsch/ScpWagonWithProxyTest.java
@@ -18,6 +18,8 @@
  */
 package org.apache.maven.wagon.providers.ssh.jsch;
 
+import javax.inject.Inject;
+import javax.inject.Named;
 import javax.servlet.ServletException;
 import javax.servlet.http.HttpServletRequest;
 import javax.servlet.http.HttpServletResponse;
@@ -34,7 +36,8 @@
 import org.apache.maven.wagon.repository.Repository;
 import org.codehaus.plexus.ContainerConfiguration;
 import org.codehaus.plexus.PlexusConstants;
-import org.codehaus.plexus.PlexusTestCase;
+import org.codehaus.plexus.testing.PlexusTest;
+import org.codehaus.plexus.testing.PlexusTestConfiguration;
 import org.eclipse.jetty.server.Handler;
 import org.eclipse.jetty.server.HttpConfiguration;
 import org.eclipse.jetty.server.HttpConnectionFactory;
@@ -42,16 +45,29 @@
 import org.eclipse.jetty.server.Server;
 import org.eclipse.jetty.server.ServerConnector;
 import org.eclipse.jetty.server.handler.AbstractHandler;
+import org.junit.jupiter.api.Test;
 
-public class ScpWagonWithProxyTest extends PlexusTestCase {
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertTrue;
+import static org.junit.jupiter.api.Assertions.fail;
+
+@PlexusTest
+public class ScpWagonWithProxyTest implements PlexusTestConfiguration {
     @Override
-    protected void customizeContainerConfiguration(ContainerConfiguration configuration) {
+    public void customizeConfiguration(ContainerConfiguration configuration) {
         // the providers are @Named beans now, so the container has to read META-INF/sisu
         configuration.setClassPathScanning(PlexusConstants.SCANNING_INDEX);
     }
 
+    // injected by the container so the wagon keeps the collaborators AbstractJschWagon
+    // declares with @Inject; constructing it directly would leave them null
+    @Inject
+    @Named("scp")
+    private Wagon wagon;
+
     private boolean handled;
 
+    @Test
     public void testHttpProxy() throws Exception {
         handled = false;
         Handler handler = new AbstractHandler() {
@@ -78,7 +94,6 @@ public void handle(
         proxyInfo.setType("http");
         proxyInfo.setNonProxyHosts(null);
 
-        Wagon wagon = (Wagon) lookup(Wagon.ROLE, "scp");
         try {
             wagon.connect(new Repository("id", "scp://localhost/tmp"), proxyInfo);
             fail();
@@ -90,6 +105,7 @@ public void handle(
         }
     }
 
+    @Test
     public void testSocksProxy() throws Exception {
         handled = false;
 
@@ -106,7 +122,6 @@ public void testSocksProxy() throws Exception {
         proxyInfo.setType("socks_5");
         proxyInfo.setNonProxyHosts(null);
 
-        Wagon wagon = (Wagon) lookup(Wagon.ROLE, "scp");
         try {
             wagon.connect(new Repository("id", "scp://localhost/tmp"), proxyInfo);
             fail();