### Question:
Utils { public static Integer getPort(String address) { Matcher matcher = HOST_PORT_PATTERN.matcher(address); return matcher.matches() ? Integer.parseInt(matcher.group(2)) : null; }  static List<T> sorted(Collection<T> collection); static String utf8(byte[] bytes); static String utf8(ByteBuffer buffer, int length); static String utf8(ByteBuffer buffer, int offset, int length); static byte[] utf8(String string); static int abs(int n); static long min(long first, long ... rest); static long max(long first, long ... rest); static short min(short first, short second); static int utf8Length(CharSequence s); static byte[] toArray(ByteBuffer buffer); static byte[] toArray(ByteBuffer buffer, int size); static byte[] toNullableArray(ByteBuffer buffer); static ByteBuffer wrapNullable(byte[] array); static byte[] toArray(ByteBuffer buffer, int offset, int size); static T notNull(T t); static void sleep(long ms); static T newInstance(Class<T> c); static T newInstance(String klass, Class<T> base); static int murmur2(final byte[] data); static String getHost(String address); static Integer getPort(String address); static String formatAddress(String host, Integer port); static String join(T[] strs, String separator); static String join(Collection<T> list, String separator); static String mkString(Map<K, V> map, String begin, String end,
                                         String keyValueSeparator, String elementSeparator); static Properties loadProps(String filename); static Map<String, String> propsToStringMap(Properties props); static String stackTrace(Throwable e); static Thread newThread(String name, Runnable runnable, boolean daemon); static Thread daemonThread(String name, Runnable runnable); static void croak(String message); static byte[] readBytes(ByteBuffer buffer, int offset, int length); static byte[] readBytes(ByteBuffer buffer); static String readFileAsString(String path, Charset charset); static String readFileAsString(String path); static ByteBuffer ensureCapacity(ByteBuffer existingBuffer, int newLength); @SafeVarargs static Set<T> mkSet(T... elems); @SafeVarargs static List<T> mkList(T... elems); static void delete(final File file); static List<T> safe(List<T> other); static ClassLoader getKafkaClassLoader(); static ClassLoader getContextOrKafkaClassLoader(); static void atomicMoveWithFallback(Path source, Path target); static void closeAll(Closeable... closeables); static void closeQuietly(AutoCloseable closeable, String name); static int toPositive(int number); static int longHashcode(long value); static ByteBuffer sizeDelimited(ByteBuffer buffer, int start); static void readFullyOrFail(FileChannel channel, ByteBuffer destinationBuffer, long position,
                                       String description); static void readFully(FileChannel channel, ByteBuffer destinationBuffer, long position); static final void readFully(InputStream inputStream, ByteBuffer destinationBuffer); static void writeFully(FileChannel channel, ByteBuffer sourceBuffer); static void writeTo(DataOutput out, ByteBuffer buffer, int length); static List<T> toList(Iterator<T> iterator); static final String NL; }### Answer:
@Test public void testGetPort() { assertEquals(8000, getPort("127.0.0.1:8000").intValue()); assertEquals(8080, getPort("mydomain.com:8080").intValue()); assertEquals(8080, getPort("MyDomain.com:8080").intValue()); assertEquals(1234, getPort("[::1]:1234").intValue()); assertEquals(5678, getPort("[2001:db8:85a3:8d3:1319:8a2e:370:7348]:5678").intValue()); assertEquals(5678, getPort("[2001:DB8:85A3:8D3:1319:8A2E:370:7348]:5678").intValue()); assertEquals(5678, getPort("[fe80::b1da:69ca:57f7:63d8%3]:5678").intValue()); }