Replace assert calls by simpler but equivalent calls.

This commit is contained in:
Arturo Bernal 2021-06-13 13:30:21 +02:00 committed by Oleg Kalnichevski
parent fde3fca687
commit d77112f608
23 changed files with 223 additions and 250 deletions

View File

@ -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

View File

@ -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<HeaderElement> 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());
}
}

View File

@ -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<HeaderElement> it = MessageSupport.iterate(result, HttpHeaders.VARY);
while (it.hasNext()) {
final HeaderElement elt = it.next();
Assert.assertFalse("*".equals(elt.getName()));
Assert.assertNotEquals("*", elt.getName());
}
}

View File

@ -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());
}

View File

@ -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("<any auth scheme> <any realm> 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("<any auth scheme> <any realm> <any protocol>://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("<any auth scheme> <any realm> <any protocol>://<any host>:<any port>", 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());
}
}

View File

@ -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);
}

View File

@ -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());
}
}

View File

@ -67,8 +67,8 @@ public class TestCookiePathComparator {
final BasicClientCookie cookie2 = new BasicClientCookie("name1", "value");
cookie2.setPath("/a");
final Comparator<Cookie> 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<Cookie> 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<Cookie> 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<Cookie> 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));
}
}

View File

@ -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

View File

@ -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);
}

View File

@ -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());
}
}

View File

@ -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<NameValuePair> 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<NameValuePair> 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<NameValuePair> 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<NameValuePair> 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<NameValuePair> 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<NameValuePair> 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<NameValuePair> 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

View File

@ -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

View File

@ -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

View File

@ -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));
}
}

View File

@ -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

View File

@ -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());

View File

@ -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);

View File

@ -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

View File

@ -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<rt.getHopCount(); i++) {
final String hts = rt.getHopTarget(i).toString();
Assert.assertFalse("hop "+i+" ("+hts+") missing in toString(): " + rts,
!rts.contains(hts));
Assert.assertTrue("hop " + i + " (" + hts + ") missing in toString(): " + rts, rts.contains(hts));
}
return rts;

View File

@ -60,9 +60,9 @@ public class TestPublicSuffixMatcher {
Assert.assertEquals("xx", matcher.getDomainRoot("www.blah.blah.example.XX"));
Assert.assertEquals("appspot.com", matcher.getDomainRoot("example.appspot.com"));
// Too short
Assert.assertEquals(null, matcher.getDomainRoot("jp"));
Assert.assertEquals(null, matcher.getDomainRoot("ac.jp"));
Assert.assertEquals(null, matcher.getDomainRoot("any.tokyo.jp"));
Assert.assertNull(matcher.getDomainRoot("jp"));
Assert.assertNull(matcher.getDomainRoot("ac.jp"));
Assert.assertNull(matcher.getDomainRoot("any.tokyo.jp"));
// ICANN
Assert.assertEquals("metro.tokyo.jp", matcher.getDomainRoot("metro.tokyo.jp"));
Assert.assertEquals("blah.blah.tokyo.jp", matcher.getDomainRoot("blah.blah.tokyo.jp"));
@ -82,40 +82,40 @@ public class TestPublicSuffixMatcher {
Assert.assertEquals("xx", matcher.getDomainRoot("www.blah.blah.example.XX", DomainType.PRIVATE));
Assert.assertEquals("appspot.com", matcher.getDomainRoot("example.appspot.com"));
// Too short
Assert.assertEquals(null, matcher.getDomainRoot("jp", DomainType.PRIVATE));
Assert.assertEquals(null, matcher.getDomainRoot("ac.jp", DomainType.PRIVATE));
Assert.assertEquals(null, matcher.getDomainRoot("any.tokyo.jp", DomainType.PRIVATE));
Assert.assertNull(matcher.getDomainRoot("jp", DomainType.PRIVATE));
Assert.assertNull(matcher.getDomainRoot("ac.jp", DomainType.PRIVATE));
Assert.assertNull(matcher.getDomainRoot("any.tokyo.jp", DomainType.PRIVATE));
// ICANN
Assert.assertEquals(null, matcher.getDomainRoot("metro.tokyo.jp", DomainType.PRIVATE));
Assert.assertEquals(null, matcher.getDomainRoot("blah.blah.tokyo.jp", DomainType.PRIVATE));
Assert.assertEquals(null, matcher.getDomainRoot("blah.blah.ac.jp", DomainType.PRIVATE));
Assert.assertNull(matcher.getDomainRoot("metro.tokyo.jp", DomainType.PRIVATE));
Assert.assertNull(matcher.getDomainRoot("blah.blah.tokyo.jp", DomainType.PRIVATE));
Assert.assertNull(matcher.getDomainRoot("blah.blah.ac.jp", DomainType.PRIVATE));
// Unknown
Assert.assertEquals(null, matcher.getDomainRoot("garbage", DomainType.PRIVATE));
Assert.assertEquals(null, matcher.getDomainRoot("garbage.garbage", DomainType.PRIVATE));
Assert.assertEquals(null, matcher.getDomainRoot("*.garbage.garbage", DomainType.PRIVATE));
Assert.assertEquals(null, matcher.getDomainRoot("*.garbage.garbage.garbage", DomainType.PRIVATE));
Assert.assertNull(matcher.getDomainRoot("garbage", DomainType.PRIVATE));
Assert.assertNull(matcher.getDomainRoot("garbage.garbage", DomainType.PRIVATE));
Assert.assertNull(matcher.getDomainRoot("*.garbage.garbage", DomainType.PRIVATE));
Assert.assertNull(matcher.getDomainRoot("*.garbage.garbage.garbage", DomainType.PRIVATE));
}
@Test
public void testGetDomainRootOnlyICANN() {
// Private
Assert.assertEquals(null, matcher.getDomainRoot("example.XX", DomainType.ICANN));
Assert.assertEquals(null, matcher.getDomainRoot("www.example.XX", DomainType.ICANN));
Assert.assertEquals(null, matcher.getDomainRoot("www.blah.blah.example.XX", DomainType.ICANN));
Assert.assertNull(matcher.getDomainRoot("example.XX", DomainType.ICANN));
Assert.assertNull(matcher.getDomainRoot("www.example.XX", DomainType.ICANN));
Assert.assertNull(matcher.getDomainRoot("www.blah.blah.example.XX", DomainType.ICANN));
// Too short
Assert.assertEquals(null, matcher.getDomainRoot("xx", DomainType.ICANN));
Assert.assertEquals(null, matcher.getDomainRoot("jp", DomainType.ICANN));
Assert.assertEquals(null, matcher.getDomainRoot("ac.jp", DomainType.ICANN));
Assert.assertEquals(null, matcher.getDomainRoot("any.tokyo.jp", DomainType.ICANN));
Assert.assertNull(matcher.getDomainRoot("xx", DomainType.ICANN));
Assert.assertNull(matcher.getDomainRoot("jp", DomainType.ICANN));
Assert.assertNull(matcher.getDomainRoot("ac.jp", DomainType.ICANN));
Assert.assertNull(matcher.getDomainRoot("any.tokyo.jp", DomainType.ICANN));
// ICANN
Assert.assertEquals("metro.tokyo.jp", matcher.getDomainRoot("metro.tokyo.jp", DomainType.ICANN));
Assert.assertEquals("blah.blah.tokyo.jp", matcher.getDomainRoot("blah.blah.tokyo.jp", DomainType.ICANN));
Assert.assertEquals("blah.ac.jp", matcher.getDomainRoot("blah.blah.ac.jp", DomainType.ICANN));
// Unknown
Assert.assertEquals(null, matcher.getDomainRoot("garbage", DomainType.ICANN));
Assert.assertEquals(null, matcher.getDomainRoot("garbage.garbage", DomainType.ICANN));
Assert.assertEquals(null, matcher.getDomainRoot("*.garbage.garbage", DomainType.ICANN));
Assert.assertEquals(null, matcher.getDomainRoot("*.garbage.garbage.garbage", DomainType.ICANN));
Assert.assertNull(matcher.getDomainRoot("garbage", DomainType.ICANN));
Assert.assertNull(matcher.getDomainRoot("garbage.garbage", DomainType.ICANN));
Assert.assertNull(matcher.getDomainRoot("*.garbage.garbage", DomainType.ICANN));
Assert.assertNull(matcher.getDomainRoot("*.garbage.garbage.garbage", DomainType.ICANN));
}

View File

@ -323,57 +323,46 @@ public class TestHttpRoute {
Assert.assertEquals("hashcode 2e 2f", route2e.hashCode(), route2f.hashCode());
Assert.assertEquals("toString 2e 2f", route2e.toString(), route2f.toString());
Assert.assertFalse("1a 2a", route1a.equals(route2a));
Assert.assertFalse("1a 2b", route1a.equals(route2b));
Assert.assertFalse("1a 2c", route1a.equals(route2c));
Assert.assertFalse("1a 2d", route1a.equals(route2d));
Assert.assertFalse("1a 2e", route1a.equals(route2e));
Assert.assertFalse("1a 2f", route1a.equals(route2f));
Assert.assertFalse("1a 2g", route1a.equals(route2g));
Assert.assertFalse("1a 2h", route1a.equals(route2h));
Assert.assertFalse("1a 2i", route1a.equals(route2i));
Assert.assertFalse("1a 2j", route1a.equals(route2j));
Assert.assertFalse("1a 2k", route1a.equals(route2k));
Assert.assertNotEquals("1a 2a", route1a, route2a);
Assert.assertNotEquals("1a 2b", route1a, route2b);
Assert.assertNotEquals("1a 2c", route1a, route2c);
Assert.assertNotEquals("1a 2d", route1a, route2d);
Assert.assertNotEquals("1a 2e", route1a, route2e);
Assert.assertNotEquals("1a 2f", route1a, route2f);
Assert.assertNotEquals("1a 2g", route1a, route2g);
Assert.assertNotEquals("1a 2h", route1a, route2h);
Assert.assertNotEquals("1a 2i", route1a, route2i);
Assert.assertNotEquals("1a 2j", route1a, route2j);
Assert.assertNotEquals("1a 2k", route1a, route2k);
// repeat the checks in the other direction
// there could be problems with detecting null attributes
Assert.assertFalse("2a 1a", route2a.equals(route1a));
Assert.assertFalse("2b 1a", route2b.equals(route1a));
Assert.assertFalse("2c 1a", route2c.equals(route1a));
Assert.assertFalse("2d 1a", route2d.equals(route1a));
Assert.assertFalse("2e 1a", route2e.equals(route1a));
Assert.assertFalse("2f 1a", route2f.equals(route1a));
Assert.assertFalse("2g 1a", route2g.equals(route1a));
Assert.assertFalse("2h 1a", route2h.equals(route1a));
Assert.assertFalse("2i 1a", route2i.equals(route1a));
Assert.assertFalse("2j 1a", route2j.equals(route1a));
Assert.assertFalse("2k 1a", route2k.equals(route1a));
Assert.assertNotEquals("2a 1a", route2a, route1a);
Assert.assertNotEquals("2b 1a", route2b, route1a);
Assert.assertNotEquals("2c 1a", route2c, route1a);
Assert.assertNotEquals("2d 1a", route2d, route1a);
Assert.assertNotEquals("2e 1a", route2e, route1a);
Assert.assertNotEquals("2f 1a", route2f, route1a);
Assert.assertNotEquals("2g 1a", route2g, route1a);
Assert.assertNotEquals("2h 1a", route2h, route1a);
Assert.assertNotEquals("2i 1a", route2i, route1a);
Assert.assertNotEquals("2j 1a", route2j, route1a);
Assert.assertNotEquals("2k 1a", route2k, route1a);
// don't check hashCode, it's not guaranteed to be different
Assert.assertFalse("toString 1a 2a",
route1a.toString().equals(route2a.toString()));
Assert.assertFalse("toString 1a 2b",
route1a.toString().equals(route2b.toString()));
Assert.assertFalse("toString 1a 2c",
route1a.toString().equals(route2c.toString()));
Assert.assertFalse("toString 1a 2d",
route1a.toString().equals(route2d.toString()));
Assert.assertFalse("toString 1a 2e",
route1a.toString().equals(route2e.toString()));
Assert.assertFalse("toString 1a 2f",
route1a.toString().equals(route2f.toString()));
Assert.assertFalse("toString 1a 2g",
route1a.toString().equals(route2g.toString()));
Assert.assertFalse("toString 1a 2h",
route1a.toString().equals(route2h.toString()));
Assert.assertFalse("toString 1a 2i",
route1a.toString().equals(route2i.toString()));
Assert.assertFalse("toString 1a 2j",
route1a.toString().equals(route2j.toString()));
Assert.assertFalse("toString 1a 2k",
route1a.toString().equals(route2k.toString()));
Assert.assertNotEquals("toString 1a 2a", route1a.toString(), route2a.toString());
Assert.assertNotEquals("toString 1a 2b", route1a.toString(), route2b.toString());
Assert.assertNotEquals("toString 1a 2c", route1a.toString(), route2c.toString());
Assert.assertNotEquals("toString 1a 2d", route1a.toString(), route2d.toString());
Assert.assertNotEquals("toString 1a 2e", route1a.toString(), route2e.toString());
Assert.assertNotEquals("toString 1a 2f", route1a.toString(), route2f.toString());
Assert.assertNotEquals("toString 1a 2g", route1a.toString(), route2g.toString());
Assert.assertNotEquals("toString 1a 2h", route1a.toString(), route2h.toString());
Assert.assertNotEquals("toString 1a 2i", route1a.toString(), route2i.toString());
Assert.assertNotEquals("toString 1a 2j", route1a.toString(), route2j.toString());
Assert.assertNotEquals("toString 1a 2k", route1a.toString(), route2k.toString());
// now check that all of the routes are different from eachother
// except for those that aren't :-)
@ -417,8 +406,8 @@ public class TestHttpRoute {
11, routestrings.size());
// finally, compare with nonsense
Assert.assertFalse("route equals null", route1a.equals(null));
Assert.assertFalse("route equals string", route1a.equals("route1a"));
Assert.assertNotEquals("route equals null", null, route1a);
Assert.assertNotEquals("route equals string", "route1a", route1a);
}
@Test

View File

@ -170,14 +170,10 @@ public class TestURIUtils {
Assert.assertEquals(new HttpHost("localhost",8080),
URIUtils.extractHost(new URI("http://localhost:8080/;sessionid=stuff/abcd")));
Assert.assertEquals(null,
URIUtils.extractHost(new URI("http://localhost:8080;sessionid=stuff/abcd")));
Assert.assertEquals(null,
URIUtils.extractHost(new URI("http://localhost:;sessionid=stuff/abcd")));
Assert.assertEquals(null,
URIUtils.extractHost(new URI("http://:80/robots.txt")));
Assert.assertEquals(null,
URIUtils.extractHost(new URI("http://some%20domain:80/robots.txt")));
Assert.assertNull(URIUtils.extractHost(new URI("http://localhost:8080;sessionid=stuff/abcd")));
Assert.assertNull(URIUtils.extractHost(new URI("http://localhost:;sessionid=stuff/abcd")));
Assert.assertNull(URIUtils.extractHost(new URI("http://:80/robots.txt")));
Assert.assertNull(URIUtils.extractHost(new URI("http://some%20domain:80/robots.txt")));
}
@Test