public void send(Message message, TestContext context) {
String correlationKey = getEndpointConfiguration().getCorrelator().getCorrelationKey(message);
context.saveCorrelationKey(correlationKey, this);
String payload = (String) message.getPayload();
SshRequest request = (SshRequest) getEndpointConfiguration().getXmlMapper().fromXML(payload);
if (getEndpointConfiguration().isStrictHostChecking()) {
setKnownHosts();
}
String rUser = getRemoteUser(message);
connect(rUser);
ChannelExec channelExec = null;
ByteArrayOutputStream outStream = new ByteArrayOutputStream();
ByteArrayOutputStream errStream = new ByteArrayOutputStream();
int rc = 0;
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()) {