From 420910da4f0ec878e39eb90c6df4b2099413ee67 Mon Sep 17 00:00:00 2001 From: strangelookingnerd <49242855+strangelookingnerd@users.noreply.github.com> Date: Thu, 27 Jun 2024 09:51:47 +0200 Subject: [PATCH] Fix assertions --- .../hc/client5/http/impl/cache/ConsumableInputStream.java | 1 - .../hc/client5/http/impl/cache/TestRFC5861Compliance.java | 7 ++++--- .../java/org/apache/hc/client5/http/TestHttpRoute.java | 2 +- .../client5/http/classic/methods/TestHttpRequestBase.java | 2 +- .../hc/client5/http/impl/classic/TestRedirectExec.java | 6 +++--- 5 files changed, 9 insertions(+), 9 deletions(-) diff --git a/httpclient5-cache/src/test/java/org/apache/hc/client5/http/impl/cache/ConsumableInputStream.java b/httpclient5-cache/src/test/java/org/apache/hc/client5/http/impl/cache/ConsumableInputStream.java index 1cd8c3490..e7969f2e5 100644 --- a/httpclient5-cache/src/test/java/org/apache/hc/client5/http/impl/cache/ConsumableInputStream.java +++ b/httpclient5-cache/src/test/java/org/apache/hc/client5/http/impl/cache/ConsumableInputStream.java @@ -27,7 +27,6 @@ package org.apache.hc.client5.http.impl.cache; import java.io.ByteArrayInputStream; -import java.io.IOException; import java.io.InputStream; import org.apache.hc.core5.io.Closer; diff --git a/httpclient5-cache/src/test/java/org/apache/hc/client5/http/impl/cache/TestRFC5861Compliance.java b/httpclient5-cache/src/test/java/org/apache/hc/client5/http/impl/cache/TestRFC5861Compliance.java index 1d43834ca..cb5c34835 100644 --- a/httpclient5-cache/src/test/java/org/apache/hc/client5/http/impl/cache/TestRFC5861Compliance.java +++ b/httpclient5-cache/src/test/java/org/apache/hc/client5/http/impl/cache/TestRFC5861Compliance.java @@ -28,6 +28,7 @@ package org.apache.hc.client5.http.impl.cache; import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertNotEquals; import static org.junit.jupiter.api.Assertions.assertTrue; import java.io.ByteArrayInputStream; @@ -170,7 +171,7 @@ class TestRFC5861Compliance { final ClassicHttpResponse result = execute(req2); - assertTrue(HttpStatus.SC_OK != result.getCode()); + assertNotEquals(HttpStatus.SC_OK, result.getCode()); } @Test @@ -193,7 +194,7 @@ class TestRFC5861Compliance { final ClassicHttpResponse result = execute(req2); - assertTrue(HttpStatus.SC_OK != result.getCode()); + assertNotEquals(HttpStatus.SC_OK, result.getCode()); } @Test @@ -216,7 +217,7 @@ class TestRFC5861Compliance { final ClassicHttpResponse result = execute(req2); - assertTrue(HttpStatus.SC_OK != result.getCode()); + assertNotEquals(HttpStatus.SC_OK, result.getCode()); } @Test diff --git a/httpclient5/src/test/java/org/apache/hc/client5/http/TestHttpRoute.java b/httpclient5/src/test/java/org/apache/hc/client5/http/TestHttpRoute.java index c1ba0b5eb..6614f4236 100644 --- a/httpclient5/src/test/java/org/apache/hc/client5/http/TestHttpRoute.java +++ b/httpclient5/src/test/java/org/apache/hc/client5/http/TestHttpRoute.java @@ -359,7 +359,7 @@ class TestHttpRoute { final HttpHost[] proxies3 = new HttpHost[]{ PROXY3, PROXY1, PROXY2 }; final HttpRoute route3 = new HttpRoute(TARGET1, LOCAL42, proxies3, false, TunnelType.PLAIN, LayerType.LAYERED); - Assertions.assertEquals(route3.getHopCount(), 4, "C: hop count"); + Assertions.assertEquals(4, route3.getHopCount(), "C: hop count"); Assertions.assertEquals(PROXY3 , route3.getHopTarget(0), "C: hop 0"); Assertions.assertEquals(PROXY1 , route3.getHopTarget(1), "C: hop 1"); Assertions.assertEquals(PROXY2 , route3.getHopTarget(2), "C: hop 2"); diff --git a/httpclient5/src/test/java/org/apache/hc/client5/http/classic/methods/TestHttpRequestBase.java b/httpclient5/src/test/java/org/apache/hc/client5/http/classic/methods/TestHttpRequestBase.java index 7103294ae..7854d8acf 100644 --- a/httpclient5/src/test/java/org/apache/hc/client5/http/classic/methods/TestHttpRequestBase.java +++ b/httpclient5/src/test/java/org/apache/hc/client5/http/classic/methods/TestHttpRequestBase.java @@ -176,7 +176,7 @@ class TestHttpRequestBase { final Set methods = httpOptions.getAllowedMethods(response); assertAll("Must all pass", () -> assertFalse(methods.isEmpty()), - () -> assertEquals(methods.size(), 3), + () -> assertEquals(3, methods.size()), () -> assertTrue(methods.containsAll(Stream.of("HEAD", "DELETE", "GET") .collect(Collectors.toCollection(HashSet::new)))) ); diff --git a/httpclient5/src/test/java/org/apache/hc/client5/http/impl/classic/TestRedirectExec.java b/httpclient5/src/test/java/org/apache/hc/client5/http/impl/classic/TestRedirectExec.java index 4a21390a1..2bbedebe6 100644 --- a/httpclient5/src/test/java/org/apache/hc/client5/http/impl/classic/TestRedirectExec.java +++ b/httpclient5/src/test/java/org/apache/hc/client5/http/impl/classic/TestRedirectExec.java @@ -404,9 +404,9 @@ class TestRedirectExec { final ClassicHttpRequest request2 = allValues.get(1); final ClassicHttpRequest request3 = allValues.get(2); Assertions.assertSame(request, request1); - Assertions.assertEquals(request1.getMethod(), "PUT"); - Assertions.assertEquals(request2.getMethod(), "GET"); - Assertions.assertEquals(request3.getMethod(), "GET"); + Assertions.assertEquals("PUT", request1.getMethod()); + Assertions.assertEquals("GET", request2.getMethod()); + Assertions.assertEquals("GET", request3.getMethod()); } private static class HttpRequestMatcher implements ArgumentMatcher {