Search in sources :

Example 71 with MockMessageListener

use of com.adaptris.core.stubs.MockMessageListener in project interlok by adaptris.

the class FtpConsumerTest method testBasicConsume_NoDebug.

@Test
public void testBasicConsume_NoDebug() throws Exception {
    int count = 1;
    EmbeddedFtpServer helper = new EmbeddedFtpServer();
    MockMessageListener listener = new MockMessageListener();
    FakeFtpServer server = helper.createAndStart(helper.createFilesystem(count));
    StandaloneConsumer sc = null;
    try {
        FtpConsumer ftpConsumer = createForTests(listener);
        FtpConnection consumeConnection = create(server);
        consumeConnection.setAdditionalDebug(false);
        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 : FakeFtpServer(org.mockftpserver.fake.FakeFtpServer) MockMessageListener(com.adaptris.core.stubs.MockMessageListener) StandaloneConsumer(com.adaptris.core.StandaloneConsumer) Test(org.junit.Test)

Example 72 with MockMessageListener

use of com.adaptris.core.stubs.MockMessageListener in project interlok by adaptris.

the class FtpConsumerTest method testConsume_WithProcDirectory.

@Test
public void testConsume_WithProcDirectory() throws Exception {
    int count = 1;
    EmbeddedFtpServer helper = new EmbeddedFtpServer();
    MockMessageListener listener = new MockMessageListener(100);
    FileSystem filesystem = helper.createFilesystem_DirsOnly();
    for (int i = 0; i < count; i++) {
        filesystem.add(new FileEntry(DEFAULT_WORK_DIR_CANONICAL + SLASH + DEFAULT_FILENAME + i + ".txt", PAYLOAD));
    }
    FakeFtpServer server = helper.createAndStart(filesystem);
    StandaloneConsumer sc = null;
    try {
        FtpConsumer ftpConsumer = createForTests(listener);
        ftpConsumer.setProcDirectory(DEFAULT_PROC_DIR_CANONICAL);
        FtpConnection consumeConnection = create(server);
        sc = new StandaloneConsumer(consumeConnection, ftpConsumer);
        start(sc);
        waitForMessages(listener, count);
        Thread.sleep(500);
        helper.assertMessages(listener.getMessages(), count);
        assertEquals(count, filesystem.listFiles(DEFAULT_PROC_DIR_CANONICAL).size());
    } catch (Exception e) {
        throw e;
    } finally {
        stop(sc);
        server.stop();
    }
}
Also used : FakeFtpServer(org.mockftpserver.fake.FakeFtpServer) FileSystem(org.mockftpserver.fake.filesystem.FileSystem) FileEntry(org.mockftpserver.fake.filesystem.FileEntry) MockMessageListener(com.adaptris.core.stubs.MockMessageListener) StandaloneConsumer(com.adaptris.core.StandaloneConsumer) Test(org.junit.Test)

Example 73 with MockMessageListener

use of com.adaptris.core.stubs.MockMessageListener in project interlok by adaptris.

the class ActiveMqJmsPollingConsumerTest method testTopic_ProduceConsume.

@Test
public void testTopic_ProduceConsume() throws Exception {
    int msgCount = 5;
    String rfc6167 = "jms:topic:" + testName.getMethodName() + "?subscriptionId=" + testName.getMethodName();
    final StandaloneProducer sender = new StandaloneProducer(activeMqBroker.getJmsConnection(), new JmsProducer().withEndpoint(rfc6167));
    Sometime poller = new Sometime();
    JmsPollingConsumer consumer = createConsumer(activeMqBroker, testName.getMethodName(), rfc6167, poller);
    final StandaloneConsumer receiver = new StandaloneConsumer(consumer);
    try {
        MockMessageListener jms = new MockMessageListener();
        receiver.registerAdaptrisMessageListener(jms);
        startAndStop(receiver);
        start(receiver);
        start(sender);
        for (int i = 0; i < msgCount; i++) {
            sender.doService(createMessage());
        }
        waitForMessages(jms, msgCount);
        assertMessages(jms, msgCount);
    } finally {
        shutdownQuietly(sender, receiver);
    }
}
Also used : JmsProducer(com.adaptris.core.jms.JmsProducer) JmsPollingConsumer(com.adaptris.core.jms.JmsPollingConsumer) Sometime(com.adaptris.core.jms.activemq.ActiveMqPasPollingConsumerTest.Sometime) StandaloneConsumer(com.adaptris.core.StandaloneConsumer) MockMessageListener(com.adaptris.core.stubs.MockMessageListener) StandaloneProducer(com.adaptris.core.StandaloneProducer) Test(org.junit.Test)

Example 74 with MockMessageListener

use of com.adaptris.core.stubs.MockMessageListener in project interlok by adaptris.

the class ActiveMqJmsPollingConsumerTest method testTopic_NoSubscriptionId.

@Test
public void testTopic_NoSubscriptionId() throws Exception {
    String rfc6167 = "jms:topic:" + testName.getMethodName();
    final StandaloneConsumer consumer = createStandaloneConsumer(activeMqBroker, testName.getMethodName(), rfc6167);
    try {
        consumer.registerAdaptrisMessageListener(new MockMessageListener());
        // This won't fail, but... there will be errors in the log file...
        start(consumer);
    } finally {
        shutdownQuietly(null, consumer);
    }
}
Also used : StandaloneConsumer(com.adaptris.core.StandaloneConsumer) MockMessageListener(com.adaptris.core.stubs.MockMessageListener) Test(org.junit.Test)

Example 75 with MockMessageListener

use of com.adaptris.core.stubs.MockMessageListener in project interlok by adaptris.

the class ActiveMqJmsSyncConsumerTest method testTopic_ProduceConsume.

@Test
public void testTopic_ProduceConsume() throws Exception {
    int msgCount = 5;
    String rfc6167 = "jms:topic:" + testName.getMethodName() + "?subscriptionId=" + testName.getMethodName();
    final StandaloneProducer sender = new StandaloneProducer(activeMqBroker.getJmsConnection(), new JmsProducer().withEndpoint(rfc6167));
    Sometime poller = new Sometime();
    JmsSyncConsumer consumer = createConsumer(testName.getMethodName(), rfc6167, poller);
    final StandaloneConsumer receiver = new StandaloneConsumer(activeMqBroker.getJmsConnection(), consumer);
    try {
        MockMessageListener jms = new MockMessageListener();
        receiver.registerAdaptrisMessageListener(jms);
        startAndStop(receiver);
        start(receiver);
        start(sender);
        for (int i = 0; i < msgCount; i++) {
            sender.doService(createMessage());
        }
        waitForMessages(jms, msgCount);
        assertMessages(jms, msgCount);
    } finally {
        shutdownQuietly(sender, receiver);
    }
}
Also used : JmsSyncConsumer(com.adaptris.core.jms.JmsSyncConsumer) JmsProducer(com.adaptris.core.jms.JmsProducer) Sometime(com.adaptris.core.jms.activemq.ActiveMqPasPollingConsumerTest.Sometime) StandaloneConsumer(com.adaptris.core.StandaloneConsumer) MockMessageListener(com.adaptris.core.stubs.MockMessageListener) StandaloneProducer(com.adaptris.core.StandaloneProducer) Test(org.junit.Test)

Aggregations

MockMessageListener (com.adaptris.core.stubs.MockMessageListener)173 Test (org.junit.Test)171 StandaloneConsumer (com.adaptris.core.StandaloneConsumer)160 StandaloneProducer (com.adaptris.core.StandaloneProducer)91 TimeInterval (com.adaptris.util.TimeInterval)42 FakeFtpServer (org.mockftpserver.fake.FakeFtpServer)36 FixedIntervalPoller (com.adaptris.core.FixedIntervalPoller)32 AdaptrisMessage (com.adaptris.core.AdaptrisMessage)28 File (java.io.File)28 GuidGenerator (com.adaptris.util.GuidGenerator)27 FilenameFilter (java.io.FilenameFilter)24 Perl5FilenameFilter (org.apache.oro.io.Perl5FilenameFilter)24 PtpProducer (com.adaptris.core.jms.PtpProducer)23 PtpConsumer (com.adaptris.core.jms.PtpConsumer)22 RandomAccessFile (java.io.RandomAccessFile)21 QuartzCronPoller (com.adaptris.core.QuartzCronPoller)16 FileSystem (org.mockftpserver.fake.filesystem.FileSystem)16 PasProducer (com.adaptris.core.jms.PasProducer)15 LargeFsConsumer (com.adaptris.core.lms.LargeFsConsumer)15 CoreException (com.adaptris.core.CoreException)14