Search in sources :

Example 1 with FileBackedMessageFactory

use of com.adaptris.core.lms.FileBackedMessageFactory in project interlok by adaptris.

the class FilesystemRetryStoreTest method testWrite_FileBacked.

@Test
public void testWrite_FileBacked() throws Exception {
    FilesystemRetryStore store = new FilesystemRetryStore().withBaseUrl(BaseCase.getConfiguration(TEST_BASE_URL));
    try {
        LifecycleHelper.initAndStart(store);
        AdaptrisMessage msg = new FileBackedMessageFactory().newMessage("hello");
        store.write(msg);
        File dir = FsHelper.toFile(BaseCase.getConfiguration(TEST_BASE_URL));
        assertTrue(dir.listFiles((FileFilter) DirectoryFileFilter.DIRECTORY).length >= 1);
    } finally {
        LifecycleHelper.stopAndClose(store);
    }
}
Also used : FileBackedMessageFactory(com.adaptris.core.lms.FileBackedMessageFactory) AdaptrisMessage(com.adaptris.core.AdaptrisMessage) DirectoryFileFilter(org.apache.commons.io.filefilter.DirectoryFileFilter) FileFilter(java.io.FileFilter) File(java.io.File) Test(org.junit.Test)

Example 2 with FileBackedMessageFactory

use of com.adaptris.core.lms.FileBackedMessageFactory in project interlok by adaptris.

the class FtpRecursiveConsumerTest method testBasicConsume_WithFileBackedMessage.

@Test
public void testBasicConsume_WithFileBackedMessage() throws Exception {
    int count = 1;
    EmbeddedFtpServer helper = new EmbeddedFtpServer();
    MockMessageListener listener = new MockMessageListener();
    FakeFtpServer server = helper.createAndStart(helper.createFilesystem(count));
    StandaloneConsumer sc = null;
    try {
        FtpRecursiveConsumer ftpConsumer = createForTests(listener);
        ftpConsumer.setMessageFactory(new FileBackedMessageFactory());
        FtpConnection consumeConnection = create(server);
        sc = new StandaloneConsumer(consumeConnection, ftpConsumer);
        start(sc);
        waitForMessages(listener, count);
        helper.assertMessages(listener.getMessages(), count);
    } catch (Exception e) {
        throw e;
    } finally {
        stop(sc);
        server.stop();
    }
}
Also used : FileBackedMessageFactory(com.adaptris.core.lms.FileBackedMessageFactory) FakeFtpServer(org.mockftpserver.fake.FakeFtpServer) MockMessageListener(com.adaptris.core.stubs.MockMessageListener) StandaloneConsumer(com.adaptris.core.StandaloneConsumer) Test(org.junit.Test)

Example 3 with FileBackedMessageFactory

use of com.adaptris.core.lms.FileBackedMessageFactory in project interlok by adaptris.

the class BasicActiveMqConsumerTest method testBlobProduceAndConsumeWithFileMessageFactory.

@Test
public void testBlobProduceAndConsumeWithFileMessageFactory() throws Exception {
    if (!ExternalResourcesHelper.isExternalServerAvailable()) {
        log.debug("Blob Server not available; skipping test");
        return;
    }
    PtpConsumer consumer = new PtpConsumer().withQueue(getName());
    consumer.setAcknowledgeMode("AUTO_ACKNOWLEDGE");
    consumer.setMessageTranslator(new BlobMessageTranslator());
    StandaloneConsumer standaloneConsumer = new StandaloneConsumer(activeMqBroker.getJmsConnection(createVendorImpl()), consumer);
    MockMessageListener jms = new MockMessageListener();
    standaloneConsumer.registerAdaptrisMessageListener(jms);
    PtpProducer producer = new PtpProducer().withQueue((getName()));
    producer.setMessageTranslator(new BlobMessageTranslator("blobUrl"));
    StandaloneProducer standaloneProducer = new StandaloneProducer(activeMqBroker.getJmsConnection(createVendorImpl()), producer);
    execute(standaloneConsumer, standaloneProducer, addBlobUrlRef(createMessage(new FileBackedMessageFactory()), "blobUrl"), jms);
    assertMessages(jms, 1, false);
}
Also used : PtpConsumer(com.adaptris.core.jms.PtpConsumer) FileBackedMessageFactory(com.adaptris.core.lms.FileBackedMessageFactory) PtpProducer(com.adaptris.core.jms.PtpProducer) StandaloneConsumer(com.adaptris.core.StandaloneConsumer) MockMessageListener(com.adaptris.core.stubs.MockMessageListener) StandaloneProducer(com.adaptris.core.StandaloneProducer) Test(org.junit.Test)

Example 4 with FileBackedMessageFactory

use of com.adaptris.core.lms.FileBackedMessageFactory in project interlok by adaptris.

the class ExampleEventHandlerCase method testSetMessageFactory.

@Test
public void testSetMessageFactory() throws Exception {
    T eh = newEventHandler(getName());
    assertNull(eh.getMessageFactory());
    assertEquals(DefaultMessageFactory.class, eh.currentMessageFactory().getClass());
    eh.setMessageFactory(new FileBackedMessageFactory());
    assertNotNull(eh.getMessageFactory());
    assertEquals(FileBackedMessageFactory.class, eh.getMessageFactory().getClass());
    assertEquals(FileBackedMessageFactory.class, eh.currentMessageFactory().getClass());
}
Also used : FileBackedMessageFactory(com.adaptris.core.lms.FileBackedMessageFactory) Test(org.junit.Test)

Example 5 with FileBackedMessageFactory

use of com.adaptris.core.lms.FileBackedMessageFactory in project interlok by adaptris.

the class SerializableMessageTranslatorTest method testMessageFactory.

@Test
public void testMessageFactory() throws Exception {
    DefaultSerializableMessageTranslator translator = new DefaultSerializableMessageTranslator();
    assertEquals(DefaultMessageFactory.class, translator.currentMessageFactory().getClass());
    translator.registerMessageFactory(new FileBackedMessageFactory());
    assertEquals(FileBackedMessageFactory.class, translator.currentMessageFactory().getClass());
}
Also used : FileBackedMessageFactory(com.adaptris.core.lms.FileBackedMessageFactory) Test(org.junit.Test)

Aggregations

FileBackedMessageFactory (com.adaptris.core.lms.FileBackedMessageFactory)16 Test (org.junit.Test)16 AdaptrisMessage (com.adaptris.core.AdaptrisMessage)4 StandaloneConsumer (com.adaptris.core.StandaloneConsumer)4 MockMessageListener (com.adaptris.core.stubs.MockMessageListener)4 DefaultMessageFactory (com.adaptris.core.DefaultMessageFactory)2 StandaloneProducer (com.adaptris.core.StandaloneProducer)2 PtpConsumer (com.adaptris.core.jms.PtpConsumer)2 PtpProducer (com.adaptris.core.jms.PtpProducer)2 FileBackedMessage (com.adaptris.core.lms.FileBackedMessage)2 SerializableMessage (com.adaptris.interlok.types.SerializableMessage)2 File (java.io.File)2 FakeFtpServer (org.mockftpserver.fake.FakeFtpServer)2 FileFilter (java.io.FileFilter)1 RandomAccessFile (java.io.RandomAccessFile)1 DirectoryFileFilter (org.apache.commons.io.filefilter.DirectoryFileFilter)1