Search in sources :

Example 96 with StandaloneConsumer

use of com.adaptris.core.StandaloneConsumer in project interlok by adaptris.

the class BasicActiveMqProducerTest method testBlobConsumeWithNonBlob.

@Test
public void testBlobConsumeWithNonBlob() throws Exception {
    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 TextMessageTranslator());
    StandaloneProducer standaloneProducer = new StandaloneProducer(activeMqBroker.getJmsConnection(createVendorImpl()), producer);
    execute(standaloneConsumer, standaloneProducer, EmbeddedActiveMq.createMessage(null), jms);
    assertMessages(jms, 1, true);
}
Also used : PtpConsumer(com.adaptris.core.jms.PtpConsumer) TextMessageTranslator(com.adaptris.core.jms.TextMessageTranslator) 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 97 with StandaloneConsumer

use of com.adaptris.core.StandaloneConsumer in project interlok by adaptris.

the class BasicActiveMqProducerTest method testQueueProduceAndConsumeWithSecurity_EncryptedPassword.

@Test
public void testQueueProduceAndConsumeWithSecurity_EncryptedPassword() throws Exception {
    RequiresCredentialsBroker broker = new RequiresCredentialsBroker();
    try {
        broker.start();
        PtpConsumer consumer = new PtpConsumer().withQueue(RequiresCredentialsBroker.DEFAULT_PREFIX + "queue");
        consumer.setAcknowledgeMode("AUTO_ACKNOWLEDGE");
        JmsConnection conn = broker.getJmsConnection(createVendorImpl(), true);
        conn.setUserName(RequiresCredentialsBroker.DEFAULT_USERNAME);
        conn.setPassword(Password.encode(RequiresCredentialsBroker.DEFAULT_PASSWORD, Password.PORTABLE_PASSWORD));
        StandaloneConsumer standaloneConsumer = new StandaloneConsumer(conn, consumer);
        MockMessageListener jms = new MockMessageListener();
        standaloneConsumer.registerAdaptrisMessageListener(jms);
        conn = broker.getJmsConnection(createVendorImpl());
        conn.setUserName(RequiresCredentialsBroker.DEFAULT_USERNAME);
        conn.setPassword(RequiresCredentialsBroker.DEFAULT_PASSWORD);
        StandaloneProducer standaloneProducer = new StandaloneProducer(conn, new PtpProducer().withQueue((RequiresCredentialsBroker.DEFAULT_PREFIX + "queue")));
        execute(standaloneConsumer, standaloneProducer, createMessage(), jms);
        assertMessages(jms, 1);
    } finally {
        broker.destroy();
    }
}
Also used : PtpConsumer(com.adaptris.core.jms.PtpConsumer) JmsConnection(com.adaptris.core.jms.JmsConnection) 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 98 with StandaloneConsumer

use of com.adaptris.core.StandaloneConsumer in project interlok by adaptris.

the class BasicActiveMqProducerTest method testQueueProduceAndConsumeWithSecurity.

@Test
public void testQueueProduceAndConsumeWithSecurity() throws Exception {
    RequiresCredentialsBroker broker = new RequiresCredentialsBroker();
    try {
        broker.start();
        PtpConsumer consumer = new PtpConsumer().withQueue(RequiresCredentialsBroker.DEFAULT_PREFIX + "queue");
        consumer.setAcknowledgeMode("AUTO_ACKNOWLEDGE");
        JmsConnection conn = broker.getJmsConnection(createVendorImpl(), true);
        conn.setUserName(RequiresCredentialsBroker.DEFAULT_USERNAME);
        conn.setPassword(RequiresCredentialsBroker.DEFAULT_PASSWORD);
        StandaloneConsumer standaloneConsumer = new StandaloneConsumer(conn, consumer);
        MockMessageListener jms = new MockMessageListener();
        standaloneConsumer.registerAdaptrisMessageListener(jms);
        conn = broker.getJmsConnection(createVendorImpl());
        conn.setUserName(RequiresCredentialsBroker.DEFAULT_USERNAME);
        conn.setPassword(RequiresCredentialsBroker.DEFAULT_PASSWORD);
        StandaloneProducer standaloneProducer = new StandaloneProducer(conn, new PtpProducer().withQueue((RequiresCredentialsBroker.DEFAULT_PREFIX + "queue")));
        execute(standaloneConsumer, standaloneProducer, createMessage(), jms);
        assertMessages(jms, 1);
    } finally {
        broker.destroy();
    }
}
Also used : PtpConsumer(com.adaptris.core.jms.PtpConsumer) JmsConnection(com.adaptris.core.jms.JmsConnection) 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 99 with StandaloneConsumer

use of com.adaptris.core.StandaloneConsumer in project interlok by adaptris.

the class BasicActiveMqProducerTest method testTopicProduceAndConsume_CustomMessageFactory.

@Test
public void testTopicProduceAndConsume_CustomMessageFactory() throws Exception {
    PasConsumer consumer = new PasConsumer().withTopic(getName());
    consumer.setAcknowledgeMode("AUTO_ACKNOWLEDGE");
    consumer.setMessageFactory(new StubMessageFactory());
    StandaloneConsumer standaloneConsumer = new StandaloneConsumer(activeMqBroker.getJmsConnection(createVendorImpl()), consumer);
    MockMessageListener jms = new MockMessageListener();
    standaloneConsumer.registerAdaptrisMessageListener(jms);
    StandaloneProducer standaloneProducer = new StandaloneProducer(activeMqBroker.getJmsConnection(createVendorImpl()), new PasProducer().withTopic(getName()));
    execute(standaloneConsumer, standaloneProducer, createMessage(), jms);
    assertMessages(jms, 1);
    assertEquals(AdaptrisMessageStub.class, jms.getMessages().get(0).getClass());
}
Also used : PasConsumer(com.adaptris.core.jms.PasConsumer) StubMessageFactory(com.adaptris.core.stubs.StubMessageFactory) PasProducer(com.adaptris.core.jms.PasProducer) StandaloneConsumer(com.adaptris.core.StandaloneConsumer) MockMessageListener(com.adaptris.core.stubs.MockMessageListener) StandaloneProducer(com.adaptris.core.StandaloneProducer) Test(org.junit.Test)

Example 100 with StandaloneConsumer

use of com.adaptris.core.StandaloneConsumer in project interlok by adaptris.

the class BasicActiveMqConsumerTest method testTopicProduceAndConsume.

@Test
public void testTopicProduceAndConsume() throws Exception {
    PasConsumer consumer = new PasConsumer().withTopic(getName());
    consumer.setAcknowledgeMode("AUTO_ACKNOWLEDGE");
    StandaloneConsumer standaloneConsumer = new StandaloneConsumer(activeMqBroker.getJmsConnection(createVendorImpl()), consumer);
    MockMessageListener jms = new MockMessageListener();
    standaloneConsumer.registerAdaptrisMessageListener(jms);
    StandaloneProducer standaloneProducer = new StandaloneProducer(activeMqBroker.getJmsConnection(createVendorImpl()), new PasProducer().withTopic(getName()));
    // INTERLOK-3329 For coverage so the prepare() warning is executed 2x
    LifecycleHelper.prepare(standaloneConsumer);
    LifecycleHelper.prepare(standaloneProducer);
    execute(standaloneConsumer, standaloneProducer, createMessage(null), jms);
    assertMessages(jms, 1);
    AdaptrisMessage consumed = jms.getMessages().get(0);
    // Since it's not a workflow; this will be false.
    assertFalse(consumed.headersContainsKey(CoreConstants.MESSAGE_CONSUME_LOCATION));
}
Also used : PasConsumer(com.adaptris.core.jms.PasConsumer) AdaptrisMessage(com.adaptris.core.AdaptrisMessage) PasProducer(com.adaptris.core.jms.PasProducer) StandaloneConsumer(com.adaptris.core.StandaloneConsumer) MockMessageListener(com.adaptris.core.stubs.MockMessageListener) StandaloneProducer(com.adaptris.core.StandaloneProducer) Test(org.junit.Test)

Aggregations

StandaloneConsumer (com.adaptris.core.StandaloneConsumer)188 Test (org.junit.Test)164 MockMessageListener (com.adaptris.core.stubs.MockMessageListener)160 StandaloneProducer (com.adaptris.core.StandaloneProducer)91 TimeInterval (com.adaptris.util.TimeInterval)49 FixedIntervalPoller (com.adaptris.core.FixedIntervalPoller)37 File (java.io.File)31 GuidGenerator (com.adaptris.util.GuidGenerator)30 FakeFtpServer (org.mockftpserver.fake.FakeFtpServer)30 PtpConsumer (com.adaptris.core.jms.PtpConsumer)24 FilenameFilter (java.io.FilenameFilter)24 RandomAccessFile (java.io.RandomAccessFile)24 Perl5FilenameFilter (org.apache.oro.io.Perl5FilenameFilter)24 PtpProducer (com.adaptris.core.jms.PtpProducer)23 AdaptrisMessage (com.adaptris.core.AdaptrisMessage)22 QuartzCronPoller (com.adaptris.core.QuartzCronPoller)17 CoreException (com.adaptris.core.CoreException)16 PasProducer (com.adaptris.core.jms.PasProducer)15 LargeFsConsumer (com.adaptris.core.lms.LargeFsConsumer)15 PasConsumer (com.adaptris.core.jms.PasConsumer)14