UriUtils { public static Integer extractPortFromUri(URI uri) { return uri.getPort() > 0 ? uri.getPort() : null; } 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 shouldExtractPortFromUri() { assertThat(extractPortFromUri(FULL_URI).longValue()).isEqualTo(123123L); assertThat(extractPortFromUri(NO_PORT_URI)).isNull(); }