SshClient extends AbstractEndpoint implements Producer, ReplyConsumer { public void send(Message message, TestContext context) { String correlationKeyName = getEndpointConfiguration().getCorrelator().getCorrelationKeyName(getName()); String correlationKey = getEndpointConfiguration().getCorrelator().getCorrelationKey(message); correlationManager.saveCorrelationKey(correlationKeyName, correlationKey, context); SshRequest request = (SshRequest) getEndpointConfiguration().getMessageConverter().convertOutbound(message, getEndpointConfiguration(), context); if (getEndpointConfiguration().isStrictHostChecking()) { setKnownHosts(); } String rUser = getRemoteUser(message); connect(rUser); ChannelExec channelExec = null; ByteArrayOutputStream outStream = new ByteArrayOutputStream(); ByteArrayOutputStream errStream = new ByteArrayOutputStream(); int rc; try { channelExec = openChannelExec(); channelExec.setErrStream(errStream); channelExec.setOutputStream(outStream); channelExec.setCommand(request.getCommand()); doConnect(channelExec); if (request.getStdin() != null) { sendStandardInput(channelExec, request.getStdin()); } waitCommandToFinish(channelExec); rc = channelExec.getExitStatus(); } finally { if (channelExec != null && channelExec.isConnected()) { channelExec.disconnect(); } disconnect(); } SshResponse sshResp = new SshResponse(outStream.toString(),errStream.toString(),rc); Message response = getEndpointConfiguration().getMessageConverter().convertInbound(sshResp, getEndpointConfiguration(), context) .setHeader("user", rUser); correlationManager.store(correlationKey, response); } SshClient(); protected  SshClient(SshEndpointConfiguration endpointConfiguration); @Override SshEndpointConfiguration getEndpointConfiguration(); void send(Message message, TestContext context); @Override Message receive(TestContext context); @Override Message receive(String selector, TestContext context); @Override Message receive(TestContext context, long timeout); @Override Message receive(String selector, TestContext context, long timeout); @Override Producer createProducer(); @Override SelectiveConsumer createConsumer(); JSch getJsch(); void setJsch(JSch jsch); void setCorrelationManager(CorrelationManager<Message> correlationManager);  }
@Test(expectedExceptions = CitrusRuntimeException.class,expectedExceptionsMessageRegExp = ".*knownHosts.*") public void strictHostCheckingWithoutKnownHosts() throws JSchException { strictHostChecking(true, null); send(); }
@Test(expectedExceptions = CitrusRuntimeException.class,expectedExceptionsMessageRegExp = ".*blaHosts.*") public void strictHostCheckingWithFaultyKnownHosts() throws JSchException { strictHostChecking(true, "classpath:/com/consol/citrus/ssh/blaHosts"); send(); }
@Test(expectedExceptions = CitrusRuntimeException.class,expectedExceptionsMessageRegExp = ".*/does/not/exist.*") public void strictHostCheckingWithFaultyKnownHosts2() throws JSchException { strictHostChecking(true, "/file/that/does/not/exist"); send(); }