Search in sources :

Example 16 with QuartzCronPoller

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

the class RelaxedFtpCase method testConsumeWithFilter.

@Test
public void testConsumeWithFilter() 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(".txt");
        ftpConsumer.setPoller(new QuartzCronPoller("*/1 * * * * ?"));
        StandaloneConsumer sc = new StandaloneConsumer(createConnection(), ftpConsumer);
        start(sc);
        int count = 1;
        try {
            RelaxedFtpProducer 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);
            waitForMessages(listener, count);
            assertMessages(listener.getMessages(), count);
        } finally {
            stop(sc);
        }
    }
}
Also used : QuartzCronPoller(com.adaptris.core.QuartzCronPoller) GlobFilenameFilter(org.apache.oro.io.GlobFilenameFilter) SafeGuidGenerator(com.adaptris.util.SafeGuidGenerator) 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 17 with QuartzCronPoller

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

the class RelaxedFtpCase method testConsumeWithQuietPeriod.

@Test
public void testConsumeWithQuietPeriod() 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 {
            produce(new StandaloneProducer(createConnection(), 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 18 with QuartzCronPoller

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

the class RelaxedFtpCase method testBasicConsume.

@Test
public void testBasicConsume() 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 * * * * ?"));
        StandaloneConsumer sc = new StandaloneConsumer(createConnection(), ftpConsumer);
        start(sc);
        int count = 1;
        try {
            produce(new StandaloneProducer(createConnection(), createFtpProducer()), 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)

Example 19 with QuartzCronPoller

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

the class RelaxedFtpCase method testConsume_CachedConnection.

@Test
public void testConsume_CachedConnection() 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 * * * * ?"));
        FileTransferConnectionUsingPassword consumeConnection = createConnection();
        consumeConnection.setCacheConnection(true);
        StandaloneConsumer sc = new StandaloneConsumer(consumeConnection, ftpConsumer);
        start(sc);
        int count = 1;
        try {
            FileTransferConnectionUsingPassword 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 : 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