Search in sources :

Example 6 with FsConsumer

use of com.adaptris.core.fs.FsConsumer in project interlok by adaptris.

the class LargeFsConsumerTest method testConsume_WithUnsupportedEncoder.

@Test
public void testConsume_WithUnsupportedEncoder() throws Exception {
    String subDir = GUID.safeUUID();
    MockMessageListener stub = new MockMessageListener(10);
    FsConsumer fs = createConsumer(subDir);
    fs.setResetWipFiles(false);
    fs.setPoller(new FixedIntervalPoller(new TimeInterval(300L, TimeUnit.MILLISECONDS)));
    fs.setEncoder(new MimeEncoder());
    StandaloneConsumer sc = new StandaloneConsumer(fs);
    sc.registerAdaptrisMessageListener(stub);
    int count = 10;
    File parentDir = FsHelper.createFileReference(FsHelper.createUrlFromString(PROPERTIES.getProperty(BASE_KEY), true));
    try {
        File baseDir = new File(parentDir, subDir);
        baseDir.mkdirs();
        createMimeFiles(baseDir, ".xml", count);
        start(sc);
        waitForMessages(stub, count);
        assertEquals(count, stub.getMessages().size());
        assertIgnoreSize(stub.getMessages(), count, baseDir.listFiles((FilenameFilter) new Perl5FilenameFilter(".*\\.xml")));
    } finally {
        stop(sc);
    // FileUtils.deleteQuietly(new File(parentDir, subDir));
    }
}
Also used : FilenameFilter(java.io.FilenameFilter) Perl5FilenameFilter(org.apache.oro.io.Perl5FilenameFilter) Perl5FilenameFilter(org.apache.oro.io.Perl5FilenameFilter) TimeInterval(com.adaptris.util.TimeInterval) MimeEncoder(com.adaptris.core.MimeEncoder) FsConsumer(com.adaptris.core.fs.FsConsumer) MockMessageListener(com.adaptris.core.stubs.MockMessageListener) FixedIntervalPoller(com.adaptris.core.FixedIntervalPoller) StandaloneConsumer(com.adaptris.core.StandaloneConsumer) File(java.io.File) FsMessageConsumerTest(com.adaptris.core.fs.FsMessageConsumerTest) Test(org.junit.Test)

Example 7 with FsConsumer

use of com.adaptris.core.fs.FsConsumer in project interlok by adaptris.

the class LargeFsConsumerTest method testConsume_WithEncoder.

@Test
public void testConsume_WithEncoder() throws Exception {
    String subDir = GUID.safeUUID();
    MockMessageListener stub = new MockMessageListener(10);
    FsConsumer fs = createConsumer(subDir);
    fs.setResetWipFiles(false);
    fs.setPoller(new FixedIntervalPoller(new TimeInterval(300L, TimeUnit.MILLISECONDS)));
    fs.setEncoder(new FileBackedMimeEncoder());
    StandaloneConsumer sc = new StandaloneConsumer(fs);
    sc.registerAdaptrisMessageListener(stub);
    int count = 10;
    File parentDir = FsHelper.createFileReference(FsHelper.createUrlFromString(PROPERTIES.getProperty(BASE_KEY), true));
    try {
        File baseDir = new File(parentDir, subDir);
        baseDir.mkdirs();
        createMimeFiles(baseDir, ".xml", count);
        start(sc);
        waitForMessages(stub, count);
        assertEquals(count, stub.getMessages().size());
        assertIgnoreSize(stub.getMessages(), count, baseDir.listFiles((FilenameFilter) new Perl5FilenameFilter(".*\\.xml")));
    } finally {
        stop(sc);
    // FileUtils.deleteQuietly(new File(parentDir, subDir));
    }
}
Also used : FilenameFilter(java.io.FilenameFilter) Perl5FilenameFilter(org.apache.oro.io.Perl5FilenameFilter) Perl5FilenameFilter(org.apache.oro.io.Perl5FilenameFilter) TimeInterval(com.adaptris.util.TimeInterval) FsConsumer(com.adaptris.core.fs.FsConsumer) MockMessageListener(com.adaptris.core.stubs.MockMessageListener) FixedIntervalPoller(com.adaptris.core.FixedIntervalPoller) StandaloneConsumer(com.adaptris.core.StandaloneConsumer) File(java.io.File) FsMessageConsumerTest(com.adaptris.core.fs.FsMessageConsumerTest) Test(org.junit.Test)

Aggregations

FsConsumer (com.adaptris.core.fs.FsConsumer)7 Test (org.junit.Test)4 FixedIntervalPoller (com.adaptris.core.FixedIntervalPoller)3 StandaloneConsumer (com.adaptris.core.StandaloneConsumer)3 FsMessageConsumerTest (com.adaptris.core.fs.FsMessageConsumerTest)3 MockMessageListener (com.adaptris.core.stubs.MockMessageListener)3 TimeInterval (com.adaptris.util.TimeInterval)3 File (java.io.File)3 FilenameFilter (java.io.FilenameFilter)3 Perl5FilenameFilter (org.apache.oro.io.Perl5FilenameFilter)3 Channel (com.adaptris.core.Channel)1 CoreException (com.adaptris.core.CoreException)1 DefaultMessageFactory (com.adaptris.core.DefaultMessageFactory)1 MimeEncoder (com.adaptris.core.MimeEncoder)1 FsProducer (com.adaptris.core.fs.FsProducer)1 JmsConnection (com.adaptris.core.jms.JmsConnection)1 JmsConsumer (com.adaptris.core.jms.JmsConsumer)1 JmsProducer (com.adaptris.core.jms.JmsProducer)1 LogMessageService (com.adaptris.core.services.LogMessageService)1 MockChannel (com.adaptris.core.stubs.MockChannel)1