Search in sources :

Example 1 with FsConsumer

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

the class JmsTransactedWorkflowTest method testInit_UnsupportedConsumer.

@Test
public void testInit_UnsupportedConsumer() throws Exception {
    Channel channel = createStartableChannel(activeMqBroker);
    JmsTransactedWorkflow workflow = (JmsTransactedWorkflow) channel.getWorkflowList().get(0);
    workflow.setConsumer(new FsConsumer().withBaseDirectoryUrl("file:////path/to/directory"));
    try {
        channel.requestInit();
    } catch (CoreException expected) {
        assertEquals("JmsTransactedWorkflow must be used with a JMSConsumer", expected.getMessage());
    } finally {
        channel.requestClose();
    }
}
Also used : CoreException(com.adaptris.core.CoreException) FsConsumer(com.adaptris.core.fs.FsConsumer) MockChannel(com.adaptris.core.stubs.MockChannel) Channel(com.adaptris.core.Channel) Test(org.junit.Test)

Example 2 with FsConsumer

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

the class DefaultFailedMessageRetrierTest method createForExamples.

@Override
protected DefaultFailedMessageRetrier createForExamples() {
    DefaultFailedMessageRetrier fmr = new DefaultFailedMessageRetrier();
    FsConsumer consumer = new FsConsumer();
    consumer.setBaseDirectoryUrl("/path/to/retry-directory");
    consumer.setEncoder(new MimeEncoder(true, null, null));
    fmr.setStandaloneConsumer(new StandaloneConsumer(consumer));
    return fmr;
}
Also used : FsConsumer(com.adaptris.core.fs.FsConsumer)

Example 3 with FsConsumer

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

the class SharedComponentListTest method createAdapter.

private Adapter createAdapter() throws CoreException, PasswordException {
    Adapter adapter = new Adapter();
    adapter.setUniqueId("upbeat_liskov");
    JmsConnection jmsConnection = createPtpConnection("jms-connection");
    adapter.getSharedComponents().addConnection(jmsConnection);
    ServiceList serviceList = new ServiceList();
    serviceList.setUniqueId("shared-service-list");
    serviceList.add(new LogMessageService("log-message-service"));
    adapter.getSharedComponents().addService(serviceList);
    StandardWorkflow wf1 = new StandardWorkflow();
    wf1.setUniqueId("reverent-edison");
    wf1.setConsumer(new FsConsumer().withBaseDirectoryUrl("in-directory"));
    wf1.setProducer(new FsProducer().withBaseDirectoryUrl("out-directory"));
    wf1.getServiceCollection().add(new SharedService("shared-service-list"));
    StandardWorkflow wf = new StandardWorkflow();
    wf.setUniqueId("pedantic_brown");
    wf.setConsumer(new JmsConsumer().withEndpoint("jms:queue:SampleQueue1"));
    wf.setProducer(new NullMessageProducer());
    wf.getServiceCollection().add(new StandaloneProducer(new SharedConnection("jms-connection"), new JmsProducer().withEndpoint("jms:topic:MyTopicName")));
    Channel channel = new Channel();
    channel.setUniqueId("quirky_shannon");
    channel.setConsumeConnection(new SharedConnection("jms-connection"));
    channel.getWorkflowList().add(wf);
    channel.getWorkflowList().add(wf1);
    adapter.getChannelList().add(channel);
    return adapter;
}
Also used : JmsProducer(com.adaptris.core.jms.JmsProducer) LogMessageService(com.adaptris.core.services.LogMessageService) FsProducer(com.adaptris.core.fs.FsProducer) JmsConsumer(com.adaptris.core.jms.JmsConsumer) FsConsumer(com.adaptris.core.fs.FsConsumer) JmsConnection(com.adaptris.core.jms.JmsConnection)

Example 4 with FsConsumer

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

the class DefaultFailedMessageRetrierTest method retrieveObjectForSampleConfig.

@Override
protected Object retrieveObjectForSampleConfig() {
    Adapter result = null;
    try {
        DefaultFailedMessageRetrier fmr = new DefaultFailedMessageRetrier();
        FsConsumer consumer = new FsConsumer().withBaseDirectoryUrl("/path/to/retry-directory");
        StandaloneConsumer c = new StandaloneConsumer(consumer);
        fmr.setStandaloneConsumer(c);
        result = new Adapter();
        result.setFailedMessageRetrier(fmr);
        result.setChannelList(new ChannelList());
        result.setEventHandler(new StubEventHandler());
        result.setUniqueId(UUID.randomUUID().toString());
    } catch (Exception e) {
        throw new RuntimeException(e);
    }
    return result;
}
Also used : FsConsumer(com.adaptris.core.fs.FsConsumer) StubEventHandler(com.adaptris.core.stubs.StubEventHandler)

Example 5 with FsConsumer

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

the class LargeFsConsumerTest method testConsumeWithAlternateFactory.

@Test
public void testConsumeWithAlternateFactory() throws Exception {
    String subDir = GUID.safeUUID();
    MockMessageListener stub = new MockMessageListener(10);
    FsConsumer fs = createConsumer(subDir);
    fs.setResetWipFiles(false);
    fs.setMessageFactory(new DefaultMessageFactory());
    fs.setPoller(new FixedIntervalPoller(new TimeInterval(300L, TimeUnit.MILLISECONDS)));
    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();
        super.createFiles(baseDir, ".xml", count);
        start(sc);
        waitForMessages(stub, count);
        assertEquals(count, stub.getMessages().size());
        super.assertMessages(stub.getMessages(), count, baseDir.listFiles((FilenameFilter) new Perl5FilenameFilter(".*\\.xml")));
        assertDefaultMessageType(stub.getMessages());
    } finally {
        stop(sc);
        FileUtils.deleteQuietly(new File(parentDir, subDir));
    }
}
Also used : DefaultMessageFactory(com.adaptris.core.DefaultMessageFactory) 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