UriUtils { public static List<InetSocketAddress> parseInetSocketAddresses(String uri) { return parseInetSocketAddresses(uri, 9410); } private  UriUtils(); static List<String> parseSegments(String uri); static List<InetSocketAddress> parseInetSocketAddresses(String uri); static List<InetSocketAddress> parseInetSocketAddresses(String uri, int defaultPort); static String parseScheme(String uri); static String parseAuthority(String uri); static String parseUserInfo(String uri); static String parsePath(String uri); static String parseQuery(String uri); static String appendSegmentToPath(String path, String segment);  }
@Test public void testParseAuthorities_missing_authority() { assertThat(UriUtils.parseInetSocketAddresses("localhost").size(), equalTo(0)); }
@Test public void testParseAuthorities_missing_port() { List<InetSocketAddress> socketAddresses = UriUtils.parseInetSocketAddresses("scheme: assertThat(socketAddresses.size(), equalTo(1)); assertThat(socketAddresses.get(0).getHostString(), equalTo("localhost")); assertThat(socketAddresses.get(0).getPort(), equalTo(9410)); }
@Test public void testParseAuthorities_all_explicit_port() { List<InetSocketAddress> socketAddresses = UriUtils.parseInetSocketAddresses("scheme: assertThat(socketAddresses.size(), equalTo(1)); assertThat(socketAddresses.get(0).getHostString(), equalTo("localhost")); assertThat(socketAddresses.get(0).getPort(), equalTo(9510)); }
@Test public void generateHostPortsByServerNamesFromUriTest() { List<InetSocketAddress> hostPortsByServerNames = UriUtils.parseInetSocketAddresses("terracotta: assertEquals(hostPortsByServerNames, Arrays.asList( InetSocketAddress.createUnresolved("server1", 9510), InetSocketAddress.createUnresolved("server2", 9511) )); }
@Test(expected = IllegalArgumentException.class) public void testParseAuthorities_too_many_colons() { UriUtils.parseInetSocketAddresses("scheme: }