Search in sources :

Example 6 with FileTransferException

use of com.adaptris.filetransfer.FileTransferException in project interlok by adaptris.

the class RelaxedFtpConsumerTest method testSingleFileConsumeDeleteFailsWithExceptionOnFail.

@Test
public void testSingleFileConsumeDeleteFailsWithExceptionOnFail() throws Exception {
    setFilesToConsume(new String[] { "/MySingleFile.txt" }, new String[] { "My file payload" }, new long[] { calendarOneYearAgo.getTimeInMillis() });
    consumer.setFailOnDeleteFailure(true);
    doThrow(new FileTransferException("expected")).when(mockFileTransferClient).delete(anyString());
    LifecycleHelper.init(consumer);
    LifecycleHelper.start(consumer);
    waitForConsumer(1, 3000);
    assertEquals(1, messageListener.getMessages().size());
}
Also used : FileTransferException(com.adaptris.filetransfer.FileTransferException) Test(org.junit.Test)

Example 7 with FileTransferException

use of com.adaptris.filetransfer.FileTransferException in project interlok by adaptris.

the class StandardSftpConnectionTest method testConnectOnly_StrictKnownHosts_UnknownHost.

@Test
public void testConnectOnly_StrictKnownHosts_UnknownHost() throws Exception {
    Assume.assumeTrue(areTestsEnabled());
    File tempHostsFile = copyHostsFile(new File(PROPERTIES.getProperty(CFG_UNKNOWN_HOSTS_FILE)));
    StandardSftpConnection conn = createConnection();
    conn.setConfiguration(new InlineConfigRepositoryBuilder(true).build());
    conn.setKnownHostsFile(tempHostsFile.getCanonicalPath());
    try {
        start(conn);
        FileTransferClient c = conn.connect(getDestinationString());
        fail();
    } catch (FileTransferException expected) {
    } finally {
        stop(conn);
    }
}
Also used : FileTransferException(com.adaptris.filetransfer.FileTransferException) FileTransferClient(com.adaptris.filetransfer.FileTransferClient) File(java.io.File) Test(org.junit.Test)

Example 8 with FileTransferException

use of com.adaptris.filetransfer.FileTransferException in project interlok by adaptris.

the class RelaxedFtpConsumerTest method testIncorrectPathConsume.

@Test
public void testIncorrectPathConsume() throws Exception {
    when(mockFtpConnection.connect(consumeDestination)).thenThrow(new FileTransferException("testIncorrectPathConsume"));
    setFilesToConsume(new String[] { "/MySingleFile.txt" }, new String[] { "My file payload" }, new long[] { calendarOneYearAgo.getTimeInMillis() });
    LifecycleHelper.init(consumer);
    LifecycleHelper.start(consumer);
    waitForConsumer(1, 1000);
    assertEquals(0, messageListener.getMessages().size());
}
Also used : FileTransferException(com.adaptris.filetransfer.FileTransferException) Test(org.junit.Test)

Aggregations

FileTransferException (com.adaptris.filetransfer.FileTransferException)8 Test (org.junit.Test)5 IOException (java.io.IOException)3 FtpException (com.adaptris.ftp.FtpException)2 FileTransferClient (com.adaptris.filetransfer.FileTransferClient)1 LsEntry (com.jcraft.jsch.ChannelSftp.LsEntry)1 SftpATTRS (com.jcraft.jsch.SftpATTRS)1 File (java.io.File)1 FileFilter (java.io.FileFilter)1 ArrayList (java.util.ArrayList)1