diff --git a/dialogue-apache-hc5-client/src/test/java/com/palantir/dialogue/hc5/ApacheHttpClientBlockingChannelTest.java b/dialogue-apache-hc5-client/src/test/java/com/palantir/dialogue/hc5/ApacheHttpClientBlockingChannelTest.java index 7e33bdc8b..8e8c37f79 100644 --- a/dialogue-apache-hc5-client/src/test/java/com/palantir/dialogue/hc5/ApacheHttpClientBlockingChannelTest.java +++ b/dialogue-apache-hc5-client/src/test/java/com/palantir/dialogue/hc5/ApacheHttpClientBlockingChannelTest.java @@ -29,13 +29,9 @@ import java.net.InetAddress; import java.net.URI; import java.net.URL; -import java.net.URLDecoder; import java.net.UnknownHostException; -import java.nio.charset.StandardCharsets; import java.util.Comparator; import java.util.Map; -import java.util.Objects; -import javax.annotation.Nullable; import org.apache.hc.core5.http.ClassicHttpRequest; import org.apache.hc.core5.net.URIAuthority; import org.junit.jupiter.api.Test; @@ -120,41 +116,26 @@ public void renderPath(ListMultimap params, UrlBuilder url) { "https://user@[0000:0000:0000:0000:0000:ffff:c0a8:0102]:8443/path/to/foo/bar?baz=quux&hello=world#an-octothorpe" + " , 0000:0000:0000:0000:0000:ffff:c0a8:0102, 8443, user", "https://user:slash%2Fslash@www.example.com, www.example.com, -1, user:slash%2Fslash", + "https://schloßnagle.example.com, xn--schlonagle-93a.example.com, -1,", + "https://xn--schlonagle-93a.example.com, schloßnagle.example.com, -1,", }) void parseAuthority(String input, String expectedHost, int expectedPort, String expectedUserInfo) throws Exception { URL url = new URL(input); - URI uri = URI.create(input); - assertThat(url).isEqualTo(uri.toURL()); - assertThat(uri).isEqualTo(url.toURI()); assertThat(ApacheHttpClientBlockingChannel.parseAuthority(url)) - .isEqualTo(ApacheHttpClientBlockingChannel.parseAuthority(uri.toURL())) - .isEqualTo(ApacheHttpClientBlockingChannel.parseAuthority(new URL(uri.toString()))) - .isEqualTo(URIAuthority.create(uri.getRawAuthority())) .isEqualTo(URIAuthority.create(url.toURI().getRawAuthority())) .isEqualTo(URIAuthority.create(url.getAuthority())) .satisfies(authority -> { assertThat(authority.getHostName()) .usingComparator(hostComparator) .isEqualTo(expectedHost) - .isEqualTo(uri.getHost()) .isEqualTo(url.getHost()); - assertThat(authority.getPort()) - .isEqualTo(expectedPort) - .isEqualTo(uri.getPort()) - .isEqualTo(url.getPort()); + assertThat(authority.getPort()).isEqualTo(expectedPort).isEqualTo(url.getPort()); assertThat(authority.getUserInfo()) - .usingComparator(userInfoComparator) .isEqualTo(expectedUserInfo) - .isEqualTo(decode(uri.getUserInfo())) - .isEqualTo(decode(url.getUserInfo())); + .isEqualTo(url.getUserInfo()); }); } - @Nullable - private static String decode(String userInfo) { - return userInfo == null ? null : URLDecoder.decode(userInfo, StandardCharsets.UTF_8); - } - @Test void testHostComparator() { assertThat("www.example.com") @@ -180,21 +161,6 @@ void testHostComparator() { .isNotEqualTo("[::ffff:c0a8:101]"); } - private static final Comparator userInfoComparator = (info1, info2) -> { - String u1 = decode(info1); - String u2 = decode(info2); - if (Objects.equals(u1, u2)) { - return 0; - } - if (u1 == null) { - return -1; - } - if (u2 == null) { - return 1; - } - return u1.compareTo(u2); - }; - private static final Comparator hostComparator = (host1, host2) -> { if (host1.equals(host2)) { return 0; @@ -212,7 +178,7 @@ private static InetAddress tryGetAddress(String host) { try { return InetAddress.getByName(host); } catch (UnknownHostException e) { - throw new RuntimeException(e); + return null; } } }