### Question:
HostnamePort { public HostnamePort( String hostnamePort ) throws IllegalArgumentException { Objects.requireNonNull( hostnamePort ); String[] parts = splitHostAndPort( hostnamePort ); if ( parts.length == 1 ) { host = StringUtils.defaultIfBlank( parts[0], null ); ports = new int[]{0, 0}; } else if ( parts.length == 2 ) { host = StringUtils.defaultIfBlank( parts[0], null ); String[] portStrings = parts[1].split( "-" ); ports = new int[2]; if ( portStrings.length == 1 ) { ports[0] = ports[1] = Integer.parseInt( portStrings[0] ); } else if ( portStrings.length == 2 ) { ports[0] = Integer.parseInt( portStrings[0] ); ports[1] = Integer.parseInt( portStrings[1] ); } else { throw new IllegalArgumentException( format( "Cannot have more than two port ranges: %s", hostnamePort ) ); } } else { throw new IllegalArgumentException( hostnamePort ); } } HostnamePort( String hostnamePort );  HostnamePort( String host, int port );  HostnamePort( String host, int portFrom, int portTo ); String getHost(); static String getHostAddress( String host, String defaultHost ); String getHost( String defaultHost ); int[] getPorts(); int getPort(); boolean isRange(); @Override String toString(); String toString( String defaultHost ); boolean matches( URI toMatch ); @Override boolean equals( Object o ); @Override int hashCode();  }### Answer:
@Test void testHostnamePort() { HostnamePort hostnamePort = new HostnamePort( "myhost:1234" ); assertThat( hostnamePort.getHost(), equalTo( "myhost" ) ); assertThat( hostnamePort.getPort(), equalTo( 1234 ) ); assertThat( hostnamePort.getPorts(), equalTo( new int[] {1234, 1234} ) ); }