This is an automated email from the ASF dual-hosted git repository.
slachiewicz pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/maven-shared-io.git
The following commit(s) were added to refs/heads/master by this push:
new bfc4f70 Cleanup tests (#77)
bfc4f70 is described below
commit bfc4f7037ad7a760c74967f7dcf5395b9ae8a4e8
Author: Sylwester Lachiewicz <[email protected]>
AuthorDate: Sun Dec 21 15:03:38 2025 +0100
Cleanup tests (#77)
Co-authored-by: Moderne <[email protected]>
---
pom.xml | 5 +-
.../io/download/DefaultDownloadManagerTest.java | 159 +++++++++------------
.../io/download/DownloadFailedExceptionTest.java | 8 +-
.../shared/io/location/ArtifactLocationTest.java | 7 +-
.../io/location/ArtifactLocatorStrategyTest.java | 88 ++++--------
.../ClasspathResourceLocatorStrategyTest.java | 10 +-
.../maven/shared/io/location/FileLocationTest.java | 37 +++--
.../io/location/FileLocatorStrategyTest.java | 7 +-
.../maven/shared/io/location/LocatorTest.java | 19 ++-
.../maven/shared/io/location/URLLocationTest.java | 13 +-
.../shared/io/location/URLLocatorStrategyTest.java | 11 +-
.../io/logging/DefaultMessageHolderTest.java | 32 ++---
.../scan/SimpleResourceInclusionScannerTest.java | 18 +--
.../shared/io/scan/mapping/SuffixMappingTest.java | 13 +-
14 files changed, 179 insertions(+), 248 deletions(-)
diff --git a/pom.xml b/pom.xml
index f1084db..a716c1d 100644
--- a/pom.xml
+++ b/pom.xml
@@ -104,9 +104,8 @@
<version>3.4.2</version>
</dependency>
<dependency>
- <groupId>org.sonatype.sisu</groupId>
- <artifactId>sisu-inject-plexus</artifactId>
- <version>2.6.0</version>
+ <groupId>org.eclipse.sisu</groupId>
+ <artifactId>org.eclipse.sisu.plexus</artifactId>
</dependency>
<dependency>
<groupId>commons-io</groupId>
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 b73469e..27a566f 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
@@ -19,7 +19,6 @@
package org.apache.maven.shared.io.download;
import java.io.File;
-import java.io.IOException;
import java.nio.file.Files;
import java.util.Collections;
@@ -48,30 +47,31 @@ import static org.easymock.EasyMock.expect;
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.assertDoesNotThrow;
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 {
+class DefaultDownloadManagerTest {
private WagonManager wagonManager;
private Wagon wagon;
@BeforeEach
- public void setUp() throws Exception {
+ void setUp() {
wagonManager = createMock(WagonManager.class);
wagon = createMock(Wagon.class);
}
@Test
- public void testShouldConstructWithNoParamsAndHaveNonNullMessageHolder() {
+ void shouldConstructWithNoParamsAndHaveNonNullMessageHolder() {
new DefaultDownloadManager();
}
@Test
- public void testShouldConstructWithWagonManager() {
+ void shouldConstructWithWagonManager() {
replay(wagonManager);
new DefaultDownloadManager(wagonManager);
@@ -80,7 +80,7 @@ public class DefaultDownloadManagerTest {
}
@Test
- public void testShouldFailToDownloadMalformedURL() {
+ void shouldFailToDownloadMalformedURL() {
replay(wagonManager);
DownloadManager mgr = new DefaultDownloadManager(wagonManager);
@@ -90,14 +90,14 @@ public class DefaultDownloadManagerTest {
fail("Should not download with invalid URL.");
} catch (DownloadFailedException e) {
- assertTrue(e.getMessage().indexOf("invalid URL") > -1);
+ assertTrue(e.getMessage().contains("invalid URL"));
}
verify(wagonManager);
}
@Test
- public void testShouldDownloadFromTempFileWithNoTransferListeners() throws
IOException, DownloadFailedException {
+ void shouldDownloadFromTempFileWithNoTransferListeners() throws Exception {
File tempFile = Files.createTempFile("download-source",
"test").toFile();
tempFile.deleteOnExit();
@@ -113,7 +113,7 @@ public class DefaultDownloadManagerTest {
}
@Test
- public void testShouldDownloadFromTempFileTwiceAndUseCache() throws
IOException, DownloadFailedException {
+ void shouldDownloadFromTempFileTwiceAndUseCache() throws Exception {
File tempFile = Files.createTempFile("download-source",
"test").toFile();
tempFile.deleteOnExit();
@@ -131,13 +131,13 @@ public class DefaultDownloadManagerTest {
assertSame(first, second);
assertEquals(1, mh.size());
- assertTrue(mh.render().indexOf("Using cached") > -1);
+ assertTrue(mh.render().contains("Using cached"));
verify(wagon, wagonManager);
}
@Test
- public void testShouldDownloadFromTempFileWithOneTransferListener() throws
IOException, DownloadFailedException {
+ void shouldDownloadFromTempFileWithOneTransferListener() throws Exception {
File tempFile = Files.createTempFile("download-source",
"test").toFile();
tempFile.deleteOnExit();
@@ -162,7 +162,7 @@ public class DefaultDownloadManagerTest {
}
@Test
- public void testShouldFailToDownloadWhenWagonProtocolNotFound() throws
IOException {
+ void shouldFailToDownloadWhenWagonProtocolNotFound() throws Exception {
File tempFile = Files.createTempFile("download-source",
"test").toFile();
tempFile.deleteOnExit();
@@ -177,14 +177,14 @@ public class DefaultDownloadManagerTest {
fail("should have failed to retrieve wagon.");
} catch (DownloadFailedException e) {
-
assertTrue(ExceptionUtils.getStackTrace(e).indexOf("UnsupportedProtocolException")
> -1);
+
assertTrue(ExceptionUtils.getStackTrace(e).contains("UnsupportedProtocolException"));
}
verify(wagon, wagonManager);
}
@Test
- public void
testShouldFailToDownloadWhenWagonConnectThrowsConnectionException() throws
IOException {
+ void shouldFailToDownloadWhenWagonConnectThrowsConnectionException()
throws Exception {
File tempFile = Files.createTempFile("download-source",
"test").toFile();
tempFile.deleteOnExit();
@@ -199,14 +199,14 @@ public class DefaultDownloadManagerTest {
fail("should have failed to connect wagon.");
} catch (DownloadFailedException e) {
-
assertTrue(ExceptionUtils.getStackTrace(e).indexOf("ConnectionException") > -1);
+
assertTrue(ExceptionUtils.getStackTrace(e).contains("ConnectionException"));
}
verify(wagon, wagonManager);
}
@Test
- public void
testShouldFailToDownloadWhenWagonConnectThrowsAuthenticationException() throws
IOException {
+ void shouldFailToDownloadWhenWagonConnectThrowsAuthenticationException()
throws Exception {
File tempFile = Files.createTempFile("download-source",
"test").toFile();
tempFile.deleteOnExit();
@@ -221,14 +221,14 @@ public class DefaultDownloadManagerTest {
fail("should have failed to connect wagon.");
} catch (DownloadFailedException e) {
-
assertTrue(ExceptionUtils.getStackTrace(e).indexOf("AuthenticationException") >
-1);
+
assertTrue(ExceptionUtils.getStackTrace(e).contains("AuthenticationException"));
}
verify(wagon, wagonManager);
}
@Test
- public void
testShouldFailToDownloadWhenWagonGetThrowsTransferFailedException() throws
IOException {
+ void shouldFailToDownloadWhenWagonGetThrowsTransferFailedException()
throws Exception {
File tempFile = Files.createTempFile("download-source",
"test").toFile();
tempFile.deleteOnExit();
@@ -243,14 +243,14 @@ public class DefaultDownloadManagerTest {
fail("should have failed to get resource.");
} catch (DownloadFailedException e) {
-
assertTrue(ExceptionUtils.getStackTrace(e).indexOf("TransferFailedException") >
-1);
+
assertTrue(ExceptionUtils.getStackTrace(e).contains("TransferFailedException"));
}
verify(wagon, wagonManager);
}
@Test
- public void
testShouldFailToDownloadWhenWagonGetThrowsResourceDoesNotExistException()
throws IOException {
+ void shouldFailToDownloadWhenWagonGetThrowsResourceDoesNotExistException()
throws Exception {
File tempFile = Files.createTempFile("download-source",
"test").toFile();
tempFile.deleteOnExit();
@@ -265,14 +265,14 @@ public class DefaultDownloadManagerTest {
fail("should have failed to get resource.");
} catch (DownloadFailedException e) {
-
assertTrue(ExceptionUtils.getStackTrace(e).indexOf("ResourceDoesNotExistException")
> -1);
+
assertTrue(ExceptionUtils.getStackTrace(e).contains("ResourceDoesNotExistException"));
}
verify(wagon, wagonManager);
}
@Test
- public void
testShouldFailToDownloadWhenWagonGetThrowsAuthorizationException() throws
IOException {
+ void shouldFailToDownloadWhenWagonGetThrowsAuthorizationException() throws
Exception {
File tempFile = Files.createTempFile("download-source",
"test").toFile();
tempFile.deleteOnExit();
@@ -287,15 +287,14 @@ public class DefaultDownloadManagerTest {
fail("should have failed to get resource.");
} catch (DownloadFailedException e) {
-
assertTrue(ExceptionUtils.getStackTrace(e).indexOf("AuthorizationException") >
-1);
+
assertTrue(ExceptionUtils.getStackTrace(e).contains("AuthorizationException"));
}
verify(wagon, wagonManager);
}
@Test
- public void
testShouldFailToDownloadWhenWagonDisconnectThrowsConnectionException()
- throws IOException, DownloadFailedException {
+ void shouldFailToDownloadWhenWagonDisconnectThrowsConnectionException()
throws Exception {
File tempFile = Files.createTempFile("download-source",
"test").toFile();
tempFile.deleteOnExit();
@@ -309,17 +308,17 @@ public class DefaultDownloadManagerTest {
downloadManager.download(tempFile.toURI().toASCIIString(), mh);
- assertTrue(mh.render().indexOf("ConnectionException") > -1);
+ assertTrue(mh.render().contains("ConnectionException"));
verify(wagon, wagonManager);
}
private void setupDefaultMockConfiguration() {
- try {
- expect(wagonManager.getWagon("file")).andReturn(wagon);
- } catch (UnsupportedProtocolException e) {
- fail("This shouldn't happen!!");
- }
+ assertDoesNotThrow(
+ () -> {
+ expect(wagonManager.getWagon("file")).andReturn(wagon);
+ },
+ "This shouldn't happen!!");
expect(wagonManager.getAuthenticationInfo(anyString())).andReturn(null);
@@ -327,43 +326,33 @@ public class DefaultDownloadManagerTest {
try {
wagon.connect(anyObject(Repository.class),
anyObject(AuthenticationInfo.class), anyObject(ProxyInfo.class));
- } catch (ConnectionException e) {
- fail("This shouldn't happen!!");
- } catch (AuthenticationException e) {
+ } catch (ConnectionException | AuthenticationException e) {
fail("This shouldn't happen!!");
}
try {
wagon.get(anyString(), anyObject(File.class));
- } catch (TransferFailedException e) {
- fail("This shouldn't happen!!");
- } catch (ResourceDoesNotExistException e) {
- fail("This shouldn't happen!!");
- } catch (AuthorizationException e) {
+ } catch (TransferFailedException | AuthorizationException |
ResourceDoesNotExistException e) {
fail("This shouldn't happen!!");
}
- try {
- wagon.disconnect();
- } catch (ConnectionException e) {
- fail("This shouldn't happen!!");
- }
+ assertDoesNotThrow(() -> wagon.disconnect(), "This shouldn't
happen!!");
}
private void setupMocksWithWagonManagerGetException(Throwable error) {
- try {
- expect(wagonManager.getWagon("file")).andThrow(error);
- } catch (UnsupportedProtocolException e) {
- fail("This shouldn't happen!!");
- }
+ assertDoesNotThrow(
+ () -> {
+ expect(wagonManager.getWagon("file")).andThrow(error);
+ },
+ "This shouldn't happen!!");
}
private void setupMocksWithWagonConnectionException(Throwable error) {
- try {
- expect(wagonManager.getWagon("file")).andReturn(wagon);
- } catch (UnsupportedProtocolException e) {
- fail("This shouldn't happen!!");
- }
+ assertDoesNotThrow(
+ () -> {
+ expect(wagonManager.getWagon("file")).andReturn(wagon);
+ },
+ "This shouldn't happen!!");
expect(wagonManager.getAuthenticationInfo(anyString())).andReturn(null);
@@ -372,19 +361,17 @@ public class DefaultDownloadManagerTest {
try {
wagon.connect(anyObject(Repository.class),
anyObject(AuthenticationInfo.class), anyObject(ProxyInfo.class));
expectLastCall().andThrow(error);
- } catch (ConnectionException e) {
- fail("This shouldn't happen!!");
- } catch (AuthenticationException e) {
+ } catch (ConnectionException | AuthenticationException e) {
fail("This shouldn't happen!!");
}
}
private void setupMocksWithWagonGetException(Throwable error) {
- try {
- expect(wagonManager.getWagon("file")).andReturn(wagon);
- } catch (UnsupportedProtocolException e) {
- fail("This shouldn't happen!!");
- }
+ assertDoesNotThrow(
+ () -> {
+ expect(wagonManager.getWagon("file")).andReturn(wagon);
+ },
+ "This shouldn't happen!!");
expect(wagonManager.getAuthenticationInfo(anyString())).andReturn(null);
@@ -392,36 +379,26 @@ public class DefaultDownloadManagerTest {
try {
wagon.connect(anyObject(Repository.class),
anyObject(AuthenticationInfo.class), anyObject(ProxyInfo.class));
- } catch (ConnectionException e) {
- fail("This shouldn't happen!!");
- } catch (AuthenticationException e) {
+ } catch (ConnectionException | AuthenticationException e) {
fail("This shouldn't happen!!");
}
try {
wagon.get(anyString(), anyObject(File.class));
expectLastCall().andThrow(error);
- } catch (TransferFailedException e) {
- fail("This shouldn't happen!!");
- } catch (ResourceDoesNotExistException e) {
- fail("This shouldn't happen!!");
- } catch (AuthorizationException e) {
+ } catch (TransferFailedException | AuthorizationException |
ResourceDoesNotExistException e) {
fail("This shouldn't happen!!");
}
- try {
- wagon.disconnect();
- } catch (ConnectionException e) {
- fail("This shouldn't happen!!");
- }
+ assertDoesNotThrow(() -> wagon.disconnect(), "This shouldn't
happen!!");
}
private void setupMocksWithWagonDisconnectException(Throwable error) {
- try {
- expect(wagonManager.getWagon("file")).andReturn(wagon);
- } catch (UnsupportedProtocolException e) {
- fail("This shouldn't happen!!");
- }
+ assertDoesNotThrow(
+ () -> {
+ expect(wagonManager.getWagon("file")).andReturn(wagon);
+ },
+ "This shouldn't happen!!");
expect(wagonManager.getAuthenticationInfo(anyString())).andReturn(null);
@@ -429,27 +406,21 @@ public class DefaultDownloadManagerTest {
try {
wagon.connect(anyObject(Repository.class),
anyObject(AuthenticationInfo.class), anyObject(ProxyInfo.class));
- } catch (ConnectionException e) {
- fail("This shouldn't happen!!");
- } catch (AuthenticationException e) {
+ } catch (ConnectionException | AuthenticationException e) {
fail("This shouldn't happen!!");
}
try {
wagon.get(anyString(), anyObject(File.class));
- } catch (TransferFailedException e) {
- fail("This shouldn't happen!!");
- } catch (ResourceDoesNotExistException e) {
- fail("This shouldn't happen!!");
- } catch (AuthorizationException e) {
+ } catch (TransferFailedException | AuthorizationException |
ResourceDoesNotExistException e) {
fail("This shouldn't happen!!");
}
- try {
- wagon.disconnect();
- expectLastCall().andThrow(error);
- } catch (ConnectionException e) {
- fail("This shouldn't happen!!");
- }
+ assertDoesNotThrow(
+ () -> {
+ wagon.disconnect();
+ expectLastCall().andThrow(error);
+ },
+ "This shouldn't happen!!");
}
}
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 ec75642..99750d5 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
@@ -22,20 +22,20 @@ import org.junit.jupiter.api.Test;
import static org.junit.jupiter.api.Assertions.assertEquals;
-public class DownloadFailedExceptionTest {
+class DownloadFailedExceptionTest {
@Test
- public void testShouldConstructWithUrlAndMessage() {
+ void shouldConstructWithUrlAndMessage() {
new DownloadFailedException("http://www.google.com", "can't find.");
}
@Test
- public void testShouldConstructWithUrlMessageAndException() {
+ void shouldConstructWithUrlMessageAndException() {
new DownloadFailedException("http://www.google.com", "can't find.",
new NullPointerException());
}
@Test
- public void testShouldRetrieveUrlFromConstructor() {
+ void shouldRetrieveUrlFromConstructor() {
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 654fd42..4cbd583 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
@@ -19,7 +19,6 @@
package org.apache.maven.shared.io.location;
import java.io.File;
-import java.io.IOException;
import java.nio.file.Files;
import org.apache.commons.io.FileUtils;
@@ -32,10 +31,10 @@ import org.junit.jupiter.api.Test;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertSame;
-public class ArtifactLocationTest {
+class ArtifactLocationTest {
@Test
- public void testShouldConstructFromTempFileSpecification() throws
IOException {
+ void shouldConstructFromTempFileSpecification() throws Exception {
File f = Files.createTempFile("artifact-location.", ".test").toFile();
f.deleteOnExit();
@@ -56,7 +55,7 @@ public class ArtifactLocationTest {
}
@Test
- public void testShouldRead() throws IOException {
+ void shouldRead() throws Exception {
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 3638c6b..3ab8143 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
@@ -19,7 +19,6 @@
package org.apache.maven.shared.io.location;
import java.io.File;
-import java.io.IOException;
import java.nio.file.Files;
import java.util.Collections;
@@ -46,7 +45,7 @@ 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 ArtifactLocatorStrategyTest {
+class ArtifactLocatorStrategyTest {
private ArtifactFactory factory;
@@ -55,14 +54,14 @@ public class ArtifactLocatorStrategyTest {
private ArtifactRepository localRepository;
@BeforeEach
- public void setUp() {
+ void setUp() {
factory = createMock(ArtifactFactory.class);
resolver = createMock(ArtifactResolver.class);
localRepository = createMock(ArtifactRepository.class);
}
@Test
- public void testShouldConstructWithoutDefaultArtifactType() {
+ void shouldConstructWithoutDefaultArtifactType() {
replay(factory, resolver, localRepository);
new ArtifactLocatorStrategy(factory, resolver, localRepository,
Collections.EMPTY_LIST);
@@ -71,7 +70,7 @@ public class ArtifactLocatorStrategyTest {
}
@Test
- public void testShouldConstructWithDefaultArtifactType() {
+ void shouldConstructWithDefaultArtifactType() {
replay(factory, resolver, localRepository);
new ArtifactLocatorStrategy(factory, resolver, localRepository,
Collections.EMPTY_LIST, "zip");
@@ -80,7 +79,7 @@ public class ArtifactLocatorStrategyTest {
}
@Test
- public void testShouldFailToResolveSpecWithOneToken() {
+ void shouldFailToResolveSpecWithOneToken() {
replay(factory, resolver, localRepository);
LocatorStrategy strategy =
@@ -96,7 +95,7 @@ public class ArtifactLocatorStrategyTest {
}
@Test
- public void testShouldFailToResolveSpecWithTwoTokens() {
+ void shouldFailToResolveSpecWithTwoTokens() {
replay(factory, resolver, localRepository);
LocatorStrategy strategy =
@@ -112,7 +111,7 @@ public class ArtifactLocatorStrategyTest {
}
@Test
- public void testShouldResolveSpecWithThreeTokensUsingDefaultType() throws
IOException {
+ void shouldResolveSpecWithThreeTokensUsingDefaultType() throws Exception {
File tempFile = Files.createTempFile("artifact-location.",
".temp").toFile();
tempFile.deleteOnExit();
@@ -126,10 +125,7 @@ public class ArtifactLocatorStrategyTest {
try {
resolver.resolve(artifact,
Collections.<ArtifactRepository>emptyList(), localRepository);
- } catch (ArtifactResolutionException e) {
- // should never happen
- fail("This should NEVER happen. It's a mock!");
- } catch (ArtifactNotFoundException e) {
+ } catch (ArtifactResolutionException | ArtifactNotFoundException e) {
// should never happen
fail("This should NEVER happen. It's a mock!");
}
@@ -151,7 +147,7 @@ public class ArtifactLocatorStrategyTest {
}
@Test
- public void
testShouldResolveSpecWithThreeTokensUsingCustomizedDefaultType() throws
IOException {
+ void shouldResolveSpecWithThreeTokensUsingCustomizedDefaultType() throws
Exception {
File tempFile = Files.createTempFile("artifact-location.",
".temp").toFile();
tempFile.deleteOnExit();
@@ -165,10 +161,7 @@ public class ArtifactLocatorStrategyTest {
try {
resolver.resolve(artifact,
Collections.<ArtifactRepository>emptyList(), localRepository);
- } catch (ArtifactResolutionException e) {
- // should never happen
- fail("This should NEVER happen. It's a mock!");
- } catch (ArtifactNotFoundException e) {
+ } catch (ArtifactResolutionException | ArtifactNotFoundException e) {
// should never happen
fail("This should NEVER happen. It's a mock!");
}
@@ -190,7 +183,7 @@ public class ArtifactLocatorStrategyTest {
}
@Test
- public void testShouldResolveSpecWithFourTokens() throws IOException {
+ void shouldResolveSpecWithFourTokens() throws Exception {
File tempFile = Files.createTempFile("artifact-location.",
".temp").toFile();
tempFile.deleteOnExit();
@@ -204,10 +197,7 @@ public class ArtifactLocatorStrategyTest {
try {
resolver.resolve(artifact,
Collections.<ArtifactRepository>emptyList(), localRepository);
- } catch (ArtifactResolutionException e) {
- // should never happen
- fail("This should NEVER happen. It's a mock!");
- } catch (ArtifactNotFoundException e) {
+ } catch (ArtifactResolutionException | ArtifactNotFoundException e) {
// should never happen
fail("This should NEVER happen. It's a mock!");
}
@@ -229,7 +219,7 @@ public class ArtifactLocatorStrategyTest {
}
@Test
- public void testShouldResolveSpecWithFiveTokens() throws IOException {
+ void shouldResolveSpecWithFiveTokens() throws Exception {
File tempFile = Files.createTempFile("artifact-location.",
".temp").toFile();
tempFile.deleteOnExit();
@@ -243,10 +233,7 @@ public class ArtifactLocatorStrategyTest {
try {
resolver.resolve(artifact,
Collections.<ArtifactRepository>emptyList(), localRepository);
- } catch (ArtifactResolutionException e) {
- // should never happen
- fail("This should NEVER happen. It's a mock!");
- } catch (ArtifactNotFoundException e) {
+ } catch (ArtifactResolutionException | ArtifactNotFoundException e) {
// should never happen
fail("This should NEVER happen. It's a mock!");
}
@@ -268,7 +255,7 @@ public class ArtifactLocatorStrategyTest {
}
@Test
- public void testShouldResolveSpecWithFiveTokensAndEmptyTypeToken() throws
IOException {
+ void shouldResolveSpecWithFiveTokensAndEmptyTypeToken() throws Exception {
File tempFile = Files.createTempFile("artifact-location.",
".temp").toFile();
tempFile.deleteOnExit();
@@ -282,10 +269,7 @@ public class ArtifactLocatorStrategyTest {
try {
resolver.resolve(artifact,
Collections.<ArtifactRepository>emptyList(), localRepository);
- } catch (ArtifactResolutionException e) {
- // should never happen
- fail("This should NEVER happen. It's a mock!");
- } catch (ArtifactNotFoundException e) {
+ } catch (ArtifactResolutionException | ArtifactNotFoundException e) {
// should never happen
fail("This should NEVER happen. It's a mock!");
}
@@ -307,7 +291,7 @@ public class ArtifactLocatorStrategyTest {
}
@Test
- public void testShouldResolveSpecWithMoreThanFiveTokens() throws
IOException {
+ void shouldResolveSpecWithMoreThanFiveTokens() throws Exception {
File tempFile = Files.createTempFile("artifact-location.",
".temp").toFile();
tempFile.deleteOnExit();
@@ -321,10 +305,7 @@ public class ArtifactLocatorStrategyTest {
try {
resolver.resolve(artifact,
Collections.<ArtifactRepository>emptyList(), localRepository);
- } catch (ArtifactResolutionException e) {
- // should never happen
- fail("This should NEVER happen. It's a mock!");
- } catch (ArtifactNotFoundException e) {
+ } catch (ArtifactResolutionException | ArtifactNotFoundException e) {
// should never happen
fail("This should NEVER happen. It's a mock!");
}
@@ -340,7 +321,7 @@ public class ArtifactLocatorStrategyTest {
assertNotNull(location);
assertEquals(1, mh.size());
- assertTrue(mh.render().indexOf(":six:seven") > -1);
+ assertTrue(mh.render().contains(":six:seven"));
assertSame(tempFile, location.getFile());
@@ -348,7 +329,7 @@ public class ArtifactLocatorStrategyTest {
}
@Test
- public void testShouldNotResolveSpecToArtifactWithNullFile() throws
IOException {
+ void shouldNotResolveSpecToArtifactWithNullFile() throws Exception {
Artifact artifact = createMock(Artifact.class);
expect(artifact.getFile()).andReturn(null);
@@ -359,10 +340,7 @@ public class ArtifactLocatorStrategyTest {
try {
resolver.resolve(artifact,
Collections.<ArtifactRepository>emptyList(), localRepository);
- } catch (ArtifactResolutionException e) {
- // should never happen
- fail("This should NEVER happen. It's a mock!");
- } catch (ArtifactNotFoundException e) {
+ } catch (ArtifactResolutionException | ArtifactNotFoundException e) {
// should never happen
fail("This should NEVER happen. It's a mock!");
}
@@ -378,13 +356,13 @@ public class ArtifactLocatorStrategyTest {
assertNull(location);
assertEquals(1, mh.size());
- assertTrue(mh.render().indexOf("<some-artifact-id>") > -1);
+ assertTrue(mh.render().contains("<some-artifact-id>"));
verify(factory, resolver, localRepository, artifact);
}
@Test
- public void testShouldNotResolveWhenArtifactNotFoundExceptionThrown()
throws IOException {
+ void shouldNotResolveWhenArtifactNotFoundExceptionThrown() throws
Exception {
Artifact artifact = createMock(Artifact.class);
expect(artifact.getId()).andReturn("<some-artifact-id>");
@@ -406,10 +384,7 @@ public class ArtifactLocatorStrategyTest {
"http://nowhere.com",
Collections.<String>emptyList(),
new NullPointerException()));
- } catch (ArtifactResolutionException e) {
- // should never happen
- fail("This should NEVER happen. It's a mock!");
- } catch (ArtifactNotFoundException e) {
+ } catch (ArtifactResolutionException | ArtifactNotFoundException e) {
// should never happen
fail("This should NEVER happen. It's a mock!");
}
@@ -425,14 +400,14 @@ public class ArtifactLocatorStrategyTest {
assertNull(location);
assertEquals(1, mh.size());
- assertTrue(mh.render().indexOf("<some-artifact-id>") > -1);
- assertTrue(mh.render().indexOf("not found") > -1);
+ assertTrue(mh.render().contains("<some-artifact-id>"));
+ assertTrue(mh.render().contains("not found"));
verify(factory, resolver, localRepository, artifact);
}
@Test
- public void testShouldNotResolveWhenArtifactResolutionExceptionThrown()
throws IOException {
+ void shouldNotResolveWhenArtifactResolutionExceptionThrown() throws
Exception {
Artifact artifact = createMock(Artifact.class);
expect(artifact.getId()).andReturn("<some-artifact-id>");
@@ -454,10 +429,7 @@ public class ArtifactLocatorStrategyTest {
Collections.<String>emptyList(),
new NullPointerException()));
- } catch (ArtifactResolutionException e) {
- // should never happen
- fail("This should NEVER happen. It's a mock!");
- } catch (ArtifactNotFoundException e) {
+ } catch (ArtifactResolutionException | ArtifactNotFoundException e) {
// should never happen
fail("This should NEVER happen. It's a mock!");
}
@@ -473,8 +445,8 @@ public class ArtifactLocatorStrategyTest {
assertNull(location);
assertEquals(1, mh.size());
- assertTrue(mh.render().indexOf("<some-artifact-id>") > -1);
- assertTrue(mh.render().indexOf("resolution failed") > -1);
+ assertTrue(mh.render().contains("<some-artifact-id>"));
+ assertTrue(mh.render().contains("resolution failed"));
verify(factory, resolver, localRepository, artifact);
}
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 200341a..fd18b0b 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
@@ -26,20 +26,20 @@ import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertNotNull;
import static org.junit.jupiter.api.Assertions.assertNull;
-public class ClasspathResourceLocatorStrategyTest {
+class ClasspathResourceLocatorStrategyTest {
@Test
- public void testShouldConstructWithNoParams() {
+ void shouldConstructWithNoParams() {
new ClasspathResourceLocatorStrategy();
}
@Test
- public void testShouldConstructWithTempFileOptions() {
+ void shouldConstructWithTempFileOptions() {
new ClasspathResourceLocatorStrategy("prefix.", ".suffix", true);
}
@Test
- public void testShouldFailToResolveMissingClasspathResource() {
+ void shouldFailToResolveMissingClasspathResource() {
MessageHolder mh = new DefaultMessageHolder();
Location location = new
ClasspathResourceLocatorStrategy().resolve("/some/missing/path", mh);
@@ -48,7 +48,7 @@ public class ClasspathResourceLocatorStrategyTest {
}
@Test
- public void
testShouldResolveExistingClasspathResourceWithoutPrecedingSlash() {
+ void shouldResolveExistingClasspathResourceWithoutPrecedingSlash() {
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 78134ae..4ae737e 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
@@ -20,9 +20,9 @@ package org.apache.maven.shared.io.location;
import java.io.ByteArrayOutputStream;
import java.io.File;
-import java.io.IOException;
import java.io.InputStream;
import java.nio.ByteBuffer;
+import java.nio.charset.StandardCharsets;
import java.nio.file.Files;
import org.apache.commons.io.FileUtils;
@@ -31,12 +31,12 @@ import org.junit.jupiter.api.Test;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertSame;
-import static org.junit.jupiter.api.Assertions.fail;
+import static org.junit.jupiter.api.Assertions.assertThrows;
-public class FileLocationTest {
+class FileLocationTest {
@Test
- public void testShouldConstructWithFileThenRetrieveSameFile() throws
IOException {
+ void shouldConstructWithFileThenRetrieveSameFile() throws Exception {
File file = Files.createTempFile("test.", ".file-location").toFile();
file.deleteOnExit();
@@ -47,7 +47,7 @@ public class FileLocationTest {
}
@Test
- public void testShouldReadFileContentsUsingByteBuffer() throws IOException
{
+ void shouldReadFileContentsUsingByteBuffer() throws Exception {
File file = Files.createTempFile("test.", ".file-location").toFile();
file.deleteOnExit();
@@ -62,11 +62,11 @@ public class FileLocationTest {
ByteBuffer buffer = ByteBuffer.allocate(testStr.length());
location.read(buffer);
- assertEquals(testStr, new String(buffer.array(), "US-ASCII"));
+ assertEquals(testStr, new String(buffer.array(),
StandardCharsets.US_ASCII));
}
@Test
- public void testShouldReadFileContentsUsingStream() throws IOException {
+ void shouldReadFileContentsUsingStream() throws Exception {
File file = Files.createTempFile("test.", ".file-location").toFile();
file.deleteOnExit();
@@ -82,12 +82,12 @@ public class FileLocationTest {
ByteArrayOutputStream out = new ByteArrayOutputStream();
IOUtils.copy(stream, out);
- assertEquals(testStr, new String(out.toByteArray(), "US-ASCII"));
+ assertEquals(testStr, new String(out.toByteArray(),
StandardCharsets.US_ASCII));
}
}
@Test
- public void testShouldReadFileContentsUsingByteArray() throws IOException {
+ void shouldReadFileContentsUsingByteArray() throws Exception {
File file = Files.createTempFile("test.", ".file-location").toFile();
file.deleteOnExit();
@@ -102,11 +102,11 @@ public class FileLocationTest {
byte[] buffer = new byte[testStr.length()];
location.read(buffer);
- assertEquals(testStr, new String(buffer, "US-ASCII"));
+ assertEquals(testStr, new String(buffer, StandardCharsets.US_ASCII));
}
@Test
- public void testShouldReadThenClose() throws IOException {
+ void shouldReadThenClose() throws Exception {
File file = Files.createTempFile("test.", ".file-location").toFile();
file.deleteOnExit();
@@ -121,13 +121,13 @@ public class FileLocationTest {
byte[] buffer = new byte[testStr.length()];
location.read(buffer);
- assertEquals(testStr, new String(buffer, "US-ASCII"));
+ assertEquals(testStr, new String(buffer, StandardCharsets.US_ASCII));
location.close();
}
@Test
- public void testShouldOpenThenFailToSetFile() throws IOException {
+ void shouldOpenThenFailToSetFile() throws Exception {
File file = Files.createTempFile("test.", ".file-location").toFile();
file.deleteOnExit();
@@ -135,16 +135,11 @@ public class FileLocationTest {
location.open();
- try {
- location.setFile(file);
-
- fail("should not succeed.");
- } catch (IllegalStateException e) {
- }
+ assertThrows(IllegalStateException.class, () ->
location.setFile(file));
}
@Test
- public void testShouldConstructWithoutFileThenSetFileThenOpen() throws
IOException {
+ void shouldConstructWithoutFileThenSetFileThenOpen() throws Exception {
File file = Files.createTempFile("test.", ".file-location").toFile();
file.deleteOnExit();
@@ -155,7 +150,7 @@ public class FileLocationTest {
}
@Test
- public void testShouldConstructWithLocationThenRetrieveEquivalentFile()
throws IOException {
+ void shouldConstructWithLocationThenRetrieveEquivalentFile() throws
Exception {
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 65ccc32..4de62e5 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
@@ -19,7 +19,6 @@
package org.apache.maven.shared.io.location;
import java.io.File;
-import java.io.IOException;
import java.nio.file.Files;
import org.apache.maven.shared.io.logging.DefaultMessageHolder;
@@ -31,10 +30,10 @@ import static
org.junit.jupiter.api.Assertions.assertNotNull;
import static org.junit.jupiter.api.Assertions.assertNull;
import static org.junit.jupiter.api.Assertions.assertTrue;
-public class FileLocatorStrategyTest {
+class FileLocatorStrategyTest {
@Test
- public void testShouldResolveExistingTempFileLocation() throws IOException
{
+ void shouldResolveExistingTempFileLocation() throws Exception {
File f = Files.createTempFile("file-locator.", ".test").toFile();
f.deleteOnExit();
@@ -52,7 +51,7 @@ public class FileLocatorStrategyTest {
}
@Test
- public void testShouldFailToResolveNonExistentFileLocation() throws
IOException {
+ void shouldFailToResolveNonExistentFileLocation() throws Exception {
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 afdc62a..0b14261 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
@@ -35,22 +35,21 @@ import static
org.junit.jupiter.api.Assertions.assertNotNull;
import static org.junit.jupiter.api.Assertions.assertNull;
import static org.junit.jupiter.api.Assertions.assertTrue;
-public class LocatorTest {
+class LocatorTest {
@Test
- public void testShouldConstructWithNoParams() {
+ void shouldConstructWithNoParams() {
new Locator();
}
@Test
- public void testShouldConstructWithStrategyStackAndMessageHolder() {
+ void shouldConstructWithStrategyStackAndMessageHolder() {
new Locator(Collections.<LocatorStrategy>emptyList(), new
DefaultMessageHolder());
}
@Test
- public void
testShouldAllowModificationOfStrategiesAfterConstructionWithUnmodifiableStack()
{
- Locator locator = new Locator(
-
Collections.unmodifiableList(Collections.<LocatorStrategy>emptyList()), new
DefaultMessageHolder());
+ void
shouldAllowModificationOfStrategiesAfterConstructionWithUnmodifiableStack() {
+ Locator locator = new Locator(Collections.emptyList(), new
DefaultMessageHolder());
locator.addStrategy(new FileLocatorStrategy());
@@ -58,12 +57,12 @@ public class LocatorTest {
}
@Test
- public void
testShouldRetrieveNonNullMessageHolderWhenConstructedWithoutParams() {
+ void shouldRetrieveNonNullMessageHolderWhenConstructedWithoutParams() {
assertNotNull(new Locator().getMessageHolder());
}
@Test
- public void testSetStrategiesShouldClearAnyPreExistingStrategiesOut() {
+ void setStrategiesShouldClearAnyPreExistingStrategiesOut() {
LocatorStrategy originalStrategy = createMock(LocatorStrategy.class);
LocatorStrategy replacementStrategy =
createMock(LocatorStrategy.class);
@@ -83,7 +82,7 @@ public class LocatorTest {
}
@Test
- public void testShouldRemovePreviouslyAddedStrategy() {
+ void shouldRemovePreviouslyAddedStrategy() {
LocatorStrategy originalStrategy = createMock(LocatorStrategy.class);
replay(originalStrategy);
@@ -105,7 +104,7 @@ public class LocatorTest {
}
@Test
- public void
testResolutionFallsThroughStrategyStackAndReturnsNullIfNotResolved() {
+ void resolutionFallsThroughStrategyStackAndReturnsNullIfNotResolved() {
List<LocatorStrategy> strategies = new ArrayList<>();
strategies.add(new LoggingLocatorStrategy());
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 3d3b29d..62e3db8 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
@@ -19,7 +19,6 @@
package org.apache.maven.shared.io.location;
import java.io.File;
-import java.io.IOException;
import java.net.URL;
import java.nio.file.Files;
@@ -27,13 +26,13 @@ import org.apache.commons.io.FileUtils;
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.assertNotEquals;
import static org.junit.jupiter.api.Assertions.assertNotNull;
-public class URLLocationTest {
+class URLLocationTest {
@Test
- public void testShouldConstructFromUrlAndTempFileSpecifications() throws
IOException {
+ void shouldConstructFromUrlAndTempFileSpecifications() throws Exception {
File f = Files.createTempFile("url-location.", ".test").toFile();
f.deleteOnExit();
@@ -43,7 +42,7 @@ public class URLLocationTest {
}
@Test
- public void testShouldTransferFromTempFile() throws IOException {
+ void shouldTransferFromTempFile() throws Exception {
File f = Files.createTempFile("url-location.", ".test").toFile();
f.deleteOnExit();
@@ -52,11 +51,11 @@ public class URLLocationTest {
URLLocation location = new URLLocation(url, f.getAbsolutePath(),
"prefix.", ".suffix", true);
assertNotNull(location.getFile());
- assertFalse(f.equals(location.getFile()));
+ assertNotEquals(f, location.getFile());
}
@Test
- public void testShouldTransferFromTempFileThenRead() throws IOException {
+ void shouldTransferFromTempFileThenRead() throws Exception {
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 6a6a94b..34be17c 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
@@ -19,7 +19,6 @@
package org.apache.maven.shared.io.location;
import java.io.File;
-import java.io.IOException;
import java.nio.file.Files;
import org.apache.commons.io.FileUtils;
@@ -31,20 +30,20 @@ import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertNotNull;
import static org.junit.jupiter.api.Assertions.assertNull;
-public class URLLocatorStrategyTest {
+class URLLocatorStrategyTest {
@Test
- public void testShouldConstructWithNoParams() {
+ void shouldConstructWithNoParams() {
new URLLocatorStrategy();
}
@Test
- public void testShouldConstructWithTempFileOptions() {
+ void shouldConstructWithTempFileOptions() {
new URLLocatorStrategy("prefix.", ".suffix", true);
}
@Test
- public void testShouldFailToResolveWithMalformedUrl() {
+ void shouldFailToResolveWithMalformedUrl() {
MessageHolder mh = new DefaultMessageHolder();
Location location = new
URLLocatorStrategy().resolve("://www.google.com", mh);
@@ -54,7 +53,7 @@ public class URLLocatorStrategyTest {
}
@Test
- public void testShouldResolveUrlForTempFile() throws IOException {
+ void shouldResolveUrlForTempFile() throws Exception {
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 12e70b9..9186148 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
@@ -28,13 +28,13 @@ import static org.junit.jupiter.api.Assertions.assertFalse;
import static org.junit.jupiter.api.Assertions.assertSame;
import static org.junit.jupiter.api.Assertions.assertTrue;
-public class DefaultMessageHolderTest {
+class DefaultMessageHolderTest {
// MessageHolder newMessage();
// int size();
// String render();
@Test
- public void testNewMessageIncrementsSizeWhenEmpty() {
+ void newMessageIncrementsSizeWhenEmpty() {
MessageHolder mh = new DefaultMessageHolder();
assertEquals(0, mh.size());
@@ -52,7 +52,7 @@ public class DefaultMessageHolderTest {
// int size();
// String render();
@Test
- public void testAppendCreatesNewMessageIfNoneCurrent() {
+ void appendCreatesNewMessageIfNoneCurrent() {
MessageHolder mh = new DefaultMessageHolder();
assertEquals(0, mh.size());
@@ -70,7 +70,7 @@ public class DefaultMessageHolderTest {
// int size();
// String render();
@Test
- public void testAppendErrorCreatesNewMessageIfNoneCurrent() {
+ void appendErrorCreatesNewMessageIfNoneCurrent() {
MessageHolder mh = new DefaultMessageHolder();
assertEquals(0, mh.size());
@@ -96,7 +96,7 @@ public class DefaultMessageHolderTest {
// int size();
// String render();
@Test
- public void testNewMessageThenAppendOnlyIncrementsSizeByOne() {
+ void newMessageThenAppendOnlyIncrementsSizeByOne() {
MessageHolder mh = new DefaultMessageHolder();
assertEquals(0, mh.size());
@@ -120,7 +120,7 @@ public class DefaultMessageHolderTest {
// int size();
// String render();
@Test
- public void testNewMessageThenAppendTwiceOnlyIncrementsSizeByOne() {
+ void newMessageThenAppendTwiceOnlyIncrementsSizeByOne() {
MessageHolder mh = new DefaultMessageHolder();
assertEquals(0, mh.size());
@@ -148,7 +148,7 @@ public class DefaultMessageHolderTest {
// int size();
// String render();
@Test
- public void
testNewMessageThenAppendBothMessageAndErrorOnlyIncrementsSizeByOne() {
+ void newMessageThenAppendBothMessageAndErrorOnlyIncrementsSizeByOne() {
MessageHolder mh = new DefaultMessageHolder();
assertEquals(0, mh.size());
@@ -181,7 +181,7 @@ public class DefaultMessageHolderTest {
// int size();
// String render();
@Test
- public void testAddMessageIncrementsSizeByOne() {
+ void addMessageIncrementsSizeByOne() {
MessageHolder mh = new DefaultMessageHolder();
MessageHolder check = mh.addMessage("test");
@@ -195,7 +195,7 @@ public class DefaultMessageHolderTest {
// int size();
// String render();
@Test
- public void testAddMessageTwiceIncrementsSizeByTwo() {
+ void addMessageTwiceIncrementsSizeByTwo() {
MessageHolder mh = new DefaultMessageHolder();
MessageHolder check = mh.addMessage("test");
@@ -213,7 +213,7 @@ public class DefaultMessageHolderTest {
// int size();
// String render();
@Test
- public void testAddMessageWithErrorIncrementsSizeByOne() {
+ void addMessageWithErrorIncrementsSizeByOne() {
MessageHolder mh = new DefaultMessageHolder();
NullPointerException npe = new NullPointerException();
@@ -237,7 +237,7 @@ public class DefaultMessageHolderTest {
// int size();
// String render();
@Test
- public void
testAddMessageWithErrorThenWithJustMessageIncrementsSizeByTwo() {
+ void addMessageWithErrorThenWithJustMessageIncrementsSizeByTwo() {
MessageHolder mh = new DefaultMessageHolder();
NullPointerException npe = new NullPointerException();
@@ -264,7 +264,7 @@ public class DefaultMessageHolderTest {
// int size();
// String render();
@Test
- public void testAddMessageWithJustErrorIncrementsSizeByOne() {
+ void addMessageWithJustErrorIncrementsSizeByOne() {
MessageHolder mh = new DefaultMessageHolder();
NullPointerException npe = new NullPointerException();
@@ -285,21 +285,21 @@ public class DefaultMessageHolderTest {
// boolean isEmpty();
@Test
- public void testIsEmptyAfterConstruction() {
+ void isEmptyAfterConstruction() {
assertTrue(new DefaultMessageHolder().isEmpty());
}
// boolean isEmpty();
@Test
- public void testIsNotEmptyAfterConstructionAndNewMessageCall() {
+ void isNotEmptyAfterConstructionAndNewMessageCall() {
assertFalse(new DefaultMessageHolder().newMessage().isEmpty());
}
@Test
- public void testAppendCharSequence() {
+ void appendCharSequence() {
MessageHolder mh = new DefaultMessageHolder();
mh.newMessage().append(new StringBuffer("This is a test"));
- assertTrue(mh.render().indexOf("This is a test") > -1);
+ assertTrue(mh.render().contains("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 9022121..796f0e2 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
@@ -19,7 +19,6 @@
package org.apache.maven.shared.io.scan;
import java.io.File;
-import java.io.IOException;
import java.nio.file.Files;
import java.util.HashSet;
import java.util.Set;
@@ -28,15 +27,16 @@ import
org.apache.maven.shared.io.scan.mapping.SuffixMapping;
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.assertFalse;
+import static org.junit.jupiter.api.Assertions.assertInstanceOf;
/**
* @author dengliming
*/
-public class SimpleResourceInclusionScannerTest {
+class SimpleResourceInclusionScannerTest {
@Test
- public void testGetIncludedSources() throws IOException,
InclusionScanException {
+ void getIncludedSources() throws Exception {
File baseDir = new File("target");
baseDir.deleteOnExit();
baseDir.mkdirs();
@@ -50,10 +50,10 @@ public class SimpleResourceInclusionScannerTest {
Set<String> targets = new HashSet<>();
targets.add(".class");
simpleResourceInclusionScanner.addSourceMapping(new
SuffixMapping(".java", targets));
- Set results =
simpleResourceInclusionScanner.getIncludedSources(baseDir, baseDir);
- assertTrue(results.size() > 0);
- Object file = results.iterator().next();
- assertTrue(file instanceof File);
- assertEquals(f.getName(), ((File) file).getName());
+ Set<File> results =
simpleResourceInclusionScanner.getIncludedSources(baseDir, baseDir);
+ assertFalse(results.isEmpty());
+ File file = results.iterator().next();
+ assertInstanceOf(File.class, file);
+ assertEquals(f.getName(), file.getName());
}
}
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 e97e26d..c376ad0 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
@@ -22,7 +22,6 @@ import java.io.File;
import java.util.HashSet;
import java.util.Set;
-import org.apache.maven.shared.io.scan.InclusionScanException;
import org.junit.jupiter.api.Test;
import static org.junit.jupiter.api.Assertions.assertEquals;
@@ -31,9 +30,9 @@ import static org.junit.jupiter.api.Assertions.assertTrue;
/**
* @author jdcasey
*/
-public class SuffixMappingTest {
+class SuffixMappingTest {
@Test
- public void testShouldReturnSingleClassFileForSingleJavaFile() throws
InclusionScanException {
+ void shouldReturnSingleClassFileForSingleJavaFile() throws Exception {
String base = "path/to/file";
File basedir = new File(".");
@@ -48,7 +47,7 @@ public class SuffixMappingTest {
}
@Test
- public void testShouldNotReturnClassFileWhenSourceFileHasWrongSuffix()
throws InclusionScanException {
+ void shouldNotReturnClassFileWhenSourceFileHasWrongSuffix() throws
Exception {
String base = "path/to/file";
File basedir = new File(".");
@@ -61,7 +60,7 @@ public class SuffixMappingTest {
}
@Test
- public void testShouldReturnOneClassFileAndOneXmlFileForSingleJavaFile()
throws InclusionScanException {
+ void shouldReturnOneClassFileAndOneXmlFileForSingleJavaFile() throws
Exception {
String base = "path/to/file";
File basedir = new File(".");
@@ -82,7 +81,7 @@ public class SuffixMappingTest {
}
@Test
- public void testShouldReturnNoTargetFilesWhenSourceFileHasWrongSuffix()
throws InclusionScanException {
+ void shouldReturnNoTargetFilesWhenSourceFileHasWrongSuffix() throws
Exception {
String base = "path/to/file";
File basedir = new File(".");
@@ -99,7 +98,7 @@ public class SuffixMappingTest {
}
@Test
- public void testSingleTargetMapper() throws InclusionScanException {
+ void singleTargetMapper() throws Exception {
String base = "path/to/file";
File basedir = new File("target/");