Search in sources :

Example 11 with QuartzCronPoller

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

the class FtpCase method testConsumeWithQuietPeriod.

@Test
public void testConsumeWithQuietPeriod() throws Exception {
    Assume.assumeTrue(areTestsEnabled());
    MockMessageListener listener = new MockMessageListener();
    FtpConsumer ftpConsumer = new FtpConsumer();
    ftpConsumer.setFtpEndpoint(getDestinationString());
    ftpConsumer.setWorkDirectory(DEFAULT_WORK_DIR);
    ftpConsumer.setQuietInterval(new TimeInterval(3L, TimeUnit.SECONDS));
    ftpConsumer.registerAdaptrisMessageListener(listener);
    ftpConsumer.setPoller(new QuartzCronPoller("*/1 * * * * ?"));
    StandaloneConsumer sc = new StandaloneConsumer(createConnection(), ftpConsumer);
    start(sc);
    int count = 1;
    try {
        produce(new StandaloneProducer(createConnection(), createFtpProducer()), 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 : 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) Test(org.junit.Test)

Example 12 with QuartzCronPoller

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

the class FtpCase method testBasicConsumeWithOverride.

@Test
public void testBasicConsumeWithOverride() throws Exception {
    Assume.assumeTrue(areTestsEnabled());
    MockMessageListener listener = new MockMessageListener();
    FtpConsumer ftpConsumer = new FtpConsumer();
    ftpConsumer.setFtpEndpoint(getDestinationStringWithOverride());
    ftpConsumer.setWorkDirectory(DEFAULT_WORK_DIR);
    ftpConsumer.registerAdaptrisMessageListener(listener);
    // Pass in a QuartzId so we don't print out the uname+password.
    ftpConsumer.setPoller(new QuartzCronPoller("*/1 * * * * ?", "testBasicConsumeWithOverride"));
    FileTransferConnection con = createConnection();
    con.setDefaultUserName(null);
    StandaloneConsumer sc = new StandaloneConsumer(con, ftpConsumer);
    start(sc);
    int count = 1;
    try {
        produce(new StandaloneProducer(createConnection(), createFtpProducer()), 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) MockMessageListener(com.adaptris.core.stubs.MockMessageListener) StandaloneConsumer(com.adaptris.core.StandaloneConsumer) StandaloneProducer(com.adaptris.core.StandaloneProducer) Test(org.junit.Test)

Example 13 with QuartzCronPoller

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

the class FtpCase method testConsumeWithNonMatchingFilter.

@Test
public void testConsumeWithNonMatchingFilter() 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.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)

Example 14 with QuartzCronPoller

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

the class RelaxedFtpCase method testConsume_WithEncoder.

@Test
public void testConsume_WithEncoder() throws Exception {
    if (areTestsEnabled()) {
        MockMessageListener listener = new MockMessageListener();
        RelaxedFtpConsumer ftpConsumer = new RelaxedFtpConsumer();
        ftpConsumer.setFtpEndpoint(getDestinationString());
        ftpConsumer.registerAdaptrisMessageListener(listener);
        ftpConsumer.setQuietInterval(DEFAULT_QUIET_PERIOD);
        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 = 1;
        try {
            FileTransferConnection produceConnection = createConnection();
            produceConnection.setCacheConnection(true);
            RelaxedFtpProducer 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 : 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 15 with QuartzCronPoller

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

the class RelaxedFtpCase method testBasicConsume_WithTrailingSlash.

@Test
public void testBasicConsume_WithTrailingSlash() throws Exception {
    if (areTestsEnabled()) {
        MockMessageListener listener = new MockMessageListener();
        RelaxedFtpConsumer ftpConsumer = new RelaxedFtpConsumer();
        String destination = getDestinationString() + "/";
        ftpConsumer.setFtpEndpoint(getDestinationString());
        ftpConsumer.registerAdaptrisMessageListener(listener);
        ftpConsumer.setQuietInterval(DEFAULT_QUIET_PERIOD);
        ftpConsumer.setPoller(new QuartzCronPoller("*/1 * * * * ?"));
        StandaloneConsumer sc = new StandaloneConsumer(createConnection(), ftpConsumer);
        start(sc);
        int count = 1;
        try {
            RelaxedFtpProducer producer = createFtpProducer();
            producer.setFtpEndpoint(destination);
            produce(new StandaloneProducer(createConnection(), producer), count);
            waitForMessages(listener, count);
            assertMessages(listener.getMessages(), count);
        } catch (Exception e) {
            log.error(e.getMessage(), e);
            throw e;
        } 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) 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