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/17 18:44:08 UTC

(maven-wagon) 01/01: Migrate the standalone wagon-http tests to JUnit 5

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

slachiewicz pushed a commit to branch junit5-standalone-http-tests
in repository https://gitbox.apache.org/repos/asf/maven-wagon.git

commit 1dd29c53088a941a7c617fc374c7850e2a879177
Author: Sylwester Lachiewicz <sl...@apache.org>
AuthorDate: Mon Aug 17 20:41:07 2026 +0200

    Migrate the standalone wagon-http tests to JUnit 5
    
    Continues a8cafa27 with the three tests in wagon-http that do not extend
    the published bases in wagon-provider-test. Those bases stay on
    PlexusTestCase.
    
    wagon-http keeps junit and gains junit-vintage-engine: HttpWagonTest,
    HttpsWagonTest and both Preemptive variants inherit their test methods
    from the published HttpWagonTestCase by the testXxx() convention, and
    surefire provisions the jupiter engine but not the vintage one.
---
 wagon-providers/wagon-http/pom.xml                 | 11 ++++++++
 .../http/AbstractHttpClientWagonTest.java          | 12 ++++-----
 .../wagon/providers/http/BasicAuthScopeTest.java   | 31 +++++++++++-----------
 .../wagon/providers/http/HttpClientWagonTest.java  | 11 ++++++--
 4 files changed, 42 insertions(+), 23 deletions(-)

diff --git a/wagon-providers/wagon-http/pom.xml b/wagon-providers/wagon-http/pom.xml
index fdd51c41..ff3e98ce 100644
--- a/wagon-providers/wagon-http/pom.xml
+++ b/wagon-providers/wagon-http/pom.xml
@@ -69,6 +69,17 @@ under the License.
       <artifactId>slf4j-simple</artifactId>
       <scope>test</scope>
     </dependency>
+    <dependency>
+      <groupId>org.junit.jupiter</groupId>
+      <artifactId>junit-jupiter</artifactId>
+      <scope>test</scope>
+    </dependency>
+    <!-- HttpWagonTest and its subclasses inherit JUnit 4 tests from the published HttpWagonTestCase -->
+    <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-http/src/test/java/org/apache/maven/wagon/providers/http/AbstractHttpClientWagonTest.java b/wagon-providers/wagon-http/src/test/java/org/apache/maven/wagon/providers/http/AbstractHttpClientWagonTest.java
index 856d0e24..4869eccc 100644
--- a/wagon-providers/wagon-http/src/test/java/org/apache/maven/wagon/providers/http/AbstractHttpClientWagonTest.java
+++ b/wagon-providers/wagon-http/src/test/java/org/apache/maven/wagon/providers/http/AbstractHttpClientWagonTest.java
@@ -37,13 +37,13 @@
 import org.apache.http.impl.client.DefaultHttpRequestRetryHandler;
 import org.apache.http.impl.execchain.RedirectExec;
 import org.apache.http.impl.execchain.RetryExec;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
 
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertTrue;
-import static org.junit.Assert.fail;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertFalse;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertTrue;
+import static org.junit.jupiter.api.Assertions.fail;
 
 public class AbstractHttpClientWagonTest {
 
diff --git a/wagon-providers/wagon-http/src/test/java/org/apache/maven/wagon/providers/http/BasicAuthScopeTest.java b/wagon-providers/wagon-http/src/test/java/org/apache/maven/wagon/providers/http/BasicAuthScopeTest.java
index 0ce431a6..1512eeb3 100644
--- a/wagon-providers/wagon-http/src/test/java/org/apache/maven/wagon/providers/http/BasicAuthScopeTest.java
+++ b/wagon-providers/wagon-http/src/test/java/org/apache/maven/wagon/providers/http/BasicAuthScopeTest.java
@@ -20,8 +20,9 @@
 
 import org.apache.http.auth.AuthScope;
 import org.apache.maven.wagon.shared.http.BasicAuthScope;
-import org.junit.Assert;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
+
+import static org.junit.jupiter.api.Assertions.assertEquals;
 
 public class BasicAuthScopeTest {
 
@@ -34,9 +35,9 @@ public void testGetScopeNothingOverridden() {
         BasicAuthScope scope = new BasicAuthScope();
 
         AuthScope authScope = scope.getScope("original.host.com", 3456);
-        Assert.assertEquals("original.host.com", authScope.getHost());
-        Assert.assertEquals(3456, authScope.getPort());
-        Assert.assertEquals(AuthScope.ANY_REALM, authScope.getRealm());
+        assertEquals("original.host.com", authScope.getHost());
+        assertEquals(3456, authScope.getPort());
+        assertEquals(AuthScope.ANY_REALM, authScope.getRealm());
     }
 
     /**
@@ -49,9 +50,9 @@ public void testGetScopeAllOverridden() {
         scope.setPort("1234");
         scope.setRealm("override-realm");
         AuthScope authScope = scope.getScope("original.host.com", 3456);
-        Assert.assertEquals("override.host.com", authScope.getHost());
-        Assert.assertEquals(1234, authScope.getPort());
-        Assert.assertEquals("override-realm", authScope.getRealm());
+        assertEquals("override.host.com", authScope.getHost());
+        assertEquals(1234, authScope.getPort());
+        assertEquals("override-realm", authScope.getRealm());
     }
 
     /**
@@ -64,9 +65,9 @@ public void testGetScopeAllAny() {
         scope.setPort("ANY");
         scope.setRealm("ANY");
         AuthScope authScope = scope.getScope("original.host.com", 3456);
-        Assert.assertEquals(AuthScope.ANY_HOST, authScope.getHost());
-        Assert.assertEquals(AuthScope.ANY_PORT, authScope.getPort());
-        Assert.assertEquals(AuthScope.ANY_REALM, authScope.getRealm());
+        assertEquals(AuthScope.ANY_HOST, authScope.getHost());
+        assertEquals(AuthScope.ANY_PORT, authScope.getPort());
+        assertEquals(AuthScope.ANY_REALM, authScope.getRealm());
     }
 
     /**
@@ -77,9 +78,9 @@ public void testGetScopeRealmOverridden() {
         BasicAuthScope scope = new BasicAuthScope();
         scope.setRealm("override-realm");
         AuthScope authScope = scope.getScope("original.host.com", 3456);
-        Assert.assertEquals("original.host.com", authScope.getHost());
-        Assert.assertEquals(3456, authScope.getPort());
-        Assert.assertEquals("override-realm", authScope.getRealm());
+        assertEquals("original.host.com", authScope.getHost());
+        assertEquals(3456, authScope.getPort());
+        assertEquals("override-realm", authScope.getRealm());
     }
 
     /**
@@ -89,6 +90,6 @@ public void testGetScopeRealmOverridden() {
     public void testGetScopeOriginalPortIsNegativeOne() {
         BasicAuthScope scope = new BasicAuthScope();
         AuthScope authScope = scope.getScope("original.host.com", -1);
-        Assert.assertEquals(AuthScope.ANY_PORT, authScope.getPort());
+        assertEquals(AuthScope.ANY_PORT, authScope.getPort());
     }
 }
diff --git a/wagon-providers/wagon-http/src/test/java/org/apache/maven/wagon/providers/http/HttpClientWagonTest.java b/wagon-providers/wagon-http/src/test/java/org/apache/maven/wagon/providers/http/HttpClientWagonTest.java
index f7d48479..3c630bf7 100755
--- a/wagon-providers/wagon-http/src/test/java/org/apache/maven/wagon/providers/http/HttpClientWagonTest.java
+++ b/wagon-providers/wagon-http/src/test/java/org/apache/maven/wagon/providers/http/HttpClientWagonTest.java
@@ -18,7 +18,6 @@
  */
 package org.apache.maven.wagon.providers.http;
 
-import junit.framework.TestCase;
 import org.apache.http.Header;
 import org.apache.http.client.config.RequestConfig;
 import org.apache.http.client.methods.HttpHead;
@@ -28,9 +27,15 @@
 import org.apache.maven.wagon.shared.http.ConfigurationUtils;
 import org.apache.maven.wagon.shared.http.HttpConfiguration;
 import org.apache.maven.wagon.shared.http.HttpMethodConfiguration;
+import org.junit.jupiter.api.Test;
 
-public class HttpClientWagonTest extends TestCase {
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertNull;
 
+public class HttpClientWagonTest {
+
+    @Test
     public void testSetMaxRedirectsParamViaConfig() {
         HttpMethodConfiguration methodConfig = new HttpMethodConfiguration();
         int maxRedirects = 2;
@@ -47,6 +52,7 @@ public void testSetMaxRedirectsParamViaConfig() {
         assertEquals(2, requestConfig.getMaxRedirects());
     }
 
+    @Test
     public void testDefaultHeadersUsedByDefault() {
         HttpConfiguration config = new HttpConfiguration();
         config.setAll(new HttpMethodConfiguration());
@@ -71,6 +77,7 @@ public void testDefaultHeadersUsedByDefault() {
         assertEquals("no-cache", header.getValue());
     }
 
+    @Test
     public void testTurnOffDefaultHeaders() {
         HttpConfiguration config = new HttpConfiguration();
         config.setAll(new HttpMethodConfiguration().setUseDefaultHeaders(false));