Removed references to deprecated Assert#assertThat
diff --git a/httpcore5-h2/src/test/java/org/apache/hc/core5/http2/hpack/TestHPackCoding.java b/httpcore5-h2/src/test/java/org/apache/hc/core5/http2/hpack/TestHPackCoding.java
index 8e71d5f..57ab798 100644
--- a/httpcore5-h2/src/test/java/org/apache/hc/core5/http2/hpack/TestHPackCoding.java
+++ b/httpcore5-h2/src/test/java/org/apache/hc/core5/http2/hpack/TestHPackCoding.java
@@ -37,6 +37,7 @@
import org.apache.hc.core5.http.message.BasicHeader;
import org.apache.hc.core5.util.ByteArrayBuffer;
import org.hamcrest.CoreMatchers;
+import org.hamcrest.MatcherAssert;
import org.junit.Assert;
import org.junit.Test;
@@ -1053,10 +1054,10 @@
"123456789012345678901234567890123456789012345678901234567890")),
false);
- Assert.assertThat(decoder.decodeHeaders(wrap(buf)).size(), CoreMatchers.equalTo(2));
+ MatcherAssert.assertThat(decoder.decodeHeaders(wrap(buf)).size(), CoreMatchers.equalTo(2));
decoder.setMaxListSize(1000000);
- Assert.assertThat(decoder.decodeHeaders(wrap(buf)).size(), CoreMatchers.equalTo(2));
+ MatcherAssert.assertThat(decoder.decodeHeaders(wrap(buf)).size(), CoreMatchers.equalTo(2));
decoder.setMaxListSize(200);
decoder.decodeHeaders(wrap(buf));
diff --git a/httpcore5-testing/src/test/java/org/apache/hc/core5/benchmark/ResultFormatterTest.java b/httpcore5-testing/src/test/java/org/apache/hc/core5/benchmark/ResultFormatterTest.java
index 023f81b..33e7185 100644
--- a/httpcore5-testing/src/test/java/org/apache/hc/core5/benchmark/ResultFormatterTest.java
+++ b/httpcore5-testing/src/test/java/org/apache/hc/core5/benchmark/ResultFormatterTest.java
@@ -32,7 +32,7 @@
import org.apache.hc.core5.http.HttpVersion;
import org.hamcrest.CoreMatchers;
-import org.junit.Assert;
+import org.hamcrest.MatcherAssert;
import org.junit.Test;
public class ResultFormatterTest {
@@ -56,7 +56,7 @@
50000000);
final ByteArrayOutputStream buf = new ByteArrayOutputStream();
ResultFormatter.print(new PrintStream(buf, true, StandardCharsets.US_ASCII.name()), results);
- Assert.assertThat(new String(buf.toByteArray(), StandardCharsets.US_ASCII).replace("\r\n", "\n"),
+ MatcherAssert.assertThat(new String(buf.toByteArray(), StandardCharsets.US_ASCII).replace("\r\n", "\n"),
CoreMatchers.equalTo(
"Server Software:\t\tTestServer/1.1\n" +
"Protocol version:\t\tHTTP/1.1\n" +
diff --git a/httpcore5-testing/src/test/java/org/apache/hc/core5/testing/classic/ClassicAuthenticationTest.java b/httpcore5-testing/src/test/java/org/apache/hc/core5/testing/classic/ClassicAuthenticationTest.java
index c14254d..ce1b332 100644
--- a/httpcore5-testing/src/test/java/org/apache/hc/core5/testing/classic/ClassicAuthenticationTest.java
+++ b/httpcore5-testing/src/test/java/org/apache/hc/core5/testing/classic/ClassicAuthenticationTest.java
@@ -60,7 +60,7 @@
import org.apache.hc.core5.net.URIAuthority;
import org.apache.hc.core5.util.Timeout;
import org.hamcrest.CoreMatchers;
-import org.junit.Assert;
+import org.hamcrest.MatcherAssert;
import org.junit.Rule;
import org.junit.Test;
import org.junit.rules.ExternalResource;
@@ -193,16 +193,16 @@
final HttpCoreContext context = HttpCoreContext.create();
final ClassicHttpRequest request1 = new BasicClassicHttpRequest(Method.GET, "/stuff");
try (final ClassicHttpResponse response1 = requester.execute(target, request1, TIMEOUT, context)) {
- Assert.assertThat(response1.getCode(), CoreMatchers.equalTo(HttpStatus.SC_UNAUTHORIZED));
+ MatcherAssert.assertThat(response1.getCode(), CoreMatchers.equalTo(HttpStatus.SC_UNAUTHORIZED));
final String body1 = EntityUtils.toString(response1.getEntity());
- Assert.assertThat(body1, CoreMatchers.equalTo("You shall not pass!!!"));
+ MatcherAssert.assertThat(body1, CoreMatchers.equalTo("You shall not pass!!!"));
}
final ClassicHttpRequest request2 = new BasicClassicHttpRequest(Method.GET, "/stuff");
request2.setHeader(HttpHeaders.AUTHORIZATION, "let me pass");
try (final ClassicHttpResponse response2 = requester.execute(target, request2, TIMEOUT, context)) {
- Assert.assertThat(response2.getCode(), CoreMatchers.equalTo(HttpStatus.SC_OK));
+ MatcherAssert.assertThat(response2.getCode(), CoreMatchers.equalTo(HttpStatus.SC_OK));
final String body1 = EntityUtils.toString(response2.getEntity());
- Assert.assertThat(body1, CoreMatchers.equalTo(""));
+ MatcherAssert.assertThat(body1, CoreMatchers.equalTo(""));
}
}
@@ -219,17 +219,17 @@
final ClassicHttpRequest request1 = new BasicClassicHttpRequest(Method.POST, "/stuff");
request1.setEntity(new ByteArrayEntity(stuff, ContentType.TEXT_PLAIN));
try (final ClassicHttpResponse response1 = requester.execute(target, request1, TIMEOUT, context)) {
- Assert.assertThat(response1.getCode(), CoreMatchers.equalTo(HttpStatus.SC_UNAUTHORIZED));
+ MatcherAssert.assertThat(response1.getCode(), CoreMatchers.equalTo(HttpStatus.SC_UNAUTHORIZED));
final String body1 = EntityUtils.toString(response1.getEntity());
- Assert.assertThat(body1, CoreMatchers.equalTo("You shall not pass!!!"));
+ MatcherAssert.assertThat(body1, CoreMatchers.equalTo("You shall not pass!!!"));
}
final ClassicHttpRequest request2 = new BasicClassicHttpRequest(Method.POST, "/stuff");
request2.setHeader(HttpHeaders.AUTHORIZATION, "let me pass");
request2.setEntity(new ByteArrayEntity(stuff, ContentType.TEXT_PLAIN));
try (final ClassicHttpResponse response2 = requester.execute(target, request2, TIMEOUT, context)) {
- Assert.assertThat(response2.getCode(), CoreMatchers.equalTo(HttpStatus.SC_OK));
+ MatcherAssert.assertThat(response2.getCode(), CoreMatchers.equalTo(HttpStatus.SC_OK));
final String body1 = EntityUtils.toString(response2.getEntity());
- Assert.assertThat(body1, CoreMatchers.equalTo(new String(stuff, StandardCharsets.US_ASCII)));
+ MatcherAssert.assertThat(body1, CoreMatchers.equalTo(new String(stuff, StandardCharsets.US_ASCII)));
}
}
@@ -247,18 +247,18 @@
request1.setVersion(HttpVersion.HTTP_1_0);
request1.setEntity(new ByteArrayEntity(stuff, ContentType.TEXT_PLAIN));
try (final ClassicHttpResponse response1 = requester.execute(target, request1, TIMEOUT, context)) {
- Assert.assertThat(response1.getCode(), CoreMatchers.equalTo(HttpStatus.SC_UNAUTHORIZED));
+ MatcherAssert.assertThat(response1.getCode(), CoreMatchers.equalTo(HttpStatus.SC_UNAUTHORIZED));
final String body1 = EntityUtils.toString(response1.getEntity());
- Assert.assertThat(body1, CoreMatchers.equalTo("You shall not pass!!!"));
+ MatcherAssert.assertThat(body1, CoreMatchers.equalTo("You shall not pass!!!"));
}
final ClassicHttpRequest request2 = new BasicClassicHttpRequest(Method.POST, "/stuff");
request2.setHeader(HttpHeaders.AUTHORIZATION, "let me pass");
request2.setVersion(HttpVersion.HTTP_1_0);
request2.setEntity(new ByteArrayEntity(stuff, ContentType.TEXT_PLAIN));
try (final ClassicHttpResponse response2 = requester.execute(target, request2, TIMEOUT, context)) {
- Assert.assertThat(response2.getCode(), CoreMatchers.equalTo(HttpStatus.SC_OK));
+ MatcherAssert.assertThat(response2.getCode(), CoreMatchers.equalTo(HttpStatus.SC_OK));
final String body1 = EntityUtils.toString(response2.getEntity());
- Assert.assertThat(body1, CoreMatchers.equalTo(new String(stuff, StandardCharsets.US_ASCII)));
+ MatcherAssert.assertThat(body1, CoreMatchers.equalTo(new String(stuff, StandardCharsets.US_ASCII)));
}
}
diff --git a/httpcore5-testing/src/test/java/org/apache/hc/core5/testing/classic/ClassicServerAndRequesterTest.java b/httpcore5-testing/src/test/java/org/apache/hc/core5/testing/classic/ClassicServerAndRequesterTest.java
index 462cd8d..83377b3 100644
--- a/httpcore5-testing/src/test/java/org/apache/hc/core5/testing/classic/ClassicServerAndRequesterTest.java
+++ b/httpcore5-testing/src/test/java/org/apache/hc/core5/testing/classic/ClassicServerAndRequesterTest.java
@@ -58,7 +58,7 @@
import org.apache.hc.core5.testing.SSLTestContexts;
import org.apache.hc.core5.util.Timeout;
import org.hamcrest.CoreMatchers;
-import org.junit.Assert;
+import org.hamcrest.MatcherAssert;
import org.junit.Rule;
import org.junit.Test;
import org.junit.rules.ExternalResource;
@@ -189,23 +189,23 @@
final ClassicHttpRequest request1 = new BasicClassicHttpRequest(Method.POST, "/stuff");
request1.setEntity(new StringEntity("some stuff", ContentType.TEXT_PLAIN));
try (final ClassicHttpResponse response1 = requester.execute(target, request1, TIMEOUT, context)) {
- Assert.assertThat(response1.getCode(), CoreMatchers.equalTo(HttpStatus.SC_OK));
+ MatcherAssert.assertThat(response1.getCode(), CoreMatchers.equalTo(HttpStatus.SC_OK));
final String body1 = EntityUtils.toString(response1.getEntity());
- Assert.assertThat(body1, CoreMatchers.equalTo("some stuff"));
+ MatcherAssert.assertThat(body1, CoreMatchers.equalTo("some stuff"));
}
final ClassicHttpRequest request2 = new BasicClassicHttpRequest(Method.POST, "/other-stuff");
request2.setEntity(new StringEntity("some other stuff", ContentType.TEXT_PLAIN));
try (final ClassicHttpResponse response2 = requester.execute(target, request2, TIMEOUT, context)) {
- Assert.assertThat(response2.getCode(), CoreMatchers.equalTo(HttpStatus.SC_OK));
+ MatcherAssert.assertThat(response2.getCode(), CoreMatchers.equalTo(HttpStatus.SC_OK));
final String body2 = EntityUtils.toString(response2.getEntity());
- Assert.assertThat(body2, CoreMatchers.equalTo("some other stuff"));
+ MatcherAssert.assertThat(body2, CoreMatchers.equalTo("some other stuff"));
}
final ClassicHttpRequest request3 = new BasicClassicHttpRequest(Method.POST, "/more-stuff");
request3.setEntity(new StringEntity("some more stuff", ContentType.TEXT_PLAIN));
try (final ClassicHttpResponse response3 = requester.execute(target, request3, TIMEOUT, context)) {
- Assert.assertThat(response3.getCode(), CoreMatchers.equalTo(HttpStatus.SC_OK));
+ MatcherAssert.assertThat(response3.getCode(), CoreMatchers.equalTo(HttpStatus.SC_OK));
final String body3 = EntityUtils.toString(response3.getEntity());
- Assert.assertThat(body3, CoreMatchers.equalTo("some more stuff"));
+ MatcherAssert.assertThat(body3, CoreMatchers.equalTo("some more stuff"));
}
}
@@ -217,23 +217,23 @@
final ClassicHttpRequest request1 = new BasicClassicHttpRequest(Method.POST, "/no-keep-alive/stuff");
request1.setEntity(new StringEntity("some stuff", ContentType.TEXT_PLAIN));
try (final ClassicHttpResponse response1 = requester.execute(target, request1, TIMEOUT, context)) {
- Assert.assertThat(response1.getCode(), CoreMatchers.equalTo(HttpStatus.SC_OK));
+ MatcherAssert.assertThat(response1.getCode(), CoreMatchers.equalTo(HttpStatus.SC_OK));
final String body1 = EntityUtils.toString(response1.getEntity());
- Assert.assertThat(body1, CoreMatchers.equalTo("some stuff"));
+ MatcherAssert.assertThat(body1, CoreMatchers.equalTo("some stuff"));
}
final ClassicHttpRequest request2 = new BasicClassicHttpRequest(Method.POST, "/no-keep-alive/other-stuff");
request2.setEntity(new StringEntity("some other stuff", ContentType.TEXT_PLAIN));
try (final ClassicHttpResponse response2 = requester.execute(target, request2, TIMEOUT, context)) {
- Assert.assertThat(response2.getCode(), CoreMatchers.equalTo(HttpStatus.SC_OK));
+ MatcherAssert.assertThat(response2.getCode(), CoreMatchers.equalTo(HttpStatus.SC_OK));
final String body2 = EntityUtils.toString(response2.getEntity());
- Assert.assertThat(body2, CoreMatchers.equalTo("some other stuff"));
+ MatcherAssert.assertThat(body2, CoreMatchers.equalTo("some other stuff"));
}
final ClassicHttpRequest request3 = new BasicClassicHttpRequest(Method.POST, "/no-keep-alive/more-stuff");
request3.setEntity(new StringEntity("some more stuff", ContentType.TEXT_PLAIN));
try (final ClassicHttpResponse response3 = requester.execute(target, request3, TIMEOUT, context)) {
- Assert.assertThat(response3.getCode(), CoreMatchers.equalTo(HttpStatus.SC_OK));
+ MatcherAssert.assertThat(response3.getCode(), CoreMatchers.equalTo(HttpStatus.SC_OK));
final String body3 = EntityUtils.toString(response3.getEntity());
- Assert.assertThat(body3, CoreMatchers.equalTo("some more stuff"));
+ MatcherAssert.assertThat(body3, CoreMatchers.equalTo("some more stuff"));
}
}
diff --git a/httpcore5-testing/src/test/java/org/apache/hc/core5/testing/classic/ClassicTLSIntegrationTest.java b/httpcore5-testing/src/test/java/org/apache/hc/core5/testing/classic/ClassicTLSIntegrationTest.java
index bd344b0..c839f01 100644
--- a/httpcore5-testing/src/test/java/org/apache/hc/core5/testing/classic/ClassicTLSIntegrationTest.java
+++ b/httpcore5-testing/src/test/java/org/apache/hc/core5/testing/classic/ClassicTLSIntegrationTest.java
@@ -60,6 +60,7 @@
import org.apache.hc.core5.testing.SSLTestContexts;
import org.apache.hc.core5.util.Timeout;
import org.hamcrest.CoreMatchers;
+import org.hamcrest.MatcherAssert;
import org.junit.Assert;
import org.junit.Rule;
import org.junit.Test;
@@ -140,15 +141,15 @@
final ClassicHttpRequest request1 = new BasicClassicHttpRequest(Method.POST, "/stuff");
request1.setEntity(new StringEntity("some stuff", ContentType.TEXT_PLAIN));
try (final ClassicHttpResponse response1 = requester.execute(target, request1, TIMEOUT, context)) {
- Assert.assertThat(response1.getCode(), CoreMatchers.equalTo(HttpStatus.SC_OK));
+ MatcherAssert.assertThat(response1.getCode(), CoreMatchers.equalTo(HttpStatus.SC_OK));
final String body1 = EntityUtils.toString(response1.getEntity());
- Assert.assertThat(body1, CoreMatchers.equalTo("some stuff"));
+ MatcherAssert.assertThat(body1, CoreMatchers.equalTo("some stuff"));
}
final SSLSession sslSession = sslSessionRef.getAndSet(null);
final ProtocolVersion tlsVersion = TLS.parse(sslSession.getProtocol());
- Assert.assertThat(tlsVersion.greaterEquals(TLS.V_1_2.version), CoreMatchers.equalTo(true));
- Assert.assertThat(sslSession.getPeerPrincipal().getName(),
+ MatcherAssert.assertThat(tlsVersion.greaterEquals(TLS.V_1_2.version), CoreMatchers.equalTo(true));
+ MatcherAssert.assertThat(sslSession.getPeerPrincipal().getName(),
CoreMatchers.equalTo("CN=localhost,OU=Apache HttpComponents,O=Apache Software Foundation"));
}
diff --git a/httpcore5-testing/src/test/java/org/apache/hc/core5/testing/framework/TestTestingFramework.java b/httpcore5-testing/src/test/java/org/apache/hc/core5/testing/framework/TestTestingFramework.java
index c9b7980..a3abfcd 100644
--- a/httpcore5-testing/src/test/java/org/apache/hc/core5/testing/framework/TestTestingFramework.java
+++ b/httpcore5-testing/src/test/java/org/apache/hc/core5/testing/framework/TestTestingFramework.java
@@ -50,6 +50,7 @@
import org.hamcrest.BaseMatcher;
import org.hamcrest.Description;
import org.hamcrest.Matcher;
+import org.hamcrest.MatcherAssert;
import org.junit.Assert;
import org.junit.Test;
import org.mockito.ArgumentMatchers;
@@ -179,7 +180,7 @@
final Map<String, Object> request,
final TestingFrameworkRequestHandler requestHandler,
final Map<String, Object> responseExpectations) throws TestingFrameworkException {
- Assert.assertThat(defaultURI, matchesDefaultURI());
+ MatcherAssert.assertThat(defaultURI, matchesDefaultURI());
Assert.assertNotNull("request should not be null", request);
diff --git a/httpcore5-testing/src/test/java/org/apache/hc/core5/testing/nio/H2AlpnTest.java b/httpcore5-testing/src/test/java/org/apache/hc/core5/testing/nio/H2AlpnTest.java
index 76e8d9a..b9b7cb6 100644
--- a/httpcore5-testing/src/test/java/org/apache/hc/core5/testing/nio/H2AlpnTest.java
+++ b/httpcore5-testing/src/test/java/org/apache/hc/core5/testing/nio/H2AlpnTest.java
@@ -65,7 +65,7 @@
import org.apache.hc.core5.util.ReflectionUtils;
import org.apache.hc.core5.util.Timeout;
import org.hamcrest.CoreMatchers;
-import org.junit.Assert;
+import org.hamcrest.MatcherAssert;
import org.junit.Assume;
import org.junit.BeforeClass;
import org.junit.Rule;
@@ -204,10 +204,10 @@
}
assertTrue("h2 negotiation was disabled, but h2 was negotiated", h2Allowed);
- Assert.assertThat(message1, CoreMatchers.notNullValue());
+ MatcherAssert.assertThat(message1, CoreMatchers.notNullValue());
final HttpResponse response1 = message1.getHead();
- Assert.assertThat(response1.getCode(), CoreMatchers.equalTo(HttpStatus.SC_OK));
+ MatcherAssert.assertThat(response1.getCode(), CoreMatchers.equalTo(HttpStatus.SC_OK));
final String body1 = message1.getBody();
- Assert.assertThat(body1, CoreMatchers.equalTo("some stuff"));
+ MatcherAssert.assertThat(body1, CoreMatchers.equalTo("some stuff"));
}
}
diff --git a/httpcore5-testing/src/test/java/org/apache/hc/core5/testing/nio/H2IntegrationTest.java b/httpcore5-testing/src/test/java/org/apache/hc/core5/testing/nio/H2IntegrationTest.java
index 35b1a66..8493256 100644
--- a/httpcore5-testing/src/test/java/org/apache/hc/core5/testing/nio/H2IntegrationTest.java
+++ b/httpcore5-testing/src/test/java/org/apache/hc/core5/testing/nio/H2IntegrationTest.java
@@ -125,6 +125,7 @@
import org.apache.hc.core5.util.TimeValue;
import org.apache.hc.core5.util.Timeout;
import org.hamcrest.CoreMatchers;
+import org.hamcrest.MatcherAssert;
import org.junit.After;
import org.junit.Assert;
import org.junit.Before;
@@ -1048,11 +1049,11 @@
future.get(TIMEOUT.getDuration(), TIMEOUT.getTimeUnit());
Assert.fail("ExecutionException is expected");
} catch (final ExecutionException ex) {
- Assert.assertThat(ex.getCause(), CoreMatchers.instanceOf(ProtocolException.class));
+ MatcherAssert.assertThat(ex.getCause(), CoreMatchers.instanceOf(ProtocolException.class));
}
final EndpointDetails endpointDetails = coreContext.getEndpointDetails();
- Assert.assertThat(endpointDetails.getRequestCount(), CoreMatchers.equalTo(0L));
+ MatcherAssert.assertThat(endpointDetails.getRequestCount(), CoreMatchers.equalTo(0L));
}
@Test
diff --git a/httpcore5-testing/src/test/java/org/apache/hc/core5/testing/nio/H2ProtocolNegotiationTest.java b/httpcore5-testing/src/test/java/org/apache/hc/core5/testing/nio/H2ProtocolNegotiationTest.java
index b77d390..d97b8f5 100644
--- a/httpcore5-testing/src/test/java/org/apache/hc/core5/testing/nio/H2ProtocolNegotiationTest.java
+++ b/httpcore5-testing/src/test/java/org/apache/hc/core5/testing/nio/H2ProtocolNegotiationTest.java
@@ -63,7 +63,7 @@
import org.apache.hc.core5.util.ReflectionUtils;
import org.apache.hc.core5.util.Timeout;
import org.hamcrest.CoreMatchers;
-import org.junit.Assert;
+import org.hamcrest.MatcherAssert;
import org.junit.Assume;
import org.junit.Before;
import org.junit.BeforeClass;
@@ -184,10 +184,10 @@
new StringAsyncEntityProducer("some stuff", ContentType.TEXT_PLAIN)),
new BasicResponseConsumer<>(new StringAsyncEntityConsumer()), null);
final Message<HttpResponse, String> message1 = resultFuture1.get(TIMEOUT.getDuration(), TIMEOUT.getTimeUnit());
- Assert.assertThat(message1, CoreMatchers.notNullValue());
+ MatcherAssert.assertThat(message1, CoreMatchers.notNullValue());
final HttpResponse response1 = message1.getHead();
- Assert.assertThat(response1.getCode(), CoreMatchers.equalTo(HttpStatus.SC_OK));
- Assert.assertThat(response1.getVersion(), CoreMatchers.<ProtocolVersion>equalTo(HttpVersion.HTTP_1_1));
+ MatcherAssert.assertThat(response1.getCode(), CoreMatchers.equalTo(HttpStatus.SC_OK));
+ MatcherAssert.assertThat(response1.getVersion(), CoreMatchers.<ProtocolVersion>equalTo(HttpVersion.HTTP_1_1));
}
@Test
@@ -207,10 +207,10 @@
new StringAsyncEntityProducer("some stuff", ContentType.TEXT_PLAIN)),
new BasicResponseConsumer<>(new StringAsyncEntityConsumer()), null);
final Message<HttpResponse, String> message1 = resultFuture1.get(TIMEOUT.getDuration(), TIMEOUT.getTimeUnit());
- Assert.assertThat(message1, CoreMatchers.notNullValue());
+ MatcherAssert.assertThat(message1, CoreMatchers.notNullValue());
final HttpResponse response1 = message1.getHead();
- Assert.assertThat(response1.getCode(), CoreMatchers.equalTo(HttpStatus.SC_OK));
- Assert.assertThat(response1.getVersion(), CoreMatchers.<ProtocolVersion>equalTo(HttpVersion.HTTP_2));
+ MatcherAssert.assertThat(response1.getCode(), CoreMatchers.equalTo(HttpStatus.SC_OK));
+ MatcherAssert.assertThat(response1.getVersion(), CoreMatchers.<ProtocolVersion>equalTo(HttpVersion.HTTP_2));
}
@Test
@@ -230,14 +230,14 @@
new StringAsyncEntityProducer("some stuff", ContentType.TEXT_PLAIN)),
new BasicResponseConsumer<>(new StringAsyncEntityConsumer()), null);
final Message<HttpResponse, String> message1 = resultFuture1.get(TIMEOUT.getDuration(), TIMEOUT.getTimeUnit());
- Assert.assertThat(message1, CoreMatchers.notNullValue());
+ MatcherAssert.assertThat(message1, CoreMatchers.notNullValue());
final HttpResponse response1 = message1.getHead();
- Assert.assertThat(response1.getCode(), CoreMatchers.equalTo(HttpStatus.SC_OK));
+ MatcherAssert.assertThat(response1.getCode(), CoreMatchers.equalTo(HttpStatus.SC_OK));
if (isAlpnSupported()) {
- Assert.assertThat(response1.getVersion(), CoreMatchers.<ProtocolVersion>equalTo(HttpVersion.HTTP_2));
+ MatcherAssert.assertThat(response1.getVersion(), CoreMatchers.<ProtocolVersion>equalTo(HttpVersion.HTTP_2));
} else {
- Assert.assertThat(response1.getVersion(), CoreMatchers.<ProtocolVersion>equalTo(HttpVersion.HTTP_1_1));
+ MatcherAssert.assertThat(response1.getVersion(), CoreMatchers.<ProtocolVersion>equalTo(HttpVersion.HTTP_1_1));
}
}
diff --git a/httpcore5-testing/src/test/java/org/apache/hc/core5/testing/nio/H2ServerAndMultiplexingRequesterTest.java b/httpcore5-testing/src/test/java/org/apache/hc/core5/testing/nio/H2ServerAndMultiplexingRequesterTest.java
index 6a60017..325e6ea 100644
--- a/httpcore5-testing/src/test/java/org/apache/hc/core5/testing/nio/H2ServerAndMultiplexingRequesterTest.java
+++ b/httpcore5-testing/src/test/java/org/apache/hc/core5/testing/nio/H2ServerAndMultiplexingRequesterTest.java
@@ -67,7 +67,7 @@
import org.apache.hc.core5.util.TimeValue;
import org.apache.hc.core5.util.Timeout;
import org.hamcrest.CoreMatchers;
-import org.junit.Assert;
+import org.hamcrest.MatcherAssert;
import org.junit.Assume;
import org.junit.Before;
import org.junit.BeforeClass;
@@ -197,33 +197,33 @@
new StringAsyncEntityProducer("some stuff", ContentType.TEXT_PLAIN)),
new BasicResponseConsumer<>(new StringAsyncEntityConsumer()), TIMEOUT, null);
final Message<HttpResponse, String> message1 = resultFuture1.get(TIMEOUT.getDuration(), TIMEOUT.getTimeUnit());
- Assert.assertThat(message1, CoreMatchers.notNullValue());
+ MatcherAssert.assertThat(message1, CoreMatchers.notNullValue());
final HttpResponse response1 = message1.getHead();
- Assert.assertThat(response1.getCode(), CoreMatchers.equalTo(HttpStatus.SC_OK));
+ MatcherAssert.assertThat(response1.getCode(), CoreMatchers.equalTo(HttpStatus.SC_OK));
final String body1 = message1.getBody();
- Assert.assertThat(body1, CoreMatchers.equalTo("some stuff"));
+ MatcherAssert.assertThat(body1, CoreMatchers.equalTo("some stuff"));
final Future<Message<HttpResponse, String>> resultFuture2 = requester.execute(
new BasicRequestProducer(Method.POST, target, "/other-stuff",
new StringAsyncEntityProducer("some other stuff", ContentType.TEXT_PLAIN)),
new BasicResponseConsumer<>(new StringAsyncEntityConsumer()), TIMEOUT, null);
final Message<HttpResponse, String> message2 = resultFuture2.get(TIMEOUT.getDuration(), TIMEOUT.getTimeUnit());
- Assert.assertThat(message2, CoreMatchers.notNullValue());
+ MatcherAssert.assertThat(message2, CoreMatchers.notNullValue());
final HttpResponse response2 = message2.getHead();
- Assert.assertThat(response2.getCode(), CoreMatchers.equalTo(HttpStatus.SC_OK));
+ MatcherAssert.assertThat(response2.getCode(), CoreMatchers.equalTo(HttpStatus.SC_OK));
final String body2 = message2.getBody();
- Assert.assertThat(body2, CoreMatchers.equalTo("some other stuff"));
+ MatcherAssert.assertThat(body2, CoreMatchers.equalTo("some other stuff"));
final Future<Message<HttpResponse, String>> resultFuture3 = requester.execute(
new BasicRequestProducer(Method.POST, target, "/more-stuff",
new StringAsyncEntityProducer("some more stuff", ContentType.TEXT_PLAIN)),
new BasicResponseConsumer<>(new StringAsyncEntityConsumer()), TIMEOUT, null);
final Message<HttpResponse, String> message3 = resultFuture3.get(TIMEOUT.getDuration(), TIMEOUT.getTimeUnit());
- Assert.assertThat(message3, CoreMatchers.notNullValue());
+ MatcherAssert.assertThat(message3, CoreMatchers.notNullValue());
final HttpResponse response3 = message3.getHead();
- Assert.assertThat(response3.getCode(), CoreMatchers.equalTo(HttpStatus.SC_OK));
+ MatcherAssert.assertThat(response3.getCode(), CoreMatchers.equalTo(HttpStatus.SC_OK));
final String body3 = message3.getBody();
- Assert.assertThat(body3, CoreMatchers.equalTo("some more stuff"));
+ MatcherAssert.assertThat(body3, CoreMatchers.equalTo("some more stuff"));
}
@Test
@@ -253,11 +253,11 @@
while (!queue.isEmpty()) {
final Future<Message<HttpResponse, String>> resultFuture = queue.remove();
final Message<HttpResponse, String> message = resultFuture.get(TIMEOUT.getDuration(), TIMEOUT.getTimeUnit());
- Assert.assertThat(message, CoreMatchers.notNullValue());
+ MatcherAssert.assertThat(message, CoreMatchers.notNullValue());
final HttpResponse response = message.getHead();
- Assert.assertThat(response.getCode(), CoreMatchers.equalTo(HttpStatus.SC_OK));
+ MatcherAssert.assertThat(response.getCode(), CoreMatchers.equalTo(HttpStatus.SC_OK));
final String body = message.getBody();
- Assert.assertThat(body, CoreMatchers.containsString("stuff"));
+ MatcherAssert.assertThat(body, CoreMatchers.containsString("stuff"));
}
}
@@ -276,11 +276,11 @@
new StringAsyncEntityProducer("some stuff", ContentType.TEXT_PLAIN)),
new BasicResponseConsumer<>(new StringAsyncEntityConsumer()), TIMEOUT, null);
final Message<HttpResponse, String> message1 = resultFuture1.get(TIMEOUT.getDuration(), TIMEOUT.getTimeUnit());
- Assert.assertThat(message1, CoreMatchers.notNullValue());
+ MatcherAssert.assertThat(message1, CoreMatchers.notNullValue());
final HttpResponse response1 = message1.getHead();
- Assert.assertThat(response1.getCode(), CoreMatchers.equalTo(HttpStatus.SC_OK));
+ MatcherAssert.assertThat(response1.getCode(), CoreMatchers.equalTo(HttpStatus.SC_OK));
final String body1 = message1.getBody();
- Assert.assertThat(body1, CoreMatchers.equalTo("some stuff"));
+ MatcherAssert.assertThat(body1, CoreMatchers.equalTo("some stuff"));
Thread.sleep(100);
@@ -289,11 +289,11 @@
new StringAsyncEntityProducer("some other stuff", ContentType.TEXT_PLAIN)),
new BasicResponseConsumer<>(new StringAsyncEntityConsumer()), TIMEOUT, null);
final Message<HttpResponse, String> message2 = resultFuture2.get(TIMEOUT.getDuration(), TIMEOUT.getTimeUnit());
- Assert.assertThat(message2, CoreMatchers.notNullValue());
+ MatcherAssert.assertThat(message2, CoreMatchers.notNullValue());
final HttpResponse response2 = message2.getHead();
- Assert.assertThat(response2.getCode(), CoreMatchers.equalTo(HttpStatus.SC_OK));
+ MatcherAssert.assertThat(response2.getCode(), CoreMatchers.equalTo(HttpStatus.SC_OK));
final String body2 = message2.getBody();
- Assert.assertThat(body2, CoreMatchers.equalTo("some other stuff"));
+ MatcherAssert.assertThat(body2, CoreMatchers.equalTo("some other stuff"));
Thread.sleep(100);
@@ -302,11 +302,11 @@
new StringAsyncEntityProducer("some more stuff", ContentType.TEXT_PLAIN)),
new BasicResponseConsumer<>(new StringAsyncEntityConsumer()), TIMEOUT, null);
final Message<HttpResponse, String> message3 = resultFuture3.get(TIMEOUT.getDuration(), TIMEOUT.getTimeUnit());
- Assert.assertThat(message3, CoreMatchers.notNullValue());
+ MatcherAssert.assertThat(message3, CoreMatchers.notNullValue());
final HttpResponse response3 = message3.getHead();
- Assert.assertThat(response3.getCode(), CoreMatchers.equalTo(HttpStatus.SC_OK));
+ MatcherAssert.assertThat(response3.getCode(), CoreMatchers.equalTo(HttpStatus.SC_OK));
final String body3 = message3.getBody();
- Assert.assertThat(body3, CoreMatchers.equalTo("some more stuff"));
+ MatcherAssert.assertThat(body3, CoreMatchers.equalTo("some more stuff"));
}
@Test
@@ -350,7 +350,7 @@
Thread.sleep(random.nextInt(10));
cancellable.cancel();
}
- Assert.assertThat(countDownLatch.await(TIMEOUT.getDuration(), TIMEOUT.getTimeUnit()), CoreMatchers.equalTo(true));
+ MatcherAssert.assertThat(countDownLatch.await(TIMEOUT.getDuration(), TIMEOUT.getTimeUnit()), CoreMatchers.equalTo(true));
}
}
diff --git a/httpcore5-testing/src/test/java/org/apache/hc/core5/testing/nio/H2ServerAndRequesterTest.java b/httpcore5-testing/src/test/java/org/apache/hc/core5/testing/nio/H2ServerAndRequesterTest.java
index fc8a0d0..f0e789d 100644
--- a/httpcore5-testing/src/test/java/org/apache/hc/core5/testing/nio/H2ServerAndRequesterTest.java
+++ b/httpcore5-testing/src/test/java/org/apache/hc/core5/testing/nio/H2ServerAndRequesterTest.java
@@ -64,7 +64,7 @@
import org.apache.hc.core5.util.ReflectionUtils;
import org.apache.hc.core5.util.Timeout;
import org.hamcrest.CoreMatchers;
-import org.junit.Assert;
+import org.hamcrest.MatcherAssert;
import org.junit.Assume;
import org.junit.Before;
import org.junit.BeforeClass;
@@ -200,33 +200,33 @@
new StringAsyncEntityProducer("some stuff", ContentType.TEXT_PLAIN)),
new BasicResponseConsumer<>(new StringAsyncEntityConsumer()), TIMEOUT, null);
final Message<HttpResponse, String> message1 = resultFuture1.get(TIMEOUT.getDuration(), TIMEOUT.getTimeUnit());
- Assert.assertThat(message1, CoreMatchers.notNullValue());
+ MatcherAssert.assertThat(message1, CoreMatchers.notNullValue());
final HttpResponse response1 = message1.getHead();
- Assert.assertThat(response1.getCode(), CoreMatchers.equalTo(HttpStatus.SC_OK));
+ MatcherAssert.assertThat(response1.getCode(), CoreMatchers.equalTo(HttpStatus.SC_OK));
final String body1 = message1.getBody();
- Assert.assertThat(body1, CoreMatchers.equalTo("some stuff"));
+ MatcherAssert.assertThat(body1, CoreMatchers.equalTo("some stuff"));
final Future<Message<HttpResponse, String>> resultFuture2 = requester.execute(
new BasicRequestProducer(Method.POST, target, "/other-stuff",
new StringAsyncEntityProducer("some other stuff", ContentType.TEXT_PLAIN)),
new BasicResponseConsumer<>(new StringAsyncEntityConsumer()), TIMEOUT, null);
final Message<HttpResponse, String> message2 = resultFuture2.get(TIMEOUT.getDuration(), TIMEOUT.getTimeUnit());
- Assert.assertThat(message2, CoreMatchers.notNullValue());
+ MatcherAssert.assertThat(message2, CoreMatchers.notNullValue());
final HttpResponse response2 = message2.getHead();
- Assert.assertThat(response2.getCode(), CoreMatchers.equalTo(HttpStatus.SC_OK));
+ MatcherAssert.assertThat(response2.getCode(), CoreMatchers.equalTo(HttpStatus.SC_OK));
final String body2 = message2.getBody();
- Assert.assertThat(body2, CoreMatchers.equalTo("some other stuff"));
+ MatcherAssert.assertThat(body2, CoreMatchers.equalTo("some other stuff"));
final Future<Message<HttpResponse, String>> resultFuture3 = requester.execute(
new BasicRequestProducer(Method.POST, target, "/more-stuff",
new StringAsyncEntityProducer("some more stuff", ContentType.TEXT_PLAIN)),
new BasicResponseConsumer<>(new StringAsyncEntityConsumer()), TIMEOUT, null);
final Message<HttpResponse, String> message3 = resultFuture3.get(TIMEOUT.getDuration(), TIMEOUT.getTimeUnit());
- Assert.assertThat(message3, CoreMatchers.notNullValue());
+ MatcherAssert.assertThat(message3, CoreMatchers.notNullValue());
final HttpResponse response3 = message3.getHead();
- Assert.assertThat(response3.getCode(), CoreMatchers.equalTo(HttpStatus.SC_OK));
+ MatcherAssert.assertThat(response3.getCode(), CoreMatchers.equalTo(HttpStatus.SC_OK));
final String body3 = message3.getBody();
- Assert.assertThat(body3, CoreMatchers.equalTo("some more stuff"));
+ MatcherAssert.assertThat(body3, CoreMatchers.equalTo("some more stuff"));
}
@Test
@@ -247,33 +247,33 @@
new StringAsyncEntityProducer("some stuff", ContentType.TEXT_PLAIN)),
new BasicResponseConsumer<>(new StringAsyncEntityConsumer()), null);
final Message<HttpResponse, String> message1 = resultFuture1.get(TIMEOUT.getDuration(), TIMEOUT.getTimeUnit());
- Assert.assertThat(message1, CoreMatchers.notNullValue());
+ MatcherAssert.assertThat(message1, CoreMatchers.notNullValue());
final HttpResponse response1 = message1.getHead();
- Assert.assertThat(response1.getCode(), CoreMatchers.equalTo(HttpStatus.SC_OK));
+ MatcherAssert.assertThat(response1.getCode(), CoreMatchers.equalTo(HttpStatus.SC_OK));
final String body1 = message1.getBody();
- Assert.assertThat(body1, CoreMatchers.equalTo("some stuff"));
+ MatcherAssert.assertThat(body1, CoreMatchers.equalTo("some stuff"));
final Future<Message<HttpResponse, String>> resultFuture2 = endpoint.execute(
new BasicRequestProducer(Method.POST, target, "/other-stuff",
new StringAsyncEntityProducer("some other stuff", ContentType.TEXT_PLAIN)),
new BasicResponseConsumer<>(new StringAsyncEntityConsumer()), null);
final Message<HttpResponse, String> message2 = resultFuture2.get(TIMEOUT.getDuration(), TIMEOUT.getTimeUnit());
- Assert.assertThat(message2, CoreMatchers.notNullValue());
+ MatcherAssert.assertThat(message2, CoreMatchers.notNullValue());
final HttpResponse response2 = message2.getHead();
- Assert.assertThat(response2.getCode(), CoreMatchers.equalTo(HttpStatus.SC_OK));
+ MatcherAssert.assertThat(response2.getCode(), CoreMatchers.equalTo(HttpStatus.SC_OK));
final String body2 = message2.getBody();
- Assert.assertThat(body2, CoreMatchers.equalTo("some other stuff"));
+ MatcherAssert.assertThat(body2, CoreMatchers.equalTo("some other stuff"));
final Future<Message<HttpResponse, String>> resultFuture3 = endpoint.execute(
new BasicRequestProducer(Method.POST, target, "/more-stuff",
new StringAsyncEntityProducer("some more stuff", ContentType.TEXT_PLAIN)),
new BasicResponseConsumer<>(new StringAsyncEntityConsumer()), null);
final Message<HttpResponse, String> message3 = resultFuture3.get(TIMEOUT.getDuration(), TIMEOUT.getTimeUnit());
- Assert.assertThat(message3, CoreMatchers.notNullValue());
+ MatcherAssert.assertThat(message3, CoreMatchers.notNullValue());
final HttpResponse response3 = message3.getHead();
- Assert.assertThat(response3.getCode(), CoreMatchers.equalTo(HttpStatus.SC_OK));
+ MatcherAssert.assertThat(response3.getCode(), CoreMatchers.equalTo(HttpStatus.SC_OK));
final String body3 = message3.getBody();
- Assert.assertThat(body3, CoreMatchers.equalTo("some more stuff"));
+ MatcherAssert.assertThat(body3, CoreMatchers.equalTo("some more stuff"));
} finally {
endpoint.releaseAndReuse();
@@ -311,11 +311,11 @@
while (!queue.isEmpty()) {
final Future<Message<HttpResponse, String>> resultFuture = queue.remove();
final Message<HttpResponse, String> message = resultFuture.get(TIMEOUT.getDuration(), TIMEOUT.getTimeUnit());
- Assert.assertThat(message, CoreMatchers.notNullValue());
+ MatcherAssert.assertThat(message, CoreMatchers.notNullValue());
final HttpResponse response = message.getHead();
- Assert.assertThat(response.getCode(), CoreMatchers.equalTo(HttpStatus.SC_OK));
+ MatcherAssert.assertThat(response.getCode(), CoreMatchers.equalTo(HttpStatus.SC_OK));
final String body = message.getBody();
- Assert.assertThat(body, CoreMatchers.containsString("stuff"));
+ MatcherAssert.assertThat(body, CoreMatchers.containsString("stuff"));
}
} finally {
diff --git a/httpcore5-testing/src/test/java/org/apache/hc/core5/testing/nio/H2TLSIntegrationTest.java b/httpcore5-testing/src/test/java/org/apache/hc/core5/testing/nio/H2TLSIntegrationTest.java
index 0833c57..e95c460 100644
--- a/httpcore5-testing/src/test/java/org/apache/hc/core5/testing/nio/H2TLSIntegrationTest.java
+++ b/httpcore5-testing/src/test/java/org/apache/hc/core5/testing/nio/H2TLSIntegrationTest.java
@@ -72,6 +72,7 @@
import org.apache.hc.core5.testing.classic.LoggingConnPoolListener;
import org.apache.hc.core5.util.Timeout;
import org.hamcrest.CoreMatchers;
+import org.hamcrest.MatcherAssert;
import org.junit.Assert;
import org.junit.Rule;
import org.junit.Test;
@@ -176,16 +177,16 @@
new StringAsyncEntityProducer("some stuff", ContentType.TEXT_PLAIN)),
new BasicResponseConsumer<>(new StringAsyncEntityConsumer()), TIMEOUT, null);
final Message<HttpResponse, String> message1 = resultFuture1.get(TIMEOUT.getDuration(), TIMEOUT.getTimeUnit());
- Assert.assertThat(message1, CoreMatchers.notNullValue());
+ MatcherAssert.assertThat(message1, CoreMatchers.notNullValue());
final HttpResponse response1 = message1.getHead();
- Assert.assertThat(response1.getCode(), CoreMatchers.equalTo(HttpStatus.SC_OK));
+ MatcherAssert.assertThat(response1.getCode(), CoreMatchers.equalTo(HttpStatus.SC_OK));
final String body1 = message1.getBody();
- Assert.assertThat(body1, CoreMatchers.equalTo("some stuff"));
+ MatcherAssert.assertThat(body1, CoreMatchers.equalTo("some stuff"));
final SSLSession sslSession = sslSessionRef.getAndSet(null);
final ProtocolVersion tlsVersion = TLS.parse(sslSession.getProtocol());
- Assert.assertThat(tlsVersion.greaterEquals(TLS.V_1_2.version), CoreMatchers.equalTo(true));
- Assert.assertThat(sslSession.getPeerPrincipal().getName(),
+ MatcherAssert.assertThat(tlsVersion.greaterEquals(TLS.V_1_2.version), CoreMatchers.equalTo(true));
+ MatcherAssert.assertThat(sslSession.getPeerPrincipal().getName(),
CoreMatchers.equalTo("CN=localhost,OU=Apache HttpComponents,O=Apache Software Foundation"));
}
@@ -241,7 +242,7 @@
Assert.fail("ExecutionException expected");
} catch (final ExecutionException ex) {
final Throwable cause = ex.getCause();
- Assert.assertThat(cause, CoreMatchers.<Throwable>instanceOf(SSLHandshakeException.class));
+ MatcherAssert.assertThat(cause, CoreMatchers.<Throwable>instanceOf(SSLHandshakeException.class));
}
}
@@ -306,7 +307,7 @@
Assert.fail("ExecutionException expected");
} catch (final ExecutionException ex) {
final Throwable cause = ex.getCause();
- Assert.assertThat(cause, CoreMatchers.<Throwable>instanceOf(IOException.class));
+ MatcherAssert.assertThat(cause, CoreMatchers.<Throwable>instanceOf(IOException.class));
}
}
@@ -371,7 +372,7 @@
Assert.fail("ExecutionException expected");
} catch (final ExecutionException ex) {
final Throwable cause = ex.getCause();
- Assert.assertThat(cause, CoreMatchers.<Throwable>instanceOf(IOException.class));
+ MatcherAssert.assertThat(cause, CoreMatchers.<Throwable>instanceOf(IOException.class));
}
}
@@ -454,7 +455,7 @@
Assert.fail("ExecutionException expected");
} catch (final ExecutionException ex) {
final Throwable cause = ex.getCause();
- Assert.assertThat(cause, CoreMatchers.<Throwable>instanceOf(IOException.class));
+ MatcherAssert.assertThat(cause, CoreMatchers.<Throwable>instanceOf(IOException.class));
}
} finally {
server.close(CloseMode.IMMEDIATE);
diff --git a/httpcore5-testing/src/test/java/org/apache/hc/core5/testing/nio/Http1AuthenticationTest.java b/httpcore5-testing/src/test/java/org/apache/hc/core5/testing/nio/Http1AuthenticationTest.java
index 8d12aa1..9b779cc 100644
--- a/httpcore5-testing/src/test/java/org/apache/hc/core5/testing/nio/Http1AuthenticationTest.java
+++ b/httpcore5-testing/src/test/java/org/apache/hc/core5/testing/nio/Http1AuthenticationTest.java
@@ -67,7 +67,7 @@
import org.apache.hc.core5.testing.classic.LoggingConnPoolListener;
import org.apache.hc.core5.util.Timeout;
import org.hamcrest.CoreMatchers;
-import org.junit.Assert;
+import org.hamcrest.MatcherAssert;
import org.junit.Rule;
import org.junit.Test;
import org.junit.rules.ExternalResource;
@@ -217,11 +217,11 @@
new BasicRequestProducer(request1, null),
new BasicResponseConsumer<>(new StringAsyncEntityConsumer()), TIMEOUT, null);
final Message<HttpResponse, String> message1 = resultFuture1.get(TIMEOUT.getDuration(), TIMEOUT.getTimeUnit());
- Assert.assertThat(message1, CoreMatchers.notNullValue());
+ MatcherAssert.assertThat(message1, CoreMatchers.notNullValue());
final HttpResponse response1 = message1.getHead();
- Assert.assertThat(response1.getCode(), CoreMatchers.equalTo(HttpStatus.SC_UNAUTHORIZED));
+ MatcherAssert.assertThat(response1.getCode(), CoreMatchers.equalTo(HttpStatus.SC_UNAUTHORIZED));
final String body1 = message1.getBody();
- Assert.assertThat(body1, CoreMatchers.equalTo("You shall not pass!!!"));
+ MatcherAssert.assertThat(body1, CoreMatchers.equalTo("You shall not pass!!!"));
final HttpRequest request2 = new BasicHttpRequest(Method.GET, target, "/stuff");
request2.setHeader(HttpHeaders.AUTHORIZATION, "let me pass");
@@ -229,11 +229,11 @@
new BasicRequestProducer(request2, null),
new BasicResponseConsumer<>(new StringAsyncEntityConsumer()), TIMEOUT, null);
final Message<HttpResponse, String> message2 = resultFuture2.get(TIMEOUT.getDuration(), TIMEOUT.getTimeUnit());
- Assert.assertThat(message2, CoreMatchers.notNullValue());
+ MatcherAssert.assertThat(message2, CoreMatchers.notNullValue());
final HttpResponse response2 = message2.getHead();
- Assert.assertThat(response2.getCode(), CoreMatchers.equalTo(HttpStatus.SC_OK));
+ MatcherAssert.assertThat(response2.getCode(), CoreMatchers.equalTo(HttpStatus.SC_OK));
final String body2 = message2.getBody();
- Assert.assertThat(body2, CoreMatchers.equalTo(""));
+ MatcherAssert.assertThat(body2, CoreMatchers.equalTo(""));
}
@Test
@@ -255,11 +255,11 @@
new BasicRequestProducer(request1, AsyncEntityProducers.create(stuff, ContentType.TEXT_PLAIN)),
new BasicResponseConsumer<>(new StringAsyncEntityConsumer()), TIMEOUT, null);
final Message<HttpResponse, String> message1 = resultFuture1.get(TIMEOUT.getDuration(), TIMEOUT.getTimeUnit());
- Assert.assertThat(message1, CoreMatchers.notNullValue());
+ MatcherAssert.assertThat(message1, CoreMatchers.notNullValue());
final HttpResponse response1 = message1.getHead();
- Assert.assertThat(response1.getCode(), CoreMatchers.equalTo(HttpStatus.SC_UNAUTHORIZED));
+ MatcherAssert.assertThat(response1.getCode(), CoreMatchers.equalTo(HttpStatus.SC_UNAUTHORIZED));
final String body1 = message1.getBody();
- Assert.assertThat(body1, CoreMatchers.equalTo("You shall not pass!!!"));
+ MatcherAssert.assertThat(body1, CoreMatchers.equalTo("You shall not pass!!!"));
final HttpRequest request2 = new BasicHttpRequest(Method.POST, target, "/stuff");
request2.setHeader(HttpHeaders.AUTHORIZATION, "let me pass");
@@ -267,11 +267,11 @@
new BasicRequestProducer(request2, AsyncEntityProducers.create(stuff, ContentType.TEXT_PLAIN)),
new BasicResponseConsumer<>(new StringAsyncEntityConsumer()), TIMEOUT, null);
final Message<HttpResponse, String> message2 = resultFuture2.get(TIMEOUT.getDuration(), TIMEOUT.getTimeUnit());
- Assert.assertThat(message2, CoreMatchers.notNullValue());
+ MatcherAssert.assertThat(message2, CoreMatchers.notNullValue());
final HttpResponse response2 = message2.getHead();
- Assert.assertThat(response2.getCode(), CoreMatchers.equalTo(HttpStatus.SC_OK));
+ MatcherAssert.assertThat(response2.getCode(), CoreMatchers.equalTo(HttpStatus.SC_OK));
final String body2 = message2.getBody();
- Assert.assertThat(body2, CoreMatchers.equalTo(new String(stuff, StandardCharsets.US_ASCII)));
+ MatcherAssert.assertThat(body2, CoreMatchers.equalTo(new String(stuff, StandardCharsets.US_ASCII)));
}
@Test
@@ -295,11 +295,11 @@
new BasicRequestProducer(request1, AsyncEntityProducers.create(stuff, ContentType.TEXT_PLAIN)),
new BasicResponseConsumer<>(new StringAsyncEntityConsumer()), TIMEOUT, null);
final Message<HttpResponse, String> message1 = resultFuture1.get(TIMEOUT.getDuration(), TIMEOUT.getTimeUnit());
- Assert.assertThat(message1, CoreMatchers.notNullValue());
+ MatcherAssert.assertThat(message1, CoreMatchers.notNullValue());
final HttpResponse response1 = message1.getHead();
- Assert.assertThat(response1.getCode(), CoreMatchers.equalTo(HttpStatus.SC_UNAUTHORIZED));
+ MatcherAssert.assertThat(response1.getCode(), CoreMatchers.equalTo(HttpStatus.SC_UNAUTHORIZED));
final String body1 = message1.getBody();
- Assert.assertThat(body1, CoreMatchers.equalTo("You shall not pass!!!"));
+ MatcherAssert.assertThat(body1, CoreMatchers.equalTo("You shall not pass!!!"));
final HttpRequest request2 = new BasicHttpRequest(Method.POST, target, "/stuff");
request2.setVersion(HttpVersion.HTTP_1_0);
@@ -308,11 +308,11 @@
new BasicRequestProducer(request2, AsyncEntityProducers.create(stuff, ContentType.TEXT_PLAIN)),
new BasicResponseConsumer<>(new StringAsyncEntityConsumer()), TIMEOUT, null);
final Message<HttpResponse, String> message2 = resultFuture2.get(TIMEOUT.getDuration(), TIMEOUT.getTimeUnit());
- Assert.assertThat(message2, CoreMatchers.notNullValue());
+ MatcherAssert.assertThat(message2, CoreMatchers.notNullValue());
final HttpResponse response2 = message2.getHead();
- Assert.assertThat(response2.getCode(), CoreMatchers.equalTo(HttpStatus.SC_OK));
+ MatcherAssert.assertThat(response2.getCode(), CoreMatchers.equalTo(HttpStatus.SC_OK));
final String body2 = message2.getBody();
- Assert.assertThat(body2, CoreMatchers.equalTo(new String(stuff, StandardCharsets.US_ASCII)));
+ MatcherAssert.assertThat(body2, CoreMatchers.equalTo(new String(stuff, StandardCharsets.US_ASCII)));
}
}
diff --git a/httpcore5-testing/src/test/java/org/apache/hc/core5/testing/nio/Http1ServerAndRequesterTest.java b/httpcore5-testing/src/test/java/org/apache/hc/core5/testing/nio/Http1ServerAndRequesterTest.java
index 2d961d7..4fd8002 100644
--- a/httpcore5-testing/src/test/java/org/apache/hc/core5/testing/nio/Http1ServerAndRequesterTest.java
+++ b/httpcore5-testing/src/test/java/org/apache/hc/core5/testing/nio/Http1ServerAndRequesterTest.java
@@ -76,7 +76,7 @@
import org.apache.hc.core5.testing.classic.LoggingConnPoolListener;
import org.apache.hc.core5.util.Timeout;
import org.hamcrest.CoreMatchers;
-import org.junit.Assert;
+import org.hamcrest.MatcherAssert;
import org.junit.Rule;
import org.junit.Test;
import org.junit.rules.ExternalResource;
@@ -228,33 +228,33 @@
new StringAsyncEntityProducer("some stuff", ContentType.TEXT_PLAIN)),
new BasicResponseConsumer<>(new StringAsyncEntityConsumer()), TIMEOUT, null);
final Message<HttpResponse, String> message1 = resultFuture1.get(TIMEOUT.getDuration(), TIMEOUT.getTimeUnit());
- Assert.assertThat(message1, CoreMatchers.notNullValue());
+ MatcherAssert.assertThat(message1, CoreMatchers.notNullValue());
final HttpResponse response1 = message1.getHead();
- Assert.assertThat(response1.getCode(), CoreMatchers.equalTo(HttpStatus.SC_OK));
+ MatcherAssert.assertThat(response1.getCode(), CoreMatchers.equalTo(HttpStatus.SC_OK));
final String body1 = message1.getBody();
- Assert.assertThat(body1, CoreMatchers.equalTo("some stuff"));
+ MatcherAssert.assertThat(body1, CoreMatchers.equalTo("some stuff"));
final Future<Message<HttpResponse, String>> resultFuture2 = requester.execute(
new BasicRequestProducer(Method.POST, target, "/other-stuff",
new StringAsyncEntityProducer("some other stuff", ContentType.TEXT_PLAIN)),
new BasicResponseConsumer<>(new StringAsyncEntityConsumer()), TIMEOUT, null);
final Message<HttpResponse, String> message2 = resultFuture2.get(TIMEOUT.getDuration(), TIMEOUT.getTimeUnit());
- Assert.assertThat(message2, CoreMatchers.notNullValue());
+ MatcherAssert.assertThat(message2, CoreMatchers.notNullValue());
final HttpResponse response2 = message2.getHead();
- Assert.assertThat(response2.getCode(), CoreMatchers.equalTo(HttpStatus.SC_OK));
+ MatcherAssert.assertThat(response2.getCode(), CoreMatchers.equalTo(HttpStatus.SC_OK));
final String body2 = message2.getBody();
- Assert.assertThat(body2, CoreMatchers.equalTo("some other stuff"));
+ MatcherAssert.assertThat(body2, CoreMatchers.equalTo("some other stuff"));
final Future<Message<HttpResponse, String>> resultFuture3 = requester.execute(
new BasicRequestProducer(Method.POST, target, "/more-stuff",
new StringAsyncEntityProducer("some more stuff", ContentType.TEXT_PLAIN)),
new BasicResponseConsumer<>(new StringAsyncEntityConsumer()), TIMEOUT, null);
final Message<HttpResponse, String> message3 = resultFuture3.get(TIMEOUT.getDuration(), TIMEOUT.getTimeUnit());
- Assert.assertThat(message3, CoreMatchers.notNullValue());
+ MatcherAssert.assertThat(message3, CoreMatchers.notNullValue());
final HttpResponse response3 = message3.getHead();
- Assert.assertThat(response3.getCode(), CoreMatchers.equalTo(HttpStatus.SC_OK));
+ MatcherAssert.assertThat(response3.getCode(), CoreMatchers.equalTo(HttpStatus.SC_OK));
final String body3 = message3.getBody();
- Assert.assertThat(body3, CoreMatchers.equalTo("some more stuff"));
+ MatcherAssert.assertThat(body3, CoreMatchers.equalTo("some more stuff"));
}
@Test
@@ -271,33 +271,33 @@
new StringAsyncEntityProducer("some stuff", ContentType.TEXT_PLAIN)),
new BasicResponseConsumer<>(new StringAsyncEntityConsumer()), TIMEOUT, null);
final Message<HttpResponse, String> message1 = resultFuture1.get(TIMEOUT.getDuration(), TIMEOUT.getTimeUnit());
- Assert.assertThat(message1, CoreMatchers.notNullValue());
+ MatcherAssert.assertThat(message1, CoreMatchers.notNullValue());
final HttpResponse response1 = message1.getHead();
- Assert.assertThat(response1.getCode(), CoreMatchers.equalTo(HttpStatus.SC_OK));
+ MatcherAssert.assertThat(response1.getCode(), CoreMatchers.equalTo(HttpStatus.SC_OK));
final String body1 = message1.getBody();
- Assert.assertThat(body1, CoreMatchers.equalTo("some stuff"));
+ MatcherAssert.assertThat(body1, CoreMatchers.equalTo("some stuff"));
final Future<Message<HttpResponse, String>> resultFuture2 = requester.execute(
new BasicRequestProducer(Method.POST, target, "/no-keep-alive/other-stuff",
new StringAsyncEntityProducer("some other stuff", ContentType.TEXT_PLAIN)),
new BasicResponseConsumer<>(new StringAsyncEntityConsumer()), TIMEOUT, null);
final Message<HttpResponse, String> message2 = resultFuture2.get(TIMEOUT.getDuration(), TIMEOUT.getTimeUnit());
- Assert.assertThat(message2, CoreMatchers.notNullValue());
+ MatcherAssert.assertThat(message2, CoreMatchers.notNullValue());
final HttpResponse response2 = message2.getHead();
- Assert.assertThat(response2.getCode(), CoreMatchers.equalTo(HttpStatus.SC_OK));
+ MatcherAssert.assertThat(response2.getCode(), CoreMatchers.equalTo(HttpStatus.SC_OK));
final String body2 = message2.getBody();
- Assert.assertThat(body2, CoreMatchers.equalTo("some other stuff"));
+ MatcherAssert.assertThat(body2, CoreMatchers.equalTo("some other stuff"));
final Future<Message<HttpResponse, String>> resultFuture3 = requester.execute(
new BasicRequestProducer(Method.POST, target, "/no-keep-alive/more-stuff",
new StringAsyncEntityProducer("some more stuff", ContentType.TEXT_PLAIN)),
new BasicResponseConsumer<>(new StringAsyncEntityConsumer()), TIMEOUT, null);
final Message<HttpResponse, String> message3 = resultFuture3.get(TIMEOUT.getDuration(), TIMEOUT.getTimeUnit());
- Assert.assertThat(message3, CoreMatchers.notNullValue());
+ MatcherAssert.assertThat(message3, CoreMatchers.notNullValue());
final HttpResponse response3 = message3.getHead();
- Assert.assertThat(response3.getCode(), CoreMatchers.equalTo(HttpStatus.SC_OK));
+ MatcherAssert.assertThat(response3.getCode(), CoreMatchers.equalTo(HttpStatus.SC_OK));
final String body3 = message3.getBody();
- Assert.assertThat(body3, CoreMatchers.equalTo("some more stuff"));
+ MatcherAssert.assertThat(body3, CoreMatchers.equalTo("some more stuff"));
}
@Test
@@ -318,33 +318,33 @@
new StringAsyncEntityProducer("some stuff", ContentType.TEXT_PLAIN)),
new BasicResponseConsumer<>(new StringAsyncEntityConsumer()), null);
final Message<HttpResponse, String> message1 = resultFuture1.get(TIMEOUT.getDuration(), TIMEOUT.getTimeUnit());
- Assert.assertThat(message1, CoreMatchers.notNullValue());
+ MatcherAssert.assertThat(message1, CoreMatchers.notNullValue());
final HttpResponse response1 = message1.getHead();
- Assert.assertThat(response1.getCode(), CoreMatchers.equalTo(HttpStatus.SC_OK));
+ MatcherAssert.assertThat(response1.getCode(), CoreMatchers.equalTo(HttpStatus.SC_OK));
final String body1 = message1.getBody();
- Assert.assertThat(body1, CoreMatchers.equalTo("some stuff"));
+ MatcherAssert.assertThat(body1, CoreMatchers.equalTo("some stuff"));
final Future<Message<HttpResponse, String>> resultFuture2 = endpoint.execute(
new BasicRequestProducer(Method.POST, target, "/other-stuff",
new StringAsyncEntityProducer("some other stuff", ContentType.TEXT_PLAIN)),
new BasicResponseConsumer<>(new StringAsyncEntityConsumer()), null);
final Message<HttpResponse, String> message2 = resultFuture2.get(TIMEOUT.getDuration(), TIMEOUT.getTimeUnit());
- Assert.assertThat(message2, CoreMatchers.notNullValue());
+ MatcherAssert.assertThat(message2, CoreMatchers.notNullValue());
final HttpResponse response2 = message2.getHead();
- Assert.assertThat(response2.getCode(), CoreMatchers.equalTo(HttpStatus.SC_OK));
+ MatcherAssert.assertThat(response2.getCode(), CoreMatchers.equalTo(HttpStatus.SC_OK));
final String body2 = message2.getBody();
- Assert.assertThat(body2, CoreMatchers.equalTo("some other stuff"));
+ MatcherAssert.assertThat(body2, CoreMatchers.equalTo("some other stuff"));
final Future<Message<HttpResponse, String>> resultFuture3 = endpoint.execute(
new BasicRequestProducer(Method.POST, target, "/more-stuff",
new StringAsyncEntityProducer("some more stuff", ContentType.TEXT_PLAIN)),
new BasicResponseConsumer<>(new StringAsyncEntityConsumer()), null);
final Message<HttpResponse, String> message3 = resultFuture3.get(TIMEOUT.getDuration(), TIMEOUT.getTimeUnit());
- Assert.assertThat(message3, CoreMatchers.notNullValue());
+ MatcherAssert.assertThat(message3, CoreMatchers.notNullValue());
final HttpResponse response3 = message3.getHead();
- Assert.assertThat(response3.getCode(), CoreMatchers.equalTo(HttpStatus.SC_OK));
+ MatcherAssert.assertThat(response3.getCode(), CoreMatchers.equalTo(HttpStatus.SC_OK));
final String body3 = message3.getBody();
- Assert.assertThat(body3, CoreMatchers.equalTo("some more stuff"));
+ MatcherAssert.assertThat(body3, CoreMatchers.equalTo("some more stuff"));
} finally {
endpoint.releaseAndReuse();
@@ -382,11 +382,11 @@
while (!queue.isEmpty()) {
final Future<Message<HttpResponse, String>> resultFuture = queue.remove();
final Message<HttpResponse, String> message = resultFuture.get(TIMEOUT.getDuration(), TIMEOUT.getTimeUnit());
- Assert.assertThat(message, CoreMatchers.notNullValue());
+ MatcherAssert.assertThat(message, CoreMatchers.notNullValue());
final HttpResponse response = message.getHead();
- Assert.assertThat(response.getCode(), CoreMatchers.equalTo(HttpStatus.SC_OK));
+ MatcherAssert.assertThat(response.getCode(), CoreMatchers.equalTo(HttpStatus.SC_OK));
final String body = message.getBody();
- Assert.assertThat(body, CoreMatchers.containsString("stuff"));
+ MatcherAssert.assertThat(body, CoreMatchers.containsString("stuff"));
}
} finally {
@@ -415,10 +415,10 @@
while (!queue.isEmpty()) {
final Future<Message<HttpResponse, String>> resultFuture = queue.remove();
final Message<HttpResponse, String> message = resultFuture.get(TIMEOUT.getDuration(), TIMEOUT.getTimeUnit());
- Assert.assertThat(message, CoreMatchers.notNullValue());
+ MatcherAssert.assertThat(message, CoreMatchers.notNullValue());
final HttpResponse response = message.getHead();
- Assert.assertThat(response.getCode(), CoreMatchers.equalTo(HttpStatus.SC_OK));
- Assert.assertThat(message.getBody(), CoreMatchers.nullValue());
+ MatcherAssert.assertThat(response.getCode(), CoreMatchers.equalTo(HttpStatus.SC_OK));
+ MatcherAssert.assertThat(message.getBody(), CoreMatchers.nullValue());
}
}
diff --git a/httpcore5/src/test/java/org/apache/hc/core5/concurrent/TestComplexCancellable.java b/httpcore5/src/test/java/org/apache/hc/core5/concurrent/TestComplexCancellable.java
index 8013dd9..9904576 100644
--- a/httpcore5/src/test/java/org/apache/hc/core5/concurrent/TestComplexCancellable.java
+++ b/httpcore5/src/test/java/org/apache/hc/core5/concurrent/TestComplexCancellable.java
@@ -27,6 +27,7 @@
package org.apache.hc.core5.concurrent;
import org.hamcrest.CoreMatchers;
+import org.hamcrest.MatcherAssert;
import org.junit.Assert;
import org.junit.Test;
@@ -42,12 +43,12 @@
Assert.assertFalse(cancellable.isCancelled());
cancellable.cancel();
- Assert.assertThat(cancellable.isCancelled(), CoreMatchers.is(true));
- Assert.assertThat(dependency1.isCancelled(), CoreMatchers.is(true));
+ MatcherAssert.assertThat(cancellable.isCancelled(), CoreMatchers.is(true));
+ MatcherAssert.assertThat(dependency1.isCancelled(), CoreMatchers.is(true));
final BasicFuture<Object> dependency2 = new BasicFuture<>(null);
cancellable.setDependency(dependency2);
- Assert.assertThat(dependency2.isCancelled(), CoreMatchers.is(true));
+ MatcherAssert.assertThat(dependency2.isCancelled(), CoreMatchers.is(true));
}
}
diff --git a/httpcore5/src/test/java/org/apache/hc/core5/concurrent/TestComplexFuture.java b/httpcore5/src/test/java/org/apache/hc/core5/concurrent/TestComplexFuture.java
index ed04a82..7653260 100644
--- a/httpcore5/src/test/java/org/apache/hc/core5/concurrent/TestComplexFuture.java
+++ b/httpcore5/src/test/java/org/apache/hc/core5/concurrent/TestComplexFuture.java
@@ -29,6 +29,7 @@
import java.util.concurrent.Future;
import org.hamcrest.CoreMatchers;
+import org.hamcrest.MatcherAssert;
import org.junit.Assert;
import org.junit.Test;
@@ -44,12 +45,12 @@
Assert.assertFalse(future.isDone());
future.cancel();
- Assert.assertThat(future.isCancelled(), CoreMatchers.is(true));
- Assert.assertThat(dependency1.isCancelled(), CoreMatchers.is(true));
+ MatcherAssert.assertThat(future.isCancelled(), CoreMatchers.is(true));
+ MatcherAssert.assertThat(dependency1.isCancelled(), CoreMatchers.is(true));
final Future<Object> dependency2 = new BasicFuture<>(null);
future.setDependency(dependency2);
- Assert.assertThat(dependency2.isCancelled(), CoreMatchers.is(true));
+ MatcherAssert.assertThat(dependency2.isCancelled(), CoreMatchers.is(true));
}
@Test
@@ -62,12 +63,12 @@
Assert.assertFalse(future.isDone());
future.completed(Boolean.TRUE);
- Assert.assertThat(future.isCancelled(), CoreMatchers.is(false));
- Assert.assertThat(dependency1.isCancelled(), CoreMatchers.is(false));
+ MatcherAssert.assertThat(future.isCancelled(), CoreMatchers.is(false));
+ MatcherAssert.assertThat(dependency1.isCancelled(), CoreMatchers.is(false));
final Future<Object> dependency2 = new BasicFuture<>(null);
future.setDependency(dependency2);
- Assert.assertThat(dependency2.isCancelled(), CoreMatchers.is(true));
+ MatcherAssert.assertThat(dependency2.isCancelled(), CoreMatchers.is(true));
}
@Test
@@ -86,12 +87,12 @@
Assert.assertFalse(future.isDone());
future.cancel();
- Assert.assertThat(future.isCancelled(), CoreMatchers.is(true));
- Assert.assertThat(dependency1.isCancelled(), CoreMatchers.is(true));
+ MatcherAssert.assertThat(future.isCancelled(), CoreMatchers.is(true));
+ MatcherAssert.assertThat(dependency1.isCancelled(), CoreMatchers.is(true));
final Future<Object> dependency2 = new BasicFuture<>(null);
future.setDependency(dependency2);
- Assert.assertThat(dependency2.isCancelled(), CoreMatchers.is(true));
+ MatcherAssert.assertThat(dependency2.isCancelled(), CoreMatchers.is(true));
}
}
diff --git a/httpcore5/src/test/java/org/apache/hc/core5/http/config/TestNamedElementChain.java b/httpcore5/src/test/java/org/apache/hc/core5/http/config/TestNamedElementChain.java
index 203d54d..67c2ad1 100644
--- a/httpcore5/src/test/java/org/apache/hc/core5/http/config/TestNamedElementChain.java
+++ b/httpcore5/src/test/java/org/apache/hc/core5/http/config/TestNamedElementChain.java
@@ -28,7 +28,7 @@
package org.apache.hc.core5.http.config;
import org.hamcrest.CoreMatchers;
-import org.junit.Assert;
+import org.hamcrest.MatcherAssert;
import org.junit.Test;
/**
@@ -39,59 +39,59 @@
@Test
public void testBasics() {
final NamedElementChain<Character> list = new NamedElementChain<>();
- Assert.assertThat(list.getFirst(), CoreMatchers.nullValue());
- Assert.assertThat(list.getLast(), CoreMatchers.nullValue());
+ MatcherAssert.assertThat(list.getFirst(), CoreMatchers.nullValue());
+ MatcherAssert.assertThat(list.getLast(), CoreMatchers.nullValue());
final NamedElementChain<Character>.Node nodeA = list.addFirst('a', "a");
- Assert.assertThat(list.getFirst(), CoreMatchers.sameInstance(nodeA));
- Assert.assertThat(list.getLast(), CoreMatchers.sameInstance(nodeA));
+ MatcherAssert.assertThat(list.getFirst(), CoreMatchers.sameInstance(nodeA));
+ MatcherAssert.assertThat(list.getLast(), CoreMatchers.sameInstance(nodeA));
final NamedElementChain<Character>.Node nodeB = list.addLast('b', "b");
- Assert.assertThat(list.getFirst(), CoreMatchers.sameInstance(nodeA));
- Assert.assertThat(list.getLast(), CoreMatchers.sameInstance(nodeB));
+ MatcherAssert.assertThat(list.getFirst(), CoreMatchers.sameInstance(nodeA));
+ MatcherAssert.assertThat(list.getLast(), CoreMatchers.sameInstance(nodeB));
final NamedElementChain<Character>.Node nodeZ = list.addLast('z', "z");
- Assert.assertThat(list.getFirst(), CoreMatchers.sameInstance(nodeA));
- Assert.assertThat(list.getLast(), CoreMatchers.sameInstance(nodeZ));
+ MatcherAssert.assertThat(list.getFirst(), CoreMatchers.sameInstance(nodeA));
+ MatcherAssert.assertThat(list.getLast(), CoreMatchers.sameInstance(nodeZ));
- Assert.assertThat(nodeA.getPrevious(), CoreMatchers.nullValue());
- Assert.assertThat(nodeA.getNext(), CoreMatchers.sameInstance(nodeB));
- Assert.assertThat(nodeB.getPrevious(), CoreMatchers.sameInstance(nodeA));
- Assert.assertThat(nodeB.getNext(), CoreMatchers.sameInstance(nodeZ));
- Assert.assertThat(nodeZ.getPrevious(), CoreMatchers.sameInstance(nodeB));
- Assert.assertThat(nodeZ.getNext(), CoreMatchers.nullValue());
+ MatcherAssert.assertThat(nodeA.getPrevious(), CoreMatchers.nullValue());
+ MatcherAssert.assertThat(nodeA.getNext(), CoreMatchers.sameInstance(nodeB));
+ MatcherAssert.assertThat(nodeB.getPrevious(), CoreMatchers.sameInstance(nodeA));
+ MatcherAssert.assertThat(nodeB.getNext(), CoreMatchers.sameInstance(nodeZ));
+ MatcherAssert.assertThat(nodeZ.getPrevious(), CoreMatchers.sameInstance(nodeB));
+ MatcherAssert.assertThat(nodeZ.getNext(), CoreMatchers.nullValue());
final NamedElementChain<Character>.Node nodeD = list.addAfter("b", 'd', "d");
- Assert.assertThat(nodeD.getPrevious(), CoreMatchers.sameInstance(nodeB));
- Assert.assertThat(nodeD.getNext(), CoreMatchers.sameInstance(nodeZ));
- Assert.assertThat(nodeB.getNext(), CoreMatchers.sameInstance(nodeD));
- Assert.assertThat(nodeZ.getPrevious(), CoreMatchers.sameInstance(nodeD));
+ MatcherAssert.assertThat(nodeD.getPrevious(), CoreMatchers.sameInstance(nodeB));
+ MatcherAssert.assertThat(nodeD.getNext(), CoreMatchers.sameInstance(nodeZ));
+ MatcherAssert.assertThat(nodeB.getNext(), CoreMatchers.sameInstance(nodeD));
+ MatcherAssert.assertThat(nodeZ.getPrevious(), CoreMatchers.sameInstance(nodeD));
final NamedElementChain<Character>.Node nodeC = list.addBefore("d", 'c', "c");
- Assert.assertThat(nodeC.getPrevious(), CoreMatchers.sameInstance(nodeB));
- Assert.assertThat(nodeC.getNext(), CoreMatchers.sameInstance(nodeD));
- Assert.assertThat(nodeB.getNext(), CoreMatchers.sameInstance(nodeC));
- Assert.assertThat(nodeD.getPrevious(), CoreMatchers.sameInstance(nodeC));
- Assert.assertThat(list.getSize(), CoreMatchers.equalTo(5));
+ MatcherAssert.assertThat(nodeC.getPrevious(), CoreMatchers.sameInstance(nodeB));
+ MatcherAssert.assertThat(nodeC.getNext(), CoreMatchers.sameInstance(nodeD));
+ MatcherAssert.assertThat(nodeB.getNext(), CoreMatchers.sameInstance(nodeC));
+ MatcherAssert.assertThat(nodeD.getPrevious(), CoreMatchers.sameInstance(nodeC));
+ MatcherAssert.assertThat(list.getSize(), CoreMatchers.equalTo(5));
- Assert.assertThat(list.remove("a"), CoreMatchers.is(true));
- Assert.assertThat(list.remove("z"), CoreMatchers.is(true));
- Assert.assertThat(list.remove("c"), CoreMatchers.is(true));
- Assert.assertThat(list.remove("c"), CoreMatchers.is(false));
- Assert.assertThat(list.remove("blah"), CoreMatchers.is(false));
+ MatcherAssert.assertThat(list.remove("a"), CoreMatchers.is(true));
+ MatcherAssert.assertThat(list.remove("z"), CoreMatchers.is(true));
+ MatcherAssert.assertThat(list.remove("c"), CoreMatchers.is(true));
+ MatcherAssert.assertThat(list.remove("c"), CoreMatchers.is(false));
+ MatcherAssert.assertThat(list.remove("blah"), CoreMatchers.is(false));
- Assert.assertThat(list.getFirst(), CoreMatchers.sameInstance(nodeB));
- Assert.assertThat(list.getLast(), CoreMatchers.sameInstance(nodeD));
+ MatcherAssert.assertThat(list.getFirst(), CoreMatchers.sameInstance(nodeB));
+ MatcherAssert.assertThat(list.getLast(), CoreMatchers.sameInstance(nodeD));
- Assert.assertThat(list.getSize(), CoreMatchers.equalTo(2));
- Assert.assertThat(list.addBefore("blah", 'e', "e"), CoreMatchers.nullValue());
- Assert.assertThat(list.getSize(), CoreMatchers.equalTo(2));
+ MatcherAssert.assertThat(list.getSize(), CoreMatchers.equalTo(2));
+ MatcherAssert.assertThat(list.addBefore("blah", 'e', "e"), CoreMatchers.nullValue());
+ MatcherAssert.assertThat(list.getSize(), CoreMatchers.equalTo(2));
- Assert.assertThat(list.addAfter("yada", 'e', "e"), CoreMatchers.nullValue());
- Assert.assertThat(list.getSize(), CoreMatchers.equalTo(2));
+ MatcherAssert.assertThat(list.addAfter("yada", 'e', "e"), CoreMatchers.nullValue());
+ MatcherAssert.assertThat(list.getSize(), CoreMatchers.equalTo(2));
}
}
\ No newline at end of file
diff --git a/httpcore5/src/test/java/org/apache/hc/core5/http/impl/nio/TestExpandableBuffer.java b/httpcore5/src/test/java/org/apache/hc/core5/http/impl/nio/TestExpandableBuffer.java
index 4f0dfe7..d98d3fc 100644
--- a/httpcore5/src/test/java/org/apache/hc/core5/http/impl/nio/TestExpandableBuffer.java
+++ b/httpcore5/src/test/java/org/apache/hc/core5/http/impl/nio/TestExpandableBuffer.java
@@ -28,7 +28,7 @@
package org.apache.hc.core5.http.impl.nio;
import org.hamcrest.CoreMatchers;
-import org.junit.Assert;
+import org.hamcrest.MatcherAssert;
import org.junit.Test;
public class TestExpandableBuffer {
@@ -36,47 +36,47 @@
@Test
public void testBasics() throws Exception {
final ExpandableBuffer buffer = new ExpandableBuffer(16);
- Assert.assertThat(buffer.mode(), CoreMatchers.equalTo(ExpandableBuffer.Mode.INPUT));
- Assert.assertThat(buffer.hasData(), CoreMatchers.equalTo(false));
+ MatcherAssert.assertThat(buffer.mode(), CoreMatchers.equalTo(ExpandableBuffer.Mode.INPUT));
+ MatcherAssert.assertThat(buffer.hasData(), CoreMatchers.equalTo(false));
buffer.setInputMode();
buffer.buffer().put(new byte[] { 0, 1, 2, 3, 4, 5});
- Assert.assertThat(buffer.hasData(), CoreMatchers.equalTo(true));
- Assert.assertThat(buffer.length(), CoreMatchers.equalTo(6));
- Assert.assertThat(buffer.buffer().capacity(), CoreMatchers.equalTo(16));
- Assert.assertThat(buffer.mode(), CoreMatchers.equalTo(ExpandableBuffer.Mode.OUTPUT));
+ MatcherAssert.assertThat(buffer.hasData(), CoreMatchers.equalTo(true));
+ MatcherAssert.assertThat(buffer.length(), CoreMatchers.equalTo(6));
+ MatcherAssert.assertThat(buffer.buffer().capacity(), CoreMatchers.equalTo(16));
+ MatcherAssert.assertThat(buffer.mode(), CoreMatchers.equalTo(ExpandableBuffer.Mode.OUTPUT));
buffer.setInputMode();
buffer.buffer().put(new byte[] { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 });
- Assert.assertThat(buffer.length(), CoreMatchers.equalTo(16));
- Assert.assertThat(buffer.buffer().capacity(), CoreMatchers.equalTo(16));
- Assert.assertThat(buffer.mode(), CoreMatchers.equalTo(ExpandableBuffer.Mode.OUTPUT));
+ MatcherAssert.assertThat(buffer.length(), CoreMatchers.equalTo(16));
+ MatcherAssert.assertThat(buffer.buffer().capacity(), CoreMatchers.equalTo(16));
+ MatcherAssert.assertThat(buffer.mode(), CoreMatchers.equalTo(ExpandableBuffer.Mode.OUTPUT));
buffer.setInputMode();
buffer.ensureCapacity(22);
buffer.buffer().put(new byte[] { 0, 1, 2, 3, 4, 5});
- Assert.assertThat(buffer.length(), CoreMatchers.equalTo(22));
- Assert.assertThat(buffer.buffer().capacity(), CoreMatchers.equalTo(22));
- Assert.assertThat(buffer.mode(), CoreMatchers.equalTo(ExpandableBuffer.Mode.OUTPUT));
+ MatcherAssert.assertThat(buffer.length(), CoreMatchers.equalTo(22));
+ MatcherAssert.assertThat(buffer.buffer().capacity(), CoreMatchers.equalTo(22));
+ MatcherAssert.assertThat(buffer.mode(), CoreMatchers.equalTo(ExpandableBuffer.Mode.OUTPUT));
buffer.clear();
- Assert.assertThat(buffer.mode(), CoreMatchers.equalTo(ExpandableBuffer.Mode.INPUT));
- Assert.assertThat(buffer.hasData(), CoreMatchers.equalTo(false));
- Assert.assertThat(buffer.capacity(), CoreMatchers.equalTo(22));
+ MatcherAssert.assertThat(buffer.mode(), CoreMatchers.equalTo(ExpandableBuffer.Mode.INPUT));
+ MatcherAssert.assertThat(buffer.hasData(), CoreMatchers.equalTo(false));
+ MatcherAssert.assertThat(buffer.capacity(), CoreMatchers.equalTo(22));
}
@Test
public void testAdjustCapacity() throws Exception {
final ExpandableBuffer buffer = new ExpandableBuffer(16);
- Assert.assertThat(buffer.capacity(), CoreMatchers.equalTo(16));
+ MatcherAssert.assertThat(buffer.capacity(), CoreMatchers.equalTo(16));
buffer.ensureCapacity(21);
- Assert.assertThat(buffer.capacity(), CoreMatchers.equalTo(21));
+ MatcherAssert.assertThat(buffer.capacity(), CoreMatchers.equalTo(21));
buffer.ensureAdjustedCapacity(22);
- Assert.assertThat(buffer.capacity(), CoreMatchers.equalTo(1024));
+ MatcherAssert.assertThat(buffer.capacity(), CoreMatchers.equalTo(1024));
buffer.ensureAdjustedCapacity(1024);
- Assert.assertThat(buffer.capacity(), CoreMatchers.equalTo(1024));
+ MatcherAssert.assertThat(buffer.capacity(), CoreMatchers.equalTo(1024));
buffer.ensureAdjustedCapacity(1025);
- Assert.assertThat(buffer.capacity(), CoreMatchers.equalTo(2048));
+ MatcherAssert.assertThat(buffer.capacity(), CoreMatchers.equalTo(2048));
}
}
diff --git a/httpcore5/src/test/java/org/apache/hc/core5/http/ssl/TestTlsVersionParser.java b/httpcore5/src/test/java/org/apache/hc/core5/http/ssl/TestTlsVersionParser.java
index 221f49d..7966ae2 100644
--- a/httpcore5/src/test/java/org/apache/hc/core5/http/ssl/TestTlsVersionParser.java
+++ b/httpcore5/src/test/java/org/apache/hc/core5/http/ssl/TestTlsVersionParser.java
@@ -31,7 +31,7 @@
import org.apache.hc.core5.http.ProtocolVersion;
import org.apache.hc.core5.util.Tokenizer;
import org.hamcrest.CoreMatchers;
-import org.junit.Assert;
+import org.hamcrest.MatcherAssert;
import org.junit.Before;
import org.junit.Test;
@@ -49,19 +49,19 @@
@Test
public void testParseBasic() throws Exception {
- Assert.assertThat(impl.parse("TLSv1"), CoreMatchers.equalTo(TLS.V_1_0.version));
- Assert.assertThat(impl.parse("TLSv1.1"), CoreMatchers.equalTo(TLS.V_1_1.version));
- Assert.assertThat(impl.parse("TLSv1.2"), CoreMatchers.equalTo(TLS.V_1_2.version));
- Assert.assertThat(impl.parse("TLSv1.3"), CoreMatchers.equalTo(TLS.V_1_3.version));
- Assert.assertThat(impl.parse("TLSv22.356"), CoreMatchers.equalTo(new ProtocolVersion("TLS", 22, 356)));
+ MatcherAssert.assertThat(impl.parse("TLSv1"), CoreMatchers.equalTo(TLS.V_1_0.version));
+ MatcherAssert.assertThat(impl.parse("TLSv1.1"), CoreMatchers.equalTo(TLS.V_1_1.version));
+ MatcherAssert.assertThat(impl.parse("TLSv1.2"), CoreMatchers.equalTo(TLS.V_1_2.version));
+ MatcherAssert.assertThat(impl.parse("TLSv1.3"), CoreMatchers.equalTo(TLS.V_1_3.version));
+ MatcherAssert.assertThat(impl.parse("TLSv22.356"), CoreMatchers.equalTo(new ProtocolVersion("TLS", 22, 356)));
}
@Test
public void testParseBuffer() throws Exception {
final Tokenizer.Cursor cursor = new Tokenizer.Cursor(1, 13);
- Assert.assertThat(impl.parse(" TLSv1.2,0000", cursor, Tokenizer.INIT_BITSET(',')),
+ MatcherAssert.assertThat(impl.parse(" TLSv1.2,0000", cursor, Tokenizer.INIT_BITSET(',')),
CoreMatchers.equalTo(TLS.V_1_2.version));
- Assert.assertThat(cursor.getPos(), CoreMatchers.equalTo(8));
+ MatcherAssert.assertThat(cursor.getPos(), CoreMatchers.equalTo(8));
}
@Test(expected = ParseException.class)
diff --git a/httpcore5/src/test/java/org/apache/hc/core5/reactor/TestAbstractIOSessionPool.java b/httpcore5/src/test/java/org/apache/hc/core5/reactor/TestAbstractIOSessionPool.java
index fe87e61..83febce 100644
--- a/httpcore5/src/test/java/org/apache/hc/core5/reactor/TestAbstractIOSessionPool.java
+++ b/httpcore5/src/test/java/org/apache/hc/core5/reactor/TestAbstractIOSessionPool.java
@@ -34,7 +34,7 @@
import org.apache.hc.core5.util.TimeValue;
import org.apache.hc.core5.util.Timeout;
import org.hamcrest.CoreMatchers;
-import org.junit.Assert;
+import org.hamcrest.MatcherAssert;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
@@ -92,9 +92,9 @@
Mockito.when(ioSession1.isOpen()).thenReturn(true);
final Future<IOSession> future1 = impl.getSession("somehost", Timeout.ofSeconds(123L), null);
- Assert.assertThat(future1, CoreMatchers.notNullValue());
- Assert.assertThat(future1.isDone(), CoreMatchers.equalTo(false));
- Assert.assertThat(impl.getRoutes(), CoreMatchers.hasItem("somehost"));
+ MatcherAssert.assertThat(future1, CoreMatchers.notNullValue());
+ MatcherAssert.assertThat(future1.isDone(), CoreMatchers.equalTo(false));
+ MatcherAssert.assertThat(impl.getRoutes(), CoreMatchers.hasItem("somehost"));
Mockito.verify(impl).connectSession(
ArgumentMatchers.eq("somehost"),
@@ -102,9 +102,9 @@
ArgumentMatchers.<FutureCallback<IOSession>>any());
final Future<IOSession> future2 = impl.getSession("somehost", Timeout.ofSeconds(123L), null);
- Assert.assertThat(future2, CoreMatchers.notNullValue());
- Assert.assertThat(future2.isDone(), CoreMatchers.equalTo(false));
- Assert.assertThat(impl.getRoutes(), CoreMatchers.hasItem("somehost"));
+ MatcherAssert.assertThat(future2, CoreMatchers.notNullValue());
+ MatcherAssert.assertThat(future2.isDone(), CoreMatchers.equalTo(false));
+ MatcherAssert.assertThat(impl.getRoutes(), CoreMatchers.hasItem("somehost"));
Mockito.verify(impl, Mockito.times(1)).connectSession(
ArgumentMatchers.eq("somehost"),
@@ -119,11 +119,11 @@
}));
- Assert.assertThat(future1.isDone(), CoreMatchers.equalTo(true));
- Assert.assertThat(future1.get(), CoreMatchers.sameInstance(ioSession1));
+ MatcherAssert.assertThat(future1.isDone(), CoreMatchers.equalTo(true));
+ MatcherAssert.assertThat(future1.get(), CoreMatchers.sameInstance(ioSession1));
- Assert.assertThat(future2.isDone(), CoreMatchers.equalTo(true));
- Assert.assertThat(future2.get(), CoreMatchers.sameInstance(ioSession1));
+ MatcherAssert.assertThat(future2.isDone(), CoreMatchers.equalTo(true));
+ MatcherAssert.assertThat(future2.get(), CoreMatchers.sameInstance(ioSession1));
Mockito.verify(impl, Mockito.times(2)).validateSession(ArgumentMatchers.<IOSession>any(), ArgumentMatchers.<Callback<Boolean>>any());
@@ -136,8 +136,8 @@
Mockito.verify(impl, Mockito.times(3)).validateSession(ArgumentMatchers.<IOSession>any(), ArgumentMatchers.<Callback<Boolean>>any());
- Assert.assertThat(future3.isDone(), CoreMatchers.equalTo(true));
- Assert.assertThat(future3.get(), CoreMatchers.sameInstance(ioSession1));
+ MatcherAssert.assertThat(future3.isDone(), CoreMatchers.equalTo(true));
+ MatcherAssert.assertThat(future3.get(), CoreMatchers.sameInstance(ioSession1));
}
@Test
@@ -149,9 +149,9 @@
ArgumentMatchers.<FutureCallback<IOSession>>any())).thenReturn(connectFuture);
final Future<IOSession> future1 = impl.getSession("somehost", Timeout.ofSeconds(123L), null);
- Assert.assertThat(future1, CoreMatchers.notNullValue());
- Assert.assertThat(future1.isDone(), CoreMatchers.equalTo(false));
- Assert.assertThat(impl.getRoutes(), CoreMatchers.hasItem("somehost"));
+ MatcherAssert.assertThat(future1, CoreMatchers.notNullValue());
+ MatcherAssert.assertThat(future1.isDone(), CoreMatchers.equalTo(false));
+ MatcherAssert.assertThat(impl.getRoutes(), CoreMatchers.hasItem("somehost"));
Mockito.verify(impl).connectSession(
ArgumentMatchers.eq("somehost"),
@@ -159,9 +159,9 @@
ArgumentMatchers.<FutureCallback<IOSession>>any());
final Future<IOSession> future2 = impl.getSession("somehost", Timeout.ofSeconds(123L), null);
- Assert.assertThat(future2, CoreMatchers.notNullValue());
- Assert.assertThat(future2.isDone(), CoreMatchers.equalTo(false));
- Assert.assertThat(impl.getRoutes(), CoreMatchers.hasItem("somehost"));
+ MatcherAssert.assertThat(future2, CoreMatchers.notNullValue());
+ MatcherAssert.assertThat(future2.isDone(), CoreMatchers.equalTo(false));
+ MatcherAssert.assertThat(impl.getRoutes(), CoreMatchers.hasItem("somehost"));
Mockito.verify(impl, Mockito.times(1)).connectSession(
ArgumentMatchers.eq("somehost"),
@@ -176,22 +176,22 @@
}));
- Assert.assertThat(future1.isDone(), CoreMatchers.equalTo(true));
- Assert.assertThat(future2.isDone(), CoreMatchers.equalTo(true));
+ MatcherAssert.assertThat(future1.isDone(), CoreMatchers.equalTo(true));
+ MatcherAssert.assertThat(future2.isDone(), CoreMatchers.equalTo(true));
}
@Test
public void testShutdownPool() throws Exception {
final AbstractIOSessionPool.PoolEntry entry1 = impl.getPoolEntry("host1");
- Assert.assertThat(entry1, CoreMatchers.notNullValue());
+ MatcherAssert.assertThat(entry1, CoreMatchers.notNullValue());
entry1.session = ioSession1;
final AbstractIOSessionPool.PoolEntry entry2 = impl.getPoolEntry("host2");
- Assert.assertThat(entry2, CoreMatchers.notNullValue());
+ MatcherAssert.assertThat(entry2, CoreMatchers.notNullValue());
entry2.session = ioSession2;
final AbstractIOSessionPool.PoolEntry entry3 = impl.getPoolEntry("host3");
- Assert.assertThat(entry3, CoreMatchers.notNullValue());
+ MatcherAssert.assertThat(entry3, CoreMatchers.notNullValue());
entry3.sessionFuture = connectFuture;
entry3.requestQueue.add(callback1);
entry3.requestQueue.add(callback2);
@@ -208,11 +208,11 @@
@Test
public void testCloseIdleSessions() throws Exception {
final AbstractIOSessionPool.PoolEntry entry1 = impl.getPoolEntry("host1");
- Assert.assertThat(entry1, CoreMatchers.notNullValue());
+ MatcherAssert.assertThat(entry1, CoreMatchers.notNullValue());
entry1.session = ioSession1;
final AbstractIOSessionPool.PoolEntry entry2 = impl.getPoolEntry("host2");
- Assert.assertThat(entry2, CoreMatchers.notNullValue());
+ MatcherAssert.assertThat(entry2, CoreMatchers.notNullValue());
entry2.session = ioSession2;
impl.closeIdle(TimeValue.ZERO_MILLISECONDS);
@@ -220,18 +220,18 @@
Mockito.verify(impl).closeSession(ioSession1, CloseMode.GRACEFUL);
Mockito.verify(impl).closeSession(ioSession2, CloseMode.GRACEFUL);
- Assert.assertThat(entry1.session, CoreMatchers.nullValue());
- Assert.assertThat(entry2.session, CoreMatchers.nullValue());
+ MatcherAssert.assertThat(entry1.session, CoreMatchers.nullValue());
+ MatcherAssert.assertThat(entry2.session, CoreMatchers.nullValue());
}
@Test
public void testEnumSessions() throws Exception {
final AbstractIOSessionPool.PoolEntry entry1 = impl.getPoolEntry("host1");
- Assert.assertThat(entry1, CoreMatchers.notNullValue());
+ MatcherAssert.assertThat(entry1, CoreMatchers.notNullValue());
entry1.session = ioSession1;
final AbstractIOSessionPool.PoolEntry entry2 = impl.getPoolEntry("host2");
- Assert.assertThat(entry2, CoreMatchers.notNullValue());
+ MatcherAssert.assertThat(entry2, CoreMatchers.notNullValue());
entry2.session = ioSession2;
impl.enumAvailable(new Callback<IOSession>() {
@@ -249,7 +249,7 @@
@Test
public void testGetSessionReconnectAfterValidate() throws Exception {
final AbstractIOSessionPool.PoolEntry entry1 = impl.getPoolEntry("somehost");
- Assert.assertThat(entry1, CoreMatchers.notNullValue());
+ MatcherAssert.assertThat(entry1, CoreMatchers.notNullValue());
entry1.session = ioSession1;
Mockito.when(ioSession1.isOpen()).thenReturn(true);
@@ -275,7 +275,7 @@
@Test
public void testGetSessionReconnectIfClosed() throws Exception {
final AbstractIOSessionPool.PoolEntry entry1 = impl.getPoolEntry("somehost");
- Assert.assertThat(entry1, CoreMatchers.notNullValue());
+ MatcherAssert.assertThat(entry1, CoreMatchers.notNullValue());
entry1.session = ioSession1;
Mockito.when(ioSession1.isOpen()).thenReturn(false);
diff --git a/httpcore5/src/test/java/org/apache/hc/core5/util/TestTimeValue.java b/httpcore5/src/test/java/org/apache/hc/core5/util/TestTimeValue.java
index 18bc451..89ee793 100644
--- a/httpcore5/src/test/java/org/apache/hc/core5/util/TestTimeValue.java
+++ b/httpcore5/src/test/java/org/apache/hc/core5/util/TestTimeValue.java
@@ -31,6 +31,7 @@
import java.util.concurrent.TimeUnit;
import org.hamcrest.CoreMatchers;
+import org.hamcrest.MatcherAssert;
import org.junit.Assert;
import org.junit.Test;
@@ -271,19 +272,19 @@
final TimeValue tv4 = TimeValue.ofSeconds(1L);
final TimeValue tv5 = TimeValue.ofSeconds(1000L);
- Assert.assertThat(tv1.equals(tv1), CoreMatchers.equalTo(true));
- Assert.assertThat(tv1.equals(null), CoreMatchers.equalTo(false));
- Assert.assertThat(tv1.equals(tv2), CoreMatchers.equalTo(false));
- Assert.assertThat(tv1.equals(tv3), CoreMatchers.equalTo(true));
- Assert.assertThat(tv1.equals(tv4), CoreMatchers.equalTo(true));
- Assert.assertThat(tv4.equals(tv1), CoreMatchers.equalTo(true));
- Assert.assertThat(tv1.equals(tv5), CoreMatchers.equalTo(false));
+ MatcherAssert.assertThat(tv1.equals(tv1), CoreMatchers.equalTo(true));
+ MatcherAssert.assertThat(tv1.equals(null), CoreMatchers.equalTo(false));
+ MatcherAssert.assertThat(tv1.equals(tv2), CoreMatchers.equalTo(false));
+ MatcherAssert.assertThat(tv1.equals(tv3), CoreMatchers.equalTo(true));
+ MatcherAssert.assertThat(tv1.equals(tv4), CoreMatchers.equalTo(true));
+ MatcherAssert.assertThat(tv4.equals(tv1), CoreMatchers.equalTo(true));
+ MatcherAssert.assertThat(tv1.equals(tv5), CoreMatchers.equalTo(false));
- Assert.assertThat(tv1.hashCode() == tv2.hashCode(), CoreMatchers.equalTo(false));
- Assert.assertThat(tv1.hashCode() == tv3.hashCode(), CoreMatchers.equalTo(true));
- Assert.assertThat(tv1.hashCode() == tv4.hashCode(), CoreMatchers.equalTo(true));
- Assert.assertThat(tv4.hashCode() == tv1.hashCode(), CoreMatchers.equalTo(true));
- Assert.assertThat(tv1.hashCode() == tv5.hashCode(), CoreMatchers.equalTo(false));
+ MatcherAssert.assertThat(tv1.hashCode() == tv2.hashCode(), CoreMatchers.equalTo(false));
+ MatcherAssert.assertThat(tv1.hashCode() == tv3.hashCode(), CoreMatchers.equalTo(true));
+ MatcherAssert.assertThat(tv1.hashCode() == tv4.hashCode(), CoreMatchers.equalTo(true));
+ MatcherAssert.assertThat(tv4.hashCode() == tv1.hashCode(), CoreMatchers.equalTo(true));
+ MatcherAssert.assertThat(tv1.hashCode() == tv5.hashCode(), CoreMatchers.equalTo(false));
}
@Test
@@ -295,13 +296,13 @@
final TimeValue tv5 = TimeValue.ofSeconds(60L);
final TimeValue tv6 = TimeValue.ofMinutes(1L);
- Assert.assertThat(tv1.compareTo(tv1) == 0, CoreMatchers.equalTo(true));
- Assert.assertThat(tv1.compareTo(tv2) < 0, CoreMatchers.equalTo(true));
- Assert.assertThat(tv1.compareTo(tv3) == 0, CoreMatchers.equalTo(true));
- Assert.assertThat(tv1.compareTo(tv4) == 0, CoreMatchers.equalTo(true));
- Assert.assertThat(tv1.compareTo(tv5) < 0, CoreMatchers.equalTo(true));
- Assert.assertThat(tv6.compareTo(tv5) == 0, CoreMatchers.equalTo(true));
- Assert.assertThat(tv6.compareTo(tv4) > 0, CoreMatchers.equalTo(true));
+ MatcherAssert.assertThat(tv1.compareTo(tv1) == 0, CoreMatchers.equalTo(true));
+ MatcherAssert.assertThat(tv1.compareTo(tv2) < 0, CoreMatchers.equalTo(true));
+ MatcherAssert.assertThat(tv1.compareTo(tv3) == 0, CoreMatchers.equalTo(true));
+ MatcherAssert.assertThat(tv1.compareTo(tv4) == 0, CoreMatchers.equalTo(true));
+ MatcherAssert.assertThat(tv1.compareTo(tv5) < 0, CoreMatchers.equalTo(true));
+ MatcherAssert.assertThat(tv6.compareTo(tv5) == 0, CoreMatchers.equalTo(true));
+ MatcherAssert.assertThat(tv6.compareTo(tv4) > 0, CoreMatchers.equalTo(true));
try {
tv1.compareTo(null);
Assert.fail("NullPointerException expected");