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 19:46:32 UTC
(maven-wagon) branch wagon-3.x updated: Migrate the published test base classes off PlexusTestCase
This is an automated email from the ASF dual-hosted git repository.
slachiewicz pushed a commit to branch wagon-3.x
in repository https://gitbox.apache.org/repos/asf/maven-wagon.git
The following commit(s) were added to refs/heads/wagon-3.x by this push:
new 321d4603 Migrate the published test base classes off PlexusTestCase
321d4603 is described below
commit 321d4603ef7928bf0567605e6c4fe779baa767d4
Author: Sylwester Lachiewicz <sl...@apache.org>
AuthorDate: Tue Aug 18 15:55:30 2026 +0200
Migrate the published test base classes off PlexusTestCase
Tests needing an external cvs binary now use assumeTrue and report as skipped;
runTest() reported them as passing. Do not restore that to quieten CI.
---
pom.xml | 12 ++
src/config/checkstyle-suppressions.xml | 32 ++++++
wagon-provider-test/pom.xml | 15 ++-
.../maven/wagon/CommandExecutorTestCase.java | 28 ++++-
.../apache/maven/wagon/StreamingWagonTestCase.java | 20 +++-
.../java/org/apache/maven/wagon/WagonTestCase.java | 122 +++++++++++++++------
.../apache/maven/wagon/http/HttpWagonTestCase.java | 105 +++++++++++++-----
wagon-providers/pom.xml | 6 +
.../maven/wagon/providers/file/FileWagonTest.java | 6 +
.../maven/wagon/providers/ftp/FtpWagonTest.java | 8 ++
wagon-providers/wagon-http-lightweight/pom.xml | 20 +++-
.../providers/http/LightweightHttpWagonTest.java | 54 ++++-----
.../apache/maven/wagon/providers/http/TckTest.java | 8 +-
wagon-providers/wagon-http/pom.xml | 23 ++--
.../http/AbstractHttpClientWagonTest.java | 11 +-
.../apache/maven/wagon/providers/http/TckTest.java | 8 +-
.../providers/scm/AbstractScmCvsWagonTest.java | 5 +-
.../providers/scm/AbstractScmGitWagonTest.java | 4 +-
.../providers/scm/AbstractScmSvnWagonTest.java | 4 +-
.../wagon/providers/scm/AbstractScmWagonTest.java | 7 +-
.../wagon/providers/scm/ScmCvsExeWagonTest.java | 25 ++---
.../wagon/providers/scm/ScmGitExeWagonTest.java | 9 +-
wagon-providers/wagon-ssh-common-test/pom.xml | 11 ++
.../ssh/AbstractEmbeddedScpWagonTest.java | 7 +-
.../ssh/AbstractEmbeddedScpWagonWithKeyTest.java | 13 ++-
.../ssh/knownhost/KnownHostsProviderTestCase.java | 30 +++--
.../EmbeddedScpExternalWagonWithKeyTest.java | 2 +
.../ssh/external/ScpExternalWagonTest.java | 5 +
wagon-providers/wagon-ssh/pom.xml | 12 --
.../jsch/ScpWagonWithSshPrivateKeySearchTest.java | 6 +
wagon-providers/wagon-webdav-jackrabbit/pom.xml | 11 --
.../wagon/providers/webdav/WebDavWagonTest.java | 106 ++++++++++--------
wagon-tcks/wagon-tck-http/pom.xml | 9 +-
.../apache/maven/wagon/tck/http/Assertions.java | 65 ++++++-----
.../apache/maven/wagon/tck/http/GetWagonTests.java | 15 +--
.../maven/wagon/tck/http/HttpWagonTests.java | 16 +--
36 files changed, 554 insertions(+), 286 deletions(-)
diff --git a/pom.xml b/pom.xml
index 0f2c2f52..9a12a095 100644
--- a/pom.xml
+++ b/pom.xml
@@ -194,6 +194,11 @@ under the License.
<artifactId>junit</artifactId>
<version>4.13.2</version>
</dependency>
+ <dependency>
+ <groupId>org.codehaus.plexus</groupId>
+ <artifactId>plexus-testing</artifactId>
+ <version>2.1.0</version>
+ </dependency>
<dependency>
<groupId>org.codehaus.plexus</groupId>
<artifactId>plexus-interactivity-api</artifactId>
@@ -296,6 +301,13 @@ under the License.
</plugins>
</pluginManagement>
<plugins>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-checkstyle-plugin</artifactId>
+ <configuration>
+ <suppressionsLocation>src/config/checkstyle-suppressions.xml</suppressionsLocation>
+ </configuration>
+ </plugin>
<!-- indexes the @Named beans into META-INF/sisu; executions come from maven-parent -->
<plugin>
<groupId>org.eclipse.sisu</groupId>
diff --git a/src/config/checkstyle-suppressions.xml b/src/config/checkstyle-suppressions.xml
new file mode 100644
index 00000000..91902af2
--- /dev/null
+++ b/src/config/checkstyle-suppressions.xml
@@ -0,0 +1,32 @@
+<?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.
+-->
+<!DOCTYPE suppressions PUBLIC
+ "-//Checkstyle//DTD SuppressionFilter Configuration 1.2//EN"
+ "https://checkstyle.org/dtds/suppressions_1_2.dtd">
+<suppressions>
+ <!--
+ FileLength is a Checker-level check reported at line 1, so neither @SuppressWarnings nor a
+ CHECKSTYLE_OFF comment can suppress it: the annotation is only seen by TreeWalker, and a
+ line-1 comment is removed by spotless, which requires the licence header first. Adding one
+ @Test per test method took this class one line past the inherited 2000-line limit; splitting
+ it is a separate change.
+ -->
+ <suppress checks="FileLength" files="HttpWagonTestCase\.java"/>
+</suppressions>
diff --git a/wagon-provider-test/pom.xml b/wagon-provider-test/pom.xml
index 744dbdb9..7124724b 100644
--- a/wagon-provider-test/pom.xml
+++ b/wagon-provider-test/pom.xml
@@ -31,6 +31,12 @@ under the License.
<description>Suite of tests for Wagon implementations</description>
<dependencies>
+ <!-- WagonTestCase and CommandExecutorTestCase are published here and use @PlexusTest,
+ so this is compile scope rather than test scope -->
+ <dependency>
+ <groupId>org.codehaus.plexus</groupId>
+ <artifactId>plexus-testing</artifactId>
+ </dependency>
<dependency>
<groupId>org.apache.maven.wagon</groupId>
<artifactId>wagon-provider-api</artifactId>
@@ -40,6 +46,10 @@ under the License.
<artifactId>org.eclipse.sisu.plexus</artifactId>
<scope>compile</scope>
</dependency>
+ <dependency>
+ <groupId>org.junit.jupiter</groupId>
+ <artifactId>junit-jupiter</artifactId>
+ </dependency>
<dependency>
<groupId>com.google.inject</groupId>
<artifactId>guice</artifactId>
@@ -67,10 +77,5 @@ under the License.
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
</dependency>
- <dependency>
- <groupId>junit</groupId>
- <artifactId>junit</artifactId>
- <scope>compile</scope>
- </dependency>
</dependencies>
</project>
diff --git a/wagon-provider-test/src/main/java/org/apache/maven/wagon/CommandExecutorTestCase.java b/wagon-provider-test/src/main/java/org/apache/maven/wagon/CommandExecutorTestCase.java
index 5b6b3e45..d77b74e4 100644
--- a/wagon-provider-test/src/main/java/org/apache/maven/wagon/CommandExecutorTestCase.java
+++ b/wagon-provider-test/src/main/java/org/apache/maven/wagon/CommandExecutorTestCase.java
@@ -18,11 +18,19 @@
*/
package org.apache.maven.wagon;
+import javax.inject.Inject;
+
import org.apache.maven.wagon.authentication.AuthenticationInfo;
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.PlexusContainer;
+import org.codehaus.plexus.testing.PlexusTest;
+import org.codehaus.plexus.testing.PlexusTestConfiguration;
+import org.junit.jupiter.api.Test;
+
+import static org.junit.jupiter.api.Assertions.assertTrue;
+import static org.junit.jupiter.api.Assertions.fail;
/**
* Base class for command executor tests.
@@ -30,15 +38,21 @@
* @author <a href="mailto:brett@apache.org">Brett Porter</a>
*
*/
-public abstract class CommandExecutorTestCase extends PlexusTestCase {
+@PlexusTest
+public abstract class CommandExecutorTestCase implements PlexusTestConfiguration {
+
+ @Inject
+ private PlexusContainer container;
+
@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);
}
+ @Test
public void testErrorInCommandExecuted() throws Exception {
- CommandExecutor exec = (CommandExecutor) lookup(CommandExecutor.ROLE);
+ CommandExecutor exec = container.lookup(CommandExecutor.class);
Repository repository = getTestRepository();
@@ -57,8 +71,9 @@ public void testErrorInCommandExecuted() throws Exception {
}
}
+ @Test
public void testIgnoreFailuresInCommandExecuted() throws Exception {
- CommandExecutor exec = (CommandExecutor) lookup(CommandExecutor.ROLE);
+ CommandExecutor exec = container.lookup(CommandExecutor.class);
Repository repository = getTestRepository();
@@ -76,8 +91,9 @@ public void testIgnoreFailuresInCommandExecuted() throws Exception {
}
}
+ @Test
public void testExecuteSuccessfulCommand() throws Exception {
- CommandExecutor exec = (CommandExecutor) lookup(CommandExecutor.ROLE);
+ CommandExecutor exec = container.lookup(CommandExecutor.class);
Repository repository = getTestRepository();
diff --git a/wagon-provider-test/src/main/java/org/apache/maven/wagon/StreamingWagonTestCase.java b/wagon-provider-test/src/main/java/org/apache/maven/wagon/StreamingWagonTestCase.java
index 87cd7243..86d3b3d7 100644
--- a/wagon-provider-test/src/main/java/org/apache/maven/wagon/StreamingWagonTestCase.java
+++ b/wagon-provider-test/src/main/java/org/apache/maven/wagon/StreamingWagonTestCase.java
@@ -29,11 +29,18 @@
import org.apache.maven.wagon.resource.Resource;
import org.codehaus.plexus.util.FileUtils;
import org.codehaus.plexus.util.IOUtil;
+import org.junit.jupiter.api.Test;
+
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertTrue;
+import static org.junit.jupiter.api.Assertions.fail;
/**
* @author <a href="mailto:brett@apache.org">Brett Porter</a>
*/
public abstract class StreamingWagonTestCase extends WagonTestCase {
+ @Test
public void testStreamingWagon() throws Exception {
if (supportsGetIfNewer()) {
setupWagonTestingFixtures();
@@ -46,6 +53,7 @@ public void testStreamingWagon() throws Exception {
}
}
+ @Test
public void testFailedGetToStream() throws Exception {
setupWagonTestingFixtures();
@@ -85,6 +93,7 @@ public void testFailedGetToStream() throws Exception {
}
}
+ @Test
public void testWagonGetIfNewerToStreamIsNewer() throws Exception {
if (supportsGetIfNewer()) {
setupWagonTestingFixtures();
@@ -98,6 +107,7 @@ public void testWagonGetIfNewerToStreamIsNewer() throws Exception {
}
}
+ @Test
public void testWagonGetIfNewerToStreamIsOlder() throws Exception {
if (supportsGetIfNewer()) {
setupWagonTestingFixtures();
@@ -108,6 +118,7 @@ public void testWagonGetIfNewerToStreamIsOlder() throws Exception {
}
}
+ @Test
public void testWagonGetIfNewerToStreamIsSame() throws Exception {
if (supportsGetIfNewer()) {
setupWagonTestingFixtures();
@@ -141,6 +152,7 @@ private void getIfNewerToStream(long timestamp, boolean expectedResult, int expe
tearDownWagonTestingFixtures();
}
+ @Test
public void testFailedGetIfNewerToStream() throws Exception {
if (supportsGetIfNewer()) {
setupWagonTestingFixtures();
@@ -178,17 +190,17 @@ protected void streamRoundTripTesting() throws Exception {
int expectedSize = putStream();
- assertNotNull("check checksum is not null", checksumObserver.getActualChecksum());
+ assertNotNull(checksumObserver.getActualChecksum(), "check checksum is not null");
- assertEquals("compare checksums", "6b144b7285ffd6b0bc8300da162120b9", checksumObserver.getActualChecksum());
+ assertEquals("6b144b7285ffd6b0bc8300da162120b9", checksumObserver.getActualChecksum(), "compare checksums");
checksumObserver = new ChecksumObserver();
getStream(expectedSize);
- assertNotNull("check checksum is not null", checksumObserver.getActualChecksum());
+ assertNotNull(checksumObserver.getActualChecksum(), "check checksum is not null");
- assertEquals("compare checksums", "6b144b7285ffd6b0bc8300da162120b9", checksumObserver.getActualChecksum());
+ assertEquals("6b144b7285ffd6b0bc8300da162120b9", checksumObserver.getActualChecksum(), "compare checksums");
// Now compare the conents of the artifact that was placed in
// the repository with the contents of the artifact that was
diff --git a/wagon-provider-test/src/main/java/org/apache/maven/wagon/WagonTestCase.java b/wagon-provider-test/src/main/java/org/apache/maven/wagon/WagonTestCase.java
index f81dab29..6d92ee60 100644
--- a/wagon-provider-test/src/main/java/org/apache/maven/wagon/WagonTestCase.java
+++ b/wagon-provider-test/src/main/java/org/apache/maven/wagon/WagonTestCase.java
@@ -18,8 +18,11 @@
*/
package org.apache.maven.wagon;
+import javax.inject.Inject;
+
import java.io.File;
import java.io.IOException;
+import java.lang.reflect.Method;
import java.nio.charset.StandardCharsets;
import java.security.NoSuchAlgorithmException;
import java.text.SimpleDateFormat;
@@ -39,14 +42,26 @@
import org.apache.maven.wagon.resource.Resource;
import org.codehaus.plexus.ContainerConfiguration;
import org.codehaus.plexus.PlexusConstants;
-import org.codehaus.plexus.PlexusTestCase;
+import org.codehaus.plexus.PlexusContainer;
+import org.codehaus.plexus.testing.PlexusExtension;
+import org.codehaus.plexus.testing.PlexusTest;
+import org.codehaus.plexus.testing.PlexusTestConfiguration;
import org.codehaus.plexus.util.FileUtils;
-import org.junit.Assume;
+import org.junit.jupiter.api.Assumptions;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.TestInfo;
import org.mockito.invocation.InvocationOnMock;
import org.mockito.stubbing.Answer;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
+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.assertNull;
+import static org.junit.jupiter.api.Assertions.assertTrue;
+import static org.junit.jupiter.api.Assertions.fail;
import static org.mockito.ArgumentMatchers.any;
import static org.mockito.ArgumentMatchers.anyInt;
import static org.mockito.ArgumentMatchers.eq;
@@ -56,9 +71,10 @@
/**
* @author <a href="mailto:jason@maven.org">Jason van Zyl</a>
*/
-public abstract class WagonTestCase extends PlexusTestCase {
+@PlexusTest
+public abstract class WagonTestCase 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);
}
@@ -97,8 +113,6 @@ public int getSize() {
protected String resource;
- protected boolean testSkipped;
-
protected File artifactSourceFile;
protected File artifactDestFile;
@@ -111,12 +125,47 @@ public int getSize() {
// Constructors
// ----------------------------------------------------------------------
- protected void setUp() throws Exception {
+ /** The hint is only known at run time, so this needs the container rather than @Named. */
+ @Inject
+ private PlexusContainer container;
+
+ private String testName;
+
+ /** Replaces TestCase.getName(), which the subclasses use to build unique file names. */
+ protected final String getName() {
+ return testName;
+ }
+
+ /** Was inherited from PlexusTestCase; plexus-testing keeps it on PlexusExtension. */
+ protected static File getTestFile(String path) {
+ return PlexusExtension.getTestFile(path);
+ }
+
+ /** Was inherited from PlexusTestCase; plexus-testing keeps it on PlexusExtension. */
+ protected static String getTestPath(String path) {
+ return PlexusExtension.getTestPath(path);
+ }
+
+ /** Was inherited from PlexusTestCase; plexus-testing keeps it on PlexusExtension. */
+ protected static String getBasedir() {
+ return PlexusExtension.getBasedir();
+ }
+
+ /**
+ * Kept as its own callback rather than a parameter on setUp: eight subclasses override setUp()
+ * and call super.setUp(), and widening that signature would break every one of them. A
+ * superclass @BeforeEach runs before the subclass's, so the name is set in time.
+ */
+ @BeforeEach
+ final void captureTestName(TestInfo testInfo) {
+ testName = testInfo.getTestMethod().map(Method::getName).orElseGet(testInfo::getDisplayName);
+ }
+
+ @BeforeEach
+ public void setUp() throws Exception {
checksumObserver = new ChecksumObserver();
mockTransferListener = mock(TransferListener.class);
-
- super.setUp();
}
// ----------------------------------------------------------------------
@@ -193,7 +242,7 @@ protected RepositoryPermissions getPermissions() {
}
protected Wagon getWagon() throws Exception {
- Wagon wagon = (Wagon) lookup(Wagon.ROLE, getProtocol());
+ Wagon wagon = container.lookup(Wagon.class, getProtocol());
Debug debug = new Debug();
@@ -226,6 +275,7 @@ protected void message(String message) {
//
// ----------------------------------------------------------------------
+ @Test
public void testWagon() throws Exception {
setupWagonTestingFixtures();
@@ -236,6 +286,7 @@ public void testWagon() throws Exception {
tearDownWagonTestingFixtures();
}
+ @Test
public void testWagonGetIfNewerIsNewer() throws Exception {
if (supportsGetIfNewer()) {
setupWagonTestingFixtures();
@@ -248,17 +299,11 @@ public void testWagonGetIfNewerIsNewer() throws Exception {
}
}
- @Override
- protected void runTest() throws Throwable {
- if (!testSkipped) {
- super.runTest();
- }
- }
-
protected boolean supportsGetIfNewer() {
return true;
}
+ @Test
public void testWagonGetIfNewerIsSame() throws Exception {
if (supportsGetIfNewer()) {
setupWagonTestingFixtures();
@@ -268,6 +313,7 @@ public void testWagonGetIfNewerIsSame() throws Exception {
}
}
+ @Test
public void testWagonGetIfNewerIsOlder() throws Exception {
if (supportsGetIfNewer()) {
setupWagonTestingFixtures();
@@ -317,9 +363,9 @@ protected void assertGetIfNewerTest(ProgressAnswer progressAnswer, boolean expec
if (expectedResult) {
assertEquals(expectedSize, progressAnswer.getSize());
- assertNotNull("check checksum is not null", checksumObserver.getActualChecksum());
+ assertNotNull(checksumObserver.getActualChecksum(), "check checksum is not null");
- assertEquals("compare checksums", TEST_CKSUM, checksumObserver.getActualChecksum());
+ assertEquals(TEST_CKSUM, checksumObserver.getActualChecksum(), "compare checksums");
// Now compare the contents of the artifact that was placed in
// the repository with the contents of the artifact that was
@@ -329,7 +375,7 @@ protected void assertGetIfNewerTest(ProgressAnswer progressAnswer, boolean expec
String destContent = FileUtils.fileRead(destFile);
assertEquals(sourceContent, destContent);
} else {
- assertNull("check checksum is null", checksumObserver.getActualChecksum());
+ assertNull(checksumObserver.getActualChecksum(), "check checksum is null");
assertFalse(destFile.exists());
}
@@ -347,6 +393,7 @@ private void replaceMockForSkippedGetIfNewer(Wagon wagon, int expectedSize) {
// TransferEvent.REQUEST_GET, destFile ) );
}
+ @Test
public void testWagonPutDirectory() throws Exception {
setupWagonTestingFixtures();
@@ -392,6 +439,7 @@ public void testWagonPutDirectory() throws Exception {
* @throws Exception
* @since 1.0-beta-2
*/
+ @Test
public void testWagonPutDirectoryDeepDestination() throws Exception {
setupWagonTestingFixtures();
@@ -436,6 +484,7 @@ public void testWagonPutDirectoryDeepDestination() throws Exception {
* @throws Exception
* @since 1.0-beta-1
*/
+ @Test
public void testWagonPutDirectoryWhenDirectoryAlreadyExists() throws Exception {
final String dirName = "directory-copy-existing";
@@ -486,6 +535,7 @@ public void testWagonPutDirectoryWhenDirectoryAlreadyExists() throws Exception {
* @throws Exception
* @since 1.0-beta-1
*/
+ @Test
public void testWagonPutDirectoryForDot() throws Exception {
final String resourceToCreate = "test-resource-1.txt";
@@ -577,6 +627,7 @@ private void writeTestFile(String child) throws IOException {
FileUtils.fileWrite(dir.getAbsolutePath(), child);
}
+ @Test
public void testFailedGet() throws Exception {
setupWagonTestingFixtures();
@@ -609,6 +660,7 @@ public void testFailedGet() throws Exception {
}
}
+ @Test
public void testFailedGetIfNewer() throws Exception {
if (supportsGetIfNewer()) {
setupWagonTestingFixtures();
@@ -641,6 +693,7 @@ public void testFailedGetIfNewer() throws Exception {
* @throws Exception
* @since 1.0-beta-2
*/
+ @Test
public void testWagonGetFileList() throws Exception {
setupWagonTestingFixtures();
@@ -662,19 +715,19 @@ public void testWagonGetFileList() throws Exception {
try {
List<String> list = wagon.getFileList(dirName);
- assertNotNull("file list should not be null.", list);
+ assertNotNull(list, "file list should not be null.");
assertTrue(
- "file list should contain more items (actually contains '" + list + "').",
- list.size() >= filenames.length);
+ list.size() >= filenames.length,
+ "file list should contain more items (actually contains '" + list + "').");
for (String filename : filenames) {
- assertTrue("Filename '" + filename + "' should be in list.", list.contains(filename));
+ assertTrue(list.contains(filename), "Filename '" + filename + "' should be in list.");
}
// WAGON-250
list = wagon.getFileList("");
- assertNotNull("file list should not be null.", list);
- assertTrue("file list should contain items (actually contains '" + list + "').", !list.isEmpty());
+ assertNotNull(list, "file list should not be null.");
+ assertFalse(list.isEmpty(), "file list should contain items (actually contains '" + list + "').");
assertTrue(list.contains("file-list/"));
assertFalse(list.contains("file-list"));
assertFalse(list.contains("."));
@@ -683,7 +736,7 @@ public void testWagonGetFileList() throws Exception {
assertFalse(list.contains("../"));
} catch (UnsupportedOperationException e) {
// Some providers don't support this
- Assume.assumeFalse(false);
+ Assumptions.assumeFalse(false);
} finally {
wagon.disconnect();
@@ -697,6 +750,7 @@ public void testWagonGetFileList() throws Exception {
* @throws Exception
* @since 1.0-beta-2
*/
+ @Test
public void testWagonGetFileListWhenDirectoryDoesNotExist() throws Exception {
setupWagonTestingFixtures();
@@ -715,7 +769,7 @@ public void testWagonGetFileListWhenDirectoryDoesNotExist() throws Exception {
// expected
} catch (UnsupportedOperationException e) {
// Some providers don't support this
- Assume.assumeFalse(false);
+ Assumptions.assumeFalse(false);
} finally {
wagon.disconnect();
@@ -729,6 +783,7 @@ public void testWagonGetFileListWhenDirectoryDoesNotExist() throws Exception {
* @throws Exception
* @since 1.0-beta-2
*/
+ @Test
public void testWagonResourceExists() throws Exception {
setupWagonTestingFixtures();
@@ -740,7 +795,7 @@ public void testWagonResourceExists() throws Exception {
wagon.connect(testRepository, getAuthInfo());
- assertTrue(sourceFile.getName() + " does not exist", wagon.resourceExists(sourceFile.getName()));
+ assertTrue(wagon.resourceExists(sourceFile.getName()), sourceFile.getName() + " does not exist");
wagon.disconnect();
@@ -753,6 +808,7 @@ public void testWagonResourceExists() throws Exception {
* @throws Exception
* @since 1.0-beta-2
*/
+ @Test
public void testWagonResourceNotExists() throws Exception {
setupWagonTestingFixtures();
@@ -922,17 +978,17 @@ protected void fileRoundTripTesting() throws Exception {
int expectedSize = putFile();
- assertNotNull("check checksum is not null", checksumObserver.getActualChecksum());
+ assertNotNull(checksumObserver.getActualChecksum(), "check checksum is not null");
- assertEquals("compare checksums", TEST_CKSUM, checksumObserver.getActualChecksum());
+ assertEquals(TEST_CKSUM, checksumObserver.getActualChecksum(), "compare checksums");
checksumObserver = new ChecksumObserver();
getFile(expectedSize);
- assertNotNull("check checksum is not null", checksumObserver.getActualChecksum());
+ assertNotNull(checksumObserver.getActualChecksum(), "check checksum is not null");
- assertEquals("compare checksums", TEST_CKSUM, checksumObserver.getActualChecksum());
+ assertEquals(TEST_CKSUM, checksumObserver.getActualChecksum(), "compare checksums");
// Now compare the conents of the artifact that was placed in
// the repository with the contents of the artifact that was
diff --git a/wagon-provider-test/src/main/java/org/apache/maven/wagon/http/HttpWagonTestCase.java b/wagon-provider-test/src/main/java/org/apache/maven/wagon/http/HttpWagonTestCase.java
index 937d210e..9e455d79 100644
--- a/wagon-provider-test/src/main/java/org/apache/maven/wagon/http/HttpWagonTestCase.java
+++ b/wagon-provider-test/src/main/java/org/apache/maven/wagon/http/HttpWagonTestCase.java
@@ -78,6 +78,13 @@
import org.eclipse.jetty.servlet.ServletHolder;
import org.eclipse.jetty.util.security.Constraint;
import org.eclipse.jetty.util.security.Password;
+import org.junit.jupiter.api.Test;
+
+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;
/**
*
@@ -141,6 +148,7 @@ protected void tearDownWagonTestingFixtures() throws Exception {
server.stop();
}
+ @Test
public void testHttpHeaders() throws Exception {
Properties headers = new Properties();
headers.setProperty("User-Agent", "Maven-Wagon/1.0");
@@ -169,6 +177,7 @@ public void testHttpHeaders() throws Exception {
/**
* test set of User-Agent as it's done by aether wagon connector with using setHttpHeaders
*/
+ @Test
public void testHttpHeadersWithCommonMethods() throws Exception {
Properties properties = new Properties();
properties.setProperty("User-Agent", "Maven-Wagon/1.0");
@@ -196,6 +205,7 @@ public void testHttpHeadersWithCommonMethods() throws Exception {
assertEquals("Maven-Wagon/1.0", handler.headers.get("User-Agent"));
}
+ @Test
public void testUserAgentHeaderIsPresentByDefault() throws Exception {
StreamingWagon wagon = (StreamingWagon) getWagon();
Server server = new Server();
@@ -209,9 +219,10 @@ public void testUserAgentHeaderIsPresentByDefault() throws Exception {
server.stop();
assertNotNull(
- "default User-Agent header of wagon provider should be present", handler.headers.get("User-Agent"));
+ handler.headers.get("User-Agent"), "default User-Agent header of wagon provider should be present");
}
+ @Test
public void testUserAgentHeaderIsPresentOnlyOnceIfSetMultipleTimes() throws Exception {
StreamingWagon wagon = (StreamingWagon) getWagon();
@@ -253,6 +264,7 @@ protected String getRepositoryUrl(Server server) {
return getProtocol() + "://localhost:" + localPort;
}
+ @Test
public void testGetForbidden() throws Exception {
try {
runTestGet(HttpServletResponse.SC_FORBIDDEN);
@@ -262,6 +274,7 @@ public void testGetForbidden() throws Exception {
}
}
+ @Test
public void testGet404() throws Exception {
try {
runTestGet(HttpServletResponse.SC_NOT_FOUND);
@@ -271,6 +284,7 @@ public void testGet404() throws Exception {
}
}
+ @Test
public void testGet500() throws Exception {
try {
runTestGet(HttpServletResponse.SC_INTERNAL_SERVER_ERROR);
@@ -305,6 +319,7 @@ private void runTestGet(int status) throws Exception {
}
}
+ @Test
public void testResourceExistsForbidden() throws Exception {
try {
runTestResourceExists(HttpServletResponse.SC_FORBIDDEN);
@@ -314,6 +329,7 @@ public void testResourceExistsForbidden() throws Exception {
}
}
+ @Test
public void testResourceExists404() throws Exception {
try {
assertFalse(runTestResourceExists(HttpServletResponse.SC_NOT_FOUND));
@@ -322,6 +338,7 @@ public void testResourceExists404() throws Exception {
}
}
+ @Test
public void testResourceExists500() throws Exception {
try {
runTestResourceExists(HttpServletResponse.SC_INTERNAL_SERVER_ERROR);
@@ -331,6 +348,7 @@ public void testResourceExists500() throws Exception {
}
}
+ @Test
public void testResourceExists429() throws Exception {
try {
@@ -398,6 +416,7 @@ protected File getRepositoryDirectory() {
return getTestFile("target/test-output/http-repository");
}
+ @Test
public void testGzipGet() throws Exception {
Server server = new Server();
@@ -491,6 +510,7 @@ public void testDeflateGet()
}
}*/
+ @Test
public void testProxiedRequest() throws Exception {
ProxyInfo proxyInfo = createProxyInfo();
TestHeaderHandler handler = new TestHeaderHandler();
@@ -498,6 +518,7 @@ public void testProxiedRequest() throws Exception {
runTestProxiedRequest(proxyInfo, handler);
}
+ @Test
public void testProxiedRequestWithAuthentication() throws Exception {
ProxyInfo proxyInfo = createProxyInfo();
proxyInfo.setUserName("user");
@@ -518,6 +539,7 @@ public void testProxiedRequestWithAuthentication() throws Exception {
}
}
+ @Test
public void testProxiedRequestWithAuthenticationWithProvider() throws Exception {
final ProxyInfo proxyInfo = createProxyInfo();
proxyInfo.setUserName("user");
@@ -543,6 +565,7 @@ public ProxyInfo getProxyInfo(String protocol) {
}
}
+ @Test
public void testRedirectGetToStream() throws Exception {
StreamingWagon wagon = (StreamingWagon) getWagon();
@@ -586,7 +609,7 @@ public void testRedirectGetToStream() throws Exception {
fileOutputStream.flush();
fileOutputStream.close();
String found = FileUtils.fileRead(tmpResult);
- assertEquals("found:'" + found + "'", "Hello, World!", found);
+ assertEquals("Hello, World!", found, "found:'" + found + "'");
checkHandlerResult(redirectHandler.handlerRequestResponses, HttpServletResponse.SC_SEE_OTHER);
checkHandlerResult(handler.handlerRequestResponses, HttpServletResponse.SC_OK);
@@ -600,6 +623,7 @@ public void testRedirectGetToStream() throws Exception {
}
}
+ @Test
public void testRedirectGet() throws Exception {
StreamingWagon wagon = (StreamingWagon) getWagon();
@@ -641,7 +665,7 @@ public void testRedirectGet() throws Exception {
try {
wagon.get("resource", tmpResult);
String found = FileUtils.fileRead(tmpResult);
- assertEquals("found:'" + found + "'", "Hello, World!", found);
+ assertEquals("Hello, World!", found, "found:'" + found + "'");
checkHandlerResult(redirectHandler.handlerRequestResponses, HttpServletResponse.SC_SEE_OTHER);
checkHandlerResult(handler.handlerRequestResponses, HttpServletResponse.SC_OK);
@@ -655,6 +679,7 @@ public void testRedirectGet() throws Exception {
}
}
+ @Test
public void testRedirectPutFromStreamWithFullUrl() throws Exception {
Server realServer = new Server();
@@ -730,6 +755,7 @@ protected void checkRequestResponseForRedirectPutWithFullUrl(
checkHandlerResult(putHandler.handlerRequestResponses, HttpServletResponse.SC_CREATED);
}
+ @Test
public void testRedirectPutFromStreamRelativeUrl() throws Exception {
Server realServer = new Server();
addConnector(realServer);
@@ -807,6 +833,7 @@ protected void checkHandlerResult(
}
}
+ @Test
public void testRedirectPutFileWithFullUrl() throws Exception {
Server realServer = new Server();
@@ -876,6 +903,7 @@ public void testRedirectPutFileWithFullUrl() throws Exception {
}
}
+ @Test
public void testRedirectPutFileRelativeUrl() throws Exception {
Server realServer = new Server();
addConnector(realServer);
@@ -930,6 +958,7 @@ public void testRedirectPutFileRelativeUrl() throws Exception {
}
}
+ @Test
public void testRedirectPutFailureNonRepeatableStream() throws Exception {
File repositoryDirectory = getRepositoryDirectory();
FileUtils.deleteDirectory(repositoryDirectory);
@@ -1136,6 +1165,7 @@ private ProxyInfo createProxyInfo() {
return proxyInfo;
}
+ @Test
public void testSecuredGetUnauthorized() throws Exception {
try {
runTestSecuredGet(null);
@@ -1145,6 +1175,7 @@ public void testSecuredGetUnauthorized() throws Exception {
}
}
+ @Test
public void testSecuredGetWrongPassword() throws Exception {
try {
AuthenticationInfo authInfo = new AuthenticationInfo();
@@ -1157,6 +1188,7 @@ public void testSecuredGetWrongPassword() throws Exception {
}
}
+ @Test
public void testSecuredGet() throws Exception {
AuthenticationInfo authInfo = new AuthenticationInfo();
authInfo.setUserName("user");
@@ -1210,6 +1242,7 @@ public void runTestSecuredGet(AuthenticationInfo authInfo) throws Exception {
}
}
+ @Test
public void testSecuredGetToStream() throws Exception {
AuthenticationInfo authInfo = new AuthenticationInfo();
authInfo.setUserName("user");
@@ -1259,6 +1292,7 @@ public void runTestSecuredGetToStream(AuthenticationInfo authInfo) throws Except
}
}
+ @Test
public void testSecuredResourceExistsUnauthorized() throws Exception {
try {
runTestSecuredResourceExists(null);
@@ -1268,6 +1302,7 @@ public void testSecuredResourceExistsUnauthorized() throws Exception {
}
}
+ @Test
public void testSecuredResourceExistsWrongPassword() throws Exception {
try {
AuthenticationInfo authInfo = new AuthenticationInfo();
@@ -1279,6 +1314,7 @@ public void testSecuredResourceExistsWrongPassword() throws Exception {
}
}
+ @Test
public void testSecuredResourceExists() throws Exception {
AuthenticationInfo authInfo = new AuthenticationInfo();
authInfo.setUserName("user");
@@ -1381,6 +1417,7 @@ private String writeTestFile(File parent, String child, String compressionType)
return content;
}
+ @Test
public void testPutForbidden() throws Exception {
try {
runTestPut(HttpServletResponse.SC_FORBIDDEN);
@@ -1390,6 +1427,7 @@ public void testPutForbidden() throws Exception {
}
}
+ @Test
public void testPut404() throws Exception {
try {
runTestPut(HttpServletResponse.SC_NOT_FOUND);
@@ -1399,6 +1437,7 @@ public void testPut404() throws Exception {
}
}
+ @Test
public void testPut500() throws Exception {
try {
runTestPut(HttpServletResponse.SC_INTERNAL_SERVER_ERROR);
@@ -1408,6 +1447,7 @@ public void testPut500() throws Exception {
}
}
+ @Test
public void testPut429() throws Exception {
try {
@@ -1488,6 +1528,7 @@ private void runTestPut(int status) throws Exception {
}
}
+ @Test
public void testSecuredPutUnauthorized() throws Exception {
try {
runTestSecuredPut(null);
@@ -1497,6 +1538,7 @@ public void testSecuredPutUnauthorized() throws Exception {
}
}
+ @Test
public void testSecuredPutWrongPassword() throws Exception {
try {
AuthenticationInfo authInfo = new AuthenticationInfo();
@@ -1509,6 +1551,7 @@ public void testSecuredPutWrongPassword() throws Exception {
}
}
+ @Test
public void testSecuredPut() throws Exception {
AuthenticationInfo authInfo = new AuthenticationInfo();
authInfo.setUserName("user");
@@ -1562,6 +1605,7 @@ public void runTestSecuredPut(AuthenticationInfo authInfo, int putNumber) throws
testPreemptiveAuthenticationPut(sh, supportPreemptiveAuthenticationPut());
}
+ @Test
public void testNonSecuredPutFromStream() throws Exception {
AuthenticationInfo authInfo = new AuthenticationInfo();
authInfo.setUserName("user");
@@ -1569,6 +1613,7 @@ public void testNonSecuredPutFromStream() throws Exception {
runTestSecuredPutFromStream(authInfo, 1, false);
}
+ @Test
public void testSecuredPutFromStream() throws Exception {
AuthenticationInfo authInfo = new AuthenticationInfo();
authInfo.setUserName("user");
@@ -1643,23 +1688,23 @@ public void runTestSecuredPutFromStream(AuthenticationInfo authInfo, int putNumb
protected abstract boolean supportProxyPreemptiveAuthentication();
- protected void testPreemptiveAuthenticationGet(TestSecurityHandler sh, boolean preemptive) {
+ public void testPreemptiveAuthenticationGet(TestSecurityHandler sh, boolean preemptive) {
testPreemptiveAuthentication(sh, preemptive, HttpServletResponse.SC_OK);
}
- protected void testPreemptiveAuthenticationPut(TestSecurityHandler sh, boolean preemptive) {
+ public void testPreemptiveAuthenticationPut(TestSecurityHandler sh, boolean preemptive) {
testPreemptiveAuthentication(sh, preemptive, HttpServletResponse.SC_CREATED);
}
- protected void testPreemptiveAuthentication(TestSecurityHandler sh, boolean preemptive, int statusCode) {
+ public void testPreemptiveAuthentication(TestSecurityHandler sh, boolean preemptive, int statusCode) {
if (preemptive) {
assertEquals(
- "not 1 security handler use " + sh.handlerRequestResponses, 1, sh.handlerRequestResponses.size());
+ 1, sh.handlerRequestResponses.size(), "not 1 security handler use " + sh.handlerRequestResponses);
assertEquals(statusCode, sh.handlerRequestResponses.get(0).responseCode);
} else {
assertEquals(
- "not 2 security handler use " + sh.handlerRequestResponses, 2, sh.handlerRequestResponses.size());
+ 2, sh.handlerRequestResponses.size(), "not 2 security handler use " + sh.handlerRequestResponses);
assertEquals(HttpServletResponse.SC_UNAUTHORIZED, sh.handlerRequestResponses.get(0).responseCode);
assertEquals(statusCode, sh.handlerRequestResponses.get(1).responseCode);
}
@@ -1913,7 +1958,7 @@ protected void verifyWagonExceptionMessage(Exception e, int forStatusCode, Strin
// TODO: handle AuthenticationException for Wagon.connect() calls
assertNotNull(e);
try {
- assertTrue("only verify instances of WagonException", e instanceof WagonException);
+ assertTrue(e instanceof WagonException, "only verify instances of WagonException");
String reasonPhrase;
String assertMessageForBadMessage = "exception message not described properly";
@@ -1921,70 +1966,70 @@ protected void verifyWagonExceptionMessage(Exception e, int forStatusCode, Strin
case HttpServletResponse.SC_NOT_FOUND:
// TODO: add test for 410: Gone?
assertTrue(
- "404 not found response should throw ResourceDoesNotExistException",
- e instanceof ResourceDoesNotExistException);
+ e instanceof ResourceDoesNotExistException,
+ "404 not found response should throw ResourceDoesNotExistException");
reasonPhrase = (forReasonPhrase == null || forReasonPhrase.isEmpty())
? " Not Found"
: (" " + forReasonPhrase);
assertEquals(
- assertMessageForBadMessage,
"resource missing at " + forUrl + ", status: 404" + reasonPhrase,
- e.getMessage());
+ e.getMessage(),
+ assertMessageForBadMessage);
break;
case HttpServletResponse.SC_UNAUTHORIZED:
// FIXME assumes Wagon.get()/put() returning 401 instead of Wagon.connect()
assertTrue(
+ e instanceof AuthorizationException,
"401 Unauthorized should throw AuthorizationException since "
+ " AuthenticationException is not explicitly declared as thrown from wagon "
- + "methods",
- e instanceof AuthorizationException);
+ + "methods");
reasonPhrase = (forReasonPhrase == null || forReasonPhrase.isEmpty())
? " Unauthorized"
: (" " + forReasonPhrase);
assertEquals(
- assertMessageForBadMessage,
"authentication failed for " + forUrl + ", status: 401" + reasonPhrase,
- e.getMessage());
+ e.getMessage(),
+ assertMessageForBadMessage);
break;
case HttpServletResponse.SC_PROXY_AUTHENTICATION_REQUIRED:
assertTrue(
- "407 Proxy authentication required should throw AuthorizationException",
- e instanceof AuthorizationException);
+ e instanceof AuthorizationException,
+ "407 Proxy authentication required should throw AuthorizationException");
reasonPhrase = (forReasonPhrase == null || forReasonPhrase.isEmpty())
? " Proxy Authentication Required"
: (" " + forReasonPhrase);
assertEquals(
- assertMessageForBadMessage,
"proxy authentication failed for " + forUrl + ", status: 407" + reasonPhrase,
- e.getMessage());
+ e.getMessage(),
+ assertMessageForBadMessage);
break;
case HttpServletResponse.SC_FORBIDDEN:
assertTrue(
- "403 Forbidden should throw AuthorizationException", e instanceof AuthorizationException);
+ e instanceof AuthorizationException, "403 Forbidden should throw AuthorizationException");
reasonPhrase = (forReasonPhrase == null || forReasonPhrase.isEmpty())
? " Forbidden"
: (" " + forReasonPhrase);
assertEquals(
- assertMessageForBadMessage,
"authorization failed for " + forUrl + ", status: 403" + reasonPhrase,
- e.getMessage());
+ e.getMessage(),
+ assertMessageForBadMessage);
break;
default:
assertTrue(
- "transfer failures should at least be wrapped in a TransferFailedException",
- e instanceof TransferFailedException);
+ e instanceof TransferFailedException,
+ "transfer failures should at least be wrapped in a TransferFailedException");
assertTrue(
- "expected status code for transfer failures should be >= 400",
- forStatusCode >= HttpServletResponse.SC_BAD_REQUEST);
+ forStatusCode >= HttpServletResponse.SC_BAD_REQUEST,
+ "expected status code for transfer failures should be >= 400");
reasonPhrase = forReasonPhrase == null ? "" : " " + forReasonPhrase;
assertEquals(
- assertMessageForBadMessage,
"transfer failed for " + forUrl + ", status: " + forStatusCode + reasonPhrase,
- e.getMessage());
+ e.getMessage(),
+ assertMessageForBadMessage);
break;
}
} catch (AssertionError assertionError) {
diff --git a/wagon-providers/pom.xml b/wagon-providers/pom.xml
index 6b0a9178..dbed163b 100644
--- a/wagon-providers/pom.xml
+++ b/wagon-providers/pom.xml
@@ -78,6 +78,12 @@ under the License.
<groupId>org.apache.maven.wagon</groupId>
<artifactId>wagon-provider-test</artifactId>
<scope>test</scope>
+ <exclusions>
+ <exclusion>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ </exclusion>
+ </exclusions>
</dependency>
</dependencies>
</project>
diff --git a/wagon-providers/wagon-file/src/test/java/org/apache/maven/wagon/providers/file/FileWagonTest.java b/wagon-providers/wagon-file/src/test/java/org/apache/maven/wagon/providers/file/FileWagonTest.java
index e1b551f4..57f40777 100644
--- a/wagon-providers/wagon-file/src/test/java/org/apache/maven/wagon/providers/file/FileWagonTest.java
+++ b/wagon-providers/wagon-file/src/test/java/org/apache/maven/wagon/providers/file/FileWagonTest.java
@@ -28,6 +28,10 @@
import org.apache.maven.wagon.authentication.AuthenticationException;
import org.apache.maven.wagon.repository.Repository;
import org.apache.maven.wagon.resource.Resource;
+import org.junit.jupiter.api.Test;
+
+import static org.junit.jupiter.api.Assertions.assertFalse;
+import static org.junit.jupiter.api.Assertions.assertTrue;
/**
* @author <a href="michal.maczka@dimatics.com">Michal Maczka</a>
@@ -51,6 +55,7 @@ protected String getTestRepositoryUrl() throws IOException {
* @throws ConnectionException
* @throws AuthenticationException
*/
+ @Test
public void testNullFileWagon() throws ConnectionException, AuthenticationException {
Wagon wagon = new FileWagon();
Resource resource = new Resource();
@@ -64,6 +69,7 @@ protected long getExpectedLastModifiedOnGet(Repository repository, Resource reso
return new File(repository.getBasedir(), resource.getName()).lastModified();
}
+ @Test
public void testResourceExists() throws Exception {
String url = new File(getBasedir()).toPath().toUri().toASCIIString();
diff --git a/wagon-providers/wagon-ftp/src/test/java/org/apache/maven/wagon/providers/ftp/FtpWagonTest.java b/wagon-providers/wagon-ftp/src/test/java/org/apache/maven/wagon/providers/ftp/FtpWagonTest.java
index f206d20f..e501289d 100644
--- a/wagon-providers/wagon-ftp/src/test/java/org/apache/maven/wagon/providers/ftp/FtpWagonTest.java
+++ b/wagon-providers/wagon-ftp/src/test/java/org/apache/maven/wagon/providers/ftp/FtpWagonTest.java
@@ -39,6 +39,11 @@
import org.apache.maven.wagon.authentication.AuthenticationInfo;
import org.apache.maven.wagon.repository.Repository;
import org.apache.maven.wagon.resource.Resource;
+import org.junit.jupiter.api.Test;
+
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertTrue;
+import static org.junit.jupiter.api.Assertions.fail;
/**
* @author <a href="michal.maczka@dimatics.com">Michal Maczka</a>
@@ -138,6 +143,7 @@ private File getRepositoryDirectory() {
return getTestFile("target/test-output/local-repository");
}
+ @Test
public void testNoPassword() throws Exception {
AuthenticationInfo authenticationInfo = new AuthenticationInfo();
authenticationInfo.setUserName("me");
@@ -149,6 +155,7 @@ public void testNoPassword() throws Exception {
}
}
+ @Test
public void testDefaultUserName() throws Exception {
AuthenticationInfo authenticationInfo = new AuthenticationInfo();
authenticationInfo.setPassword("secret");
@@ -163,6 +170,7 @@ public void testDefaultUserName() throws Exception {
/**
* This is a unit test to show WAGON-265
*/
+ @Test
public void testPutDirectoryCreation() throws Exception {
setupWagonTestingFixtures();
diff --git a/wagon-providers/wagon-http-lightweight/pom.xml b/wagon-providers/wagon-http-lightweight/pom.xml
index 00455b85..155b6fbd 100644
--- a/wagon-providers/wagon-http-lightweight/pom.xml
+++ b/wagon-providers/wagon-http-lightweight/pom.xml
@@ -31,6 +31,12 @@ under the License.
<description>Wagon provider that gets and puts artifacts through http using standard Java library</description>
<dependencies>
+ <!-- TckTest aggregates the TCK suites, now through the JUnit Platform -->
+ <dependency>
+ <groupId>org.junit.platform</groupId>
+ <artifactId>junit-platform-suite</artifactId>
+ <scope>test</scope>
+ </dependency>
<dependency>
<groupId>${project.groupId}</groupId>
<artifactId>wagon-http-shared</artifactId>
@@ -43,6 +49,12 @@ under the License.
<artifactId>wagon-tck-http</artifactId>
<version>${project.version}</version>
<scope>test</scope>
+ <exclusions>
+ <exclusion>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ </exclusion>
+ </exclusions>
</dependency>
<dependency>
<groupId>org.codehaus.plexus</groupId>
@@ -53,13 +65,13 @@ under the License.
<artifactId>slf4j-api</artifactId>
</dependency>
<dependency>
- <groupId>junit</groupId>
- <artifactId>junit</artifactId>
+ <groupId>org.eclipse.jetty.aggregate</groupId>
+ <artifactId>jetty-all</artifactId>
<scope>test</scope>
</dependency>
<dependency>
- <groupId>org.eclipse.jetty.aggregate</groupId>
- <artifactId>jetty-all</artifactId>
+ <groupId>org.junit.jupiter</groupId>
+ <artifactId>junit-jupiter</artifactId>
<scope>test</scope>
</dependency>
<dependency>
diff --git a/wagon-providers/wagon-http-lightweight/src/test/java/org/apache/maven/wagon/providers/http/LightweightHttpWagonTest.java b/wagon-providers/wagon-http-lightweight/src/test/java/org/apache/maven/wagon/providers/http/LightweightHttpWagonTest.java
index 0cb908cd..c34c509c 100644
--- a/wagon-providers/wagon-http-lightweight/src/test/java/org/apache/maven/wagon/providers/http/LightweightHttpWagonTest.java
+++ b/wagon-providers/wagon-http-lightweight/src/test/java/org/apache/maven/wagon/providers/http/LightweightHttpWagonTest.java
@@ -31,6 +31,10 @@
import org.apache.maven.wagon.authorization.AuthorizationException;
import org.apache.maven.wagon.http.HttpWagonTestCase;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertTrue;
+
/**
* @author <a href="michal.maczka@dimatics.com">Michal Maczka</a>
*
@@ -72,89 +76,89 @@ protected void verifyWagonExceptionMessage(Exception e, int forStatusCode, Strin
assertNotNull(e);
try {
- assertTrue("only verify instances of WagonException", e instanceof WagonException);
+ assertTrue(e instanceof WagonException, "only verify instances of WagonException");
String assertMessageForBadMessage = "exception message not described properly: ";
switch (forStatusCode) {
case HttpServletResponse.SC_GONE:
case HttpServletResponse.SC_NOT_FOUND:
assertTrue(
- "404 or 410 should throw ResourceDoesNotExistException",
- e instanceof ResourceDoesNotExistException);
+ e instanceof ResourceDoesNotExistException,
+ "404 or 410 should throw ResourceDoesNotExistException");
if (e.getCause() != null) {
assertTrue(
- "ResourceDoesNotExistException should have the expected cause",
- e.getCause() instanceof FileNotFoundException);
+ e.getCause() instanceof FileNotFoundException,
+ "ResourceDoesNotExistException should have the expected cause");
// the status code and reason phrase cannot always be learned due to implementation limitations
// which means the message may not include them
- assertEquals(assertMessageForBadMessage, "resource missing at " + forUrl, e.getMessage());
+ assertEquals("resource missing at " + forUrl, e.getMessage(), assertMessageForBadMessage);
} else {
assertEquals(
- assertMessageForBadMessage,
"resource missing at " + forUrl + ", status: " + forStatusCode + " " + forReasonPhrase,
- e.getMessage());
+ e.getMessage(),
+ assertMessageForBadMessage);
}
break;
case HttpServletResponse.SC_FORBIDDEN:
- assertTrue("403 Forbidden throws AuthorizationException", e instanceof AuthorizationException);
+ assertTrue(e instanceof AuthorizationException, "403 Forbidden throws AuthorizationException");
assertEquals(
- assertMessageForBadMessage,
"authorization failed for " + forUrl + ", status: 403"
+ ((forReasonPhrase == null || forReasonPhrase.isEmpty())
? " Forbidden"
: (" " + forReasonPhrase)),
- e.getMessage());
+ e.getMessage(),
+ assertMessageForBadMessage);
break;
case HttpServletResponse.SC_UNAUTHORIZED:
- assertTrue("401 Unauthorized throws AuthorizationException", e instanceof AuthorizationException);
+ assertTrue(e instanceof AuthorizationException, "401 Unauthorized throws AuthorizationException");
assertEquals(
- assertMessageForBadMessage,
"authentication failed for " + forUrl + ", status: 401"
+ ((forReasonPhrase == null || forReasonPhrase.isEmpty())
? " Unauthorized"
: (" " + forReasonPhrase)),
- e.getMessage());
+ e.getMessage(),
+ assertMessageForBadMessage);
break;
default:
assertTrue(
- "general exception must be TransferFailedException", e instanceof TransferFailedException);
+ e instanceof TransferFailedException, "general exception must be TransferFailedException");
assertTrue(
+ forStatusCode >= HttpServletResponse.SC_BAD_REQUEST,
"expected status code for transfer failures should be >= 400, but none of "
- + " the already handled codes",
- forStatusCode >= HttpServletResponse.SC_BAD_REQUEST);
+ + " the already handled codes");
if (e.getCause() != null) {
assertTrue(
- "TransferFailedException should have the original cause for diagnosis",
- e.getCause() instanceof IOException);
+ e.getCause() instanceof IOException,
+ "TransferFailedException should have the original cause for diagnosis");
}
// the status code and reason phrase cannot always be learned due to implementation limitations
// so the message may not include them, but the implementation should use a consistent format
assertTrue(
- "message should always include url",
- e.getMessage().startsWith("transfer failed for " + forUrl));
+ e.getMessage().startsWith("transfer failed for " + forUrl),
+ "message should always include url");
if (e.getMessage().length() > ("transfer failed for " + forUrl).length()) {
assertTrue(
- "message should include url and status code",
e.getMessage()
- .startsWith("transfer failed for " + forUrl + ", status: " + forStatusCode));
+ .startsWith("transfer failed for " + forUrl + ", status: " + forStatusCode),
+ "message should include url and status code");
}
if (e.getMessage().length()
> ("transfer failed for " + forUrl + ", status: " + forStatusCode).length()) {
assertEquals(
- "message should include url and status code and reason phrase",
"transfer failed for " + forUrl + ", status: " + forStatusCode + " " + forReasonPhrase,
- e.getMessage());
+ e.getMessage(),
+ "message should include url and status code and reason phrase");
}
break;
diff --git a/wagon-providers/wagon-http-lightweight/src/test/java/org/apache/maven/wagon/providers/http/TckTest.java b/wagon-providers/wagon-http-lightweight/src/test/java/org/apache/maven/wagon/providers/http/TckTest.java
index b39fbd31..8a3de19d 100644
--- a/wagon-providers/wagon-http-lightweight/src/test/java/org/apache/maven/wagon/providers/http/TckTest.java
+++ b/wagon-providers/wagon-http-lightweight/src/test/java/org/apache/maven/wagon/providers/http/TckTest.java
@@ -20,14 +20,14 @@
import org.apache.maven.wagon.tck.http.GetWagonTests;
import org.apache.maven.wagon.tck.http.HttpsGetWagonTests;
-import org.junit.runner.RunWith;
-import org.junit.runners.Suite;
+import org.junit.platform.suite.api.SelectClasses;
+import org.junit.platform.suite.api.Suite;
/**
* This test will runn the TCK suite on wagon-http-lightweight
*/
-@RunWith(Suite.class)
-@Suite.SuiteClasses({GetWagonTests.class, HttpsGetWagonTests.class})
+@Suite
+@SelectClasses({GetWagonTests.class, HttpsGetWagonTests.class})
public class TckTest {
// no op
}
diff --git a/wagon-providers/wagon-http/pom.xml b/wagon-providers/wagon-http/pom.xml
index 90556767..9b4f7094 100644
--- a/wagon-providers/wagon-http/pom.xml
+++ b/wagon-providers/wagon-http/pom.xml
@@ -31,6 +31,12 @@ under the License.
<description>Wagon provider that gets and puts artifacts through HTTP(S) using Apache HttpClient-4.x.</description>
<dependencies>
+ <!-- TckTest aggregates the TCK suites, now through the JUnit Platform -->
+ <dependency>
+ <groupId>org.junit.platform</groupId>
+ <artifactId>junit-platform-suite</artifactId>
+ <scope>test</scope>
+ </dependency>
<dependency>
<groupId>${project.groupId}</groupId>
<artifactId>wagon-http-shared</artifactId>
@@ -74,17 +80,6 @@ under the License.
<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>
- <scope>test</scope>
- </dependency>
<dependency>
<groupId>org.eclipse.jetty.aggregate</groupId>
<artifactId>jetty-all</artifactId>
@@ -113,6 +108,12 @@ under the License.
<artifactId>wagon-tck-http</artifactId>
<version>${project.version}</version>
<scope>test</scope>
+ <exclusions>
+ <exclusion>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ </exclusion>
+ </exclusions>
</dependency>
</dependencies>
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 fd4c3e2b..c84e8a64 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
@@ -45,10 +45,9 @@
import org.junit.jupiter.api.Disabled;
import org.junit.jupiter.api.Test;
-import static org.hamcrest.CoreMatchers.instanceOf;
-import static org.hamcrest.MatcherAssert.assertThat;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertFalse;
+import static org.junit.jupiter.api.Assertions.assertInstanceOf;
import static org.junit.jupiter.api.Assertions.assertNotNull;
import static org.junit.jupiter.api.Assertions.assertTrue;
import static org.junit.jupiter.api.Assertions.fail;
@@ -82,7 +81,7 @@ public void retryableConfigurationDefaultTest() throws Exception {
public void run() {
final HttpRequestRetryHandler handler = getCurrentHandler();
assertNotNull(handler);
- assertThat(handler, instanceOf(DefaultHttpRequestRetryHandler.class));
+ assertInstanceOf(DefaultHttpRequestRetryHandler.class, handler);
final DefaultHttpRequestRetryHandler impl = DefaultHttpRequestRetryHandler.class.cast(handler);
assertEquals(3, impl.getRetryCount());
assertFalse(impl.isRequestSentRetryEnabled());
@@ -100,7 +99,7 @@ public void run() {
final HttpRequestRetryHandler handler = getCurrentHandler();
assertNotNull(handler);
- assertThat(handler, instanceOf(DefaultHttpRequestRetryHandler.class));
+ assertInstanceOf(DefaultHttpRequestRetryHandler.class, handler);
final DefaultHttpRequestRetryHandler impl = DefaultHttpRequestRetryHandler.class.cast(handler);
assertEquals(5, impl.getRetryCount());
assertFalse(impl.isRequestSentRetryEnabled());
@@ -118,7 +117,7 @@ public void run() {
final HttpRequestRetryHandler handler = getCurrentHandler();
assertNotNull(handler);
- assertThat(handler, instanceOf(DefaultHttpRequestRetryHandler.class));
+ assertInstanceOf(DefaultHttpRequestRetryHandler.class, handler);
final DefaultHttpRequestRetryHandler impl = DefaultHttpRequestRetryHandler.class.cast(handler);
assertEquals(3, impl.getRetryCount());
assertTrue(impl.isRequestSentRetryEnabled());
@@ -136,7 +135,7 @@ public void run() {
final HttpRequestRetryHandler handler = getCurrentHandler();
assertNotNull(handler);
- assertThat(handler, instanceOf(DefaultHttpRequestRetryHandler.class));
+ assertInstanceOf(DefaultHttpRequestRetryHandler.class, handler);
final DefaultHttpRequestRetryHandler impl = DefaultHttpRequestRetryHandler.class.cast(handler);
assertEquals(3, impl.getRetryCount());
assertFalse(impl.isRequestSentRetryEnabled());
diff --git a/wagon-providers/wagon-http/src/test/java/org/apache/maven/wagon/providers/http/TckTest.java b/wagon-providers/wagon-http/src/test/java/org/apache/maven/wagon/providers/http/TckTest.java
index 2de4cc33..71b27498 100644
--- a/wagon-providers/wagon-http/src/test/java/org/apache/maven/wagon/providers/http/TckTest.java
+++ b/wagon-providers/wagon-http/src/test/java/org/apache/maven/wagon/providers/http/TckTest.java
@@ -20,14 +20,14 @@
import org.apache.maven.wagon.tck.http.GetWagonTests;
import org.apache.maven.wagon.tck.http.HttpsGetWagonTests;
-import org.junit.runner.RunWith;
-import org.junit.runners.Suite;
+import org.junit.platform.suite.api.SelectClasses;
+import org.junit.platform.suite.api.Suite;
/**
* This test will run the TCK suite on wagon-http-lightweight
*/
-@RunWith(Suite.class)
-@Suite.SuiteClasses({GetWagonTests.class, HttpsGetWagonTests.class})
+@Suite
+@SelectClasses({GetWagonTests.class, HttpsGetWagonTests.class})
public class TckTest {
// no op
}
diff --git a/wagon-providers/wagon-scm/src/test/java/org/apache/maven/wagon/providers/scm/AbstractScmCvsWagonTest.java b/wagon-providers/wagon-scm/src/test/java/org/apache/maven/wagon/providers/scm/AbstractScmCvsWagonTest.java
index c59bd86d..6cb3350e 100644
--- a/wagon-providers/wagon-scm/src/test/java/org/apache/maven/wagon/providers/scm/AbstractScmCvsWagonTest.java
+++ b/wagon-providers/wagon-scm/src/test/java/org/apache/maven/wagon/providers/scm/AbstractScmCvsWagonTest.java
@@ -22,6 +22,7 @@
import java.io.IOException;
import org.codehaus.plexus.util.FileUtils;
+import org.junit.jupiter.api.BeforeEach;
/**
* Test for ScmWagon using CVS as underlying SCM
@@ -32,8 +33,8 @@
public abstract class AbstractScmCvsWagonTest extends AbstractScmWagonTest {
private String repository;
- @Override
- protected void setUp() throws Exception {
+ @BeforeEach
+ public void setUp() throws Exception {
super.setUp();
File origRepo = getTestFile("target/test-classes/test-repo-cvs");
diff --git a/wagon-providers/wagon-scm/src/test/java/org/apache/maven/wagon/providers/scm/AbstractScmGitWagonTest.java b/wagon-providers/wagon-scm/src/test/java/org/apache/maven/wagon/providers/scm/AbstractScmGitWagonTest.java
index 98d0f349..d8be4429 100644
--- a/wagon-providers/wagon-scm/src/test/java/org/apache/maven/wagon/providers/scm/AbstractScmGitWagonTest.java
+++ b/wagon-providers/wagon-scm/src/test/java/org/apache/maven/wagon/providers/scm/AbstractScmGitWagonTest.java
@@ -21,6 +21,7 @@
import java.io.File;
import org.codehaus.plexus.util.FileUtils;
+import org.junit.jupiter.api.BeforeEach;
/**
* Test for ScmWagon using Git as underlying SCM
@@ -28,7 +29,8 @@
public abstract class AbstractScmGitWagonTest extends AbstractScmWagonTest {
private String repository;
- protected void setUp() throws Exception {
+ @BeforeEach
+ public void setUp() throws Exception {
super.setUp();
// copy the repo for the test
diff --git a/wagon-providers/wagon-scm/src/test/java/org/apache/maven/wagon/providers/scm/AbstractScmSvnWagonTest.java b/wagon-providers/wagon-scm/src/test/java/org/apache/maven/wagon/providers/scm/AbstractScmSvnWagonTest.java
index b606bab2..37946ba4 100644
--- a/wagon-providers/wagon-scm/src/test/java/org/apache/maven/wagon/providers/scm/AbstractScmSvnWagonTest.java
+++ b/wagon-providers/wagon-scm/src/test/java/org/apache/maven/wagon/providers/scm/AbstractScmSvnWagonTest.java
@@ -21,6 +21,7 @@
import java.io.File;
import org.codehaus.plexus.util.FileUtils;
+import org.junit.jupiter.api.BeforeEach;
/**
* Test for ScmWagon using SVN as underlying SCM
@@ -31,7 +32,8 @@
public abstract class AbstractScmSvnWagonTest extends AbstractScmWagonTest {
private String repository;
- protected void setUp() throws Exception {
+ @BeforeEach
+ public void setUp() throws Exception {
super.setUp();
// copy the repo for the test
diff --git a/wagon-providers/wagon-scm/src/test/java/org/apache/maven/wagon/providers/scm/AbstractScmWagonTest.java b/wagon-providers/wagon-scm/src/test/java/org/apache/maven/wagon/providers/scm/AbstractScmWagonTest.java
index df6f6038..ebfe4395 100644
--- a/wagon-providers/wagon-scm/src/test/java/org/apache/maven/wagon/providers/scm/AbstractScmWagonTest.java
+++ b/wagon-providers/wagon-scm/src/test/java/org/apache/maven/wagon/providers/scm/AbstractScmWagonTest.java
@@ -38,6 +38,8 @@
import org.apache.maven.wagon.repository.Repository;
import org.apache.maven.wagon.resource.Resource;
import org.codehaus.plexus.util.FileUtils;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
/**
* Test for {@link ScmWagon}. You need a subclass for each SCM provider you want to test.
@@ -47,7 +49,7 @@
*/
public abstract class AbstractScmWagonTest extends WagonTestCase {
- @Override
+ @Test
public void testWagonPutDirectory() throws Exception {
super.testWagonPutDirectory();
// repeat the test on a non-empty repo
@@ -60,7 +62,8 @@ public void testWagonPutDirectory() throws Exception {
private String providerClassName;
- protected void setUp() throws Exception {
+ @BeforeEach
+ public void setUp() throws Exception {
super.setUp();
FileUtils.deleteDirectory(getCheckoutDirectory());
diff --git a/wagon-providers/wagon-scm/src/test/java/org/apache/maven/wagon/providers/scm/ScmCvsExeWagonTest.java b/wagon-providers/wagon-scm/src/test/java/org/apache/maven/wagon/providers/scm/ScmCvsExeWagonTest.java
index ca9b99d9..8e18abc0 100644
--- a/wagon-providers/wagon-scm/src/test/java/org/apache/maven/wagon/providers/scm/ScmCvsExeWagonTest.java
+++ b/wagon-providers/wagon-scm/src/test/java/org/apache/maven/wagon/providers/scm/ScmCvsExeWagonTest.java
@@ -20,6 +20,10 @@
import org.apache.maven.scm.provider.ScmProvider;
import org.apache.maven.scm.provider.cvslib.cvsexe.CvsExeScmProvider;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
+
+import static org.junit.jupiter.api.Assumptions.assumeTrue;
/**
* Test for ScmWagon using CVS Exe as underlying SCM
@@ -29,29 +33,27 @@
*/
public class ScmCvsExeWagonTest extends AbstractScmCvsWagonTest {
- @Override
- protected void setUp() throws Exception {
+ @BeforeEach
+ public void setUp() throws Exception {
assumeHaveCvsBinary();
- if (!testSkipped) {
- super.setUp();
- }
+ super.setUp();
}
protected ScmProvider getScmProvider() {
return new CvsExeScmProvider();
}
- @Override
+ @Test
public void testWagonGetFileList() throws Exception {
// cvs rls is rare
}
- @Override
+ @Test
public void testWagonResourceExists() throws Exception {
// cvs rls is rare
}
- @Override
+ @Test
public void testWagonResourceNotExists() throws Exception {
// cvs rls is rare
}
@@ -61,12 +63,9 @@ protected boolean supportsGetIfNewer() {
return false;
}
- /** Optionally set the testSkipped flag */
+ /** Aborts the test when cvs is not installed. */
protected void assumeHaveCvsBinary() {
- if (!isSystemCmd(CVS_COMMAND_LINE)) {
- testSkipped = true;
- System.err.println("'" + CVS_COMMAND_LINE + "' is not a system command. Ignored " + getName() + ".");
- }
+ assumeTrue(isSystemCmd(CVS_COMMAND_LINE), "'" + CVS_COMMAND_LINE + "' is not a system command");
}
/** 'cvs' command line */
diff --git a/wagon-providers/wagon-scm/src/test/java/org/apache/maven/wagon/providers/scm/ScmGitExeWagonTest.java b/wagon-providers/wagon-scm/src/test/java/org/apache/maven/wagon/providers/scm/ScmGitExeWagonTest.java
index dcedd79b..f5abea5d 100644
--- a/wagon-providers/wagon-scm/src/test/java/org/apache/maven/wagon/providers/scm/ScmGitExeWagonTest.java
+++ b/wagon-providers/wagon-scm/src/test/java/org/apache/maven/wagon/providers/scm/ScmGitExeWagonTest.java
@@ -19,6 +19,7 @@
package org.apache.maven.wagon.providers.scm;
import org.apache.maven.scm.provider.ScmProvider;
+import org.junit.jupiter.api.Test;
/**
* Test for ScmWagon using Git Exe as underlying SCM
@@ -29,7 +30,7 @@ protected ScmProvider getScmProvider() {
return new UserSafeGitExeScmProvider();
}
- @Override
+ @Test
public void testWagonGetFileList() throws Exception {
// remote list unsupported
// When a command is unsupported, SCM throws NoSuchCommandScmException.
@@ -39,17 +40,17 @@ public void testWagonGetFileList() throws Exception {
// and skip the test using org.junit.Assume
}
- @Override
+ @Test
public void testWagonGetFileListWhenDirectoryDoesNotExist() throws Exception {
// remote list unsupported
}
- @Override
+ @Test
public void testWagonResourceExists() throws Exception {
// remote list unsupported
}
- @Override
+ @Test
public void testWagonResourceNotExists() throws Exception {
// remote list unsupported
}
diff --git a/wagon-providers/wagon-ssh-common-test/pom.xml b/wagon-providers/wagon-ssh-common-test/pom.xml
index 77c2d9c6..0b4261cb 100644
--- a/wagon-providers/wagon-ssh-common-test/pom.xml
+++ b/wagon-providers/wagon-ssh-common-test/pom.xml
@@ -33,6 +33,11 @@ under the License.
<sshdVersion>2.19.0</sshdVersion>
</properties>
<dependencies>
+ <!-- KnownHostsProviderTestCase is published here and uses @PlexusTest -->
+ <dependency>
+ <groupId>org.codehaus.plexus</groupId>
+ <artifactId>plexus-testing</artifactId>
+ </dependency>
<dependency>
<groupId>org.eclipse.sisu</groupId>
<artifactId>org.eclipse.sisu.plexus</artifactId>
@@ -55,6 +60,12 @@ under the License.
<dependency>
<groupId>org.apache.maven.wagon</groupId>
<artifactId>wagon-provider-test</artifactId>
+ <exclusions>
+ <exclusion>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ </exclusion>
+ </exclusions>
</dependency>
<dependency>
<groupId>org.apache.maven.wagon</groupId>
diff --git a/wagon-providers/wagon-ssh-common-test/src/main/java/org/apache/maven/wagon/providers/ssh/AbstractEmbeddedScpWagonTest.java b/wagon-providers/wagon-ssh-common-test/src/main/java/org/apache/maven/wagon/providers/ssh/AbstractEmbeddedScpWagonTest.java
index 4fa398d8..2d12e702 100644
--- a/wagon-providers/wagon-ssh-common-test/src/main/java/org/apache/maven/wagon/providers/ssh/AbstractEmbeddedScpWagonTest.java
+++ b/wagon-providers/wagon-ssh-common-test/src/main/java/org/apache/maven/wagon/providers/ssh/AbstractEmbeddedScpWagonTest.java
@@ -25,6 +25,9 @@
import org.apache.maven.wagon.authentication.AuthenticationInfo;
import org.apache.maven.wagon.repository.Repository;
import org.apache.maven.wagon.resource.Resource;
+import org.junit.jupiter.api.BeforeEach;
+
+import static org.junit.jupiter.api.Assertions.assertEquals;
/**
* @author <a href="michal.maczka@dimatics.com">Michal Maczka</a>
@@ -34,8 +37,8 @@ public abstract class AbstractEmbeddedScpWagonTest extends StreamingWagonTestCas
SshServerEmbedded sshServer;
- @Override
- protected void setUp() throws Exception {
+ @BeforeEach
+ public void setUp() throws Exception {
super.setUp();
String sshKeyResource = "ssh-keys/id_rsa";
diff --git a/wagon-providers/wagon-ssh-common-test/src/main/java/org/apache/maven/wagon/providers/ssh/AbstractEmbeddedScpWagonWithKeyTest.java b/wagon-providers/wagon-ssh-common-test/src/main/java/org/apache/maven/wagon/providers/ssh/AbstractEmbeddedScpWagonWithKeyTest.java
index 3f5ede7a..48e331d4 100644
--- a/wagon-providers/wagon-ssh-common-test/src/main/java/org/apache/maven/wagon/providers/ssh/AbstractEmbeddedScpWagonWithKeyTest.java
+++ b/wagon-providers/wagon-ssh-common-test/src/main/java/org/apache/maven/wagon/providers/ssh/AbstractEmbeddedScpWagonWithKeyTest.java
@@ -28,6 +28,13 @@
import org.apache.maven.wagon.repository.Repository;
import org.apache.maven.wagon.resource.Resource;
import org.codehaus.plexus.util.FileUtils;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
+
+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;
/**
* @author <a href="michal.maczka@dimatics.com">Michal Maczka</a>
@@ -37,8 +44,8 @@ public abstract class AbstractEmbeddedScpWagonWithKeyTest extends StreamingWagon
SshServerEmbedded sshServerEmbedded;
- @Override
- protected void setUp() throws Exception {
+ @BeforeEach
+ public void setUp() throws Exception {
super.setUp();
String sshKeyResource = "ssh-keys/id_rsa.pub";
@@ -82,6 +89,7 @@ protected long getExpectedLastModifiedOnGet(Repository repository, Resource reso
return new File(repository.getBasedir(), resource.getName()).lastModified() / 1000L * 1000L;
}
+ @Test
public void testConnect() throws Exception {
getWagon().connect(new Repository("foo", getTestRepositoryUrl()), getAuthInfo());
assertTrue(true);
@@ -92,6 +100,7 @@ protected boolean supportsGetIfNewer() {
return false;
}
+ @Test
public void testWithSpaces() throws Exception {
String dir = "foo test";
File spaceDirectory = new File(TestData.getRepoPath(), dir);
diff --git a/wagon-providers/wagon-ssh-common-test/src/main/java/org/apache/maven/wagon/providers/ssh/knownhost/KnownHostsProviderTestCase.java b/wagon-providers/wagon-ssh-common-test/src/main/java/org/apache/maven/wagon/providers/ssh/knownhost/KnownHostsProviderTestCase.java
index fa8fc1e2..a7bcdd83 100644
--- a/wagon-providers/wagon-ssh-common-test/src/main/java/org/apache/maven/wagon/providers/ssh/knownhost/KnownHostsProviderTestCase.java
+++ b/wagon-providers/wagon-ssh-common-test/src/main/java/org/apache/maven/wagon/providers/ssh/knownhost/KnownHostsProviderTestCase.java
@@ -18,20 +18,33 @@
*/
package org.apache.maven.wagon.providers.ssh.knownhost;
-import org.apache.maven.wagon.Wagon;
+import javax.inject.Inject;
+
import org.apache.maven.wagon.providers.ssh.SshWagon;
import org.apache.maven.wagon.providers.ssh.TestData;
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.PlexusContainer;
+import org.codehaus.plexus.testing.PlexusTest;
+import org.codehaus.plexus.testing.PlexusTestConfiguration;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
+
+import static org.junit.jupiter.api.Assertions.assertTrue;
+import static org.junit.jupiter.api.Assertions.fail;
/**
*
*/
-public class KnownHostsProviderTestCase extends PlexusTestCase {
+@PlexusTest
+public class KnownHostsProviderTestCase implements PlexusTestConfiguration {
+
+ @Inject
+ private PlexusContainer container;
+
@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);
}
@@ -60,6 +73,7 @@ protected void customizeContainerConfiguration(ContainerConfiguration configurat
*
* @throws Exception on error
*/
+ @Test
public void testIncorrectKey() throws Exception {
wagon.setKnownHostsProvider(failHostsProvider);
@@ -77,6 +91,7 @@ public void testIncorrectKey() throws Exception {
*
* @throws Exception on error
*/
+ @Test
public void testChangedKey() throws Exception {
wagon.setKnownHostsProvider(changedHostsProvider);
@@ -94,6 +109,7 @@ public void testChangedKey() throws Exception {
*
* @throws Exception on error
*/
+ @Test
public void testCorrectKey() throws Exception {
wagon.setKnownHostsProvider(okHostsProvider);
@@ -102,11 +118,11 @@ public void testCorrectKey() throws Exception {
assertTrue(true);
}
- protected void setUp() throws Exception {
- super.setUp();
+ @BeforeEach
+ public void setUp() throws Exception {
source = new Repository("test", "scp://" + TestData.getUserName() + "@" + TestData.getHostname() + "/tmp/foo");
- wagon = (SshWagon) lookup(Wagon.ROLE, "scp");
+ wagon = container.lookup(SshWagon.class, "scp");
wagon.setInteractive(false);
this.okHostsProvider = new SingleKnownHostProvider(TestData.getHostname(), CORRECT_KEY);
diff --git a/wagon-providers/wagon-ssh-external/src/test/java/org/apache/maven/wagon/providers/ssh/external/EmbeddedScpExternalWagonWithKeyTest.java b/wagon-providers/wagon-ssh-external/src/test/java/org/apache/maven/wagon/providers/ssh/external/EmbeddedScpExternalWagonWithKeyTest.java
index 678bc42f..f870ab6e 100644
--- a/wagon-providers/wagon-ssh-external/src/test/java/org/apache/maven/wagon/providers/ssh/external/EmbeddedScpExternalWagonWithKeyTest.java
+++ b/wagon-providers/wagon-ssh-external/src/test/java/org/apache/maven/wagon/providers/ssh/external/EmbeddedScpExternalWagonWithKeyTest.java
@@ -27,6 +27,7 @@
import org.apache.maven.wagon.providers.ssh.AbstractEmbeddedScpWagonWithKeyTest;
import org.codehaus.plexus.util.cli.CommandLineUtils;
import org.codehaus.plexus.util.cli.Commandline;
+import org.junit.jupiter.api.Test;
/**
* @author <a href="michal.maczka@dimatics.com">Michal Maczka</a>
@@ -86,6 +87,7 @@ protected AuthenticationInfo getAuthInfo() {
}
}
+ @Test
public void testFailedGetToStream() throws Exception {
// ignore this test as it need a stream wagon
}
diff --git a/wagon-providers/wagon-ssh-external/src/test/java/org/apache/maven/wagon/providers/ssh/external/ScpExternalWagonTest.java b/wagon-providers/wagon-ssh-external/src/test/java/org/apache/maven/wagon/providers/ssh/external/ScpExternalWagonTest.java
index 8020374d..6789f6b5 100644
--- a/wagon-providers/wagon-ssh-external/src/test/java/org/apache/maven/wagon/providers/ssh/external/ScpExternalWagonTest.java
+++ b/wagon-providers/wagon-ssh-external/src/test/java/org/apache/maven/wagon/providers/ssh/external/ScpExternalWagonTest.java
@@ -26,6 +26,10 @@
import org.apache.maven.wagon.providers.ssh.TestData;
import org.apache.maven.wagon.repository.Repository;
import org.apache.maven.wagon.resource.Resource;
+import org.junit.jupiter.api.Test;
+
+import static org.junit.jupiter.api.Assertions.assertFalse;
+import static org.junit.jupiter.api.Assertions.assertTrue;
/**
* @author <a href="michal.maczka@dimatics.com">Michal Maczka</a>
@@ -70,6 +74,7 @@ protected AuthenticationInfo getAuthInfo() {
return authInfo;
}
+ @Test
public void testIsPuTTY() throws Exception {
ScpExternalWagon wagon = (ScpExternalWagon) getWagon();
diff --git a/wagon-providers/wagon-ssh/pom.xml b/wagon-providers/wagon-ssh/pom.xml
index 5f4a2ce1..2cee3fac 100644
--- a/wagon-providers/wagon-ssh/pom.xml
+++ b/wagon-providers/wagon-ssh/pom.xml
@@ -100,18 +100,6 @@ under the License.
<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>
<scope>test</scope>
</dependency>
</dependencies>
diff --git a/wagon-providers/wagon-ssh/src/test/java/org/apache/maven/wagon/providers/ssh/jsch/ScpWagonWithSshPrivateKeySearchTest.java b/wagon-providers/wagon-ssh/src/test/java/org/apache/maven/wagon/providers/ssh/jsch/ScpWagonWithSshPrivateKeySearchTest.java
index 8fdad517..af7ea4e4 100644
--- a/wagon-providers/wagon-ssh/src/test/java/org/apache/maven/wagon/providers/ssh/jsch/ScpWagonWithSshPrivateKeySearchTest.java
+++ b/wagon-providers/wagon-ssh/src/test/java/org/apache/maven/wagon/providers/ssh/jsch/ScpWagonWithSshPrivateKeySearchTest.java
@@ -26,6 +26,10 @@
import org.apache.maven.wagon.providers.ssh.TestData;
import org.apache.maven.wagon.repository.Repository;
import org.apache.maven.wagon.resource.Resource;
+import org.junit.jupiter.api.Test;
+
+import static org.junit.jupiter.api.Assertions.assertTrue;
+import static org.junit.jupiter.api.Assertions.fail;
/**
* @author <a href="michal.maczka@dimatics.com">Michal Maczka</a>
@@ -54,6 +58,7 @@ protected long getExpectedLastModifiedOnGet(Repository repository, Resource reso
return new File(repository.getBasedir(), resource.getName()).lastModified();
}
+ @Test
public void testMissingPrivateKey() throws Exception {
File file = File.createTempFile("wagon", "tmp");
file.delete();
@@ -69,6 +74,7 @@ public void testMissingPrivateKey() throws Exception {
}
}
+ @Test
public void testBadPrivateKey() throws Exception {
File file = File.createTempFile("wagon", "tmp");
file.deleteOnExit();
diff --git a/wagon-providers/wagon-webdav-jackrabbit/pom.xml b/wagon-providers/wagon-webdav-jackrabbit/pom.xml
index 8d440f50..32e669d4 100644
--- a/wagon-providers/wagon-webdav-jackrabbit/pom.xml
+++ b/wagon-providers/wagon-webdav-jackrabbit/pom.xml
@@ -85,17 +85,6 @@ under the License.
<artifactId>junit-jupiter</artifactId>
<scope>test</scope>
</dependency>
- <!-- WebDavWagonTest 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>
- <scope>test</scope>
- </dependency>
<dependency>
<groupId>org.eclipse.jetty.aggregate</groupId>
<artifactId>jetty-all</artifactId>
diff --git a/wagon-providers/wagon-webdav-jackrabbit/src/test/java/org/apache/maven/wagon/providers/webdav/WebDavWagonTest.java b/wagon-providers/wagon-webdav-jackrabbit/src/test/java/org/apache/maven/wagon/providers/webdav/WebDavWagonTest.java
index 223e2888..ff56f9e2 100644
--- a/wagon-providers/wagon-webdav-jackrabbit/src/test/java/org/apache/maven/wagon/providers/webdav/WebDavWagonTest.java
+++ b/wagon-providers/wagon-webdav-jackrabbit/src/test/java/org/apache/maven/wagon/providers/webdav/WebDavWagonTest.java
@@ -42,6 +42,13 @@
import org.eclipse.jetty.server.Server;
import org.eclipse.jetty.servlet.ServletContextHandler;
import org.eclipse.jetty.servlet.ServletHolder;
+import org.junit.jupiter.api.Test;
+
+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;
/*
* WebDAV Wagon Test
@@ -81,12 +88,13 @@ private File getDavRepository() {
private void assertURL(String userUrl, String expectedUrl) {
Repository repo = new Repository("test-geturl", userUrl);
String actualUrl = (new WebDavWagon()).getURL(repo);
- assertEquals("WebDavWagon.getURL(" + userUrl + ")", expectedUrl, actualUrl);
+ assertEquals(expectedUrl, actualUrl, "WebDavWagon.getURL(" + userUrl + ")");
}
/**
* Tests the maven 2.0.x way to define a webdav URL without SSL.
*/
+ @Test
public void testGetURLDavHttp() {
assertURL("dav:http://localhost:9080/dav/", "http://localhost:9080/dav/");
}
@@ -94,6 +102,7 @@ public void testGetURLDavHttp() {
/**
* Tests the maven 2.0.x way to define a webdav URL with SSL.
*/
+ @Test
public void testGetURLDavHttps() {
assertURL("dav:https://localhost:9443/dav/", "https://localhost:9443/dav/");
}
@@ -101,6 +110,7 @@ public void testGetURLDavHttps() {
/**
* Tests the URI spec way of defining a webdav URL without SSL.
*/
+ @Test
public void testGetURLDavUri() {
assertURL("dav://localhost:9080/dav/", "http://localhost:9080/dav/");
}
@@ -108,6 +118,7 @@ public void testGetURLDavUri() {
/**
* Tests the URI spec way of defining a webdav URL with SSL.
*/
+ @Test
public void testGetURLDavUriWithSsl() {
assertURL("davs://localhost:9443/dav/", "https://localhost:9443/dav/");
}
@@ -115,6 +126,7 @@ public void testGetURLDavUriWithSsl() {
/**
* Tests the URI spec way of defining a webdav URL without SSL.
*/
+ @Test
public void testGetURLDavPlusHttp() {
assertURL(
"dav+https://localhost:" + getTestRepositoryPort() + "/dav/",
@@ -124,10 +136,12 @@ public void testGetURLDavPlusHttp() {
/**
* Tests the URI spec way of defining a webdav URL with SSL.
*/
+ @Test
public void testGetURLDavPlusHttps() {
assertURL("dav+https://localhost:9443/dav/", "https://localhost:9443/dav/");
}
+ @Test
public void testMkdirs() throws Exception {
setupWagonTestingFixtures();
@@ -172,6 +186,7 @@ public void testMkdirs() throws Exception {
}
}
+ @Test
public void testMkdirsWithNoBasedir() throws Exception {
// WAGON-244
setupWagonTestingFixtures();
@@ -218,6 +233,7 @@ protected void setHttpConfiguration(StreamingWagon wagon, Properties headers, Pr
*
* @throws Exception
*/
+ @Test
public void testWagonWebDavGetFileList() throws Exception {
setupWagonTestingFixtures();
@@ -244,26 +260,26 @@ public void testWagonWebDavGetFileList() throws Exception {
List<String> list = wagon.getFileList(dirName);
- assertNotNull("file list should not be null.", list);
- assertEquals("file list should contain 6 items", 6, list.size());
+ assertNotNull(list, "file list should not be null.");
+ assertEquals(6, list.size(), "file list should contain 6 items");
for (int i = 0; i < filenames.length; i++) {
- assertTrue("Filename '" + filenames[i] + "' should be in list.", list.contains(filenames[i]));
+ assertTrue(list.contains(filenames[i]), "Filename '" + filenames[i] + "' should be in list.");
}
for (int i = 0; i < dirnames.length; i++) {
- assertTrue("Directory '" + dirnames[i] + "' should be in list.", list.contains(dirnames[i] + "/"));
+ assertTrue(list.contains(dirnames[i] + "/"), "Directory '" + dirnames[i] + "' should be in list.");
}
///////////////////////////////////////////////////////////////////////////
list = wagon.getFileList("");
- assertNotNull("file list should not be null.", list);
- assertEquals("file list should contain 1 items", 1, list.size());
+ assertNotNull(list, "file list should not be null.");
+ assertEquals(1, list.size(), "file list should contain 1 items");
///////////////////////////////////////////////////////////////////////////
list = wagon.getFileList(dirName + "/test-dir1");
- assertNotNull("file list should not be null.", list);
- assertEquals("file list should contain 0 items", 0, list.size());
+ assertNotNull(list, "file list should not be null.");
+ assertEquals(0, list.size(), "file list should contain 0 items");
/////////////////////////////////////////////////////////////////////////////
try {
@@ -278,6 +294,7 @@ public void testWagonWebDavGetFileList() throws Exception {
tearDownWagonTestingFixtures();
}
+ @Test
public void testWagonFailsOnPutFailureByDefault() throws Exception {
setupWagonTestingFixtures();
@@ -325,6 +342,7 @@ protected CloseableHttpResponse execute(HttpUriRequest httpRequestBase) throws H
}
}
+ @Test
public void testWagonContinuesOnPutFailureIfPropertySet() throws Exception {
setupWagonTestingFixtures();
@@ -366,40 +384,40 @@ protected boolean supportProxyPreemptiveAuthentication() {
return true;
}
- protected void testPreemptiveAuthenticationGet(TestSecurityHandler sh, boolean preemptive) {
+ public void testPreemptiveAuthenticationGet(TestSecurityHandler sh, boolean preemptive) {
if (preemptive) {
assertEquals(
- "testPreemptiveAuthenticationGet preemptive=true: expected 1 request, got "
- + sh.handlerRequestResponses,
1,
- sh.handlerRequestResponses.size());
+ sh.handlerRequestResponses.size(),
+ "testPreemptiveAuthenticationGet preemptive=true: expected 1 request, got "
+ + sh.handlerRequestResponses);
assertEquals(HttpServletResponse.SC_OK, sh.handlerRequestResponses.get(0).responseCode);
} else {
assertEquals(
- "testPreemptiveAuthenticationGet preemptive=false: expected 2 requests (401,200), got "
- + sh.handlerRequestResponses,
2,
- sh.handlerRequestResponses.size());
+ sh.handlerRequestResponses.size(),
+ "testPreemptiveAuthenticationGet preemptive=false: expected 2 requests (401,200), got "
+ + sh.handlerRequestResponses);
assertEquals(HttpServletResponse.SC_UNAUTHORIZED, sh.handlerRequestResponses.get(0).responseCode);
assertEquals(HttpServletResponse.SC_OK, sh.handlerRequestResponses.get(1).responseCode);
}
}
- protected void testPreemptiveAuthenticationPut(TestSecurityHandler sh, boolean preemptive) {
+ public void testPreemptiveAuthenticationPut(TestSecurityHandler sh, boolean preemptive) {
if (preemptive) {
assertEquals(
- "testPreemptiveAuthenticationPut preemptive=true: expected 2 requests (200,201), got "
- + sh.handlerRequestResponses,
2,
- sh.handlerRequestResponses.size());
+ sh.handlerRequestResponses.size(),
+ "testPreemptiveAuthenticationPut preemptive=true: expected 2 requests (200,201), got "
+ + sh.handlerRequestResponses);
assertEquals(HttpServletResponse.SC_OK, sh.handlerRequestResponses.get(0).responseCode);
assertEquals(HttpServletResponse.SC_CREATED, sh.handlerRequestResponses.get(1).responseCode);
} else {
assertEquals(
- "testPreemptiveAuthenticationPut preemptive=false: expected 3 requests (401,200,201), got "
- + sh.handlerRequestResponses,
3,
- sh.handlerRequestResponses.size());
+ sh.handlerRequestResponses.size(),
+ "testPreemptiveAuthenticationPut preemptive=false: expected 3 requests (401,200,201), got "
+ + sh.handlerRequestResponses);
assertEquals(HttpServletResponse.SC_UNAUTHORIZED, sh.handlerRequestResponses.get(0).responseCode);
assertEquals(HttpServletResponse.SC_OK, sh.handlerRequestResponses.get(1).responseCode);
assertEquals(HttpServletResponse.SC_CREATED, sh.handlerRequestResponses.get(2).responseCode);
@@ -409,20 +427,20 @@ protected void testPreemptiveAuthenticationPut(TestSecurityHandler sh, boolean p
/* This method cannot be reasonable used to represend GET and PUT for WebDAV, it would contain too much
* duplicate code. Leave as-is, but don't use it.
*/
- protected void testPreemptiveAuthentication(TestSecurityHandler sh, boolean preemptive) {
+ public void testPreemptiveAuthentication(TestSecurityHandler sh, boolean preemptive) {
if (preemptive) {
assertEquals(
- "testPreemptiveAuthentication preemptive=false: expected 2 requests (200,.), got "
- + sh.handlerRequestResponses,
2,
- sh.handlerRequestResponses.size());
+ sh.handlerRequestResponses.size(),
+ "testPreemptiveAuthentication preemptive=false: expected 2 requests (200,.), got "
+ + sh.handlerRequestResponses);
assertEquals(HttpServletResponse.SC_OK, sh.handlerRequestResponses.get(0).responseCode);
} else {
assertEquals(
- "testPreemptiveAuthentication preemptive=false: expected 3 requests (401,200,200), got "
- + sh.handlerRequestResponses,
3,
- sh.handlerRequestResponses.size());
+ sh.handlerRequestResponses.size(),
+ "testPreemptiveAuthentication preemptive=false: expected 3 requests (401,200,200), got "
+ + sh.handlerRequestResponses);
assertEquals(HttpServletResponse.SC_UNAUTHORIZED, sh.handlerRequestResponses.get(0).responseCode);
assertEquals(HttpServletResponse.SC_OK, sh.handlerRequestResponses.get(1).responseCode);
assertEquals(HttpServletResponse.SC_OK, sh.handlerRequestResponses.get(2).responseCode);
@@ -432,38 +450,38 @@ protected void testPreemptiveAuthentication(TestSecurityHandler sh, boolean pree
@Override
protected void checkRequestResponseForRedirectPutWithFullUrl(
RedirectHandler redirectHandler, PutHandler putHandler) {
- assertEquals("found:" + putHandler.handlerRequestResponses, 1, putHandler.handlerRequestResponses.size());
+ assertEquals(1, putHandler.handlerRequestResponses.size(), "found:" + putHandler.handlerRequestResponses);
assertEquals(
- "found:" + putHandler.handlerRequestResponses,
HttpServletResponse.SC_CREATED,
- putHandler.handlerRequestResponses.get(0).responseCode);
+ putHandler.handlerRequestResponses.get(0).responseCode,
+ "found:" + putHandler.handlerRequestResponses);
assertEquals(
- "found:" + redirectHandler.handlerRequestResponses, 2, redirectHandler.handlerRequestResponses.size());
+ 2, redirectHandler.handlerRequestResponses.size(), "found:" + redirectHandler.handlerRequestResponses);
assertEquals(
- "found:" + redirectHandler.handlerRequestResponses,
HttpServletResponse.SC_SEE_OTHER,
- redirectHandler.handlerRequestResponses.get(0).responseCode);
+ redirectHandler.handlerRequestResponses.get(0).responseCode,
+ "found:" + redirectHandler.handlerRequestResponses);
}
@Override
protected void checkRequestResponseForRedirectPutWithRelativeUrl(
RedirectHandler redirectHandler, PutHandler putHandler) {
- assertEquals("found:" + putHandler.handlerRequestResponses, 0, putHandler.handlerRequestResponses.size());
+ assertEquals(0, putHandler.handlerRequestResponses.size(), "found:" + putHandler.handlerRequestResponses);
assertEquals(
- "found:" + redirectHandler.handlerRequestResponses, 4, redirectHandler.handlerRequestResponses.size());
+ 4, redirectHandler.handlerRequestResponses.size(), "found:" + redirectHandler.handlerRequestResponses);
assertEquals(
- "found:" + redirectHandler.handlerRequestResponses,
HttpServletResponse.SC_SEE_OTHER,
- redirectHandler.handlerRequestResponses.get(0).responseCode);
+ redirectHandler.handlerRequestResponses.get(0).responseCode,
+ "found:" + redirectHandler.handlerRequestResponses);
assertEquals(
- "found:" + redirectHandler.handlerRequestResponses,
HttpServletResponse.SC_OK,
- redirectHandler.handlerRequestResponses.get(1).responseCode);
+ redirectHandler.handlerRequestResponses.get(1).responseCode,
+ "found:" + redirectHandler.handlerRequestResponses);
assertEquals(
- "found:" + redirectHandler.handlerRequestResponses,
HttpServletResponse.SC_SEE_OTHER,
- redirectHandler.handlerRequestResponses.get(2).responseCode);
+ redirectHandler.handlerRequestResponses.get(2).responseCode,
+ "found:" + redirectHandler.handlerRequestResponses);
}
@Override
diff --git a/wagon-tcks/wagon-tck-http/pom.xml b/wagon-tcks/wagon-tck-http/pom.xml
index e0c7603e..c1224455 100644
--- a/wagon-tcks/wagon-tck-http/pom.xml
+++ b/wagon-tcks/wagon-tck-http/pom.xml
@@ -37,6 +37,10 @@ under the License.
<artifactId>org.eclipse.sisu.plexus</artifactId>
<scope>compile</scope>
</dependency>
+ <dependency>
+ <groupId>org.junit.jupiter</groupId>
+ <artifactId>junit-jupiter</artifactId>
+ </dependency>
<dependency>
<groupId>com.google.inject</groupId>
<artifactId>guice</artifactId>
@@ -60,11 +64,6 @@ under the License.
<groupId>org.apache.maven.wagon</groupId>
<artifactId>wagon-provider-api</artifactId>
</dependency>
- <dependency>
- <groupId>junit</groupId>
- <artifactId>junit</artifactId>
- <scope>compile</scope>
- </dependency>
<dependency>
<groupId>org.codehaus.plexus</groupId>
<artifactId>plexus-utils</artifactId>
diff --git a/wagon-tcks/wagon-tck-http/src/main/java/org/apache/maven/wagon/tck/http/Assertions.java b/wagon-tcks/wagon-tck-http/src/main/java/org/apache/maven/wagon/tck/http/Assertions.java
index 35bda8d5..0a275b49 100644
--- a/wagon-tcks/wagon-tck-http/src/main/java/org/apache/maven/wagon/tck/http/Assertions.java
+++ b/wagon-tcks/wagon-tck-http/src/main/java/org/apache/maven/wagon/tck/http/Assertions.java
@@ -34,9 +34,9 @@
import org.slf4j.LoggerFactory;
import static org.codehaus.plexus.util.FileUtils.fileRead;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertTrue;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertTrue;
/**
*
@@ -53,7 +53,7 @@ public static void assertFileContentsFromResource(
String content = readResource(resourceBase, resourceName);
String test = fileRead(output);
- assertEquals(whyWouldItFail, content, test);
+ assertEquals(content, test, whyWouldItFail);
}
private static String readResource(final String base, final String name) throws IOException {
@@ -92,95 +92,95 @@ public static void assertWagonExceptionMessage(
// TODO: handle AuthenticationException for Wagon.connect() calls
assertNotNull(e);
try {
- assertTrue("only verify instances of WagonException", e instanceof WagonException);
+ assertTrue(e instanceof WagonException, "only verify instances of WagonException");
String reasonPhrase;
String assertMessageForBadMessage = "exception message not described properly";
if (proxyInfo != null) {
assertTrue(
- "message should end with proxy information if proxy was used",
- e.getMessage().endsWith(proxyInfo.toString()));
+ e.getMessage().endsWith(proxyInfo.toString()),
+ "message should end with proxy information if proxy was used");
}
switch (forStatusCode) {
case HttpServletResponse.SC_NOT_FOUND:
// TODO: add test for 410: Gone?
assertTrue(
- "404 not found response should throw ResourceDoesNotExistException",
- e instanceof ResourceDoesNotExistException);
+ e instanceof ResourceDoesNotExistException,
+ "404 not found response should throw ResourceDoesNotExistException");
reasonPhrase = (forReasonPhrase == null || forReasonPhrase.isEmpty())
? " Not Found"
: (" " + forReasonPhrase);
assertEquals(
- assertMessageForBadMessage,
"resource missing at " + forUrl + ", status: 404" + reasonPhrase,
- e.getMessage());
+ e.getMessage(),
+ assertMessageForBadMessage);
break;
case HttpServletResponse.SC_UNAUTHORIZED:
// FIXME assumes Wagon.get()/put() returning 401 instead of Wagon.connect()
assertTrue(
+ e instanceof AuthorizationException,
"401 Unauthorized should throw AuthorizationException since "
+ " AuthenticationException is not explicitly declared as thrown from wagon "
- + "methods",
- e instanceof AuthorizationException);
+ + "methods");
reasonPhrase = (forReasonPhrase == null || forReasonPhrase.isEmpty())
? " Unauthorized"
: (" " + forReasonPhrase);
assertEquals(
- assertMessageForBadMessage,
"authentication failed for " + forUrl + ", status: 401" + reasonPhrase,
- e.getMessage());
+ e.getMessage(),
+ assertMessageForBadMessage);
break;
case HttpServletResponse.SC_PROXY_AUTHENTICATION_REQUIRED:
assertTrue(
- "407 Proxy authentication required should throw AuthorizationException",
- e instanceof AuthorizationException);
+ e instanceof AuthorizationException,
+ "407 Proxy authentication required should throw AuthorizationException");
reasonPhrase = (forReasonPhrase == null || forReasonPhrase.isEmpty())
? " Proxy Authentication Required"
: (" " + forReasonPhrase);
assertEquals(
- assertMessageForBadMessage,
"proxy authentication failed for " + forUrl + ", status: 407" + reasonPhrase,
- e.getMessage());
+ e.getMessage(),
+ assertMessageForBadMessage);
break;
case HttpServletResponse.SC_FORBIDDEN:
assertTrue(
- "403 Forbidden should throw AuthorizationException", e instanceof AuthorizationException);
+ e instanceof AuthorizationException, "403 Forbidden should throw AuthorizationException");
reasonPhrase = (forReasonPhrase == null || forReasonPhrase.isEmpty())
? " Forbidden"
: (" " + forReasonPhrase);
assertEquals(
- assertMessageForBadMessage,
"authorization failed for " + forUrl + ", status: 403" + reasonPhrase,
- e.getMessage());
+ e.getMessage(),
+ assertMessageForBadMessage);
break;
default:
assertTrue(
- "transfer failures should at least be wrapped in a TransferFailedException",
- e instanceof TransferFailedException);
+ e instanceof TransferFailedException,
+ "transfer failures should at least be wrapped in a TransferFailedException");
// the status code and reason phrase cannot always be learned due to implementation limitations
// so the message may not include them, but the implementation should use a consistent format
assertTrue(
- "message should always include url tried: " + e.getMessage(),
- e.getMessage().startsWith("transfer failed for " + forUrl));
+ e.getMessage().startsWith("transfer failed for " + forUrl),
+ "message should always include url tried: " + e.getMessage());
String statusCodeStr = forStatusCode == NO_RESPONSE_STATUS_CODE ? "" : ", status: " + forStatusCode;
if (forStatusCode != NO_RESPONSE_STATUS_CODE) {
assertTrue(
- "if there was a response status line, the status code should be >= 400",
- forStatusCode >= HttpServletResponse.SC_BAD_REQUEST);
+ forStatusCode >= HttpServletResponse.SC_BAD_REQUEST,
+ "if there was a response status line, the status code should be >= 400");
if (e.getMessage().length() > ("transfer failed for " + forUrl).length()) {
assertTrue(
- "message should include url and status code: " + e.getMessage(),
- e.getMessage().startsWith("transfer failed for " + forUrl + statusCodeStr));
+ e.getMessage().startsWith("transfer failed for " + forUrl + statusCodeStr),
+ "message should include url and status code: " + e.getMessage());
}
reasonPhrase = forReasonPhrase == null ? "" : " " + forReasonPhrase;
@@ -189,10 +189,9 @@ public static void assertWagonExceptionMessage(
&& e.getMessage().length()
> ("transfer failed for " + forUrl + statusCodeStr).length()) {
assertTrue(
- "message should include url and status code and reason phrase: " + e.getMessage(),
e.getMessage()
- .startsWith(
- "transfer failed for " + forUrl + statusCodeStr + reasonPhrase));
+ .startsWith("transfer failed for " + forUrl + statusCodeStr + reasonPhrase),
+ "message should include url and status code and reason phrase: " + e.getMessage());
}
}
diff --git a/wagon-tcks/wagon-tck-http/src/main/java/org/apache/maven/wagon/tck/http/GetWagonTests.java b/wagon-tcks/wagon-tck-http/src/main/java/org/apache/maven/wagon/tck/http/GetWagonTests.java
index 688c16a7..73e77d2f 100644
--- a/wagon-tcks/wagon-tck-http/src/main/java/org/apache/maven/wagon/tck/http/GetWagonTests.java
+++ b/wagon-tcks/wagon-tck-http/src/main/java/org/apache/maven/wagon/tck/http/GetWagonTests.java
@@ -40,14 +40,15 @@
import org.apache.maven.wagon.tck.http.fixture.ServletExceptionServlet;
import org.apache.maven.wagon.tck.http.util.ValueHolder;
import org.codehaus.plexus.component.configurator.ComponentConfigurationException;
-import org.junit.Ignore;
-import org.junit.Test;
+import org.junit.jupiter.api.Disabled;
+import org.junit.jupiter.api.Test;
-import static junit.framework.Assert.assertTrue;
-import static junit.framework.Assert.fail;
import static org.apache.maven.wagon.tck.http.Assertions.NO_RESPONSE_STATUS_CODE;
import static org.apache.maven.wagon.tck.http.Assertions.assertFileContentsFromResource;
import static org.apache.maven.wagon.tck.http.Assertions.assertWagonExceptionMessage;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertTrue;
+import static org.junit.jupiter.api.Assertions.fail;
/**
*
@@ -64,7 +65,7 @@ public void basic()
}
@Test
- @Ignore("FIX ME!")
+ @Disabled("FIX ME!")
public void proxied()
throws ConnectionException, AuthenticationException, ComponentConfigurationException, IOException,
TransferFailedException, ResourceDoesNotExistException, AuthorizationException {
@@ -155,7 +156,7 @@ public void run() {
logger.info("Interrupting thread.");
t.interrupt();
- assertTrue("TransferFailedException should have been thrown.", holder.getValue() != null);
+ assertNotNull(holder.getValue(), "TransferFailedException should have been thrown.");
assertWagonExceptionMessage(holder.getValue(), NO_RESPONSE_STATUS_CODE, getBaseUrl() + "infinite/", "", null);
}
@@ -424,7 +425,7 @@ protected void testAuthFailure(final String path, final AuthenticationInfo info)
authFailure = true;
}
- assertTrue("Authentication/Authorization should have failed.", authFailure);
+ assertTrue(authFailure, "Authentication/Authorization should have failed.");
}
protected void testSuccessfulGet(final String path)
diff --git a/wagon-tcks/wagon-tck-http/src/main/java/org/apache/maven/wagon/tck/http/HttpWagonTests.java b/wagon-tcks/wagon-tck-http/src/main/java/org/apache/maven/wagon/tck/http/HttpWagonTests.java
index 55000dde..c7cb173a 100644
--- a/wagon-tcks/wagon-tck-http/src/main/java/org/apache/maven/wagon/tck/http/HttpWagonTests.java
+++ b/wagon-tcks/wagon-tck-http/src/main/java/org/apache/maven/wagon/tck/http/HttpWagonTests.java
@@ -38,10 +38,10 @@
import org.codehaus.plexus.component.configurator.ComponentConfigurationException;
import org.codehaus.plexus.component.repository.exception.ComponentLifecycleException;
import org.codehaus.plexus.util.FileUtils;
-import org.junit.After;
-import org.junit.AfterClass;
-import org.junit.Before;
-import org.junit.BeforeClass;
+import org.junit.jupiter.api.AfterAll;
+import org.junit.jupiter.api.AfterEach;
+import org.junit.jupiter.api.BeforeAll;
+import org.junit.jupiter.api.BeforeEach;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -72,14 +72,14 @@ public abstract class HttpWagonTests {
protected static final Logger logger = LoggerFactory.getLogger(HttpWagonTests.class);
// CHECKSTYLE_ON: ConstantName
- @Before
+ @BeforeEach
public void beforeEach() throws Exception {
serverFixture = new ServerFixture(isSsl());
serverFixture.start();
wagon = (Wagon) container.lookup(Wagon.ROLE, configurator.getWagonHint());
}
- @BeforeClass
+ @BeforeAll
public static void beforeAll() throws Exception {
File keystore = getResource(ServerFixture.SERVER_SSL_KEYSTORE_RESOURCE_PATH);
@@ -97,7 +97,7 @@ public static void beforeAll() throws Exception {
configurator = (WagonTestCaseConfigurator) container.lookup(WagonTestCaseConfigurator.class.getName());
}
- @After
+ @AfterEach
public void afterEach() {
try {
wagon.disconnect();
@@ -126,7 +126,7 @@ public void afterEach() {
}
}
- @AfterClass
+ @AfterAll
public static void afterAll() {
for (File f : TMP_FILES) {
if (f.exists()) {