From d77112f608ed188a899acb2b9940118b19568768 Mon Sep 17 00:00:00 2001 From: Arturo Bernal Date: Sun, 13 Jun 2021 13:30:21 +0200 Subject: [PATCH] Replace assert calls by simpler but equivalent calls. --- .../http/cache/TestHttpCacheEntry.java | 5 +- .../cache/TestProtocolRecommendations.java | 5 +- .../impl/cache/TestProtocolRequirements.java | 10 +-- .../client5/http/auth/TestAuthChallenge.java | 4 +- .../hc/client5/http/auth/TestAuthScope.java | 46 +++++------ .../hc/client5/http/auth/TestCredentials.java | 42 +++++----- .../http/config/TestRequestConfig.java | 28 +++---- .../http/cookie/TestCookiePathComparator.java | 16 ++-- .../cookie/TestCookiePriorityComparator.java | 12 +-- .../http/entity/TestDecompressingEntity.java | 4 +- .../mime/TestMultipartFormHttpEntity.java | 10 +-- .../impl/auth/TestAuthChallengeParser.java | 18 ++--- .../auth/TestBasicCredentialsProvider.java | 2 +- .../http/impl/auth/TestDigestScheme.java | 14 ++-- .../classic/TestCookieIdentityComparator.java | 20 ++--- .../http/impl/classic/TestRedirectExec.java | 4 +- .../impl/cookie/TestRFC6265CookieSpec.java | 2 +- .../TestBasicHttpClientConnectionManager.java | 10 +-- ...estPoolingHttpClientConnectionManager.java | 2 +- .../http/impl/routing/TestRouteTracker.java | 78 ++++++++---------- .../http/psl/TestPublicSuffixMatcher.java | 48 +++++------ .../client5/http/routing/TestHttpRoute.java | 81 ++++++++----------- .../hc/client5/http/utils/TestURIUtils.java | 12 +-- 23 files changed, 223 insertions(+), 250 deletions(-) diff --git a/httpclient5-cache/src/test/java/org/apache/hc/client5/http/cache/TestHttpCacheEntry.java b/httpclient5-cache/src/test/java/org/apache/hc/client5/http/cache/TestHttpCacheEntry.java index 791ae61d6..7401b9aeb 100644 --- a/httpclient5-cache/src/test/java/org/apache/hc/client5/http/cache/TestHttpCacheEntry.java +++ b/httpclient5-cache/src/test/java/org/apache/hc/client5/http/cache/TestHttpCacheEntry.java @@ -28,6 +28,7 @@ package org.apache.hc.client5.http.cache; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertNotEquals; import static org.junit.Assert.assertNotNull; import static org.junit.Assert.assertNull; import static org.junit.Assert.assertSame; @@ -103,7 +104,7 @@ public class TestHttpCacheEntry { new BasicHeader("bar", "barValue2") }; entry = makeEntry(headers); - assertEquals(null, entry.getFirstHeader("quux")); + assertNull(entry.getFirstHeader("quux")); } @Test @@ -260,7 +261,7 @@ public class TestHttpCacheEntry { entry = new HttpCacheEntry(new Date(), new Date(), HttpStatus.SC_OK, new Header[]{}, mockResource); assertNotNull(entry.toString()); - assertFalse("".equals(entry.toString())); + assertNotEquals("", entry.toString()); } @Test diff --git a/httpclient5-cache/src/test/java/org/apache/hc/client5/http/impl/cache/TestProtocolRecommendations.java b/httpclient5-cache/src/test/java/org/apache/hc/client5/http/impl/cache/TestProtocolRecommendations.java index ef250060e..f8f8a1e11 100644 --- a/httpclient5-cache/src/test/java/org/apache/hc/client5/http/impl/cache/TestProtocolRecommendations.java +++ b/httpclient5-cache/src/test/java/org/apache/hc/client5/http/impl/cache/TestProtocolRecommendations.java @@ -28,6 +28,7 @@ package org.apache.hc.client5.http.impl.cache; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertNotEquals; import static org.junit.Assert.assertNotNull; import static org.junit.Assert.assertNull; import static org.junit.Assert.assertTrue; @@ -395,7 +396,7 @@ public class TestProtocolRecommendations extends AbstractProtocolTest { verifyMocks(); if (result != null) { - assertFalse(result.getCode() == HttpStatus.SC_OK); + assertNotEquals(HttpStatus.SC_OK, result.getCode()); } } @@ -1226,7 +1227,7 @@ public class TestProtocolRecommendations extends AbstractProtocolTest { final Iterator it = MessageSupport.iterate(captured, HttpHeaders.IF_NONE_MATCH); while (it.hasNext()) { final HeaderElement elt = it.next(); - assertFalse("\"etag2\"".equals(elt.toString())); + assertNotEquals("\"etag2\"", elt.toString()); } } diff --git a/httpclient5-cache/src/test/java/org/apache/hc/client5/http/impl/cache/TestProtocolRequirements.java b/httpclient5-cache/src/test/java/org/apache/hc/client5/http/impl/cache/TestProtocolRequirements.java index 25d52ea9e..78c374205 100644 --- a/httpclient5-cache/src/test/java/org/apache/hc/client5/http/impl/cache/TestProtocolRequirements.java +++ b/httpclient5-cache/src/test/java/org/apache/hc/client5/http/impl/cache/TestProtocolRequirements.java @@ -1089,7 +1089,7 @@ public class TestProtocolRequirements extends AbstractProtocolTest { Assert.assertTrue("multipart/byteranges".equalsIgnoreCase(elt.getName())); Assert.assertNotNull(elt.getParameterByName("boundary")); Assert.assertNotNull(elt.getParameterByName("boundary").getValue()); - Assert.assertFalse("".equals(elt.getParameterByName("boundary").getValue().trim())); + Assert.assertNotEquals("", elt.getParameterByName("boundary").getValue().trim()); } } } @@ -2659,7 +2659,7 @@ public class TestProtocolRequirements extends AbstractProtocolTest { request.setHeader("If-Range", "W/\"etag\""); final ClassicHttpResponse response = testRequestWithWeakETagValidatorIsNotAllowed("If-Range"); - Assert.assertTrue(response.getCode() == HttpStatus.SC_BAD_REQUEST); + Assert.assertEquals(HttpStatus.SC_BAD_REQUEST, response.getCode()); } @Test @@ -2735,7 +2735,7 @@ public class TestProtocolRequirements extends AbstractProtocolTest { final ClassicHttpResponse result = execute(req2); verifyMocks(); - Assert.assertFalse(HttpStatus.SC_PARTIAL_CONTENT == result.getCode()); + Assert.assertNotEquals(HttpStatus.SC_PARTIAL_CONTENT, result.getCode()); } /* @@ -2846,7 +2846,7 @@ public class TestProtocolRequirements extends AbstractProtocolTest { final ClassicHttpResponse result = execute(req2); verifyMocks(); - Assert.assertFalse(HttpStatus.SC_NOT_MODIFIED == result.getCode()); + Assert.assertNotEquals(HttpStatus.SC_NOT_MODIFIED, result.getCode()); } @Test @@ -5365,7 +5365,7 @@ public class TestProtocolRequirements extends AbstractProtocolTest { final Iterator it = MessageSupport.iterate(result, HttpHeaders.VARY); while (it.hasNext()) { final HeaderElement elt = it.next(); - Assert.assertFalse("*".equals(elt.getName())); + Assert.assertNotEquals("*", elt.getName()); } } diff --git a/httpclient5/src/test/java/org/apache/hc/client5/http/auth/TestAuthChallenge.java b/httpclient5/src/test/java/org/apache/hc/client5/http/auth/TestAuthChallenge.java index ff26159e2..ffb66b3a4 100644 --- a/httpclient5/src/test/java/org/apache/hc/client5/http/auth/TestAuthChallenge.java +++ b/httpclient5/src/test/java/org/apache/hc/client5/http/auth/TestAuthChallenge.java @@ -40,7 +40,7 @@ public class TestAuthChallenge { final AuthChallenge authChallenge = new AuthChallenge(ChallengeType.TARGET, StandardAuthScheme.BASIC, "blah", null); Assert.assertEquals(StandardAuthScheme.BASIC, authChallenge.getSchemeName()); Assert.assertEquals("blah", authChallenge.getValue()); - Assert.assertEquals(null, authChallenge.getParams()); + Assert.assertNull(authChallenge.getParams()); Assert.assertEquals(StandardAuthScheme.BASIC + " blah", authChallenge.toString()); } @@ -49,7 +49,7 @@ public class TestAuthChallenge { final AuthChallenge authChallenge = new AuthChallenge(ChallengeType.TARGET, StandardAuthScheme.BASIC, null, Arrays.asList(new BasicNameValuePair("blah", "this"), new BasicNameValuePair("blah", "that"))); Assert.assertEquals(StandardAuthScheme.BASIC, authChallenge.getSchemeName()); - Assert.assertEquals(null, authChallenge.getValue()); + Assert.assertNull(authChallenge.getValue()); Assert.assertNotNull(authChallenge.getParams()); Assert.assertEquals(StandardAuthScheme.BASIC + " [blah=this, blah=that]", authChallenge.toString()); } diff --git a/httpclient5/src/test/java/org/apache/hc/client5/http/auth/TestAuthScope.java b/httpclient5/src/test/java/org/apache/hc/client5/http/auth/TestAuthScope.java index 11841efb3..1ea6c8147 100644 --- a/httpclient5/src/test/java/org/apache/hc/client5/http/auth/TestAuthScope.java +++ b/httpclient5/src/test/java/org/apache/hc/client5/http/auth/TestAuthScope.java @@ -50,10 +50,10 @@ public class TestAuthScope { public void testByOrigin() { final HttpHost host = new HttpHost("http", "somehost", 8080); final AuthScope authscope = new AuthScope(host); - Assert.assertEquals(null, authscope.getSchemeName()); + Assert.assertNull(authscope.getSchemeName()); Assert.assertEquals("somehost", authscope.getHost()); Assert.assertEquals(8080, authscope.getPort()); - Assert.assertEquals(null, authscope.getRealm()); + Assert.assertNull(authscope.getRealm()); Assert.assertEquals("http", authscope.getProtocol()); Assert.assertEquals(" http://somehost:8080", authscope.toString()); } @@ -61,10 +61,10 @@ public class TestAuthScope { @Test public void testMixedCaseHostname() { final AuthScope authscope = new AuthScope("SomeHost", 80); - Assert.assertEquals(null, authscope.getSchemeName()); + Assert.assertNull(authscope.getSchemeName()); Assert.assertEquals("somehost", authscope.getHost()); Assert.assertEquals(80, authscope.getPort()); - Assert.assertEquals(null, authscope.getRealm()); + Assert.assertNull(authscope.getRealm()); Assert.assertEquals(" ://somehost:80", authscope.toString()); } @@ -78,10 +78,10 @@ public class TestAuthScope { @Test public void testBasicsAllOptional() { final AuthScope authscope = new AuthScope(null, null, -1, null, null); - Assert.assertEquals(null, authscope.getSchemeName()); - Assert.assertEquals(null, authscope.getHost()); + Assert.assertNull(authscope.getSchemeName()); + Assert.assertNull(authscope.getHost()); Assert.assertEquals(-1, authscope.getPort()); - Assert.assertEquals(null, authscope.getRealm()); + Assert.assertNull(authscope.getRealm()); Assert.assertEquals(" ://:", authscope.toString()); } @@ -126,14 +126,14 @@ public class TestAuthScope { final AuthScope authscope6 = new AuthScope("http", "somehost", 80, "somerealm", "someotherscheme"); final AuthScope authscope7 = new AuthScope("https", "somehost", 80, "somerealm", "somescheme"); final AuthScope authscope8 = new AuthScope("https", "somehost", 80, "somerealm", "SomeScheme"); - Assert.assertTrue(authscope1.equals(authscope1)); - Assert.assertFalse(authscope1.equals(authscope2)); - Assert.assertTrue(authscope1.equals(authscope3)); - Assert.assertFalse(authscope1.equals(authscope4)); - Assert.assertFalse(authscope1.equals(authscope5)); - Assert.assertFalse(authscope1.equals(authscope6)); - Assert.assertFalse(authscope1.equals(authscope7)); - Assert.assertTrue(authscope7.equals(authscope8)); + Assert.assertEquals(authscope1, authscope1); + Assert.assertNotEquals(authscope1, authscope2); + Assert.assertEquals(authscope1, authscope3); + Assert.assertNotEquals(authscope1, authscope4); + Assert.assertNotEquals(authscope1, authscope5); + Assert.assertNotEquals(authscope1, authscope6); + Assert.assertNotEquals(authscope1, authscope7); + Assert.assertEquals(authscope7, authscope8); } @Test @@ -146,14 +146,14 @@ public class TestAuthScope { final AuthScope authscope6 = new AuthScope("http", "somehost", 80, "somerealm", "someotherscheme"); final AuthScope authscope7 = new AuthScope("https", "somehost", 80, "somerealm", "somescheme"); final AuthScope authscope8 = new AuthScope("https", "somehost", 80, "somerealm", "SomeScheme"); - Assert.assertTrue(authscope1.hashCode() == authscope1.hashCode()); - Assert.assertFalse(authscope1.hashCode() == authscope2.hashCode()); - Assert.assertTrue(authscope1.hashCode() == authscope3.hashCode()); - Assert.assertFalse(authscope1.hashCode() == authscope4.hashCode()); - Assert.assertFalse(authscope1.hashCode() == authscope5.hashCode()); - Assert.assertFalse(authscope1.hashCode() == authscope6.hashCode()); - Assert.assertFalse(authscope1.hashCode() == authscope7.hashCode()); - Assert.assertTrue(authscope7.hashCode() == authscope8.hashCode()); + Assert.assertEquals(authscope1.hashCode(), authscope1.hashCode()); + Assert.assertNotEquals(authscope1.hashCode(), authscope2.hashCode()); + Assert.assertEquals(authscope1.hashCode(), authscope3.hashCode()); + Assert.assertNotEquals(authscope1.hashCode(), authscope4.hashCode()); + Assert.assertNotEquals(authscope1.hashCode(), authscope5.hashCode()); + Assert.assertNotEquals(authscope1.hashCode(), authscope6.hashCode()); + Assert.assertNotEquals(authscope1.hashCode(), authscope7.hashCode()); + Assert.assertEquals(authscope7.hashCode(), authscope8.hashCode()); } } diff --git a/httpclient5/src/test/java/org/apache/hc/client5/http/auth/TestCredentials.java b/httpclient5/src/test/java/org/apache/hc/client5/http/auth/TestCredentials.java index 60177d343..199ded293 100644 --- a/httpclient5/src/test/java/org/apache/hc/client5/http/auth/TestCredentials.java +++ b/httpclient5/src/test/java/org/apache/hc/client5/http/auth/TestCredentials.java @@ -51,7 +51,7 @@ public class TestCredentials { Assert.assertEquals("name", creds2.getUserName()); Assert.assertEquals(new BasicUserPrincipal("name"), creds2.getUserPrincipal()); - Assert.assertEquals(null, creds2.getPassword()); + Assert.assertNull(creds2.getPassword()); Assert.assertEquals("[principal: name]", creds2.toString()); } @@ -70,7 +70,7 @@ public class TestCredentials { Assert.assertEquals("name", creds2.getUserName()); Assert.assertEquals(new NTUserPrincipal(null, "name"), creds2.getUserPrincipal()); - Assert.assertEquals(null, creds2.getPassword()); + Assert.assertNull(creds2.getPassword()); Assert.assertEquals("[principal: name][workstation: null][netbiosDomain: null]", creds2.toString()); } @@ -98,9 +98,9 @@ public class TestCredentials { final UsernamePasswordCredentials creds3 = new UsernamePasswordCredentials( "name", "otherpwd".toCharArray()); - Assert.assertTrue(creds1.equals(creds1)); - Assert.assertFalse(creds1.equals(creds2)); - Assert.assertTrue(creds1.equals(creds3)); + Assert.assertEquals(creds1, creds1); + Assert.assertNotEquals(creds1, creds2); + Assert.assertEquals(creds1, creds3); } @Test @@ -126,13 +126,13 @@ public class TestCredentials { Assert.assertTrue(creds1.hashCode() == creds1.hashCode()); Assert.assertTrue(creds1.hashCode() != creds2.hashCode()); - Assert.assertTrue(creds1.hashCode() == creds3.hashCode()); - Assert.assertFalse(creds1.hashCode() == creds4.hashCode()); - Assert.assertFalse(creds1.hashCode() == creds5.hashCode()); - Assert.assertFalse(creds1.hashCode() == creds6.hashCode()); - Assert.assertFalse(creds1.hashCode() == creds7.hashCode()); - Assert.assertTrue(creds8.hashCode() == creds5.hashCode()); - Assert.assertTrue(creds9.hashCode() == creds7.hashCode()); + Assert.assertEquals(creds1.hashCode(), creds3.hashCode()); + Assert.assertNotEquals(creds1.hashCode(), creds4.hashCode()); + Assert.assertNotEquals(creds1.hashCode(), creds5.hashCode()); + Assert.assertNotEquals(creds1.hashCode(), creds6.hashCode()); + Assert.assertNotEquals(creds1.hashCode(), creds7.hashCode()); + Assert.assertEquals(creds8.hashCode(), creds5.hashCode()); + Assert.assertEquals(creds9.hashCode(), creds7.hashCode()); } @Test @@ -156,15 +156,15 @@ public class TestCredentials { final NTCredentials creds9 = new NTCredentials( "name","pwd".toCharArray(), "somehost", null); - Assert.assertTrue(creds1.equals(creds1)); - Assert.assertFalse(creds1.equals(creds2)); - Assert.assertTrue(creds1.equals(creds3)); - Assert.assertFalse(creds1.equals(creds4)); - Assert.assertFalse(creds1.equals(creds5)); - Assert.assertFalse(creds1.equals(creds6)); - Assert.assertFalse(creds1.equals(creds7)); - Assert.assertTrue(creds8.equals(creds5)); - Assert.assertTrue(creds9.equals(creds7)); + Assert.assertEquals(creds1, creds1); + Assert.assertNotEquals(creds1, creds2); + Assert.assertEquals(creds1, creds3); + Assert.assertNotEquals(creds1, creds4); + Assert.assertNotEquals(creds1, creds5); + Assert.assertNotEquals(creds1, creds6); + Assert.assertNotEquals(creds1, creds7); + Assert.assertEquals(creds8, creds5); + Assert.assertEquals(creds9, creds7); } diff --git a/httpclient5/src/test/java/org/apache/hc/client5/http/config/TestRequestConfig.java b/httpclient5/src/test/java/org/apache/hc/client5/http/config/TestRequestConfig.java index 572bba0d4..b3ae04d30 100644 --- a/httpclient5/src/test/java/org/apache/hc/client5/http/config/TestRequestConfig.java +++ b/httpclient5/src/test/java/org/apache/hc/client5/http/config/TestRequestConfig.java @@ -49,16 +49,16 @@ public class TestRequestConfig { public void testDefaults() { final RequestConfig config = RequestConfig.DEFAULT; Assert.assertEquals(Timeout.ofMinutes(3), config.getConnectionRequestTimeout()); - Assert.assertEquals(false, config.isExpectContinueEnabled()); - Assert.assertEquals(true, config.isAuthenticationEnabled()); - Assert.assertEquals(true, config.isRedirectsEnabled()); - Assert.assertEquals(false, config.isCircularRedirectsAllowed()); + Assert.assertFalse(config.isExpectContinueEnabled()); + Assert.assertTrue(config.isAuthenticationEnabled()); + Assert.assertTrue(config.isRedirectsEnabled()); + Assert.assertFalse(config.isCircularRedirectsAllowed()); Assert.assertEquals(50, config.getMaxRedirects()); - Assert.assertEquals(null, config.getCookieSpec()); - Assert.assertEquals(null, config.getProxy()); - Assert.assertEquals(null, config.getTargetPreferredAuthSchemes()); - Assert.assertEquals(null, config.getProxyPreferredAuthSchemes()); - Assert.assertEquals(true, config.isContentCompressionEnabled()); + Assert.assertNull(config.getCookieSpec()); + Assert.assertNull(config.getProxy()); + Assert.assertNull(config.getTargetPreferredAuthSchemes()); + Assert.assertNull(config.getProxyPreferredAuthSchemes()); + Assert.assertTrue(config.isContentCompressionEnabled()); } @Test @@ -77,15 +77,15 @@ public class TestRequestConfig { .build(); final RequestConfig config = RequestConfig.copy(config0).build(); Assert.assertEquals(TimeValue.ofMilliseconds(44), config.getConnectionRequestTimeout()); - Assert.assertEquals(true, config.isExpectContinueEnabled()); - Assert.assertEquals(false, config.isAuthenticationEnabled()); - Assert.assertEquals(false, config.isRedirectsEnabled()); - Assert.assertEquals(true, config.isCircularRedirectsAllowed()); + Assert.assertTrue(config.isExpectContinueEnabled()); + Assert.assertFalse(config.isAuthenticationEnabled()); + Assert.assertFalse(config.isRedirectsEnabled()); + Assert.assertTrue(config.isCircularRedirectsAllowed()); Assert.assertEquals(100, config.getMaxRedirects()); Assert.assertEquals(StandardCookieSpec.STRICT, config.getCookieSpec()); Assert.assertEquals(Collections.singletonList(StandardAuthScheme.NTLM), config.getTargetPreferredAuthSchemes()); Assert.assertEquals(Collections.singletonList(StandardAuthScheme.DIGEST), config.getProxyPreferredAuthSchemes()); - Assert.assertEquals(false, config.isContentCompressionEnabled()); + Assert.assertFalse(config.isContentCompressionEnabled()); } } diff --git a/httpclient5/src/test/java/org/apache/hc/client5/http/cookie/TestCookiePathComparator.java b/httpclient5/src/test/java/org/apache/hc/client5/http/cookie/TestCookiePathComparator.java index 4dd9afc5f..8b6c90698 100644 --- a/httpclient5/src/test/java/org/apache/hc/client5/http/cookie/TestCookiePathComparator.java +++ b/httpclient5/src/test/java/org/apache/hc/client5/http/cookie/TestCookiePathComparator.java @@ -67,8 +67,8 @@ public class TestCookiePathComparator { final BasicClientCookie cookie2 = new BasicClientCookie("name1", "value"); cookie2.setPath("/a"); final Comparator comparator = new CookiePathComparator(); - Assert.assertTrue(comparator.compare(cookie1, cookie2) == 0); - Assert.assertTrue(comparator.compare(cookie2, cookie1) == 0); + Assert.assertEquals(0, comparator.compare(cookie1, cookie2)); + Assert.assertEquals(0, comparator.compare(cookie2, cookie1)); } @Test @@ -78,8 +78,8 @@ public class TestCookiePathComparator { final BasicClientCookie cookie2 = new BasicClientCookie("name1", "value"); cookie2.setPath("/a"); final Comparator comparator = new CookiePathComparator(); - Assert.assertTrue(comparator.compare(cookie1, cookie2) == 0); - Assert.assertTrue(comparator.compare(cookie2, cookie1) == 0); + Assert.assertEquals(0, comparator.compare(cookie1, cookie2)); + Assert.assertEquals(0, comparator.compare(cookie2, cookie1)); } @Test @@ -89,8 +89,8 @@ public class TestCookiePathComparator { final BasicClientCookie cookie2 = new BasicClientCookie("name1", "value"); cookie2.setPath("/"); final Comparator comparator = new CookiePathComparator(); - Assert.assertTrue(comparator.compare(cookie1, cookie2) == 0); - Assert.assertTrue(comparator.compare(cookie2, cookie1) == 0); + Assert.assertEquals(0, comparator.compare(cookie1, cookie2)); + Assert.assertEquals(0, comparator.compare(cookie2, cookie1)); } @Test @@ -100,8 +100,8 @@ public class TestCookiePathComparator { final BasicClientCookie cookie2 = new BasicClientCookie("name1", "value"); cookie2.setPath("/that"); final Comparator comparator = new CookiePathComparator(); - Assert.assertTrue(comparator.compare(cookie1, cookie2) == 0); - Assert.assertTrue(comparator.compare(cookie2, cookie1) == 0); + Assert.assertEquals(0, comparator.compare(cookie1, cookie2)); + Assert.assertEquals(0, comparator.compare(cookie2, cookie1)); } } diff --git a/httpclient5/src/test/java/org/apache/hc/client5/http/cookie/TestCookiePriorityComparator.java b/httpclient5/src/test/java/org/apache/hc/client5/http/cookie/TestCookiePriorityComparator.java index bd55aed52..f032a19e9 100644 --- a/httpclient5/src/test/java/org/apache/hc/client5/http/cookie/TestCookiePriorityComparator.java +++ b/httpclient5/src/test/java/org/apache/hc/client5/http/cookie/TestCookiePriorityComparator.java @@ -63,8 +63,8 @@ public class TestCookiePriorityComparator { cookie1.setPath("/a"); final BasicClientCookie cookie2 = new BasicClientCookie("name1", "value"); cookie2.setPath("/a"); - Assert.assertTrue(comparator.compare(cookie1, cookie2) == 0); - Assert.assertTrue(comparator.compare(cookie2, cookie1) == 0); + Assert.assertEquals(0, comparator.compare(cookie1, cookie2)); + Assert.assertEquals(0, comparator.compare(cookie2, cookie1)); } @Test @@ -83,8 +83,8 @@ public class TestCookiePriorityComparator { cookie1.setPath(null); final BasicClientCookie cookie2 = new BasicClientCookie("name1", "value"); cookie2.setPath("/"); - Assert.assertTrue(comparator.compare(cookie1, cookie2) == 0); - Assert.assertTrue(comparator.compare(cookie2, cookie1) == 0); + Assert.assertEquals(0, comparator.compare(cookie1, cookie2)); + Assert.assertEquals(0, comparator.compare(cookie2, cookie1)); } @Test @@ -93,8 +93,8 @@ public class TestCookiePriorityComparator { cookie1.setPath("/this"); final BasicClientCookie cookie2 = new BasicClientCookie("name1", "value"); cookie2.setPath("/that"); - Assert.assertTrue(comparator.compare(cookie1, cookie2) == 0); - Assert.assertTrue(comparator.compare(cookie2, cookie1) == 0); + Assert.assertEquals(0, comparator.compare(cookie1, cookie2)); + Assert.assertEquals(0, comparator.compare(cookie2, cookie1)); } @Test diff --git a/httpclient5/src/test/java/org/apache/hc/client5/http/entity/TestDecompressingEntity.java b/httpclient5/src/test/java/org/apache/hc/client5/http/entity/TestDecompressingEntity.java index 5384b6b24..d2cc07b93 100644 --- a/httpclient5/src/test/java/org/apache/hc/client5/http/entity/TestDecompressingEntity.java +++ b/httpclient5/src/test/java/org/apache/hc/client5/http/entity/TestDecompressingEntity.java @@ -56,7 +56,7 @@ public class TestDecompressingEntity { Assert.assertEquals(639479525L, crc32.getValue()); final InputStream in1 = entity.getContent(); final InputStream in2 = entity.getContent(); - Assert.assertTrue(in1 != in2); + Assert.assertNotSame(in1, in2); } @Test @@ -71,7 +71,7 @@ public class TestDecompressingEntity { Assert.assertEquals(639479525L, crc32.getValue()); final InputStream in1 = entity.getContent(); final InputStream in2 = entity.getContent(); - Assert.assertTrue(in1 == in2); + Assert.assertSame(in1, in2); EntityUtils.consume(entity); EntityUtils.consume(entity); } diff --git a/httpclient5/src/test/java/org/apache/hc/client5/http/entity/mime/TestMultipartFormHttpEntity.java b/httpclient5/src/test/java/org/apache/hc/client5/http/entity/mime/TestMultipartFormHttpEntity.java index 76ea284b9..efdff445c 100644 --- a/httpclient5/src/test/java/org/apache/hc/client5/http/entity/mime/TestMultipartFormHttpEntity.java +++ b/httpclient5/src/test/java/org/apache/hc/client5/http/entity/mime/TestMultipartFormHttpEntity.java @@ -95,7 +95,7 @@ public class TestMultipartFormHttpEntity { Assert.assertFalse(entity.isStreaming()); final long len = entity.getContentLength(); - Assert.assertTrue(len == entity.getContentLength()); + Assert.assertEquals(len, entity.getContentLength()); ByteArrayOutputStream out = new ByteArrayOutputStream(); entity.writeTo(out); @@ -103,9 +103,9 @@ public class TestMultipartFormHttpEntity { byte[] bytes = out.toByteArray(); Assert.assertNotNull(bytes); - Assert.assertTrue(bytes.length == len); + Assert.assertEquals(bytes.length, len); - Assert.assertTrue(len == entity.getContentLength()); + Assert.assertEquals(len, entity.getContentLength()); out = new ByteArrayOutputStream(); entity.writeTo(out); @@ -113,7 +113,7 @@ public class TestMultipartFormHttpEntity { bytes = out.toByteArray(); Assert.assertNotNull(bytes); - Assert.assertTrue(bytes.length == len); + Assert.assertEquals(bytes.length, len); } @Test @@ -128,7 +128,7 @@ public class TestMultipartFormHttpEntity { Assert.assertTrue(entity.isChunked()); Assert.assertTrue(entity.isStreaming()); - Assert.assertTrue(entity.getContentLength() == -1); + Assert.assertEquals(-1, entity.getContentLength()); } } diff --git a/httpclient5/src/test/java/org/apache/hc/client5/http/impl/auth/TestAuthChallengeParser.java b/httpclient5/src/test/java/org/apache/hc/client5/http/impl/auth/TestAuthChallengeParser.java index 60dee1ad4..aa4232681 100644 --- a/httpclient5/src/test/java/org/apache/hc/client5/http/impl/auth/TestAuthChallengeParser.java +++ b/httpclient5/src/test/java/org/apache/hc/client5/http/impl/auth/TestAuthChallengeParser.java @@ -133,7 +133,7 @@ public class TestAuthChallengeParser { Assert.assertEquals(1, challenges.size()); final AuthChallenge challenge1 = challenges.get(0); Assert.assertEquals(StandardAuthScheme.BASIC, challenge1.getSchemeName()); - Assert.assertEquals(null, challenge1.getValue()); + Assert.assertNull(challenge1.getValue()); final List params = challenge1.getParams(); Assert.assertNotNull(params); Assert.assertEquals(1, params.size()); @@ -150,7 +150,7 @@ public class TestAuthChallengeParser { Assert.assertEquals(1, challenges.size()); final AuthChallenge challenge1 = challenges.get(0); Assert.assertEquals(StandardAuthScheme.BASIC, challenge1.getSchemeName()); - Assert.assertEquals(null, challenge1.getValue()); + Assert.assertNull(challenge1.getValue()); final List params = challenge1.getParams(); Assert.assertNotNull(params); Assert.assertEquals(1, params.size()); @@ -190,7 +190,7 @@ public class TestAuthChallengeParser { final AuthChallenge challenge1 = challenges.get(0); Assert.assertEquals(StandardAuthScheme.BASIC, challenge1.getSchemeName()); - Assert.assertEquals(null, challenge1.getValue()); + Assert.assertNull(challenge1.getValue()); final List params1 = challenge1.getParams(); Assert.assertNotNull(params1); Assert.assertEquals(3, params1.size()); @@ -200,7 +200,7 @@ public class TestAuthChallengeParser { final AuthChallenge challenge2 = challenges.get(1); Assert.assertEquals(StandardAuthScheme.BASIC, challenge2.getSchemeName()); - Assert.assertEquals(null, challenge2.getValue()); + Assert.assertNull(challenge2.getValue()); final List params2 = challenge2.getParams(); Assert.assertNotNull(params2); Assert.assertEquals(4, params2.size()); @@ -222,7 +222,7 @@ public class TestAuthChallengeParser { final AuthChallenge challenge1 = challenges.get(0); Assert.assertEquals(StandardAuthScheme.BASIC, challenge1.getSchemeName()); - Assert.assertEquals(null, challenge1.getValue()); + Assert.assertNull(challenge1.getValue()); final List params1 = challenge1.getParams(); Assert.assertNotNull(params1); Assert.assertEquals(2, params1.size()); @@ -231,7 +231,7 @@ public class TestAuthChallengeParser { final AuthChallenge challenge2 = challenges.get(1); Assert.assertEquals(StandardAuthScheme.BASIC, challenge2.getSchemeName()); - Assert.assertEquals(null, challenge2.getValue()); + Assert.assertNull(challenge2.getValue()); final List params2 = challenge2.getParams(); Assert.assertNotNull(params2); Assert.assertEquals(1, params2.size()); @@ -249,7 +249,7 @@ public class TestAuthChallengeParser { final AuthChallenge challenge1 = challenges.get(0); Assert.assertEquals("This", challenge1.getSchemeName()); - Assert.assertEquals(null, challenge1.getValue()); + Assert.assertNull(challenge1.getValue()); Assert.assertNull(challenge1.getParams()); } @@ -306,7 +306,7 @@ public class TestAuthChallengeParser { final AuthChallenge challenge1 = challenges.get(0); Assert.assertEquals("blah", challenge1.getSchemeName()); - Assert.assertEquals(null, challenge1.getValue()); + Assert.assertNull(challenge1.getValue()); final List params1 = challenge1.getParams(); Assert.assertNotNull(params1); Assert.assertEquals(2, params1.size()); @@ -324,7 +324,7 @@ public class TestAuthChallengeParser { Assert.assertEquals(1, challenges.size()); final AuthChallenge challenge1 = challenges.get(0); Assert.assertEquals(StandardAuthScheme.NTLM, challenge1.getSchemeName()); - Assert.assertEquals(null, challenge1.getValue()); + Assert.assertNull(challenge1.getValue()); } @Test diff --git a/httpclient5/src/test/java/org/apache/hc/client5/http/impl/auth/TestBasicCredentialsProvider.java b/httpclient5/src/test/java/org/apache/hc/client5/http/impl/auth/TestBasicCredentialsProvider.java index dfbea8252..1e4e3e33c 100644 --- a/httpclient5/src/test/java/org/apache/hc/client5/http/impl/auth/TestBasicCredentialsProvider.java +++ b/httpclient5/src/test/java/org/apache/hc/client5/http/impl/auth/TestBasicCredentialsProvider.java @@ -61,7 +61,7 @@ public class TestBasicCredentialsProvider { @Test public void testBasicCredentialsProviderNoCredentials() { final BasicCredentialsProvider state = new BasicCredentialsProvider(); - Assert.assertEquals(null, state.getCredentials(BOGUS, null)); + Assert.assertNull(state.getCredentials(BOGUS, null)); } @Test diff --git a/httpclient5/src/test/java/org/apache/hc/client5/http/impl/auth/TestDigestScheme.java b/httpclient5/src/test/java/org/apache/hc/client5/http/impl/auth/TestDigestScheme.java index 7a402d712..e57a24197 100644 --- a/httpclient5/src/test/java/org/apache/hc/client5/http/impl/auth/TestDigestScheme.java +++ b/httpclient5/src/test/java/org/apache/hc/client5/http/impl/auth/TestDigestScheme.java @@ -308,11 +308,11 @@ public class TestDigestScheme { Assert.assertEquals("/", table.get("uri")); Assert.assertEquals(nonce, table.get("nonce")); Assert.assertEquals(1, Integer.parseInt(table.get("nc"),16)); - Assert.assertTrue(null != table.get("cnonce")); + Assert.assertNotNull(table.get("cnonce")); Assert.assertEquals("SomeString", table.get("opaque")); Assert.assertEquals("auth", table.get("qop")); //@TODO: add better check - Assert.assertTrue(null != table.get("response")); + Assert.assertNotNull(table.get("response")); } /** @@ -353,11 +353,11 @@ public class TestDigestScheme { Assert.assertEquals("MD5-sess", table.get("algorithm")); Assert.assertEquals("/", table.get("uri")); Assert.assertEquals(nonce, table.get("nonce")); - Assert.assertTrue(null == table.get("nc")); + Assert.assertNull(table.get("nc")); Assert.assertEquals("SomeString", table.get("opaque")); - Assert.assertTrue(null == table.get("qop")); + Assert.assertNull(table.get("qop")); //@TODO: add better check - Assert.assertTrue(null != table.get("response")); + Assert.assertNotNull(table.get("response")); } /** @@ -561,8 +561,8 @@ public class TestDigestScheme { final String cnonce4 = authscheme.getCnonce(); final String sessionKey4 = authscheme.getA1(); - Assert.assertFalse(cnonce1.equals(cnonce4)); - Assert.assertFalse(sessionKey1.equals(sessionKey4)); + Assert.assertNotEquals(cnonce1, cnonce4); + Assert.assertNotEquals(sessionKey1, sessionKey4); } @Test diff --git a/httpclient5/src/test/java/org/apache/hc/client5/http/impl/classic/TestCookieIdentityComparator.java b/httpclient5/src/test/java/org/apache/hc/client5/http/impl/classic/TestCookieIdentityComparator.java index 8f627f8ce..ade59685b 100644 --- a/httpclient5/src/test/java/org/apache/hc/client5/http/impl/classic/TestCookieIdentityComparator.java +++ b/httpclient5/src/test/java/org/apache/hc/client5/http/impl/classic/TestCookieIdentityComparator.java @@ -41,11 +41,11 @@ public class TestCookieIdentityComparator { final CookieIdentityComparator comparator = new CookieIdentityComparator(); final BasicClientCookie c1 = new BasicClientCookie("name", "value1"); final BasicClientCookie c2 = new BasicClientCookie("name", "value2"); - Assert.assertTrue(comparator.compare(c1, c2) == 0); + Assert.assertEquals(0, comparator.compare(c1, c2)); final BasicClientCookie c3 = new BasicClientCookie("name1", "value"); final BasicClientCookie c4 = new BasicClientCookie("name2", "value"); - Assert.assertFalse(comparator.compare(c3, c4) == 0); + Assert.assertNotEquals(0, comparator.compare(c3, c4)); } @Test @@ -55,13 +55,13 @@ public class TestCookieIdentityComparator { c1.setDomain("www.domain.com"); final BasicClientCookie c2 = new BasicClientCookie("name", "value2"); c2.setDomain("www.domain.com"); - Assert.assertTrue(comparator.compare(c1, c2) == 0); + Assert.assertEquals(0, comparator.compare(c1, c2)); final BasicClientCookie c3 = new BasicClientCookie("name", "value1"); c3.setDomain("www.domain.com"); final BasicClientCookie c4 = new BasicClientCookie("name", "value2"); c4.setDomain("domain.com"); - Assert.assertFalse(comparator.compare(c3, c4) == 0); + Assert.assertNotEquals(0, comparator.compare(c3, c4)); } @Test @@ -71,13 +71,13 @@ public class TestCookieIdentityComparator { c1.setDomain(null); final BasicClientCookie c2 = new BasicClientCookie("name", "value2"); c2.setDomain(null); - Assert.assertTrue(comparator.compare(c1, c2) == 0); + Assert.assertEquals(0, comparator.compare(c1, c2)); final BasicClientCookie c3 = new BasicClientCookie("name", "value1"); c3.setDomain("www.domain.com"); final BasicClientCookie c4 = new BasicClientCookie("name", "value2"); c4.setDomain(null); - Assert.assertFalse(comparator.compare(c3, c4) == 0); + Assert.assertNotEquals(0, comparator.compare(c3, c4)); } @Test @@ -89,7 +89,7 @@ public class TestCookieIdentityComparator { final BasicClientCookie c2 = new BasicClientCookie("name", "value2"); c2.setDomain("www.domain.com"); c2.setPath("/whatever"); - Assert.assertTrue(comparator.compare(c1, c2) == 0); + Assert.assertEquals(0, comparator.compare(c1, c2)); final BasicClientCookie c3 = new BasicClientCookie("name", "value1"); c3.setDomain("www.domain.com"); @@ -97,7 +97,7 @@ public class TestCookieIdentityComparator { final BasicClientCookie c4 = new BasicClientCookie("name", "value2"); c4.setDomain("domain.com"); c4.setPath("/whatever-not"); - Assert.assertFalse(comparator.compare(c3, c4) == 0); + Assert.assertNotEquals(0, comparator.compare(c3, c4)); } @Test @@ -109,7 +109,7 @@ public class TestCookieIdentityComparator { final BasicClientCookie c2 = new BasicClientCookie("name", "value2"); c2.setDomain("www.domain.com"); c2.setPath(null); - Assert.assertTrue(comparator.compare(c1, c2) == 0); + Assert.assertEquals(0, comparator.compare(c1, c2)); final BasicClientCookie c3 = new BasicClientCookie("name", "value1"); c3.setDomain("www.domain.com"); @@ -117,7 +117,7 @@ public class TestCookieIdentityComparator { final BasicClientCookie c4 = new BasicClientCookie("name", "value2"); c4.setDomain("domain.com"); c4.setPath(null); - Assert.assertFalse(comparator.compare(c3, c4) == 0); + Assert.assertNotEquals(0, comparator.compare(c3, c4)); } } 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 339eb1d7e..6a8560488 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 @@ -213,11 +213,11 @@ public class TestRedirectExec { final AuthExchange authExchange1 = context.getAuthExchange(target); Assert.assertNotNull(authExchange1); Assert.assertEquals(AuthExchange.State.UNCHALLENGED, authExchange1.getState()); - Assert.assertEquals(null, authExchange1.getAuthScheme()); + Assert.assertNull(authExchange1.getAuthScheme()); final AuthExchange authExchange2 = context.getAuthExchange(proxy); Assert.assertNotNull(authExchange2); Assert.assertEquals(AuthExchange.State.UNCHALLENGED, authExchange2.getState()); - Assert.assertEquals(null, authExchange2.getAuthScheme()); + Assert.assertNull(authExchange2.getAuthScheme()); } @Test diff --git a/httpclient5/src/test/java/org/apache/hc/client5/http/impl/cookie/TestRFC6265CookieSpec.java b/httpclient5/src/test/java/org/apache/hc/client5/http/impl/cookie/TestRFC6265CookieSpec.java index 822392f3c..79edce62c 100644 --- a/httpclient5/src/test/java/org/apache/hc/client5/http/impl/cookie/TestRFC6265CookieSpec.java +++ b/httpclient5/src/test/java/org/apache/hc/client5/http/impl/cookie/TestRFC6265CookieSpec.java @@ -64,7 +64,7 @@ public class TestRFC6265CookieSpec { Assert.assertEquals("/path", cookie.getPath()); Assert.assertEquals("host", cookie.getDomain()); Assert.assertEquals("stuff", cookie.getAttribute("this")); - Assert.assertEquals(null, cookie.getAttribute("that")); + Assert.assertNull(cookie.getAttribute("that")); Mockito.verify(h1).parse(ArgumentMatchers.any(), ArgumentMatchers.eq("stuff")); Mockito.verify(h2, Mockito.never()).parse(ArgumentMatchers.any(), ArgumentMatchers.anyString()); diff --git a/httpclient5/src/test/java/org/apache/hc/client5/http/impl/io/TestBasicHttpClientConnectionManager.java b/httpclient5/src/test/java/org/apache/hc/client5/http/impl/io/TestBasicHttpClientConnectionManager.java index 65f11ead0..5c07769cf 100644 --- a/httpclient5/src/test/java/org/apache/hc/client5/http/impl/io/TestBasicHttpClientConnectionManager.java +++ b/httpclient5/src/test/java/org/apache/hc/client5/http/impl/io/TestBasicHttpClientConnectionManager.java @@ -127,7 +127,7 @@ public class TestBasicHttpClientConnectionManager { mgr.release(endpoint1, null, TimeValue.ofMilliseconds(100)); Assert.assertEquals(route, mgr.getRoute()); - Assert.assertEquals(null, mgr.getState()); + Assert.assertNull(mgr.getState()); final LeaseRequest connRequest2 = mgr.lease("some-id", route, null); final ConnectionEndpoint conn2 = connRequest2.get(Timeout.ZERO_MILLISECONDS); @@ -183,7 +183,7 @@ public class TestBasicHttpClientConnectionManager { mgr.release(endpoint1, null, TimeValue.NEG_ONE_MILLISECOND); Assert.assertEquals(route1, mgr.getRoute()); - Assert.assertEquals(null, mgr.getState()); + Assert.assertNull(mgr.getState()); final HttpHost target2 = new HttpHost("otherhost", 80); final HttpRoute route2 = new HttpRoute(target2); @@ -214,7 +214,7 @@ public class TestBasicHttpClientConnectionManager { mgr.release(endpoint1, null, TimeValue.ofMilliseconds(10)); Assert.assertEquals(route, mgr.getRoute()); - Assert.assertEquals(null, mgr.getState()); + Assert.assertNull(mgr.getState()); Thread.sleep(50); @@ -294,7 +294,7 @@ public class TestBasicHttpClientConnectionManager { mgr.release(endpoint1, null, TimeValue.ofMilliseconds(10)); Assert.assertEquals(route, mgr.getRoute()); - Assert.assertEquals(null, mgr.getState()); + Assert.assertNull(mgr.getState()); Thread.sleep(50); @@ -321,7 +321,7 @@ public class TestBasicHttpClientConnectionManager { mgr.release(endpoint1, null, TimeValue.NEG_ONE_MILLISECOND); Assert.assertEquals(route, mgr.getRoute()); - Assert.assertEquals(null, mgr.getState()); + Assert.assertNull(mgr.getState()); Thread.sleep(100); diff --git a/httpclient5/src/test/java/org/apache/hc/client5/http/impl/io/TestPoolingHttpClientConnectionManager.java b/httpclient5/src/test/java/org/apache/hc/client5/http/impl/io/TestPoolingHttpClientConnectionManager.java index 83bb9d320..14cce077f 100644 --- a/httpclient5/src/test/java/org/apache/hc/client5/http/impl/io/TestPoolingHttpClientConnectionManager.java +++ b/httpclient5/src/test/java/org/apache/hc/client5/http/impl/io/TestPoolingHttpClientConnectionManager.java @@ -247,7 +247,7 @@ public class TestPoolingHttpClientConnectionManager { mgr.release(endpoint1, "some state", TimeValue.NEG_ONE_MILLISECOND); Mockito.verify(pool).release(entry, false); - Assert.assertEquals(null, entry.getState()); + Assert.assertNull(entry.getState()); } @Test diff --git a/httpclient5/src/test/java/org/apache/hc/client5/http/impl/routing/TestRouteTracker.java b/httpclient5/src/test/java/org/apache/hc/client5/http/impl/routing/TestRouteTracker.java index ef4fd76b1..d33ff5dca 100644 --- a/httpclient5/src/test/java/org/apache/hc/client5/http/impl/routing/TestRouteTracker.java +++ b/httpclient5/src/test/java/org/apache/hc/client5/http/impl/routing/TestRouteTracker.java @@ -92,14 +92,11 @@ public class TestRouteTracker { RouteTracker rt = new RouteTracker(TARGET1, null); Assert.assertEquals("wrong target (target,null)", TARGET1, rt.getTargetHost()); - Assert.assertEquals("wrong local address (target,null)", - null, rt.getLocalAddress()); + Assert.assertNull("wrong local address (target,null)", rt.getLocalAddress()); Assert.assertEquals("wrong hop count (target,null)", 0, rt.getHopCount()); - Assert.assertEquals("wrong proxy (target,null)", - null, rt.getProxyHost()); - Assert.assertEquals("wrong route (target,null)", - null, rt.toRoute()); + Assert.assertNull("wrong proxy (target,null)", rt.getProxyHost()); + Assert.assertNull("wrong route (target,null)", rt.toRoute()); checkCTLS(rt, false, false, false, false); @@ -110,10 +107,8 @@ public class TestRouteTracker { LOCAL61, rt.getLocalAddress()); Assert.assertEquals("wrong hop count (target,local)", 0, rt.getHopCount()); - Assert.assertEquals("wrong proxy (target,local)", - null, rt.getProxyHost()); - Assert.assertEquals("wrong route (target,local)", - null, rt.toRoute()); + Assert.assertNull("wrong proxy (target,local)", rt.getProxyHost()); + Assert.assertNull("wrong route (target,local)", rt.toRoute()); checkCTLS(rt, false, false, false, false); @@ -134,14 +129,11 @@ public class TestRouteTracker { RouteTracker rt = new RouteTracker(r); Assert.assertEquals("wrong target (r1)", TARGET1, rt.getTargetHost()); - Assert.assertEquals("wrong local address (r1)", - null, rt.getLocalAddress()); + Assert.assertNull("wrong local address (r1)", rt.getLocalAddress()); Assert.assertEquals("wrong hop count (r1)", 0, rt.getHopCount()); - Assert.assertEquals("wrong proxy (r1)", - null, rt.getProxyHost()); - Assert.assertEquals("wrong route (r1)", - null, rt.toRoute()); + Assert.assertNull("wrong proxy (r1)", rt.getProxyHost()); + Assert.assertNull("wrong route (r1)", rt.toRoute()); checkCTLS(rt, false, false, false, false); r = new HttpRoute(TARGET2, LOCAL61, true); @@ -152,10 +144,8 @@ public class TestRouteTracker { LOCAL61, rt.getLocalAddress()); Assert.assertEquals("wrong hop count (r2)", 0, rt.getHopCount()); - Assert.assertEquals("wrong proxy (r2)", - null, rt.getProxyHost()); - Assert.assertEquals("wrong route (r2)", - null, rt.toRoute()); + Assert.assertNull("wrong proxy (r2)", rt.getProxyHost()); + Assert.assertNull("wrong route (r2)", rt.toRoute()); checkCTLS(rt, false, false, false, false); @@ -167,10 +157,8 @@ public class TestRouteTracker { LOCAL42, rt.getLocalAddress()); Assert.assertEquals("wrong hop count (r3)", 0, rt.getHopCount()); - Assert.assertEquals("wrong proxy (r3)", - null, rt.getProxyHost()); - Assert.assertEquals("wrong route (r3)", - null, rt.toRoute()); + Assert.assertNull("wrong proxy (r3)", rt.getProxyHost()); + Assert.assertNull("wrong route (r3)", rt.toRoute()); checkCTLS(rt, false, false, false, false); @@ -384,35 +372,35 @@ public class TestRouteTracker { final RouteTracker rt4 = new RouteTracker(TARGET1, LOCAL41); final RouteTracker rt6 = new RouteTracker(TARGET1, LOCAL62); - Assert.assertFalse("rt0", rt0.equals(null)); - Assert.assertTrue("rt0", rt0.equals(rt0)); - Assert.assertFalse("rt0", rt0.equals(rt0.toString())); + Assert.assertNotEquals("rt0", null, rt0); + Assert.assertEquals("rt0", rt0, rt0); + Assert.assertNotEquals("rt0", rt0, rt0.toString()); - Assert.assertFalse("rt0 == rt4", rt0.equals(rt4)); - Assert.assertFalse("rt0 == rt1", rt0.equals(rt1)); // Check host takes part in equals + Assert.assertNotEquals("rt0 == rt4", rt0, rt4); + Assert.assertNotEquals("rt0 == rt1", rt0, rt1); // Check host takes part in equals // Check that connection takes part in equals - Assert.assertTrue("rt0 != rt2", rt0.equals(rt2)); + Assert.assertEquals("rt0 != rt2", rt0, rt2); rt2.connectTarget(false); - Assert.assertFalse("rt0 == rt2", rt0.equals(rt2)); + Assert.assertNotEquals("rt0 == rt2", rt0, rt2); - Assert.assertTrue("rt0 != rt3", rt0.equals(rt3)); + Assert.assertEquals("rt0 != rt3", rt0, rt3); rt3.connectTarget(true); - Assert.assertFalse("rt0 == rt3", rt0.equals(rt3)); - Assert.assertFalse("rt2 == rt3", rt2.equals(rt3)); // Test secure takes part + Assert.assertNotEquals("rt0 == rt3", rt0, rt3); + Assert.assertNotEquals("rt2 == rt3", rt2, rt3); // Test secure takes part // TODO needs tests for tunnel and layered - Assert.assertFalse("rt4 == rt0", rt4.equals(rt0)); - Assert.assertFalse("rt0 == rt6", rt0.equals(rt6)); - Assert.assertFalse("rt6 == rt0", rt6.equals(rt0)); - Assert.assertFalse("rt4 == rt6", rt4.equals(rt6)); - Assert.assertFalse("rt6 == rt4", rt6.equals(rt4)); + Assert.assertNotEquals("rt4 == rt0", rt4, rt0); + Assert.assertNotEquals("rt0 == rt6", rt0, rt6); + Assert.assertNotEquals("rt6 == rt0", rt6, rt0); + Assert.assertNotEquals("rt4 == rt6", rt4, rt6); + Assert.assertNotEquals("rt6 == rt4", rt6, rt4); // it is likely but not guaranteed that the hashcodes are different - Assert.assertFalse("rt0 == rt4 (hashcode)", rt0.hashCode() == rt4.hashCode()); - Assert.assertFalse("rt0 == rt6 (hashcode)", rt0.hashCode() == rt6.hashCode()); - Assert.assertFalse("rt6 == rt4 (hashcode)", rt6.hashCode() == rt4.hashCode()); + Assert.assertNotEquals("rt0 == rt4 (hashcode)", rt0.hashCode(), rt4.hashCode()); + Assert.assertNotEquals("rt0 == rt6 (hashcode)", rt0.hashCode(), rt6.hashCode()); + Assert.assertNotEquals("rt6 == rt4 (hashcode)", rt6.hashCode(), rt4.hashCode()); Assert.assertEquals("rt0 (clone)", rt0, rt0.clone()); Assert.assertEquals("rt4 (clone)", rt4, rt4.clone()); @@ -706,14 +694,12 @@ public class TestRouteTracker { if (rt.getLocalAddress() != null) { final String las = rt.getLocalAddress().toString(); - Assert.assertFalse("no local address in toString(): " + rts, - !rts.contains(las)); + Assert.assertTrue("no local address in toString(): " + rts, rts.contains(las)); } for (int i=0; i