SshEndpointComponent extends AbstractEndpointComponent { @Override protected Endpoint createEndpoint(String resourcePath, Map<String, String> parameters, TestContext context) { SshClient client = new SshClient(); if (resourcePath.contains(":")) { StringTokenizer tok = new StringTokenizer(resourcePath, ":"); client.getEndpointConfiguration().setHost(tok.nextToken()); if (tok.hasMoreTokens()) { client.getEndpointConfiguration().setPort(Integer.valueOf(tok.nextToken())); } } else { client.getEndpointConfiguration().setHost(resourcePath); } enrichEndpointConfiguration(client.getEndpointConfiguration(), parameters, context); return client; } SshEndpointComponent();   }
@Test public void testCreateEndpoint() throws Exception { SshEndpointComponent component = new SshEndpointComponent(); Endpoint endpoint = component.createEndpoint("ssh: Assert.assertEquals(endpoint.getClass(), SshClient.class); Assert.assertEquals(((SshClient)endpoint).getEndpointConfiguration().getHost(), "localhost"); Assert.assertEquals(((SshClient)endpoint).getEndpointConfiguration().getPort(), 2200); Assert.assertEquals(((SshClient) endpoint).getEndpointConfiguration().getTimeout(), 5000L); }
@Test public void testCreateEndpointWithoutPort() throws Exception { SshEndpointComponent component = new SshEndpointComponent(); Endpoint endpoint = component.createEndpoint("ssh:127.0.0.1", context); Assert.assertEquals(endpoint.getClass(), SshClient.class); Assert.assertEquals(((SshClient)endpoint).getEndpointConfiguration().getHost(), "127.0.0.1"); Assert.assertEquals(((SshClient)endpoint).getEndpointConfiguration().getPort(), 2222); Assert.assertEquals(((SshClient) endpoint).getEndpointConfiguration().getTimeout(), 5000L); }
@Test public void testCreateEndpointWithParameters() throws Exception { SshEndpointComponent component = new SshEndpointComponent(); Endpoint endpoint = component.createEndpoint("ssh: Assert.assertEquals(endpoint.getClass(), SshClient.class); Assert.assertEquals(((SshClient)endpoint).getEndpointConfiguration().getHost(), "localhost"); Assert.assertEquals(((SshClient)endpoint).getEndpointConfiguration().getPort(), 2200); Assert.assertEquals(((SshClient)endpoint).getEndpointConfiguration().getUser(), "foo"); Assert.assertEquals(((SshClient)endpoint).getEndpointConfiguration().getPassword(), "12345678"); Assert.assertTrue(((SshClient) endpoint).getEndpointConfiguration().isStrictHostChecking()); Assert.assertEquals(((SshClient) endpoint).getEndpointConfiguration().getTimeout(), 10000L); }