### Question:
ChaosSSHClient implements SSHClientWrapper { @Override public SSHClientWrapper withEndpoint (String hostname) { int chosenPort = SSHConstants.DEFAULT_SSH_PORT; if (hostname.matches(".*:[1-9][0-9]*$")) { log.debug("Parsing hostname with port {}", hostname); int split = hostname.lastIndexOf(':'); chosenPort = Integer.parseInt(hostname.substring(split + 1)); hostname = hostname.substring(0, split); log.debug("Evaluated as {} port {}", hostname, chosenPort); } return withEndpoint(hostname, chosenPort); }  @Override ShellClient connect(int connectionTimeout); @Override void close(); @Override SSHClientWrapper withSSHCredentials(SSHCredentials sshCredentials); @Override SSHClientWrapper withEndpoint(String hostname); @Override SSHClientWrapper withEndpoint(String hostname, Integer portNumber); @Override SSHClientWrapper withRunningDirectory(String runningDirectory); @Override String runResource(Resource resource); @Override ShellOutput runCommand(String command);  }### Answer:
@Test public void withEndpoint () { assertSame(chaosSSHClient, chaosSSHClient.withEndpoint(randomUUID().toString())); assertSame(chaosSSHClient, chaosSSHClient.withEndpoint(randomUUID().toString(), 1)); }
@Test public void withEndpointInvalidPorts () { int[] badPorts = { -1000, -65535, -65536, -1, 0, 65536, 100000 }; for (int badPort : badPorts) { try { chaosSSHClient.withEndpoint(null, badPort); fail("Should have thrown an exception"); } catch (IllegalArgumentException ignored) { } } }