junit/0002-remove-usages-of-deprecated-org.junit.Assert.assertT.patch

68 lines
2.8 KiB
Diff

From 12270ec059bb103dcfb1d11c359e25c7ce5953da Mon Sep 17 00:00:00 2001
From: Christine Poerschke <cpoerschke@bloomberg.net>
Date: Thu, 30 Dec 2021 08:44:54 +0000
Subject: [PATCH 2/2] remove usages of deprecated org.junit.Assert.assertThat()
---
src/main/java/org/junit/rules/ErrorCollector.java | 4 ++--
src/main/java/org/junit/rules/ExpectedException.java | 4 ++--
2 files changed, 4 insertions(+), 4 deletions(-)
diff --git a/src/main/java/org/junit/rules/ErrorCollector.java b/src/main/java/org/junit/rules/ErrorCollector.java
index 9711e503..f846d776 100644
--- a/src/main/java/org/junit/rules/ErrorCollector.java
+++ b/src/main/java/org/junit/rules/ErrorCollector.java
@@ -1,6 +1,5 @@
package org.junit.rules;
-import static org.junit.Assert.assertThat;
import static org.junit.Assert.assertThrows;
import java.util.ArrayList;
@@ -10,6 +9,7 @@ import java.util.concurrent.Callable;
import org.junit.function.ThrowingRunnable;
import org.junit.internal.AssumptionViolatedException;
import org.hamcrest.Matcher;
+import org.hamcrest.MatcherAssert;
import org.junit.runners.model.MultipleFailureException;
/**
@@ -74,7 +74,7 @@ public class ErrorCollector extends Verifier {
public <T> void checkThat(final String reason, final T value, final Matcher<T> matcher) {
checkSucceeds(new Callable<Object>() {
public Object call() throws Exception {
- assertThat(reason, value, matcher);
+ MatcherAssert.assertThat(reason, value, matcher);
return value;
}
});
diff --git a/src/main/java/org/junit/rules/ExpectedException.java b/src/main/java/org/junit/rules/ExpectedException.java
index 431ad495..16550851 100644
--- a/src/main/java/org/junit/rules/ExpectedException.java
+++ b/src/main/java/org/junit/rules/ExpectedException.java
@@ -3,11 +3,11 @@ package org.junit.rules;
import static java.lang.String.format;
import static org.hamcrest.CoreMatchers.containsString;
import static org.hamcrest.CoreMatchers.instanceOf;
-import static org.junit.Assert.assertThat;
import static org.junit.Assert.fail;
import static org.junit.internal.matchers.ThrowableCauseMatcher.hasCause;
import static org.junit.internal.matchers.ThrowableMessageMatcher.hasMessage;
import org.hamcrest.Matcher;
+import org.hamcrest.MatcherAssert;
import org.hamcrest.StringDescription;
import org.junit.AssumptionViolatedException;
import org.junit.runners.model.Statement;
@@ -268,7 +268,7 @@ public class ExpectedException implements TestRule {
private void handleException(Throwable e) throws Throwable {
if (isAnyExceptionExpected()) {
- assertThat(e, matcherBuilder.build());
+ MatcherAssert.assertThat(e, matcherBuilder.build());
} else {
throw e;
}
--
2.44.0