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-jlink-plugin.git
The following commit(s) were added to refs/heads/master by this push:
new a7c9260 Cleanup tests (#651)
a7c9260 is described below
commit a7c9260cdb24bbc0e05861c54204d4cb0edf4151
Author: Sylwester Lachiewicz <[email protected]>
AuthorDate: Sun Dec 21 17:33:10 2025 +0100
Cleanup tests (#651)
Co-authored-by: Moderne <[email protected]>
---
pom.xml | 6 ++++++
.../maven/plugins/jlink/AbstractJLinkMojoTest.java | 12 ++++++------
.../org/apache/maven/plugins/jlink/JLinkMojoTest.java | 18 ++++++++++--------
.../maven/plugins/jlink/MultipleLauncherTest.java | 10 +++++-----
4 files changed, 27 insertions(+), 19 deletions(-)
diff --git a/pom.xml b/pom.xml
index e7f5bb0..0913337 100644
--- a/pom.xml
+++ b/pom.xml
@@ -146,6 +146,12 @@
<version>4.11.0</version>
<scope>test</scope>
</dependency>
+ <dependency>
+ <groupId>org.mockito</groupId>
+ <artifactId>mockito-junit-jupiter</artifactId>
+ <version>4.11.0</version>
+ <scope>test</scope>
+ </dependency>
<dependency>
<groupId>org.assertj</groupId>
<artifactId>assertj-core</artifactId>
diff --git
a/src/test/java/org/apache/maven/plugins/jlink/AbstractJLinkMojoTest.java
b/src/test/java/org/apache/maven/plugins/jlink/AbstractJLinkMojoTest.java
index 62b0a71..a7df166 100644
--- a/src/test/java/org/apache/maven/plugins/jlink/AbstractJLinkMojoTest.java
+++ b/src/test/java/org/apache/maven/plugins/jlink/AbstractJLinkMojoTest.java
@@ -52,32 +52,32 @@ import static org.mockito.Mockito.when;
/**
* @author Karl Heinz Marbaise <a
href="mailto:[email protected]">[email protected]</a>
*/
-public class AbstractJLinkMojoTest {
+class AbstractJLinkMojoTest {
private AbstractJLinkMojo mojoMock;
@BeforeEach
- public void before() {
+ void before() {
this.mojoMock = mock(AbstractJLinkMojo.class,
Mockito.CALLS_REAL_METHODS);
when(mojoMock.getLog()).thenReturn(mock(Log.class));
}
@Test
@DisplayName("convert should return single characters")
- public void convertShouldReturnSingleCharacter() {
+ void convertShouldReturnSingleCharacter() {
StringBuilder result =
mojoMock.convertSeparatedModulePathToPlatformSeparatedModulePath("x");
assertThat(result).isNotEmpty().hasToString("x");
}
@Test
@DisplayName("convert should two characters separated by path separator")
- public void convertShouldReturnTwoCharactersSeparatedByPathSeparator() {
+ void convertShouldReturnTwoCharactersSeparatedByPathSeparator() {
StringBuilder result =
mojoMock.convertSeparatedModulePathToPlatformSeparatedModulePath("x;a");
assertThat(result).hasToString("x" + File.pathSeparatorChar + "a");
}
@Test
@DisplayName("convert using differential delimiter should return two
characters separated by path separator")
- public void
convertUsingDifferentDelimiterShouldReturnTwoCharactersSeparatedByPathSeparator()
{
+ void
convertUsingDifferentDelimiterShouldReturnTwoCharactersSeparatedByPathSeparator()
{
StringBuilder result =
mojoMock.convertSeparatedModulePathToPlatformSeparatedModulePath("x:a");
assertThat(result).hasToString("x" + File.pathSeparatorChar + "a");
}
@@ -85,7 +85,7 @@ public class AbstractJLinkMojoTest {
@Test
@DisplayName("convertSeparatedModulePathToPlatformSeparatedModulePath() "
+ "should return two characters separated by path separator")
- public void
convertUsingMultipleDelimitersShouldReturnTwoCharactersSeparatedByPathSeparator()
{
+ void
convertUsingMultipleDelimitersShouldReturnTwoCharactersSeparatedByPathSeparator()
{
StringBuilder result =
mojoMock.convertSeparatedModulePathToPlatformSeparatedModulePath("x:a::");
assertThat(result).hasToString("x" + File.pathSeparatorChar + "a");
}
diff --git a/src/test/java/org/apache/maven/plugins/jlink/JLinkMojoTest.java
b/src/test/java/org/apache/maven/plugins/jlink/JLinkMojoTest.java
index 44682df..a16d5d0 100644
--- a/src/test/java/org/apache/maven/plugins/jlink/JLinkMojoTest.java
+++ b/src/test/java/org/apache/maven/plugins/jlink/JLinkMojoTest.java
@@ -43,16 +43,19 @@ import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.condition.DisabledOnOs;
import org.junit.jupiter.api.condition.EnabledOnOs;
import org.junit.jupiter.api.condition.OS;
+import org.junit.jupiter.api.extension.ExtendWith;
import org.mockito.Mock;
import org.mockito.Mockito;
-import org.mockito.MockitoAnnotations;
+import org.mockito.junit.jupiter.MockitoExtension;
import static org.assertj.core.api.Assertions.assertThat;
import static org.mockito.ArgumentMatchers.any;
+import static org.mockito.Mockito.lenient;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.when;
-public class JLinkMojoTest {
+@ExtendWith(MockitoExtension.class)
+class JLinkMojoTest {
private JLinkMojo mojo;
@@ -69,8 +72,7 @@ public class JLinkMojoTest {
private LocationManager locationManager;
@BeforeEach
- public void setUp() throws Exception {
- MockitoAnnotations.openMocks(this);
+ void setUp() throws Exception {
mojo = new JLinkMojo(projectHelper, toolchainManager,
mavenResourcesFiltering, locationManager);
Field stripDebug = mojo.getClass().getDeclaredField("stripDebug");
stripDebug.setAccessible(true);
@@ -149,7 +151,7 @@ public class JLinkMojoTest {
}
@Test
- void testGetModulePathElements() throws Exception {
+ void getModulePathElements() throws Exception {
File outputDirectory = new File("target/test-classes");
outputDirectory.mkdirs();
@@ -157,7 +159,7 @@ public class JLinkMojoTest {
Artifact artifact = mock(Artifact.class);
when(artifact.getFile()).thenReturn(new
File("target/test-classes/dependency.jar"));
when(project.getArtifacts()).thenReturn(Collections.singleton(artifact));
- when(project.getBasedir()).thenReturn(new File("."));
+ lenient().when(project.getBasedir()).thenReturn(new File("."));
JavaModuleDescriptor moduleDescriptor =
mock(JavaModuleDescriptor.class);
when(moduleDescriptor.name()).thenReturn("test.module");
@@ -184,7 +186,7 @@ public class JLinkMojoTest {
}
@Test
- void testIgnoreAutomaticModules() throws Exception {
+ void ignoreAutomaticModules() throws Exception {
File outputDirectory = new File("target/test-classes");
outputDirectory.mkdirs();
@@ -195,7 +197,7 @@ public class JLinkMojoTest {
when(artifact2.getFile()).thenReturn(new
File("target/test-classes/dependency2.jar"));
when(project.getArtifacts()).thenReturn(Set.of(artifact1, artifact2));
- when(project.getBasedir()).thenReturn(new File("."));
+ lenient().when(project.getBasedir()).thenReturn(new File("."));
JavaModuleDescriptor moduleDescriptor1 =
mock(JavaModuleDescriptor.class);
when(moduleDescriptor1.name()).thenReturn("valid.module");
diff --git
a/src/test/java/org/apache/maven/plugins/jlink/MultipleLauncherTest.java
b/src/test/java/org/apache/maven/plugins/jlink/MultipleLauncherTest.java
index 5a49cbf..697137c 100644
--- a/src/test/java/org/apache/maven/plugins/jlink/MultipleLauncherTest.java
+++ b/src/test/java/org/apache/maven/plugins/jlink/MultipleLauncherTest.java
@@ -30,12 +30,12 @@ import org.junit.jupiter.api.Test;
import static org.assertj.core.api.Assertions.assertThat;
import static org.assertj.core.api.Assertions.assertThatThrownBy;
-public class MultipleLauncherTest {
+class MultipleLauncherTest {
private JLinkMojo mojo = new JLinkMojo(null, null, null, null);
@Test
- void testSingleLauncher() throws Exception {
+ void singleLauncher() throws Exception {
// It's OK to specify one launcher with "<launcher>" given
Field launcher = mojo.getClass().getDeclaredField("launcher");
launcher.setAccessible(true);
@@ -49,7 +49,7 @@ public class MultipleLauncherTest {
}
@Test
- void testOneMultipleLauncher() throws Exception {
+ void oneMultipleLauncher() throws Exception {
// It's OK to specify one launcher with "<launchers>"
Field launchers = mojo.getClass().getDeclaredField("launchers");
launchers.setAccessible(true);
@@ -63,7 +63,7 @@ public class MultipleLauncherTest {
}
@Test
- void testMultipleLaunchers() throws Exception {
+ void multipleLaunchers() throws Exception {
// It's OK to specify multiple launchers with the "<launchers>" element
Field launchers = mojo.getClass().getDeclaredField("launchers");
launchers.setAccessible(true);
@@ -77,7 +77,7 @@ public class MultipleLauncherTest {
}
@Test
- void testInvalidLauncherConfig() throws Exception {
+ void invalidLauncherConfig() throws Exception {
// It's an error to specify both "<launcher>" and "<launchers>"
Field launcher = mojo.getClass().getDeclaredField("launcher");
launcher.setAccessible(true);