GetServiceByName { public static int getPort(String serviceName, String type) { int port = -1; try { if (service == null) { service = new GetServiceByName(); } port = service.getPortByName(serviceName, type); } catch (Exception ignoredByDesign) { ; } return port; } private  GetServiceByName(); static int getPort(String serviceName, String type); static int getPort(String serviceName);  }
@Test public void testGetHttpsServicePort() { assertEquals("Get Https port", GetServiceByName.getPort("https", "tcp"), 443); }
@Test public void testGetSmtpServicePort() { assertEquals("Get SMTP port", GetServiceByName.getPort("smtp", "tcp"), 25); }
@Test public void testGetHttpServicePort() { assertEquals("Get Http port", GetServiceByName.getPort("http", "tcp"), 80); }
@Test public void testGetNonExistentPort() { assertEquals("Non-Existent Port", GetServiceByName.getPort("asdfasdfadsf", "tcp"), -1); }