Search in sources :

Example 1 with QuartzCronPoller

use of com.adaptris.core.QuartzCronPoller in project interlok by adaptris.

the class FtpCase method testConsume_WithEncoder.

@Test
public void testConsume_WithEncoder() throws Exception {
    Assume.assumeTrue(areTestsEnabled());
    MockMessageListener listener = new MockMessageListener();
    FtpConsumer ftpConsumer = new FtpConsumer();
    ftpConsumer.setFtpEndpoint(getDestinationString());
    ftpConsumer.registerAdaptrisMessageListener(listener);
    ftpConsumer.setQuietInterval(new TimeInterval(300l, TimeUnit.MILLISECONDS));
    ftpConsumer.setPoller(new QuartzCronPoller("*/1 * * * * ?"));
    ftpConsumer.setEncoder(new MimeEncoder());
    FileTransferConnection consumeConnection = createConnection();
    consumeConnection.setCacheConnection(true);
    StandaloneConsumer sc = new StandaloneConsumer(consumeConnection, ftpConsumer);
    start(sc);
    int count = 10;
    try {
        FileTransferConnection produceConnection = createConnection();
        produceConnection.setCacheConnection(true);
        FtpProducer producer = createFtpProducer();
        producer.setEncoder(new MimeEncoder());
        produce(new StandaloneProducer(produceConnection, producer), count);
        waitForMessages(listener, count);
        assertMessages(listener.getMessages(), count);
    } catch (Exception e) {
        log.error(e.getMessage(), e);
        throw e;
    } finally {
        stop(sc);
    }
}
Also used : TimeInterval(com.adaptris.util.TimeInterval) QuartzCronPoller(com.adaptris.core.QuartzCronPoller) MimeEncoder(com.adaptris.core.MimeEncoder) MockMessageListener(com.adaptris.core.stubs.MockMessageListener) StandaloneConsumer(com.adaptris.core.StandaloneConsumer) StandaloneProducer(com.adaptris.core.StandaloneProducer) CoreException(com.adaptris.core.CoreException) Test(org.junit.Test)

Example 2 with QuartzCronPoller

use of com.adaptris.core.QuartzCronPoller in project interlok by adaptris.

the class FtpCase method testConsume_CachedConnection.

@Test
public void testConsume_CachedConnection() throws Exception {
    Assume.assumeTrue(areTestsEnabled());
    MockMessageListener listener = new MockMessageListener();
    FtpConsumer ftpConsumer = new FtpConsumer();
    ftpConsumer.setFtpEndpoint(getDestinationString());
    ftpConsumer.registerAdaptrisMessageListener(listener);
    ftpConsumer.setQuietInterval(new TimeInterval(300l, TimeUnit.MILLISECONDS));
    ftpConsumer.setPoller(new QuartzCronPoller("*/1 * * * * ?"));
    FileTransferConnection consumeConnection = createConnection();
    consumeConnection.setCacheConnection(true);
    StandaloneConsumer sc = new StandaloneConsumer(consumeConnection, ftpConsumer);
    start(sc);
    int count = 10;
    try {
        FileTransferConnection produceConnection = createConnection();
        produceConnection.setCacheConnection(true);
        produce(new StandaloneProducer(produceConnection, createFtpProducer()), count);
        waitForMessages(listener, count);
        assertMessages(listener.getMessages(), count);
    } catch (Exception e) {
        log.error(e.getMessage(), e);
        throw e;
    } finally {
        stop(sc);
    }
}
Also used : TimeInterval(com.adaptris.util.TimeInterval) QuartzCronPoller(com.adaptris.core.QuartzCronPoller) MockMessageListener(com.adaptris.core.stubs.MockMessageListener) StandaloneConsumer(com.adaptris.core.StandaloneConsumer) StandaloneProducer(com.adaptris.core.StandaloneProducer) CoreException(com.adaptris.core.CoreException) Test(org.junit.Test)

Example 3 with QuartzCronPoller

use of com.adaptris.core.QuartzCronPoller in project interlok by adaptris.

the class FtpCase method testConsumeWithFilter.

@Test
public void testConsumeWithFilter() throws Exception {
    Assume.assumeTrue(areTestsEnabled());
    MockMessageListener listener = new MockMessageListener();
    FtpConsumer ftpConsumer = new FtpConsumer();
    ftpConsumer.setFtpEndpoint(getDestinationString());
    ftpConsumer.setWorkDirectory(DEFAULT_WORK_DIR);
    ftpConsumer.setFileFilterImp(GlobFilenameFilter.class.getCanonicalName());
    ftpConsumer.setFilterExpression(".txt");
    ftpConsumer.registerAdaptrisMessageListener(listener);
    ftpConsumer.setPoller(new QuartzCronPoller("*/1 * * * * ?"));
    StandaloneConsumer sc = new StandaloneConsumer(createConnection(), ftpConsumer);
    start(sc);
    int count = 1;
    try {
        FtpProducer ftpProducer = createFtpProducer();
        MetadataFileNameCreator mfc = new MetadataFileNameCreator();
        mfc.setDefaultName(new GuidGenerator().getUUID() + ".txt");
        mfc.setMetadataKey(new GuidGenerator().getUUID());
        ftpProducer.setFilenameCreator(mfc);
        produce(new StandaloneProducer(createConnection(), ftpProducer), count);
        Awaitility.await().atMost(Duration.ofSeconds(5)).with().pollInterval(Duration.ofMillis(100)).until(() -> listener.getMessages().size() >= count);
        assertMessages(listener.getMessages(), count);
    } finally {
        stop(sc);
    }
}
Also used : QuartzCronPoller(com.adaptris.core.QuartzCronPoller) GlobFilenameFilter(org.apache.oro.io.GlobFilenameFilter) GuidGenerator(com.adaptris.util.GuidGenerator) MockMessageListener(com.adaptris.core.stubs.MockMessageListener) StandaloneConsumer(com.adaptris.core.StandaloneConsumer) MetadataFileNameCreator(com.adaptris.core.MetadataFileNameCreator) StandaloneProducer(com.adaptris.core.StandaloneProducer) Test(org.junit.Test)

Example 4 with QuartzCronPoller

use of com.adaptris.core.QuartzCronPoller in project interlok by adaptris.

the class RelaxedFtpCase method testConsume_EncryptedPassword.

@Test
public void testConsume_EncryptedPassword() throws Exception {
    if (areTestsEnabled()) {
        MockMessageListener listener = new MockMessageListener();
        RelaxedFtpConsumer ftpConsumer = new RelaxedFtpConsumer();
        ftpConsumer.setFtpEndpoint(getDestinationString());
        ftpConsumer.setQuietInterval(DEFAULT_QUIET_PERIOD);
        ftpConsumer.registerAdaptrisMessageListener(listener);
        ftpConsumer.setPoller(new QuartzCronPoller("*/1 * * * * ?"));
        StandaloneConsumer sc = new StandaloneConsumer(createConnection(), ftpConsumer);
        start(sc);
        int count = 1;
        try {
            FileTransferConnectionUsingPassword conn = createConnection();
            String pw = conn.getDefaultPassword();
            String decodedPw = Password.decode(pw);
            if (pw.equals(decodedPw)) {
                // The password was never encrypted!
                conn.setDefaultPassword(Password.encode(conn.getDefaultPassword(), Password.PORTABLE_PASSWORD));
            }
            produce(new StandaloneProducer(conn, createFtpProducer()), count);
            waitForMessages(listener, count);
            assertMessages(listener.getMessages(), count);
        } finally {
            stop(sc);
        }
    }
}
Also used : QuartzCronPoller(com.adaptris.core.QuartzCronPoller) MockMessageListener(com.adaptris.core.stubs.MockMessageListener) StandaloneConsumer(com.adaptris.core.StandaloneConsumer) StandaloneProducer(com.adaptris.core.StandaloneProducer) Test(org.junit.Test)

Example 5 with QuartzCronPoller

use of com.adaptris.core.QuartzCronPoller in project interlok by adaptris.

the class RelaxedFtpCase method testConsumeWithNonMatchingFilter.

@Test
public void testConsumeWithNonMatchingFilter() throws Exception {
    if (areTestsEnabled()) {
        MockMessageListener listener = new MockMessageListener();
        RelaxedFtpConsumer ftpConsumer = new RelaxedFtpConsumer();
        ftpConsumer.setFtpEndpoint(getDestinationString());
        ftpConsumer.setQuietInterval(DEFAULT_QUIET_PERIOD);
        ftpConsumer.setFileFilterImp(GlobFilenameFilter.class.getCanonicalName());
        ftpConsumer.registerAdaptrisMessageListener(listener);
        ftpConsumer.setFilterExpression(".xml");
        ftpConsumer.setPoller(new QuartzCronPoller("*/1 * * * * ?"));
        StandaloneConsumer sc = new StandaloneConsumer(createConnection(), ftpConsumer);
        start(sc);
        int count = 1;
        try {
            produce(new StandaloneProducer(createConnection(), createFtpProducer()), count);
            try {
                Thread.sleep(1500);
            } catch (Exception e) {
                ;
            }
            assertMessages(listener.getMessages(), 0);
        } finally {
            stop(sc);
        }
    }
}
Also used : QuartzCronPoller(com.adaptris.core.QuartzCronPoller) GlobFilenameFilter(org.apache.oro.io.GlobFilenameFilter) MockMessageListener(com.adaptris.core.stubs.MockMessageListener) StandaloneConsumer(com.adaptris.core.StandaloneConsumer) StandaloneProducer(com.adaptris.core.StandaloneProducer) CoreException(com.adaptris.core.CoreException) Test(org.junit.Test)

Aggregations

QuartzCronPoller (com.adaptris.core.QuartzCronPoller)19 Test (org.junit.Test)19 StandaloneConsumer (com.adaptris.core.StandaloneConsumer)16 StandaloneProducer (com.adaptris.core.StandaloneProducer)16 MockMessageListener (com.adaptris.core.stubs.MockMessageListener)16 CoreException (com.adaptris.core.CoreException)10 GlobFilenameFilter (org.apache.oro.io.GlobFilenameFilter)4 TimeInterval (com.adaptris.util.TimeInterval)3 MetadataFileNameCreator (com.adaptris.core.MetadataFileNameCreator)2 MimeEncoder (com.adaptris.core.MimeEncoder)2 GuidGenerator (com.adaptris.util.GuidGenerator)2 SafeGuidGenerator (com.adaptris.util.SafeGuidGenerator)1