Search in sources :

Example 36 with MockMessageListener

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

the class ActiveMqJmsSyncConsumerTest method testQueue_ProduceConsume.

@Test
public void testQueue_ProduceConsume() throws Exception {
    int msgCount = 5;
    String rfc6167 = "jms:queue:" + testName.getMethodName();
    final StandaloneProducer sender = new StandaloneProducer(activeMqBroker.getJmsConnection(), new JmsProducer().withEndpoint(rfc6167));
    final StandaloneConsumer receiver = createStandaloneConsumer(activeMqBroker, testName.getMethodName(), rfc6167);
    try {
        MockMessageListener jms = new MockMessageListener();
        receiver.registerAdaptrisMessageListener(jms);
        // INTERLOK-3329 For coverage so the prepare() warning is executed 2x
        LifecycleHelper.prepare(sender);
        LifecycleHelper.prepare(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) StandaloneConsumer(com.adaptris.core.StandaloneConsumer) MockMessageListener(com.adaptris.core.stubs.MockMessageListener) StandaloneProducer(com.adaptris.core.StandaloneProducer) Test(org.junit.Test)

Example 37 with MockMessageListener

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

the class ActiveMqJmsSyncConsumerTest 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 38 with MockMessageListener

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

the class OnMessageHandlerTest method setUp.

@Before
public void setUp() throws Exception {
    MockitoAnnotations.openMocks(this);
    mockCorrelationSourceId = new MessageIdCorrelationIdSource();
    mockListener = new MockMessageListener();
    mockListener.setChannel(mockChannel);
    mockTranslator = new TextMessageTranslator();
    config = new MockConsumer();
    config.setCurrentSession(mockSession);
    messageProperties = Collections.emptyEnumeration();
    when(jmsMessage.getPropertyNames()).thenReturn(messageProperties);
    when(jmsMessage.getJMSMessageID()).thenReturn("id");
    when(mockSession.getTransacted()).thenReturn(false);
    when(mockChannel.isAvailable()).thenReturn(true);
    when(mockChannel.getConsumeConnection()).thenReturn(mockConnection);
    when(mockChannel.getProduceConnection()).thenReturn(mockConnection);
}
Also used : MockConsumer(com.adaptris.interlok.junit.scaffolding.jms.MockConsumer) MockMessageListener(com.adaptris.core.stubs.MockMessageListener) Before(org.junit.Before)

Example 39 with MockMessageListener

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

the class JndiPtpProducerCase method testProduceAndConsumeUsingJndiOnly.

@Test
public void testProduceAndConsumeUsingJndiOnly() throws Exception {
    StandardJndiImplementation recvVendorImp = createVendorImplementation();
    StandardJndiImplementation sendVendorImp = createVendorImplementation();
    String queueName = testName.getMethodName() + "_queue";
    String topicName = testName.getMethodName() + "_topic";
    StandaloneConsumer standaloneConsumer = new StandaloneConsumer(activeMqBroker.getJndiPtpConnection(recvVendorImp, true, queueName, topicName), new PtpConsumer().withQueue(queueName));
    MockMessageListener jms = new MockMessageListener();
    standaloneConsumer.registerAdaptrisMessageListener(jms);
    StandaloneProducer standaloneProducer = new StandaloneProducer(activeMqBroker.getJndiPtpConnection(sendVendorImp, true, queueName, topicName), new PtpProducer().withQueue((queueName)));
    execute(standaloneConsumer, standaloneProducer, createMessage(null), jms);
    assertMessages(jms);
}
Also used : PtpConsumer(com.adaptris.core.jms.PtpConsumer) StandardJndiImplementation(com.adaptris.core.jms.jndi.StandardJndiImplementation) 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 40 with MockMessageListener

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

the class JndiPtpProducerCase method testProduceAndConsume_ExtraConfig.

@Test
public void testProduceAndConsume_ExtraConfig() throws Exception {
    SimpleFactoryConfiguration sfc = new SimpleFactoryConfiguration();
    KeyValuePairSet kvps = new KeyValuePairSet();
    kvps.add(new KeyValuePair("ClientID", "testProduceAndConsume_ExtraConfig"));
    kvps.add(new KeyValuePair("UseCompression", "true"));
    sfc.setProperties(kvps);
    String queueName = testName.getMethodName() + "_queue";
    String topicName = testName.getMethodName() + "_topic";
    StandardJndiImplementation recvVendorImp = createVendorImplementation();
    StandardJndiImplementation sendVendorImp = createVendorImplementation();
    sendVendorImp.setExtraFactoryConfiguration(sfc);
    StandaloneConsumer standaloneConsumer = new StandaloneConsumer(activeMqBroker.getJndiPtpConnection(recvVendorImp, false, queueName, topicName), new PtpConsumer().withQueue(queueName));
    MockMessageListener jms = new MockMessageListener();
    standaloneConsumer.registerAdaptrisMessageListener(jms);
    StandaloneProducer standaloneProducer = new StandaloneProducer(activeMqBroker.getJndiPtpConnection(sendVendorImp, false, queueName, topicName), new PtpProducer().withQueue((queueName)));
    execute(standaloneConsumer, standaloneProducer, createMessage(null), jms);
    assertMessages(jms);
}
Also used : PtpConsumer(com.adaptris.core.jms.PtpConsumer) KeyValuePair(com.adaptris.util.KeyValuePair) StandardJndiImplementation(com.adaptris.core.jms.jndi.StandardJndiImplementation) SimpleFactoryConfiguration(com.adaptris.core.jms.jndi.SimpleFactoryConfiguration) PtpProducer(com.adaptris.core.jms.PtpProducer) KeyValuePairSet(com.adaptris.util.KeyValuePairSet) 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