use of com.adaptris.filetransfer.FileTransferClient in project interlok by adaptris.
the class FtpPasswordConnectionCase method testConnect_OverrideUserOnly.
@Test
public void testConnect_OverrideUserOnly() throws Exception {
Assume.assumeTrue(areTestsEnabled());
FileTransferConnectionUsingPassword connection = (FileTransferConnectionUsingPassword) createConnection();
connection.setDefaultUserName(null);
try {
start(connection);
FileTransferClient client = connection.connect(getDestinationStringWithOverrideUserOnly());
} finally {
stop(connection);
}
}
use of com.adaptris.filetransfer.FileTransferClient in project interlok by adaptris.
the class FtpConnectionCase method testConnect.
@Test
public void testConnect() throws Exception {
Assume.assumeTrue(areTestsEnabled());
FileTransferConnection connection = createConnection();
try {
start(connection);
FileTransferClient client = connection.connect(getDestinationString());
} finally {
stop(connection);
}
}
use of com.adaptris.filetransfer.FileTransferClient in project interlok by adaptris.
the class FtpConnectionCase method testConnect_UserOverride.
@Test
public void testConnect_UserOverride() throws Exception {
Assume.assumeTrue(areTestsEnabled());
FileTransferConnection connection = createConnection();
connection.setDefaultUserName(null);
try {
start(connection);
log.debug("testConnect_UserOverride connecting to : " + getDestinationStringWithOverride());
FileTransferClient client = connection.connect(getDestinationStringWithOverride());
} finally {
stop(connection);
}
}
use of com.adaptris.filetransfer.FileTransferClient in project interlok by adaptris.
the class RelaxedFtpProducer method doProduce.
/**
* @see com.adaptris.core.AdaptrisMessageProducerImp#produce(AdaptrisMessage)
*/
@Override
public void doProduce(AdaptrisMessage msg, String endpoint) throws ProduceException {
FileTransferConnection conn = retrieveConnection(FileTransferConnection.class);
FileTransferClient client = null;
try {
client = conn.connect(endpoint);
String dirRoot = conn.getDirectoryRoot(endpoint);
String fileName = filenameCreator().createName(msg);
String destFilename = dirRoot + SLASH + fileName;
if (dirRoot.endsWith(SLASH)) {
destFilename = dirRoot + fileName;
}
log.debug("destFilename=[{}]", destFilename);
msg.addMetadata(CoreConstants.PRODUCED_NAME_KEY, fileName);
if (getEncoder() != null) {
byte[] bytesToWrite = encode(msg);
client.put(bytesToWrite, destFilename);
} else {
try (InputStream in = msg.getInputStream()) {
client.put(in, destFilename);
}
}
} catch (Exception e) {
throw new ProduceException(e);
} finally {
conn.disconnect(client);
}
}
use of com.adaptris.filetransfer.FileTransferClient in project interlok by adaptris.
the class FtpConnectionCase method testConnect_NoUser.
@Test
public void testConnect_NoUser() throws Exception {
Assume.assumeTrue(areTestsEnabled());
FileTransferConnection connection = createConnection();
connection.setDefaultUserName(null);
try {
start(connection);
FileTransferClient client = connection.connect(getDestinationString());
fail();
} catch (Exception expected) {
} finally {
stop(connection);
}
}
Aggregations