diff --git a/mrm-api/pom.xml b/mrm-api/pom.xml
index ac3f5313..7ad550cd 100644
--- a/mrm-api/pom.xml
+++ b/mrm-api/pom.xml
@@ -49,8 +49,8 @@
archetype-common
- junit
- junit
+ org.junit.jupiter
+ junit-jupiter-api
test
diff --git a/mrm-api/src/test/java/org/codehaus/mojo/mrm/api/AbstractEntryTest.java b/mrm-api/src/test/java/org/codehaus/mojo/mrm/api/AbstractEntryTest.java
index 2f6f9e3c..352c0d5b 100644
--- a/mrm-api/src/test/java/org/codehaus/mojo/mrm/api/AbstractEntryTest.java
+++ b/mrm-api/src/test/java/org/codehaus/mojo/mrm/api/AbstractEntryTest.java
@@ -1,16 +1,16 @@
package org.codehaus.mojo.mrm.api;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
-import static org.junit.Assert.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.when;
-public class AbstractEntryTest {
+class AbstractEntryTest {
// MMOCKRM-13
@Test
- public void testPathForRootEntry() {
+ void testPathForRootEntry() {
FileSystem fileSystem = mock(FileSystem.class);
DefaultDirectoryEntry entry = new DefaultDirectoryEntry(fileSystem, null, "/favicon.ico");
diff --git a/mrm-api/src/test/java/org/codehaus/mojo/mrm/api/maven/ArtifactTest.java b/mrm-api/src/test/java/org/codehaus/mojo/mrm/api/maven/ArtifactTest.java
index 0208cceb..221fc7d3 100644
--- a/mrm-api/src/test/java/org/codehaus/mojo/mrm/api/maven/ArtifactTest.java
+++ b/mrm-api/src/test/java/org/codehaus/mojo/mrm/api/maven/ArtifactTest.java
@@ -15,13 +15,14 @@
*/
package org.codehaus.mojo.mrm.api.maven;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
-import static org.junit.Assert.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+
+class ArtifactTest {
-public class ArtifactTest {
@Test
- public void testSmokes() throws Exception {
+ void testSmokes() throws Exception {
assertEquals(new Artifact("foo", "bar", "1.0", "jar"), new Artifact("foo", "bar", "1.0", null, "jar"));
}
}
diff --git a/mrm-maven-plugin/pom.xml b/mrm-maven-plugin/pom.xml
index f7b22e7d..a4c6c9e8 100644
--- a/mrm-maven-plugin/pom.xml
+++ b/mrm-maven-plugin/pom.xml
@@ -112,8 +112,8 @@
- junit
- junit
+ org.junit.jupiter
+ junit-jupiter-api
test
diff --git a/mrm-maven-plugin/src/test/java/org/codehaus/mojo/mrm/maven/ProxyArtifactStoreTest.java b/mrm-maven-plugin/src/test/java/org/codehaus/mojo/mrm/maven/ProxyArtifactStoreTest.java
index f02f9402..9ee2e820 100644
--- a/mrm-maven-plugin/src/test/java/org/codehaus/mojo/mrm/maven/ProxyArtifactStoreTest.java
+++ b/mrm-maven-plugin/src/test/java/org/codehaus/mojo/mrm/maven/ProxyArtifactStoreTest.java
@@ -32,20 +32,22 @@
import org.eclipse.aether.DefaultRepositorySystemSession;
import org.eclipse.aether.RepositorySystem;
import org.eclipse.aether.resolution.ArtifactResolutionException;
-import org.junit.Before;
-import org.junit.Test;
+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.assertThrowsExactly;
import static org.mockito.ArgumentMatchers.any;
import static org.mockito.Mockito.doThrow;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.when;
-public class ProxyArtifactStoreTest {
+class ProxyArtifactStoreTest {
private MavenSession mavenSession;
- @Before
- public void setUp() {
+ @BeforeEach
+ void setUp() {
mavenSession = mock(MavenSession.class);
when(mavenSession.getCurrentProject()).thenReturn(new MavenProject() {
{
@@ -56,8 +58,8 @@ public void setUp() {
when(mavenSession.getRepositorySession()).thenReturn(new DefaultRepositorySystemSession());
}
- @Test(expected = ArtifactNotFoundException.class)
- public void verifyArtifactNotFoundExceptionOnGet() throws Exception {
+ @Test
+ void verifyArtifactNotFoundExceptionOnGet() throws Exception {
RepositorySystem repositorySystem = mock(RepositorySystem.class);
doThrow(ArtifactResolutionException.class).when(repositorySystem).resolveArtifact(any(), any());
FactoryHelper factoryHelper = mock(FactoryHelper.class);
@@ -68,13 +70,15 @@ public void verifyArtifactNotFoundExceptionOnGet() throws Exception {
ProxyArtifactStore store = new ProxyArtifactStore(factoryHelper, mavenSession, null);
- store.get(new Artifact("localhost", "test", "1.0-SNAPSHOT", "pom"));
+ assertThrowsExactly(
+ ArtifactNotFoundException.class,
+ () -> store.get(new Artifact("localhost", "test", "1.0-SNAPSHOT", "pom")));
}
- @Test(expected = RuntimeException.class)
- public void verifyArtifactResolutionExceptionOnGet() throws Exception {
+ @Test
+ void verifyArtifactResolutionExceptionOnGet() throws Exception {
RepositorySystem repositorySystem = mock(RepositorySystem.class);
- doThrow(RuntimeException.class).when(repositorySystem).resolveArtifact(any(), any());
+ doThrow(new RuntimeException("test123")).when(repositorySystem).resolveArtifact(any(), any());
FactoryHelper factoryHelper = mock(FactoryHelper.class);
when(factoryHelper.getRepositorySystem()).thenReturn(repositorySystem);
when(factoryHelper.getRepositoryMetadataManager()).then(i -> mock(RepositoryMetadataManager.class));
@@ -83,13 +87,15 @@ public void verifyArtifactResolutionExceptionOnGet() throws Exception {
ProxyArtifactStore store = new ProxyArtifactStore(factoryHelper, mavenSession, null);
- store.get(new Artifact("localhost", "test", "1.0-SNAPSHOT", "pom"));
+ RuntimeException exception = assertThrowsExactly(
+ RuntimeException.class, () -> store.get(new Artifact("localhost", "test", "1.0-SNAPSHOT", "pom")));
+ assertEquals("test123", exception.getMessage());
}
- @Test(expected = RuntimeException.class)
- public void verifyArchetypeCatalogNotFoundException() throws Exception {
+ @Test
+ void verifyArchetypeCatalogNotFoundException() throws Exception {
ArchetypeManager archetypeManager = mock(ArchetypeManager.class);
- doThrow(RuntimeException.class).when(archetypeManager).getLocalCatalog(any());
+ doThrow(new RuntimeException("test123")).when(archetypeManager).getLocalCatalog(any());
FactoryHelper factoryHelper = mock(FactoryHelper.class);
when(factoryHelper.getRepositorySystem()).then(i -> mock(RepositorySystem.class));
when(factoryHelper.getRepositoryMetadataManager()).then(i -> mock(RepositoryMetadataManager.class));
@@ -97,6 +103,7 @@ public void verifyArchetypeCatalogNotFoundException() throws Exception {
when(factoryHelper.getArchetypeManager()).thenReturn(archetypeManager);
ProxyArtifactStore store = new ProxyArtifactStore(factoryHelper, mavenSession, null);
- store.getArchetypeCatalog();
+ RuntimeException exception = assertThrowsExactly(RuntimeException.class, store::getArchetypeCatalog);
+ assertEquals("test123", exception.getMessage());
}
}
diff --git a/mrm-servlet/pom.xml b/mrm-servlet/pom.xml
index 9739cdd3..b8249818 100644
--- a/mrm-servlet/pom.xml
+++ b/mrm-servlet/pom.xml
@@ -75,8 +75,8 @@
plexus-archiver
- junit
- junit
+ org.junit.jupiter
+ junit-jupiter-api
test
diff --git a/mrm-servlet/src/test/java/org/codehaus/mojo/mrm/impl/maven/ArchetypeCatalogFileEntryTest.java b/mrm-servlet/src/test/java/org/codehaus/mojo/mrm/impl/maven/ArchetypeCatalogFileEntryTest.java
index bc716347..435e3955 100644
--- a/mrm-servlet/src/test/java/org/codehaus/mojo/mrm/impl/maven/ArchetypeCatalogFileEntryTest.java
+++ b/mrm-servlet/src/test/java/org/codehaus/mojo/mrm/impl/maven/ArchetypeCatalogFileEntryTest.java
@@ -4,38 +4,39 @@
import org.codehaus.mojo.mrm.api.DirectoryEntry;
import org.codehaus.mojo.mrm.api.FileSystem;
import org.codehaus.mojo.mrm.api.maven.ArtifactStore;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
-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.assertNull;
+import static org.junit.jupiter.api.Assertions.assertTrue;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.when;
-public class ArchetypeCatalogFileEntryTest {
+class ArchetypeCatalogFileEntryTest {
@Test
- public void testCleanArchetypeCatalogFileEntry() throws Exception {
+ void testCleanArchetypeCatalogFileEntry() throws Exception {
ArchetypeCatalogFileEntry entry = new ArchetypeCatalogFileEntry(null, null, null);
- assertEquals(null, entry.getFileSystem());
- assertEquals(null, entry.getParent());
+ assertNull(entry.getFileSystem());
+ assertNull(entry.getParent());
assertEquals("archetype-catalog.xml", entry.getName());
}
@Test
- public void testFileSystem() throws Exception {
+ void testFileSystem() throws Exception {
FileSystem fileSystem = mock(FileSystem.class);
DirectoryEntry root = mock(DirectoryEntry.class);
when(fileSystem.getRoot()).thenReturn(root);
ArchetypeCatalogFileEntry entry = new ArchetypeCatalogFileEntry(fileSystem, null, null);
assertEquals(fileSystem, entry.getFileSystem());
- assertEquals(null, entry.getParent());
+ assertNull(entry.getParent());
assertEquals("archetype-catalog.xml", entry.getName());
assertEquals("archetype-catalog.xml", entry.toPath());
}
@Test
- public void testParent() throws Exception {
+ void testParent() throws Exception {
FileSystem fileSystem = mock(FileSystem.class);
DirectoryEntry parent = mock(DirectoryEntry.class);
when(fileSystem.getRoot()).thenReturn(parent);
@@ -47,7 +48,7 @@ public void testParent() throws Exception {
}
@Test
- public void testArtifactStore() throws Exception {
+ void testArtifactStore() throws Exception {
final long lastModified = System.currentTimeMillis();
FileSystem fileSystem = mock(FileSystem.class);
DirectoryEntry parent = mock(DirectoryEntry.class);
@@ -62,10 +63,6 @@ public void testArtifactStore() throws Exception {
assertEquals("archetype-catalog.xml", entry.toPath());
assertEquals(entry.getLastModified(), lastModified);
assertTrue(entry.getSize() > 0);
- try {
- assertNotNull(entry.getInputStream());
- } finally {
- entry.getInputStream().close();
- }
+ assertNotNull(entry.getInputStream());
}
}
diff --git a/mrm-servlet/src/test/java/org/codehaus/mojo/mrm/impl/maven/ArtifactStoreFileSystemTest.java b/mrm-servlet/src/test/java/org/codehaus/mojo/mrm/impl/maven/ArtifactStoreFileSystemTest.java
index c3757d97..b271233c 100644
--- a/mrm-servlet/src/test/java/org/codehaus/mojo/mrm/impl/maven/ArtifactStoreFileSystemTest.java
+++ b/mrm-servlet/src/test/java/org/codehaus/mojo/mrm/impl/maven/ArtifactStoreFileSystemTest.java
@@ -25,20 +25,20 @@
import org.codehaus.mojo.mrm.api.maven.Artifact;
import org.codehaus.mojo.mrm.api.maven.ArtifactNotFoundException;
import org.codehaus.mojo.mrm.api.maven.ArtifactStore;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertNull;
-import static org.junit.Assert.assertTrue;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertFalse;
+import static org.junit.jupiter.api.Assertions.assertNull;
+import static org.junit.jupiter.api.Assertions.assertTrue;
import static org.mockito.ArgumentMatchers.isA;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.when;
-public class ArtifactStoreFileSystemTest {
+class ArtifactStoreFileSystemTest {
@Test
- public void testGroupMetadataRegex() {
+ void testGroupMetadataRegex() {
Matcher matcher = ArtifactStoreFileSystem.METADATA.matcher("/commons/maven-metadata.xml");
assertTrue(matcher.matches());
assertEquals("commons/", matcher.group(1));
@@ -52,7 +52,7 @@ public void testGroupMetadataRegex() {
}
@Test
- public void testArtifactRegex() {
+ void testArtifactRegex() {
Matcher matcher = ArtifactStoreFileSystem.ARTIFACT.matcher("/commons/maven-metadata.xml");
assertFalse(matcher.matches());
matcher = ArtifactStoreFileSystem.ARTIFACT.matcher("/org/apache/maven/maven-metadata.xml");
@@ -103,7 +103,7 @@ public void testArtifactRegex() {
}
@Test
- public void testSnapshotArtifactRegex() {
+ void testSnapshotArtifactRegex() {
Matcher matcher = ArtifactStoreFileSystem.SNAPSHOT_ARTIFACT.matcher("/commons/maven-metadata.xml");
assertFalse(matcher.matches());
matcher = ArtifactStoreFileSystem.SNAPSHOT_ARTIFACT.matcher("/org/apache/maven/maven-metadata.xml");
@@ -148,7 +148,7 @@ public void testSnapshotArtifactRegex() {
// MMOCKRM-5
@Test
- public void testSiteXmlReleaseVersion() throws Exception {
+ void testSiteXmlReleaseVersion() throws Exception {
ArtifactStore store = mock(ArtifactStore.class);
when(store.getSize(isA(Artifact.class))).thenThrow(ArtifactNotFoundException.class);
ArtifactStoreFileSystem system = new ArtifactStoreFileSystem(store);
@@ -157,7 +157,7 @@ public void testSiteXmlReleaseVersion() throws Exception {
}
@Test
- public void testSiteXmlSnapshotVersion() throws Exception {
+ void testSiteXmlSnapshotVersion() throws Exception {
ArtifactStore store = mock(ArtifactStore.class);
when(store.getSize(isA(Artifact.class))).thenThrow(ArtifactNotFoundException.class);
ArtifactStoreFileSystem system = new ArtifactStoreFileSystem(store);
@@ -167,7 +167,7 @@ public void testSiteXmlSnapshotVersion() throws Exception {
}
@Test
- public void testArchetypeCatalogNotFound() throws Exception {
+ void testArchetypeCatalogNotFound() throws Exception {
ArtifactStore store = mock(ArtifactStore.class);
when(store.getArchetypeCatalogLastModified()).thenThrow(ArchetypeCatalogNotFoundException.class);
ArtifactStoreFileSystem system = new ArtifactStoreFileSystem(store);
@@ -176,7 +176,7 @@ public void testArchetypeCatalogNotFound() throws Exception {
}
@Test
- public void testArchetypeCatalog() throws Exception {
+ void testArchetypeCatalog() throws Exception {
ArtifactStore store = mock(ArtifactStore.class);
when(store.getArchetypeCatalog()).thenReturn(new ArchetypeCatalog());
ArtifactStoreFileSystem system = new ArtifactStoreFileSystem(store);
diff --git a/mrm-servlet/src/test/java/org/codehaus/mojo/mrm/impl/maven/CompositeArtifactStoreTest.java b/mrm-servlet/src/test/java/org/codehaus/mojo/mrm/impl/maven/CompositeArtifactStoreTest.java
index 025368fb..16f10dba 100644
--- a/mrm-servlet/src/test/java/org/codehaus/mojo/mrm/impl/maven/CompositeArtifactStoreTest.java
+++ b/mrm-servlet/src/test/java/org/codehaus/mojo/mrm/impl/maven/CompositeArtifactStoreTest.java
@@ -2,15 +2,16 @@
import org.apache.maven.archetype.catalog.ArchetypeCatalog;
import org.codehaus.mojo.mrm.api.maven.ArtifactStore;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
-import static org.junit.Assert.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.when;
-public class CompositeArtifactStoreTest {
+class CompositeArtifactStoreTest {
+
@Test
- public void testGetArchetypeCatalog() throws Exception {
+ void testGetArchetypeCatalog() throws Exception {
ArtifactStore store = mock(ArtifactStore.class);
when(store.getArchetypeCatalog()).thenReturn(new ArchetypeCatalog());
ArtifactStore[] stores = new ArtifactStore[] {store};
diff --git a/mrm-servlet/src/test/java/org/codehaus/mojo/mrm/impl/maven/DiskArtifactStoreTest.java b/mrm-servlet/src/test/java/org/codehaus/mojo/mrm/impl/maven/DiskArtifactStoreTest.java
index d089d276..785d16d7 100644
--- a/mrm-servlet/src/test/java/org/codehaus/mojo/mrm/impl/maven/DiskArtifactStoreTest.java
+++ b/mrm-servlet/src/test/java/org/codehaus/mojo/mrm/impl/maven/DiskArtifactStoreTest.java
@@ -4,16 +4,16 @@
import org.apache.maven.archetype.catalog.Archetype;
import org.apache.maven.archetype.catalog.ArchetypeCatalog;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
-public class DiskArtifactStoreTest {
+class DiskArtifactStoreTest {
// MMOCKRM-10
@Test
- public void testArchetypeCatalog() throws Exception {
+ void testArchetypeCatalog() throws Exception {
DiskArtifactStore artifactStore = new DiskArtifactStore(new File("src/test/resources/mmockrm-10"));
ArchetypeCatalog catalog = artifactStore.getArchetypeCatalog();
assertNotNull(catalog);
diff --git a/mrm-servlet/src/test/java/org/codehaus/mojo/mrm/impl/maven/MockArtifactStoreTest.java b/mrm-servlet/src/test/java/org/codehaus/mojo/mrm/impl/maven/MockArtifactStoreTest.java
index aa83505b..22ef46e9 100644
--- a/mrm-servlet/src/test/java/org/codehaus/mojo/mrm/impl/maven/MockArtifactStoreTest.java
+++ b/mrm-servlet/src/test/java/org/codehaus/mojo/mrm/impl/maven/MockArtifactStoreTest.java
@@ -1,9 +1,10 @@
package org.codehaus.mojo.mrm.impl.maven;
import java.io.File;
-import java.io.FileInputStream;
import java.io.InputStream;
import java.nio.file.Files;
+import java.nio.file.Path;
+import java.nio.file.Paths;
import java.nio.file.StandardCopyOption;
import java.util.ArrayList;
import java.util.Enumeration;
@@ -16,21 +17,21 @@
import org.apache.maven.archetype.catalog.Archetype;
import org.apache.maven.archetype.catalog.ArchetypeCatalog;
import org.codehaus.mojo.mrm.api.maven.Artifact;
-import org.junit.Rule;
-import org.junit.Test;
-import org.junit.rules.TemporaryFolder;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.io.TempDir;
-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;
-public class MockArtifactStoreTest {
- @Rule
- public TemporaryFolder temporaryFolder = new TemporaryFolder();
+class MockArtifactStoreTest {
+
+ @TempDir
+ Path temporaryFolder;
// MMOCKRM-3
@Test
- public void testInheritGavFromParent() {
+ void testInheritGavFromParent() {
// don't fail
MockArtifactStore mockArtifactStore = new MockArtifactStore(new File("src/test/resources/mmockrm-3"));
assertEquals(2, mockArtifactStore.getArtifactIds("localhost").size());
@@ -38,29 +39,25 @@ public void testInheritGavFromParent() {
// MMOCKRM-6
@Test
- public void testClassifiers() throws Exception {
+ void testClassifiers() throws Exception {
MockArtifactStore artifactStore = new MockArtifactStore(new File("src/test/resources/mmockrm-7"));
Artifact pomArtifact = new Artifact("localhost", "mmockrm-7", "1.0", "pom");
assertNotNull(artifactStore.get(pomArtifact));
- assertTrue(
- "Content equals",
- IOUtils.contentEquals(
- new FileInputStream("src/test/resources/mmockrm-7/mmockrm-7-1.0.pom"),
- artifactStore.get(pomArtifact)));
+ assertTrue(IOUtils.contentEquals(
+ Files.newInputStream(Paths.get("src/test/resources/mmockrm-7/mmockrm-7-1.0.pom")),
+ artifactStore.get(pomArtifact)));
Artifact siteArtifact = new Artifact("localhost", "mmockrm-7", "1.0", "site", "xml");
assertNotNull(artifactStore.get(siteArtifact));
- assertTrue(
- "Content equals",
- IOUtils.contentEquals(
- new FileInputStream("src/test/resources/mmockrm-7/mmockrm-7-1.0-site.xml"),
- artifactStore.get(siteArtifact)));
+ assertTrue(IOUtils.contentEquals(
+ Files.newInputStream(Paths.get("src/test/resources/mmockrm-7/mmockrm-7-1.0-site.xml")),
+ artifactStore.get(siteArtifact)));
}
// MMOCKRM-10
@Test
- public void testArchetypeCatalog() throws Exception {
+ void testArchetypeCatalog() throws Exception {
MockArtifactStore artifactStore = new MockArtifactStore(new File("src/test/resources/mmockrm-10"));
ArchetypeCatalog catalog = artifactStore.getArchetypeCatalog();
assertNotNull(catalog);
@@ -74,16 +71,14 @@ public void testArchetypeCatalog() throws Exception {
}
@Test
- public void testDirectoryContent() throws Exception {
+ void testDirectoryContent() throws Exception {
MockArtifactStore artifactStore = new MockArtifactStore(new File("target/test-classes/mrm-15"));
Artifact pomArtifact = new Artifact("localhost", "mrm-15", "1.0", "pom");
assertNotNull(artifactStore.get(pomArtifact));
- assertTrue(
- "Content equals",
- IOUtils.contentEquals(
- new FileInputStream("target/test-classes/mrm-15/mrm-15-1.0.pom"),
- artifactStore.get(pomArtifact)));
+ assertTrue(IOUtils.contentEquals(
+ Files.newInputStream(Paths.get("target/test-classes/mrm-15/mrm-15-1.0.pom")),
+ artifactStore.get(pomArtifact)));
Artifact mainArtifact = new Artifact("localhost", "mrm-15", "1.0", "jar");
InputStream inputStreamJar = artifactStore.get(mainArtifact);
@@ -91,7 +86,7 @@ public void testDirectoryContent() throws Exception {
List names = new ArrayList<>();
- File jarFile = temporaryFolder.newFile();
+ File jarFile = Files.createTempFile(temporaryFolder, "test", ".jar").toFile();
Files.copy(inputStreamJar, jarFile.toPath(), StandardCopyOption.REPLACE_EXISTING);
try (JarFile jar = new JarFile(jarFile)) {
@@ -109,22 +104,21 @@ public void testDirectoryContent() throws Exception {
}
@Test
- public void testEmptyJarContent() throws Exception {
+ void testEmptyJarContent() throws Exception {
MockArtifactStore artifactStore = new MockArtifactStore(new File("target/test-classes/empty-jar"));
Artifact pomArtifact = new Artifact("localhost", "mrm-empty-jar", "1.0", "pom");
InputStream inputStreamPom = artifactStore.get(pomArtifact);
assertNotNull(inputStreamPom);
- assertTrue(
- "Content equals",
- IOUtils.contentEquals(
- new FileInputStream("target/test-classes/empty-jar/mrm-empty-jar-1.0.pom"), inputStreamPom));
+ assertTrue(IOUtils.contentEquals(
+ Files.newInputStream(Paths.get("target/test-classes/empty-jar/mrm-empty-jar-1.0.pom")),
+ inputStreamPom));
Artifact mainArtifact = new Artifact("localhost", "mrm-empty-jar", "1.0", "jar");
InputStream inputStreamJar = artifactStore.get(mainArtifact);
assertNotNull(inputStreamJar);
- File jarFile = temporaryFolder.newFile();
+ File jarFile = Files.createTempFile(temporaryFolder, "test", ".jar").toFile();
Files.copy(inputStreamJar, jarFile.toPath(), StandardCopyOption.REPLACE_EXISTING);
List names = new ArrayList<>();
@@ -142,23 +136,21 @@ public void testEmptyJarContent() throws Exception {
}
@Test
- public void testEmptyPluginJarContent() throws Exception {
+ void testEmptyPluginJarContent() throws Exception {
MockArtifactStore artifactStore = new MockArtifactStore(new File("target/test-classes/empty-plugin-jar"));
Artifact pomArtifact = new Artifact("localhost", "mrm-empty-plugin-jar", "1.0", "pom");
InputStream inputStreamPom = artifactStore.get(pomArtifact);
assertNotNull(inputStreamPom);
- assertTrue(
- "Content equals",
- IOUtils.contentEquals(
- new FileInputStream("target/test-classes/empty-plugin-jar/mrm-empty-plugin-jar-1.0.pom"),
- inputStreamPom));
+ assertTrue(IOUtils.contentEquals(
+ Files.newInputStream(Paths.get("target/test-classes/empty-plugin-jar/mrm-empty-plugin-jar-1.0.pom")),
+ inputStreamPom));
Artifact mainArtifact = new Artifact("localhost", "mrm-empty-plugin-jar", "1.0", "jar");
InputStream inputStreamJar = artifactStore.get(mainArtifact);
assertNotNull(inputStreamJar);
- File jarFile = temporaryFolder.newFile();
+ File jarFile = Files.createTempFile(temporaryFolder, "test", ".jar").toFile();
Files.copy(inputStreamJar, jarFile.toPath(), StandardCopyOption.REPLACE_EXISTING);
List names = new ArrayList<>();
@@ -177,16 +169,14 @@ public void testEmptyPluginJarContent() throws Exception {
}
@Test
- public void testDirectoryWithClassifierContent() throws Exception {
+ void testDirectoryWithClassifierContent() throws Exception {
MockArtifactStore artifactStore = new MockArtifactStore(new File("target/test-classes/mrm-xx"));
Artifact pomArtifact = new Artifact("localhost", "mrm-xx", "1.0", "pom");
assertNotNull(artifactStore.get(pomArtifact));
- assertTrue(
- "Content equals",
- IOUtils.contentEquals(
- new FileInputStream("target/test-classes/mrm-xx/mrm-xx-1.0.pom"),
- artifactStore.get(pomArtifact)));
+ assertTrue(IOUtils.contentEquals(
+ Files.newInputStream(Paths.get("target/test-classes/mrm-xx/mrm-xx-1.0.pom")),
+ artifactStore.get(pomArtifact)));
Artifact classifiedArtifact = new Artifact("localhost", "mrm-xx", "1.0", "javadoc-resources", "jar");
assertNotNull(artifactStore.get(classifiedArtifact));
diff --git a/pom.xml b/pom.xml
index 72fb7ea6..5bfb5655 100644
--- a/pom.xml
+++ b/pom.xml
@@ -168,12 +168,6 @@
javax.servlet-api
3.1.0
-
- junit
- junit
- 4.13.2
- test
-
org.mockito
mockito-core