From e281f0d1cbd4cb3536b5518ced3441114e12001f Mon Sep 17 00:00:00 2001 From: "H. Habighorst" Date: Sat, 3 Jun 2023 22:26:03 +0200 Subject: [PATCH] Update hamcrest-library to 2.2 --- build.sbt | 11 +++++-- project/Dependencies.scala | 4 +-- .../jupiter/api/JupiterTestFingerprint.java | 10 ++++-- .../internal/event/LoggingEventHandler.java | 2 +- .../sbt/junit/jupiter/api/StreamPairTest.java | 32 ++++++++----------- .../sbt/junit/jupiter/internal/ColorTest.java | 2 +- .../jupiter/internal/event/TaskNameTest.java | 2 +- .../internal/filter/GlobFilterTest.java | 2 +- .../internal/filter/TestFilterTest.java | 2 +- .../listeners/CapturedOutputStreamTest.java | 2 +- ...FlatPrintingTestListenerFormatterTest.java | 2 +- .../internal/options/OptionsParserTest.java | 2 +- .../jupiter/tickets/n0001/Ticket0001Test.java | 2 +- .../jupiter/tickets/n0003/Ticket0003Test.java | 2 +- .../samples/VintageParameterizedTests.java | 4 +-- test-project/project/build.properties | 2 +- 16 files changed, 43 insertions(+), 40 deletions(-) diff --git a/build.sbt b/build.sbt index 2ec0261..cae2164 100644 --- a/build.sbt +++ b/build.sbt @@ -22,13 +22,19 @@ import Dependencies.* ThisBuild / organization := "com.github.sbt.junit" ThisBuild / scalaVersion := "2.12.19" +lazy val commonSettings: Seq[Setting[_]] = Def.settings( + Compile / javacOptions ++= Seq( + "-encoding", "UTF-8", "-Xlint:all", "-Xlint:-processing", "-source", "1.8", "-target", "1.8" + ), + Compile / doc / javacOptions := Seq("-encoding", "UTF-8", "-source", "1.8"), +) + lazy val library = (project in file("src/library")) .settings( + commonSettings, name := "jupiter-interface", autoScalaLibrary := false, crossPaths := false, - (compile / javacOptions) ++= Seq("-source", "1.8", "-target", "1.8"), - (doc / javacOptions) := Seq("-source", "1.8"), libraryDependencies ++= Seq( junitPlatformLauncher, junitJupiterEngine, @@ -49,6 +55,7 @@ lazy val plugin = (project in file("src/plugin")) .enablePlugins(SbtPlugin) .dependsOn(library) .settings( + commonSettings, name := "sbt-jupiter-interface", Compile / scalacOptions ++= Seq("-Xlint", "-Xfatal-warnings"), scriptedBufferLog := false, diff --git a/project/Dependencies.scala b/project/Dependencies.scala index de1f477..5f9e68a 100644 --- a/project/Dependencies.scala +++ b/project/Dependencies.scala @@ -13,8 +13,8 @@ object Dependencies { val testInterface = "org.scala-sbt" % "test-interface" % testInterfaceVer val junitJupiterParams = "org.junit.jupiter" % "junit-jupiter-params" % junitJupiterVer val junitVintageEngine = "org.junit.vintage" % "junit-vintage-engine" % junitVintageVer - val hamcrestLibrary = "org.hamcrest" % "hamcrest-library" % "1.3" - val mockitoCore = "org.mockito" % "mockito-core" % "2.23.4" + val hamcrestLibrary = "org.hamcrest" % "hamcrest-library" % "2.2" + val mockitoCore = "org.mockito" % "mockito-core" % "4.11.0" val junit4Interface = "com.github.sbt" % "junit-interface" % "0.13.3" val junit4 = "junit" % "junit" % "4.13.2" } diff --git a/src/library/src/main/java/com/github/sbt/junit/jupiter/api/JupiterTestFingerprint.java b/src/library/src/main/java/com/github/sbt/junit/jupiter/api/JupiterTestFingerprint.java index 4ae4802..d7d6a2e 100644 --- a/src/library/src/main/java/com/github/sbt/junit/jupiter/api/JupiterTestFingerprint.java +++ b/src/library/src/main/java/com/github/sbt/junit/jupiter/api/JupiterTestFingerprint.java @@ -20,6 +20,8 @@ import sbt.testing.AnnotatedFingerprint; +import java.util.Objects; + /** * A dummy fingerprint implementation used for all discovered tests. * @@ -32,7 +34,6 @@ public class JupiterTestFingerprint implements AnnotatedFingerprint { */ @Override public boolean isModule() { - return false; } @@ -42,13 +43,11 @@ public boolean isModule() { */ @Override public String annotationName() { - return getClass().getName(); } @Override public boolean equals(Object obj) { - if (obj instanceof AnnotatedFingerprint) { AnnotatedFingerprint f = (AnnotatedFingerprint) obj; if (annotationName().equals(f.annotationName())) { @@ -58,4 +57,9 @@ public boolean equals(Object obj) { return false; } + + @Override + public int hashCode() { + return Objects.hash(this.annotationName(), this.isModule()); + } } diff --git a/src/library/src/main/java/com/github/sbt/junit/jupiter/internal/event/LoggingEventHandler.java b/src/library/src/main/java/com/github/sbt/junit/jupiter/internal/event/LoggingEventHandler.java index aedb636..d6ad9e2 100644 --- a/src/library/src/main/java/com/github/sbt/junit/jupiter/internal/event/LoggingEventHandler.java +++ b/src/library/src/main/java/com/github/sbt/junit/jupiter/internal/event/LoggingEventHandler.java @@ -32,7 +32,7 @@ /** * Writes dispatch events to a file for testing/debugging purposes. * - *

Example Usage

+ *

Example Usage

*
{@code
  *   SBT> testOnly -- --trace-dispatch-events
  * }
diff --git a/src/library/src/test/java/com/github/sbt/junit/jupiter/api/StreamPairTest.java b/src/library/src/test/java/com/github/sbt/junit/jupiter/api/StreamPairTest.java
index f49eb0e..37dce22 100644
--- a/src/library/src/test/java/com/github/sbt/junit/jupiter/api/StreamPairTest.java
+++ b/src/library/src/test/java/com/github/sbt/junit/jupiter/api/StreamPairTest.java
@@ -18,16 +18,13 @@
  */
 package com.github.sbt.junit.jupiter.api;
 
-import org.junit.Rule;
 import org.junit.Test;
-import org.junit.rules.ExpectedException;
 
 import java.io.PrintStream;
 
-import static org.hamcrest.Matchers.equalTo;
-import static org.hamcrest.Matchers.not;
-import static org.hamcrest.Matchers.startsWith;
-import static org.junit.Assert.assertThat;
+import static org.hamcrest.MatcherAssert.assertThat;
+import static org.hamcrest.Matchers.*;
+import static org.junit.Assert.assertThrows;
 import static org.mockito.Mockito.mock;
 
 /**
@@ -35,30 +32,28 @@
  */
 public class StreamPairTest {
 
-    @Rule
-    public final ExpectedException thrownException = ExpectedException.none();
-
     @Test
     public void shouldThrowExceptionIfOutIsNull() {
+        Exception thrownException = assertThrows(
+            NullPointerException.class,
+            () -> new StreamPair(null, mock(PrintStream.class))
+        );
 
-        thrownException.expect(NullPointerException.class);
-        thrownException.expectMessage(startsWith("Output stream "));
-
-        new StreamPair(null, mock(PrintStream.class));
+        assertThat(thrownException.getMessage(), startsWith("Output stream "));
     }
 
     @Test
     public void shouldThrowExceptionIfErrIsNull() {
+        Exception thrownException = assertThrows(
+            NullPointerException.class,
+            () ->  new StreamPair(mock(PrintStream.class), null)
+        );
 
-        thrownException.expect(NullPointerException.class);
-        thrownException.expectMessage(startsWith("Error stream "));
-
-        new StreamPair(mock(PrintStream.class), null);
+        assertThat(thrownException.getMessage(), startsWith("Error stream "));
     }
 
     @Test
     public void shouldGetTypeOut() {
-
         PrintStream out = mock(PrintStream.class);
         PrintStream err = mock(PrintStream.class);
 
@@ -69,7 +64,6 @@ public void shouldGetTypeOut() {
 
     @Test
     public void shouldGetTypeErr() {
-
         PrintStream out = mock(PrintStream.class);
         PrintStream err = mock(PrintStream.class);
 
diff --git a/src/library/src/test/java/com/github/sbt/junit/jupiter/internal/ColorTest.java b/src/library/src/test/java/com/github/sbt/junit/jupiter/internal/ColorTest.java
index a4497ed..dc689d1 100644
--- a/src/library/src/test/java/com/github/sbt/junit/jupiter/internal/ColorTest.java
+++ b/src/library/src/test/java/com/github/sbt/junit/jupiter/internal/ColorTest.java
@@ -21,7 +21,7 @@
 import org.junit.Test;
 
 import static org.hamcrest.Matchers.equalTo;
-import static org.junit.Assert.assertThat;
+import static org.hamcrest.MatcherAssert.assertThat;
 
 /**
  * @author Michael Aichler
diff --git a/src/library/src/test/java/com/github/sbt/junit/jupiter/internal/event/TaskNameTest.java b/src/library/src/test/java/com/github/sbt/junit/jupiter/internal/event/TaskNameTest.java
index 1e69e2b..636b29a 100644
--- a/src/library/src/test/java/com/github/sbt/junit/jupiter/internal/event/TaskNameTest.java
+++ b/src/library/src/test/java/com/github/sbt/junit/jupiter/internal/event/TaskNameTest.java
@@ -25,7 +25,7 @@
 
 import static org.hamcrest.Matchers.equalTo;
 import static org.hamcrest.Matchers.nullValue;
-import static org.junit.Assert.assertThat;
+import static org.hamcrest.MatcherAssert.assertThat;
 
 /**
  * @author Michael Aichler
diff --git a/src/library/src/test/java/com/github/sbt/junit/jupiter/internal/filter/GlobFilterTest.java b/src/library/src/test/java/com/github/sbt/junit/jupiter/internal/filter/GlobFilterTest.java
index dfe22ee..b59a77c 100644
--- a/src/library/src/test/java/com/github/sbt/junit/jupiter/internal/filter/GlobFilterTest.java
+++ b/src/library/src/test/java/com/github/sbt/junit/jupiter/internal/filter/GlobFilterTest.java
@@ -30,7 +30,7 @@
 
 import static java.util.Arrays.asList;
 import static org.hamcrest.Matchers.is;
-import static org.junit.Assert.assertThat;
+import static org.hamcrest.MatcherAssert.assertThat;
 
 /**
  * @author Michael Aichler
diff --git a/src/library/src/test/java/com/github/sbt/junit/jupiter/internal/filter/TestFilterTest.java b/src/library/src/test/java/com/github/sbt/junit/jupiter/internal/filter/TestFilterTest.java
index 6961412..701b0f9 100644
--- a/src/library/src/test/java/com/github/sbt/junit/jupiter/internal/filter/TestFilterTest.java
+++ b/src/library/src/test/java/com/github/sbt/junit/jupiter/internal/filter/TestFilterTest.java
@@ -28,7 +28,7 @@
 
 import static java.util.Arrays.asList;
 import static org.hamcrest.Matchers.is;
-import static org.junit.Assert.assertThat;
+import static org.hamcrest.MatcherAssert.assertThat;
 
 /**
  * @author Michael Aichler
diff --git a/src/library/src/test/java/com/github/sbt/junit/jupiter/internal/listeners/CapturedOutputStreamTest.java b/src/library/src/test/java/com/github/sbt/junit/jupiter/internal/listeners/CapturedOutputStreamTest.java
index 968095d..2696885 100644
--- a/src/library/src/test/java/com/github/sbt/junit/jupiter/internal/listeners/CapturedOutputStreamTest.java
+++ b/src/library/src/test/java/com/github/sbt/junit/jupiter/internal/listeners/CapturedOutputStreamTest.java
@@ -25,7 +25,7 @@
 
 import static com.github.sbt.junit.jupiter.internal.listeners.OutputCapturingTestListener.CapturedOutputStream;
 import static org.hamcrest.Matchers.contains;
-import static org.junit.Assert.assertThat;
+import static org.hamcrest.MatcherAssert.assertThat;
 
 /**
  * @author Michael Aichler
diff --git a/src/library/src/test/java/com/github/sbt/junit/jupiter/internal/listeners/FlatPrintingTestListenerFormatterTest.java b/src/library/src/test/java/com/github/sbt/junit/jupiter/internal/listeners/FlatPrintingTestListenerFormatterTest.java
index e18c13a..36b2d28 100644
--- a/src/library/src/test/java/com/github/sbt/junit/jupiter/internal/listeners/FlatPrintingTestListenerFormatterTest.java
+++ b/src/library/src/test/java/com/github/sbt/junit/jupiter/internal/listeners/FlatPrintingTestListenerFormatterTest.java
@@ -14,7 +14,7 @@
 import java.util.regex.Pattern;
 
 import static org.hamcrest.Matchers.equalTo;
-import static org.junit.Assert.assertThat;
+import static org.hamcrest.MatcherAssert.assertThat;
 
 /**
  * Test output formatting of test identifiers.
diff --git a/src/library/src/test/java/com/github/sbt/junit/jupiter/internal/options/OptionsParserTest.java b/src/library/src/test/java/com/github/sbt/junit/jupiter/internal/options/OptionsParserTest.java
index c3c4bee..9f1580d 100644
--- a/src/library/src/test/java/com/github/sbt/junit/jupiter/internal/options/OptionsParserTest.java
+++ b/src/library/src/test/java/com/github/sbt/junit/jupiter/internal/options/OptionsParserTest.java
@@ -3,7 +3,7 @@
 import org.junit.Test;
 
 import static org.hamcrest.Matchers.contains;
-import static org.junit.Assert.assertThat;
+import static org.hamcrest.MatcherAssert.assertThat;
 
 public class OptionsParserTest {
 
diff --git a/src/library/src/test/java/com/github/sbt/junit/jupiter/tickets/n0001/Ticket0001Test.java b/src/library/src/test/java/com/github/sbt/junit/jupiter/tickets/n0001/Ticket0001Test.java
index d70274f..0c9d46c 100644
--- a/src/library/src/test/java/com/github/sbt/junit/jupiter/tickets/n0001/Ticket0001Test.java
+++ b/src/library/src/test/java/com/github/sbt/junit/jupiter/tickets/n0001/Ticket0001Test.java
@@ -8,7 +8,7 @@
 import static org.hamcrest.Matchers.containsString;
 import static org.hamcrest.Matchers.hasItem;
 import static org.hamcrest.Matchers.hasSize;
-import static org.junit.Assert.assertThat;
+import static org.hamcrest.MatcherAssert.assertThat;
 
 public class Ticket0001Test {
 
diff --git a/src/library/src/test/java/com/github/sbt/junit/jupiter/tickets/n0003/Ticket0003Test.java b/src/library/src/test/java/com/github/sbt/junit/jupiter/tickets/n0003/Ticket0003Test.java
index e892c0b..7a76527 100644
--- a/src/library/src/test/java/com/github/sbt/junit/jupiter/tickets/n0003/Ticket0003Test.java
+++ b/src/library/src/test/java/com/github/sbt/junit/jupiter/tickets/n0003/Ticket0003Test.java
@@ -7,7 +7,7 @@
 import static org.hamcrest.Matchers.contains;
 import static org.hamcrest.Matchers.containsString;
 import static org.hamcrest.Matchers.hasSize;
-import static org.junit.Assert.assertThat;
+import static org.hamcrest.MatcherAssert.assertThat;
 
 public class Ticket0003Test {
 
diff --git a/src/library/src/test/java/jupiter/samples/VintageParameterizedTests.java b/src/library/src/test/java/jupiter/samples/VintageParameterizedTests.java
index f8d4228..19caa40 100644
--- a/src/library/src/test/java/jupiter/samples/VintageParameterizedTests.java
+++ b/src/library/src/test/java/jupiter/samples/VintageParameterizedTests.java
@@ -5,8 +5,8 @@
 import org.junit.runners.Parameterized;
 import org.junit.runners.Parameterized.Parameters;
 
+import static org.hamcrest.MatcherAssert.assertThat;
 import static org.hamcrest.Matchers.equalTo;
-import static org.junit.Assert.assertThat;
 
 /**
  * Sample test methods for the vintage-engine using {@link Parameterized} runner.
@@ -18,7 +18,6 @@ public class VintageParameterizedTests {
     private final int code;
 
     public VintageParameterizedTests(char alpha, int number) {
-
         this.alpha = alpha;
         this.code = number;
     }
@@ -34,7 +33,6 @@ public static Object[][] data() {
 
     @Test
     public void testParameters() {
-
         assertThat((int)alpha, equalTo(code));
     }
 }
diff --git a/test-project/project/build.properties b/test-project/project/build.properties
index 817bc38..72413de 100644
--- a/test-project/project/build.properties
+++ b/test-project/project/build.properties
@@ -1 +1 @@
-sbt.version=0.13.9
+sbt.version=1.8.3