### Question:
UriParser { public String getHost(String s) { try { return new URI(s).getHost(); } catch (URISyntaxException e) { throw new ConfigurationException(e); } }  String getHost(String s); int getPort(String serverUri);  }### Answer:
@Test public void parserReturnsHostGivenHttpUrl() { String url = "tcp: UriParser uriParser = new UriParser(); String parsedHost = uriParser.getHost(url); Assert.assertEquals("localhost", parsedHost); }
@Test public void parserReturnsIpGivenHttpUrl() { String url = "tcp: UriParser uriParser = new UriParser(); String parsedHost = uriParser.getHost(url); Assert.assertEquals("10.120.10.10", parsedHost); }
@Test public void getHostThrowsOnInvalidUri() { String url = "${"; UriParser uriParser = new UriParser(); expectedException.expect(ConfigurationException.class); uriParser.getHost(url); }