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-jarsigner-plugin.git
The following commit(s) were added to refs/heads/master by this push:
new 621920b Mockito improvements (#135)
621920b is described below
commit 621920b61e134b50ba239e805b13915ae5d10226
Author: Sylwester Lachiewicz <[email protected]>
AuthorDate: Sat Feb 14 15:34:09 2026 +0100
Mockito improvements (#135)
---
Co-authored-by: Moderne <[email protected]>
---
.../jarsigner/JarsignerSignMojoParallelTest.java | 3 +--
.../jarsigner/JarsignerSignMojoRetryTest.java | 19 ++++++-------
.../plugins/jarsigner/JarsignerSignMojoTest.java | 31 +++++++++++-----------
3 files changed, 27 insertions(+), 26 deletions(-)
diff --git
a/src/test/java/org/apache/maven/plugins/jarsigner/JarsignerSignMojoParallelTest.java
b/src/test/java/org/apache/maven/plugins/jarsigner/JarsignerSignMojoParallelTest.java
index 130156b..9f6d88f 100644
---
a/src/test/java/org/apache/maven/plugins/jarsigner/JarsignerSignMojoParallelTest.java
+++
b/src/test/java/org/apache/maven/plugins/jarsigner/JarsignerSignMojoParallelTest.java
@@ -54,7 +54,6 @@ import static org.mockito.ArgumentMatchers.contains;
import static org.mockito.ArgumentMatchers.isA;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.timeout;
-import static org.mockito.Mockito.times;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;
@@ -204,7 +203,7 @@ public class JarsignerSignMojoParallelTest {
mojo.execute();
- verify(jarSigner, times(1)).execute(any());
+ verify(jarSigner).execute(any());
verify(log).warn(contains("Invalid threadCount value"));
verify(log).warn(contains("Was '0'"));
}
diff --git
a/src/test/java/org/apache/maven/plugins/jarsigner/JarsignerSignMojoRetryTest.java
b/src/test/java/org/apache/maven/plugins/jarsigner/JarsignerSignMojoRetryTest.java
index 80b54ec..80381cb 100644
---
a/src/test/java/org/apache/maven/plugins/jarsigner/JarsignerSignMojoRetryTest.java
+++
b/src/test/java/org/apache/maven/plugins/jarsigner/JarsignerSignMojoRetryTest.java
@@ -51,6 +51,7 @@ import static org.mockito.ArgumentMatchers.any;
import static org.mockito.ArgumentMatchers.contains;
import static org.mockito.Mockito.argThat;
import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.never;
import static org.mockito.Mockito.times;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;
@@ -97,7 +98,7 @@ public class JarsignerSignMojoRetryTest {
verify(jarSigner)
.execute(argThat(request ->
request.getArchive().getPath().endsWith("my-project.jar")));
- verify(waitStrategy, times(0)).waitAfterFailure(0,
Duration.ofSeconds(0));
+ verify(waitStrategy, never()).waitAfterFailure(0,
Duration.ofSeconds(0));
}
@Test
@@ -109,8 +110,8 @@ public class JarsignerSignMojoRetryTest {
assertThrows(MojoExecutionException.class, () -> {
mojo.execute();
});
- verify(jarSigner, times(1)).execute(any());
- verify(waitStrategy, times(0)).waitAfterFailure(0,
Duration.ofSeconds(0));
+ verify(jarSigner).execute(any());
+ verify(waitStrategy, never()).waitAfterFailure(0,
Duration.ofSeconds(0));
}
@Test
@@ -125,7 +126,7 @@ public class JarsignerSignMojoRetryTest {
mojo.execute();
verify(jarSigner, times(2)).execute(any());
- verify(waitStrategy, times(1)).waitAfterFailure(0,
Duration.ofSeconds(0));
+ verify(waitStrategy).waitAfterFailure(0, Duration.ofSeconds(0));
}
@Test
@@ -140,7 +141,7 @@ public class JarsignerSignMojoRetryTest {
mojo.execute();
});
verify(jarSigner, times(2)).execute(any());
- verify(waitStrategy, times(1)).waitAfterFailure(0,
Duration.ofSeconds(0));
+ verify(waitStrategy).waitAfterFailure(0, Duration.ofSeconds(0));
}
@Test
@@ -156,7 +157,7 @@ public class JarsignerSignMojoRetryTest {
mojo.execute();
});
- verify(jarSigner, times(1)).execute(any()); // Should have tried
exactly one time, regardless of invalid value
+ verify(jarSigner).execute(any()); // Should have tried exactly one
time, regardless of invalid value
verify(log).warn(contains("Invalid maxTries"));
verify(log).warn(contains("0"));
}
@@ -172,7 +173,7 @@ public class JarsignerSignMojoRetryTest {
mojo.execute();
- verify(jarSigner, times(1)).execute(any()); // Should have tried
exactly one time, regardless of invalid value
+ verify(jarSigner).execute(any()); // Should have tried exactly one
time, regardless of invalid value
verify(log).warn(contains("Invalid maxTries"));
verify(log).warn(contains("-2"));
}
@@ -191,8 +192,8 @@ public class JarsignerSignMojoRetryTest {
mojo.execute();
- verify(waitStrategy, times(1)).waitAfterFailure(0,
Duration.ofSeconds(30));
- verify(waitStrategy, times(1)).waitAfterFailure(1,
Duration.ofSeconds(30));
+ verify(waitStrategy).waitAfterFailure(0, Duration.ofSeconds(30));
+ verify(waitStrategy).waitAfterFailure(1, Duration.ofSeconds(30));
}
@Test
diff --git
a/src/test/java/org/apache/maven/plugins/jarsigner/JarsignerSignMojoTest.java
b/src/test/java/org/apache/maven/plugins/jarsigner/JarsignerSignMojoTest.java
index beb96ab..3ccacc5 100644
---
a/src/test/java/org/apache/maven/plugins/jarsigner/JarsignerSignMojoTest.java
+++
b/src/test/java/org/apache/maven/plugins/jarsigner/JarsignerSignMojoTest.java
@@ -59,6 +59,7 @@ import static org.junit.Assert.assertTrue;
import static org.mockito.ArgumentMatchers.contains;
import static org.mockito.Mockito.any;
import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.never;
import static org.mockito.Mockito.times;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;
@@ -168,7 +169,7 @@ public class JarsignerSignMojoTest {
mojo.execute();
- verify(jarSigner, times(0)).execute(any()); // Should not try to sign
anything
+ verify(jarSigner, never()).execute(any()); // Should not try to sign
anything
}
/** Normal Java project, but avoid to process the main artifact
(processMainArtifact to false) */
@@ -181,7 +182,7 @@ public class JarsignerSignMojoTest {
mojo.execute();
- verify(jarSigner, times(0)).execute(any()); // Should not try to sign
anything
+ verify(jarSigner, never()).execute(any()); // Should not try to sign
anything
}
/** Make sure that when skip is configured the Mojo will not process
anything */
@@ -193,7 +194,7 @@ public class JarsignerSignMojoTest {
mojo.execute();
- verify(jarSigner, times(0)).execute(any()); // Should not try to sign
anything
+ verify(jarSigner, never()).execute(any()); // Should not try to sign
anything
}
/** Only process the specified archive, don't process the main artifact
nor the attached. */
@@ -209,8 +210,8 @@ public class JarsignerSignMojoTest {
mojo.execute();
// Make sure only the jar pointed by "archive" has been processed, but
not the main artifact
- verify(jarSigner,
times(0)).execute(MockitoHamcrest.argThat(RequestMatchers.hasFileName("my-project.jar")));
- verify(jarSigner,
times(1)).execute(MockitoHamcrest.argThat(RequestMatchers.hasFileName("archive.jar")));
+ verify(jarSigner,
never()).execute(MockitoHamcrest.argThat(RequestMatchers.hasFileName("my-project.jar")));
+
verify(jarSigner).execute(MockitoHamcrest.argThat(RequestMatchers.hasFileName("archive.jar")));
}
/** Test that it is possible to disable processing of attached artifacts */
@@ -230,8 +231,8 @@ public class JarsignerSignMojoTest {
mojo.execute();
// Make sure that only the main artifact has been processed, but not
the attached artifact
- verify(jarSigner,
times(1)).execute(MockitoHamcrest.argThat(RequestMatchers.hasFileName("my-project.jar")));
- verify(jarSigner, times(0))
+
verify(jarSigner).execute(MockitoHamcrest.argThat(RequestMatchers.hasFileName("my-project.jar")));
+ verify(jarSigner, never())
.execute(MockitoHamcrest.argThat(RequestMatchers.hasFileName("my-project-sources.jar")));
}
@@ -438,10 +439,10 @@ public class JarsignerSignMojoTest {
mojo.execute();
- verify(log, times(1)).info(contains("Unsupported artifact "));
- verify(log, times(1)).info(contains("Forcibly ignoring attached
artifacts"));
- verify(log, times(1)).info(contains("Processing "));
- verify(log, times(1)).info(contains("1 archive(s) processed"));
+ verify(log).info(contains("Unsupported artifact "));
+ verify(log).info(contains("Forcibly ignoring attached artifacts"));
+ verify(log).info(contains("Processing "));
+ verify(log).info(contains("1 archive(s) processed"));
}
/** Test what is logged when verbose=false */
@@ -461,9 +462,9 @@ public class JarsignerSignMojoTest {
mojo.execute();
- verify(log, times(1)).debug(contains("Unsupported artifact "));
- verify(log, times(1)).debug(contains("Forcibly ignoring attached
artifacts"));
- verify(log, times(1)).debug(contains("Processing "));
- verify(log, times(1)).info(contains("1 archive(s) processed"));
+ verify(log).debug(contains("Unsupported artifact "));
+ verify(log).debug(contains("Forcibly ignoring attached artifacts"));
+ verify(log).debug(contains("Processing "));
+ verify(log).info(contains("1 archive(s) processed"));
}
}