diff --git a/pom.xml b/pom.xml
index df8a2ab..25f82b5 100644
--- a/pom.xml
+++ b/pom.xml
@@ -124,9 +124,8 @@
test
- junit
- junit
- 4.13.2
+ org.junit.jupiter
+ junit-jupiter-api
test
diff --git a/src/test/java/org/apache/maven/shared/io/download/DefaultDownloadManagerTest.java b/src/test/java/org/apache/maven/shared/io/download/DefaultDownloadManagerTest.java
index 33bbaad..b73469e 100644
--- a/src/test/java/org/apache/maven/shared/io/download/DefaultDownloadManagerTest.java
+++ b/src/test/java/org/apache/maven/shared/io/download/DefaultDownloadManagerTest.java
@@ -38,7 +38,8 @@
import org.apache.maven.wagon.events.TransferListener;
import org.apache.maven.wagon.proxy.ProxyInfo;
import org.apache.maven.wagon.repository.Repository;
-import org.codehaus.plexus.PlexusTestCase;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
import static org.easymock.EasyMock.anyObject;
import static org.easymock.EasyMock.anyString;
@@ -47,24 +48,29 @@
import static org.easymock.EasyMock.expectLastCall;
import static org.easymock.EasyMock.replay;
import static org.easymock.EasyMock.verify;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertSame;
+import static org.junit.jupiter.api.Assertions.assertTrue;
+import static org.junit.jupiter.api.Assertions.fail;
-public class DefaultDownloadManagerTest extends PlexusTestCase {
+public class DefaultDownloadManagerTest {
private WagonManager wagonManager;
private Wagon wagon;
+ @BeforeEach
public void setUp() throws Exception {
- super.setUp();
-
wagonManager = createMock(WagonManager.class);
wagon = createMock(Wagon.class);
}
+ @Test
public void testShouldConstructWithNoParamsAndHaveNonNullMessageHolder() {
new DefaultDownloadManager();
}
+ @Test
public void testShouldConstructWithWagonManager() {
replay(wagonManager);
@@ -73,10 +79,7 @@ public void testShouldConstructWithWagonManager() {
verify(wagonManager);
}
- public void testShouldLookupInstanceDefaultRoleHint() throws Exception {
- lookup(DownloadManager.ROLE, DefaultDownloadManager.ROLE_HINT);
- }
-
+ @Test
public void testShouldFailToDownloadMalformedURL() {
replay(wagonManager);
@@ -93,6 +96,7 @@ public void testShouldFailToDownloadMalformedURL() {
verify(wagonManager);
}
+ @Test
public void testShouldDownloadFromTempFileWithNoTransferListeners() throws IOException, DownloadFailedException {
File tempFile = Files.createTempFile("download-source", "test").toFile();
tempFile.deleteOnExit();
@@ -108,6 +112,7 @@ public void testShouldDownloadFromTempFileWithNoTransferListeners() throws IOExc
verify(wagon, wagonManager);
}
+ @Test
public void testShouldDownloadFromTempFileTwiceAndUseCache() throws IOException, DownloadFailedException {
File tempFile = Files.createTempFile("download-source", "test").toFile();
tempFile.deleteOnExit();
@@ -131,6 +136,7 @@ public void testShouldDownloadFromTempFileTwiceAndUseCache() throws IOException,
verify(wagon, wagonManager);
}
+ @Test
public void testShouldDownloadFromTempFileWithOneTransferListener() throws IOException, DownloadFailedException {
File tempFile = Files.createTempFile("download-source", "test").toFile();
tempFile.deleteOnExit();
@@ -155,6 +161,7 @@ public void testShouldDownloadFromTempFileWithOneTransferListener() throws IOExc
verify(wagon, wagonManager, transferListener);
}
+ @Test
public void testShouldFailToDownloadWhenWagonProtocolNotFound() throws IOException {
File tempFile = Files.createTempFile("download-source", "test").toFile();
tempFile.deleteOnExit();
@@ -176,6 +183,7 @@ public void testShouldFailToDownloadWhenWagonProtocolNotFound() throws IOExcepti
verify(wagon, wagonManager);
}
+ @Test
public void testShouldFailToDownloadWhenWagonConnectThrowsConnectionException() throws IOException {
File tempFile = Files.createTempFile("download-source", "test").toFile();
tempFile.deleteOnExit();
@@ -197,6 +205,7 @@ public void testShouldFailToDownloadWhenWagonConnectThrowsConnectionException()
verify(wagon, wagonManager);
}
+ @Test
public void testShouldFailToDownloadWhenWagonConnectThrowsAuthenticationException() throws IOException {
File tempFile = Files.createTempFile("download-source", "test").toFile();
tempFile.deleteOnExit();
@@ -218,6 +227,7 @@ public void testShouldFailToDownloadWhenWagonConnectThrowsAuthenticationExceptio
verify(wagon, wagonManager);
}
+ @Test
public void testShouldFailToDownloadWhenWagonGetThrowsTransferFailedException() throws IOException {
File tempFile = Files.createTempFile("download-source", "test").toFile();
tempFile.deleteOnExit();
@@ -239,6 +249,7 @@ public void testShouldFailToDownloadWhenWagonGetThrowsTransferFailedException()
verify(wagon, wagonManager);
}
+ @Test
public void testShouldFailToDownloadWhenWagonGetThrowsResourceDoesNotExistException() throws IOException {
File tempFile = Files.createTempFile("download-source", "test").toFile();
tempFile.deleteOnExit();
@@ -260,6 +271,7 @@ public void testShouldFailToDownloadWhenWagonGetThrowsResourceDoesNotExistExcept
verify(wagon, wagonManager);
}
+ @Test
public void testShouldFailToDownloadWhenWagonGetThrowsAuthorizationException() throws IOException {
File tempFile = Files.createTempFile("download-source", "test").toFile();
tempFile.deleteOnExit();
@@ -281,6 +293,7 @@ public void testShouldFailToDownloadWhenWagonGetThrowsAuthorizationException() t
verify(wagon, wagonManager);
}
+ @Test
public void testShouldFailToDownloadWhenWagonDisconnectThrowsConnectionException()
throws IOException, DownloadFailedException {
File tempFile = Files.createTempFile("download-source", "test").toFile();
diff --git a/src/test/java/org/apache/maven/shared/io/download/DownloadFailedExceptionTest.java b/src/test/java/org/apache/maven/shared/io/download/DownloadFailedExceptionTest.java
index c6a263e..ec75642 100644
--- a/src/test/java/org/apache/maven/shared/io/download/DownloadFailedExceptionTest.java
+++ b/src/test/java/org/apache/maven/shared/io/download/DownloadFailedExceptionTest.java
@@ -18,18 +18,23 @@
*/
package org.apache.maven.shared.io.download;
-import junit.framework.TestCase;
+import org.junit.jupiter.api.Test;
-public class DownloadFailedExceptionTest extends TestCase {
+import static org.junit.jupiter.api.Assertions.assertEquals;
+public class DownloadFailedExceptionTest {
+
+ @Test
public void testShouldConstructWithUrlAndMessage() {
new DownloadFailedException("http://www.google.com", "can't find.");
}
+ @Test
public void testShouldConstructWithUrlMessageAndException() {
new DownloadFailedException("http://www.google.com", "can't find.", new NullPointerException());
}
+ @Test
public void testShouldRetrieveUrlFromConstructor() {
String url = "http://www.google.com";
assertEquals(url, new DownloadFailedException(url, "can't find.").getUrl());
diff --git a/src/test/java/org/apache/maven/shared/io/location/ArtifactLocationTest.java b/src/test/java/org/apache/maven/shared/io/location/ArtifactLocationTest.java
index be7e198..654fd42 100644
--- a/src/test/java/org/apache/maven/shared/io/location/ArtifactLocationTest.java
+++ b/src/test/java/org/apache/maven/shared/io/location/ArtifactLocationTest.java
@@ -22,15 +22,19 @@
import java.io.IOException;
import java.nio.file.Files;
-import junit.framework.TestCase;
import org.apache.commons.io.FileUtils;
import org.apache.maven.artifact.Artifact;
import org.apache.maven.artifact.DefaultArtifact;
import org.apache.maven.artifact.handler.DefaultArtifactHandler;
import org.apache.maven.artifact.versioning.VersionRange;
+import org.junit.jupiter.api.Test;
-public class ArtifactLocationTest extends TestCase {
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertSame;
+public class ArtifactLocationTest {
+
+ @Test
public void testShouldConstructFromTempFileSpecification() throws IOException {
File f = Files.createTempFile("artifact-location.", ".test").toFile();
f.deleteOnExit();
@@ -51,6 +55,7 @@ public void testShouldConstructFromTempFileSpecification() throws IOException {
assertSame(f, location.getFile());
}
+ @Test
public void testShouldRead() throws IOException {
File f = Files.createTempFile("url-location.", ".test").toFile();
f.deleteOnExit();
diff --git a/src/test/java/org/apache/maven/shared/io/location/ArtifactLocatorStrategyTest.java b/src/test/java/org/apache/maven/shared/io/location/ArtifactLocatorStrategyTest.java
index e0be807..1675679 100644
--- a/src/test/java/org/apache/maven/shared/io/location/ArtifactLocatorStrategyTest.java
+++ b/src/test/java/org/apache/maven/shared/io/location/ArtifactLocatorStrategyTest.java
@@ -23,7 +23,6 @@
import java.nio.file.Files;
import java.util.Collections;
-import junit.framework.TestCase;
import org.apache.maven.artifact.Artifact;
import org.apache.maven.artifact.factory.ArtifactFactory;
import org.apache.maven.artifact.repository.ArtifactRepository;
@@ -32,10 +31,13 @@
import org.apache.maven.artifact.resolver.ArtifactResolver;
import org.apache.maven.shared.io.logging.DefaultMessageHolder;
import org.apache.maven.shared.io.logging.MessageHolder;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
import static org.easymock.EasyMock.*;
+import static org.junit.jupiter.api.Assertions.*;
-public class ArtifactLocatorStrategyTest extends TestCase {
+public class ArtifactLocatorStrategyTest {
private ArtifactFactory factory;
@@ -43,12 +45,14 @@ public class ArtifactLocatorStrategyTest extends TestCase {
private ArtifactRepository localRepository;
+ @BeforeEach
public void setUp() {
factory = createMock(ArtifactFactory.class);
resolver = createMock(ArtifactResolver.class);
localRepository = createMock(ArtifactRepository.class);
}
+ @Test
public void testShouldConstructWithoutDefaultArtifactType() {
replay(factory, resolver, localRepository);
@@ -57,6 +61,7 @@ public void testShouldConstructWithoutDefaultArtifactType() {
verify(factory, resolver, localRepository);
}
+ @Test
public void testShouldConstructWithDefaultArtifactType() {
replay(factory, resolver, localRepository);
@@ -65,6 +70,7 @@ public void testShouldConstructWithDefaultArtifactType() {
verify(factory, resolver, localRepository);
}
+ @Test
public void testShouldFailToResolveSpecWithOneToken() {
replay(factory, resolver, localRepository);
@@ -80,6 +86,7 @@ public void testShouldFailToResolveSpecWithOneToken() {
verify(factory, resolver, localRepository);
}
+ @Test
public void testShouldFailToResolveSpecWithTwoTokens() {
replay(factory, resolver, localRepository);
@@ -95,6 +102,7 @@ public void testShouldFailToResolveSpecWithTwoTokens() {
verify(factory, resolver, localRepository);
}
+ @Test
public void testShouldResolveSpecWithThreeTokensUsingDefaultType() throws IOException {
File tempFile = Files.createTempFile("artifact-location.", ".temp").toFile();
tempFile.deleteOnExit();
@@ -133,6 +141,7 @@ public void testShouldResolveSpecWithThreeTokensUsingDefaultType() throws IOExce
verify(factory, resolver, localRepository, artifact);
}
+ @Test
public void testShouldResolveSpecWithThreeTokensUsingCustomizedDefaultType() throws IOException {
File tempFile = Files.createTempFile("artifact-location.", ".temp").toFile();
tempFile.deleteOnExit();
@@ -171,6 +180,7 @@ public void testShouldResolveSpecWithThreeTokensUsingCustomizedDefaultType() thr
verify(factory, resolver, localRepository, artifact);
}
+ @Test
public void testShouldResolveSpecWithFourTokens() throws IOException {
File tempFile = Files.createTempFile("artifact-location.", ".temp").toFile();
tempFile.deleteOnExit();
@@ -209,6 +219,7 @@ public void testShouldResolveSpecWithFourTokens() throws IOException {
verify(factory, resolver, localRepository, artifact);
}
+ @Test
public void testShouldResolveSpecWithFiveTokens() throws IOException {
File tempFile = Files.createTempFile("artifact-location.", ".temp").toFile();
tempFile.deleteOnExit();
@@ -247,6 +258,7 @@ public void testShouldResolveSpecWithFiveTokens() throws IOException {
verify(factory, resolver, localRepository, artifact);
}
+ @Test
public void testShouldResolveSpecWithFiveTokensAndEmptyTypeToken() throws IOException {
File tempFile = Files.createTempFile("artifact-location.", ".temp").toFile();
tempFile.deleteOnExit();
@@ -285,6 +297,7 @@ public void testShouldResolveSpecWithFiveTokensAndEmptyTypeToken() throws IOExce
verify(factory, resolver, localRepository, artifact);
}
+ @Test
public void testShouldResolveSpecWithMoreThanFiveTokens() throws IOException {
File tempFile = Files.createTempFile("artifact-location.", ".temp").toFile();
tempFile.deleteOnExit();
@@ -325,6 +338,7 @@ public void testShouldResolveSpecWithMoreThanFiveTokens() throws IOException {
verify(factory, resolver, localRepository, artifact);
}
+ @Test
public void testShouldNotResolveSpecToArtifactWithNullFile() throws IOException {
Artifact artifact = createMock(Artifact.class);
@@ -360,6 +374,7 @@ public void testShouldNotResolveSpecToArtifactWithNullFile() throws IOException
verify(factory, resolver, localRepository, artifact);
}
+ @Test
public void testShouldNotResolveWhenArtifactNotFoundExceptionThrown() throws IOException {
Artifact artifact = createMock(Artifact.class);
@@ -407,6 +422,7 @@ public void testShouldNotResolveWhenArtifactNotFoundExceptionThrown() throws IOE
verify(factory, resolver, localRepository, artifact);
}
+ @Test
public void testShouldNotResolveWhenArtifactResolutionExceptionThrown() throws IOException {
Artifact artifact = createMock(Artifact.class);
diff --git a/src/test/java/org/apache/maven/shared/io/location/ClasspathResourceLocatorStrategyTest.java b/src/test/java/org/apache/maven/shared/io/location/ClasspathResourceLocatorStrategyTest.java
index e6d26a3..ab0fff3 100644
--- a/src/test/java/org/apache/maven/shared/io/location/ClasspathResourceLocatorStrategyTest.java
+++ b/src/test/java/org/apache/maven/shared/io/location/ClasspathResourceLocatorStrategyTest.java
@@ -18,20 +18,25 @@
*/
package org.apache.maven.shared.io.location;
-import junit.framework.TestCase;
import org.apache.maven.shared.io.logging.DefaultMessageHolder;
import org.apache.maven.shared.io.logging.MessageHolder;
+import org.junit.jupiter.api.Test;
-public class ClasspathResourceLocatorStrategyTest extends TestCase {
+import static org.junit.jupiter.api.Assertions.*;
+public class ClasspathResourceLocatorStrategyTest {
+
+ @Test
public void testShouldConstructWithNoParams() {
new ClasspathResourceLocatorStrategy();
}
+ @Test
public void testShouldConstructWithTempFileOptions() {
new ClasspathResourceLocatorStrategy("prefix.", ".suffix", true);
}
+ @Test
public void testShouldFailToResolveMissingClasspathResource() {
MessageHolder mh = new DefaultMessageHolder();
Location location = new ClasspathResourceLocatorStrategy().resolve("/some/missing/path", mh);
@@ -40,6 +45,7 @@ public void testShouldFailToResolveMissingClasspathResource() {
assertEquals(1, mh.size());
}
+ @Test
public void testShouldResolveExistingClasspathResourceWithoutPrecedingSlash() {
MessageHolder mh = new DefaultMessageHolder();
Location location = new ClasspathResourceLocatorStrategy().resolve("META-INF/maven/test.properties", mh);
diff --git a/src/test/java/org/apache/maven/shared/io/location/FileLocationTest.java b/src/test/java/org/apache/maven/shared/io/location/FileLocationTest.java
index b211dbf..fec84ef 100644
--- a/src/test/java/org/apache/maven/shared/io/location/FileLocationTest.java
+++ b/src/test/java/org/apache/maven/shared/io/location/FileLocationTest.java
@@ -25,12 +25,15 @@
import java.nio.ByteBuffer;
import java.nio.file.Files;
-import junit.framework.TestCase;
import org.apache.commons.io.FileUtils;
import org.apache.commons.io.IOUtils;
+import org.junit.jupiter.api.Test;
-public class FileLocationTest extends TestCase {
+import static org.junit.jupiter.api.Assertions.*;
+public class FileLocationTest {
+
+ @Test
public void testShouldConstructWithFileThenRetrieveSameFile() throws IOException {
File file = Files.createTempFile("test.", ".file-location").toFile();
file.deleteOnExit();
@@ -41,6 +44,7 @@ public void testShouldConstructWithFileThenRetrieveSameFile() throws IOException
assertEquals(file.getAbsolutePath(), location.getSpecification());
}
+ @Test
public void testShouldReadFileContentsUsingByteBuffer() throws IOException {
File file = Files.createTempFile("test.", ".file-location").toFile();
file.deleteOnExit();
@@ -59,6 +63,7 @@ public void testShouldReadFileContentsUsingByteBuffer() throws IOException {
assertEquals(testStr, new String(buffer.array(), "US-ASCII"));
}
+ @Test
public void testShouldReadFileContentsUsingStream() throws IOException {
File file = Files.createTempFile("test.", ".file-location").toFile();
file.deleteOnExit();
@@ -79,6 +84,7 @@ public void testShouldReadFileContentsUsingStream() throws IOException {
}
}
+ @Test
public void testShouldReadFileContentsUsingByteArray() throws IOException {
File file = Files.createTempFile("test.", ".file-location").toFile();
file.deleteOnExit();
@@ -97,6 +103,7 @@ public void testShouldReadFileContentsUsingByteArray() throws IOException {
assertEquals(testStr, new String(buffer, "US-ASCII"));
}
+ @Test
public void testShouldReadThenClose() throws IOException {
File file = Files.createTempFile("test.", ".file-location").toFile();
file.deleteOnExit();
@@ -117,6 +124,7 @@ public void testShouldReadThenClose() throws IOException {
location.close();
}
+ @Test
public void testShouldOpenThenFailToSetFile() throws IOException {
File file = Files.createTempFile("test.", ".file-location").toFile();
file.deleteOnExit();
@@ -133,6 +141,7 @@ public void testShouldOpenThenFailToSetFile() throws IOException {
}
}
+ @Test
public void testShouldConstructWithoutFileThenSetFileThenOpen() throws IOException {
File file = Files.createTempFile("test.", ".file-location").toFile();
file.deleteOnExit();
@@ -143,6 +152,7 @@ public void testShouldConstructWithoutFileThenSetFileThenOpen() throws IOExcepti
location.open();
}
+ @Test
public void testShouldConstructWithLocationThenRetrieveEquivalentFile() throws IOException {
File file = Files.createTempFile("test.", ".file-location").toFile();
file.deleteOnExit();
diff --git a/src/test/java/org/apache/maven/shared/io/location/FileLocatorStrategyTest.java b/src/test/java/org/apache/maven/shared/io/location/FileLocatorStrategyTest.java
index 83d2b95..2d5c82a 100644
--- a/src/test/java/org/apache/maven/shared/io/location/FileLocatorStrategyTest.java
+++ b/src/test/java/org/apache/maven/shared/io/location/FileLocatorStrategyTest.java
@@ -22,12 +22,15 @@
import java.io.IOException;
import java.nio.file.Files;
-import junit.framework.TestCase;
import org.apache.maven.shared.io.logging.DefaultMessageHolder;
import org.apache.maven.shared.io.logging.MessageHolder;
+import org.junit.jupiter.api.Test;
-public class FileLocatorStrategyTest extends TestCase {
+import static org.junit.jupiter.api.Assertions.*;
+public class FileLocatorStrategyTest {
+
+ @Test
public void testShouldResolveExistingTempFileLocation() throws IOException {
File f = Files.createTempFile("file-locator.", ".test").toFile();
f.deleteOnExit();
@@ -45,6 +48,7 @@ public void testShouldResolveExistingTempFileLocation() throws IOException {
assertEquals(f, location.getFile());
}
+ @Test
public void testShouldFailToResolveNonExistentFileLocation() throws IOException {
File f = Files.createTempFile("file-locator.", ".test").toFile();
f.delete();
diff --git a/src/test/java/org/apache/maven/shared/io/location/LocatorTest.java b/src/test/java/org/apache/maven/shared/io/location/LocatorTest.java
index 6ce410c..b14d591 100644
--- a/src/test/java/org/apache/maven/shared/io/location/LocatorTest.java
+++ b/src/test/java/org/apache/maven/shared/io/location/LocatorTest.java
@@ -22,22 +22,26 @@
import java.util.Collections;
import java.util.List;
-import junit.framework.TestCase;
import org.apache.maven.shared.io.logging.DefaultMessageHolder;
import org.apache.maven.shared.io.logging.MessageHolder;
+import org.junit.jupiter.api.Test;
import static org.easymock.EasyMock.*;
+import static org.junit.jupiter.api.Assertions.*;
-public class LocatorTest extends TestCase {
+public class LocatorTest {
+ @Test
public void testShouldConstructWithNoParams() {
new Locator();
}
+ @Test
public void testShouldConstructWithStrategyStackAndMessageHolder() {
new Locator(Collections.emptyList(), new DefaultMessageHolder());
}
+ @Test
public void testShouldAllowModificationOfStrategiesAfterConstructionWithUnmodifiableStack() {
Locator locator = new Locator(
Collections.unmodifiableList(Collections.emptyList()), new DefaultMessageHolder());
@@ -47,10 +51,12 @@ public void testShouldAllowModificationOfStrategiesAfterConstructionWithUnmodifi
assertEquals(1, locator.getStrategies().size());
}
+ @Test
public void testShouldRetrieveNonNullMessageHolderWhenConstructedWithoutParams() {
assertNotNull(new Locator().getMessageHolder());
}
+ @Test
public void testSetStrategiesShouldClearAnyPreExistingStrategiesOut() {
LocatorStrategy originalStrategy = createMock(LocatorStrategy.class);
LocatorStrategy replacementStrategy = createMock(LocatorStrategy.class);
@@ -70,6 +76,7 @@ public void testSetStrategiesShouldClearAnyPreExistingStrategiesOut() {
verify(originalStrategy, replacementStrategy);
}
+ @Test
public void testShouldRemovePreviouslyAddedStrategy() {
LocatorStrategy originalStrategy = createMock(LocatorStrategy.class);
@@ -91,6 +98,7 @@ public void testShouldRemovePreviouslyAddedStrategy() {
verify(originalStrategy);
}
+ @Test
public void testResolutionFallsThroughStrategyStackAndReturnsNullIfNotResolved() {
List strategies = new ArrayList<>();
diff --git a/src/test/java/org/apache/maven/shared/io/location/URLLocationTest.java b/src/test/java/org/apache/maven/shared/io/location/URLLocationTest.java
index 9575eb6..c74e145 100644
--- a/src/test/java/org/apache/maven/shared/io/location/URLLocationTest.java
+++ b/src/test/java/org/apache/maven/shared/io/location/URLLocationTest.java
@@ -23,11 +23,14 @@
import java.net.URL;
import java.nio.file.Files;
-import junit.framework.TestCase;
import org.apache.commons.io.FileUtils;
+import org.junit.jupiter.api.Test;
-public class URLLocationTest extends TestCase {
+import static org.junit.jupiter.api.Assertions.*;
+public class URLLocationTest {
+
+ @Test
public void testShouldConstructFromUrlAndTempFileSpecifications() throws IOException {
File f = Files.createTempFile("url-location.", ".test").toFile();
f.deleteOnExit();
@@ -37,6 +40,7 @@ public void testShouldConstructFromUrlAndTempFileSpecifications() throws IOExcep
new URLLocation(url, f.getAbsolutePath(), "prefix.", ".suffix", true);
}
+ @Test
public void testShouldTransferFromTempFile() throws IOException {
File f = Files.createTempFile("url-location.", ".test").toFile();
f.deleteOnExit();
@@ -49,6 +53,7 @@ public void testShouldTransferFromTempFile() throws IOException {
assertFalse(f.equals(location.getFile()));
}
+ @Test
public void testShouldTransferFromTempFileThenRead() throws IOException {
File f = Files.createTempFile("url-location.", ".test").toFile();
f.deleteOnExit();
diff --git a/src/test/java/org/apache/maven/shared/io/location/URLLocatorStrategyTest.java b/src/test/java/org/apache/maven/shared/io/location/URLLocatorStrategyTest.java
index 8cb0c37..e3f81d2 100644
--- a/src/test/java/org/apache/maven/shared/io/location/URLLocatorStrategyTest.java
+++ b/src/test/java/org/apache/maven/shared/io/location/URLLocatorStrategyTest.java
@@ -22,21 +22,26 @@
import java.io.IOException;
import java.nio.file.Files;
-import junit.framework.TestCase;
import org.apache.commons.io.FileUtils;
import org.apache.maven.shared.io.logging.DefaultMessageHolder;
import org.apache.maven.shared.io.logging.MessageHolder;
+import org.junit.jupiter.api.Test;
-public class URLLocatorStrategyTest extends TestCase {
+import static org.junit.jupiter.api.Assertions.*;
+public class URLLocatorStrategyTest {
+
+ @Test
public void testShouldConstructWithNoParams() {
new URLLocatorStrategy();
}
+ @Test
public void testShouldConstructWithTempFileOptions() {
new URLLocatorStrategy("prefix.", ".suffix", true);
}
+ @Test
public void testShouldFailToResolveWithMalformedUrl() {
MessageHolder mh = new DefaultMessageHolder();
@@ -46,6 +51,7 @@ public void testShouldFailToResolveWithMalformedUrl() {
assertEquals(1, mh.size());
}
+ @Test
public void testShouldResolveUrlForTempFile() throws IOException {
File tempFile = Files.createTempFile("prefix.", ".suffix").toFile();
tempFile.deleteOnExit();
diff --git a/src/test/java/org/apache/maven/shared/io/logging/DefaultMessageHolderTest.java b/src/test/java/org/apache/maven/shared/io/logging/DefaultMessageHolderTest.java
index ea20898..e06fba1 100644
--- a/src/test/java/org/apache/maven/shared/io/logging/DefaultMessageHolderTest.java
+++ b/src/test/java/org/apache/maven/shared/io/logging/DefaultMessageHolderTest.java
@@ -21,13 +21,16 @@
import java.io.PrintWriter;
import java.io.StringWriter;
-import junit.framework.TestCase;
+import org.junit.jupiter.api.Test;
-public class DefaultMessageHolderTest extends TestCase {
+import static org.junit.jupiter.api.Assertions.*;
+
+public class DefaultMessageHolderTest {
// MessageHolder newMessage();
// int size();
// String render();
+ @Test
public void testNewMessageIncrementsSizeWhenEmpty() {
MessageHolder mh = new DefaultMessageHolder();
@@ -45,6 +48,7 @@ public void testNewMessageIncrementsSizeWhenEmpty() {
// MessageHolder append( CharSequence messagePart );
// int size();
// String render();
+ @Test
public void testAppendCreatesNewMessageIfNoneCurrent() {
MessageHolder mh = new DefaultMessageHolder();
@@ -62,6 +66,7 @@ public void testAppendCreatesNewMessageIfNoneCurrent() {
// MessageHolder append( Throwable error );
// int size();
// String render();
+ @Test
public void testAppendErrorCreatesNewMessageIfNoneCurrent() {
MessageHolder mh = new DefaultMessageHolder();
@@ -87,6 +92,7 @@ public void testAppendErrorCreatesNewMessageIfNoneCurrent() {
// MessageHolder append( CharSequence messagePart );
// int size();
// String render();
+ @Test
public void testNewMessageThenAppendOnlyIncrementsSizeByOne() {
MessageHolder mh = new DefaultMessageHolder();
@@ -110,6 +116,7 @@ public void testNewMessageThenAppendOnlyIncrementsSizeByOne() {
// MessageHolder append( CharSequence messagePart );
// int size();
// String render();
+ @Test
public void testNewMessageThenAppendTwiceOnlyIncrementsSizeByOne() {
MessageHolder mh = new DefaultMessageHolder();
@@ -137,6 +144,7 @@ public void testNewMessageThenAppendTwiceOnlyIncrementsSizeByOne() {
// MessageHolder append( Throwable error );
// int size();
// String render();
+ @Test
public void testNewMessageThenAppendBothMessageAndErrorOnlyIncrementsSizeByOne() {
MessageHolder mh = new DefaultMessageHolder();
@@ -169,6 +177,7 @@ public void testNewMessageThenAppendBothMessageAndErrorOnlyIncrementsSizeByOne()
// MessageHolder addMessage( CharSequence messagePart );
// int size();
// String render();
+ @Test
public void testAddMessageIncrementsSizeByOne() {
MessageHolder mh = new DefaultMessageHolder();
MessageHolder check = mh.addMessage("test");
@@ -182,6 +191,7 @@ public void testAddMessageIncrementsSizeByOne() {
// MessageHolder addMessage( CharSequence messagePart );
// int size();
// String render();
+ @Test
public void testAddMessageTwiceIncrementsSizeByTwo() {
MessageHolder mh = new DefaultMessageHolder();
MessageHolder check = mh.addMessage("test");
@@ -199,6 +209,7 @@ public void testAddMessageTwiceIncrementsSizeByTwo() {
// MessageHolder addMessage( CharSequence messagePart, Throwable error );
// int size();
// String render();
+ @Test
public void testAddMessageWithErrorIncrementsSizeByOne() {
MessageHolder mh = new DefaultMessageHolder();
@@ -222,6 +233,7 @@ public void testAddMessageWithErrorIncrementsSizeByOne() {
// MessageHolder addMessage( CharSequence messagePart );
// int size();
// String render();
+ @Test
public void testAddMessageWithErrorThenWithJustMessageIncrementsSizeByTwo() {
MessageHolder mh = new DefaultMessageHolder();
@@ -248,6 +260,7 @@ public void testAddMessageWithErrorThenWithJustMessageIncrementsSizeByTwo() {
// MessageHolder addMessage( Throwable error );
// int size();
// String render();
+ @Test
public void testAddMessageWithJustErrorIncrementsSizeByOne() {
MessageHolder mh = new DefaultMessageHolder();
@@ -268,15 +281,18 @@ public void testAddMessageWithJustErrorIncrementsSizeByOne() {
}
// boolean isEmpty();
+ @Test
public void testIsEmptyAfterConstruction() {
assertTrue(new DefaultMessageHolder().isEmpty());
}
// boolean isEmpty();
+ @Test
public void testIsNotEmptyAfterConstructionAndNewMessageCall() {
assertFalse(new DefaultMessageHolder().newMessage().isEmpty());
}
+ @Test
public void testAppendCharSequence() {
MessageHolder mh = new DefaultMessageHolder();
mh.newMessage().append(new StringBuffer("This is a test"));
diff --git a/src/test/java/org/apache/maven/shared/io/scan/SimpleResourceInclusionScannerTest.java b/src/test/java/org/apache/maven/shared/io/scan/SimpleResourceInclusionScannerTest.java
index 6e4ea99..9022121 100644
--- a/src/test/java/org/apache/maven/shared/io/scan/SimpleResourceInclusionScannerTest.java
+++ b/src/test/java/org/apache/maven/shared/io/scan/SimpleResourceInclusionScannerTest.java
@@ -25,10 +25,10 @@
import java.util.Set;
import org.apache.maven.shared.io.scan.mapping.SuffixMapping;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertTrue;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertTrue;
/**
* @author dengliming
diff --git a/src/test/java/org/apache/maven/shared/io/scan/mapping/SuffixMappingTest.java b/src/test/java/org/apache/maven/shared/io/scan/mapping/SuffixMappingTest.java
index 461aeb6..e97e26d 100644
--- a/src/test/java/org/apache/maven/shared/io/scan/mapping/SuffixMappingTest.java
+++ b/src/test/java/org/apache/maven/shared/io/scan/mapping/SuffixMappingTest.java
@@ -23,10 +23,10 @@
import java.util.Set;
import org.apache.maven.shared.io.scan.InclusionScanException;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertTrue;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertTrue;
/**
* @author jdcasey
@@ -42,12 +42,9 @@ public void testShouldReturnSingleClassFileForSingleJavaFile() throws InclusionS
Set results = mapping.getTargetFiles(basedir, base + ".java");
- assertEquals("Returned wrong number of target files.", 1, results.size());
+ assertEquals(1, results.size(), "Returned wrong number of target files.");
- assertEquals(
- "Target file is wrong.",
- new File(basedir, base + ".class"),
- results.iterator().next());
+ assertEquals(new File(basedir, base + ".class"), results.iterator().next(), "Target file is wrong.");
}
@Test
@@ -60,7 +57,7 @@ public void testShouldNotReturnClassFileWhenSourceFileHasWrongSuffix() throws In
Set results = mapping.getTargetFiles(basedir, base + ".xml");
- assertTrue("Returned wrong number of target files.", results.isEmpty());
+ assertTrue(results.isEmpty(), "Returned wrong number of target files.");
}
@Test
@@ -77,11 +74,11 @@ public void testShouldReturnOneClassFileAndOneXmlFileForSingleJavaFile() throws
Set results = mapping.getTargetFiles(basedir, base + ".java");
- assertEquals("Returned wrong number of target files.", 2, results.size());
+ assertEquals(2, results.size(), "Returned wrong number of target files.");
- assertTrue("Targets do not contain class target.", results.contains(new File(basedir, base + ".class")));
+ assertTrue(results.contains(new File(basedir, base + ".class")), "Targets do not contain class target.");
- assertTrue("Targets do not contain class target.", results.contains(new File(basedir, base + ".xml")));
+ assertTrue(results.contains(new File(basedir, base + ".xml")), "Targets do not contain class target.");
}
@Test
@@ -98,7 +95,7 @@ public void testShouldReturnNoTargetFilesWhenSourceFileHasWrongSuffix() throws I
Set results = mapping.getTargetFiles(basedir, base + ".apt");
- assertTrue("Returned wrong number of target files.", results.isEmpty());
+ assertTrue(results.isEmpty(), "Returned wrong number of target files.");
}
@Test