TcpUriFactory { public static URI createUri(final InetSocketAddress address) throws URISyntaxException { final String host = address.getHostName(); final int port = address.getPort(); return new URI("tcp", null, host, port, null, null, null); } private  TcpUriFactory(); static URI createUri(final InetSocketAddress address); static URI createUri(final InetAddress address);  }
@Test public void testCreateUri() throws Exception { final InetAddress localhost = InetAddress.getByName("127.0.0.1"); final InetSocketAddress address = new InetSocketAddress(localhost, 4242); final URI uri = TcpUriFactory.createUri(address); Assert.assertEquals("tcp: + ":4242", uri.toString()); }