UriUtils { public static String extractAddressFromUri(URI uri) { String address = extractHostFromUri(uri); if (uri.getPort() > 0) { address += ":" + uri.getPort(); } return address; } private  UriUtils(); static String extractHostFromUri(URI uri); static Integer extractPortFromUri(URI uri); static String extractAddressFromUri(URI uri); static String extractUserNameFromUri(URI uri); static String extractPasswordFromUri(URI uri); static String extractContextFromUri(URI uri); static String extractDestinationTopicFromUri(URI uri); static URI appendContext(URI uri, String context);  }
@Test public void shouldExtractAddressFromUri() { assertThat(extractAddressFromUri(FULL_URI)).isEqualTo("localhost:123123"); assertThat(extractAddressFromUri(NO_PORT_URI)).isEqualTo("localhost"); }