Search in sources :

Example 1 with StubMessageFactory

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

the class DecodingServiceTest method testSetMessageFactory.

@Test
public void testSetMessageFactory() throws Exception {
    DecodingService s = new DecodingService();
    assertNull(s.getMessageFactory());
    s = new DecodingService(new MockEncoder());
    assertNull(s.getMessageFactory());
    assertTrue(s.getEncoder().currentMessageFactory() instanceof DefaultMessageFactory);
    s = new DecodingService(new MockEncoder());
    AdaptrisMessageFactory amf = new StubMessageFactory();
    s.setMessageFactory(amf);
    try {
        LifecycleHelper.init(s);
        assertEquals(amf, s.getMessageFactory());
        assertTrue(s.getEncoder().currentMessageFactory() instanceof StubMessageFactory);
        assertEquals(amf, s.getEncoder().currentMessageFactory());
    } finally {
        LifecycleHelper.close(s);
    }
}
Also used : DefaultMessageFactory(com.adaptris.core.DefaultMessageFactory) AdaptrisMessageFactory(com.adaptris.core.AdaptrisMessageFactory) MockEncoder(com.adaptris.core.stubs.MockEncoder) StubMessageFactory(com.adaptris.core.stubs.StubMessageFactory) Test(org.junit.Test)

Example 2 with StubMessageFactory

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

the class EncodingServiceTest method testSetMessageFactory.

@Test
public void testSetMessageFactory() throws Exception {
    EncodingService s = new EncodingService();
    assertNull(s.getMessageFactory());
    s = new EncodingService(new MockEncoder());
    assertNull(s.getMessageFactory());
    assertTrue(s.getEncoder().currentMessageFactory() instanceof DefaultMessageFactory);
    s = new EncodingService(new MockEncoder());
    AdaptrisMessageFactory amf = new StubMessageFactory();
    s.setMessageFactory(amf);
    try {
        LifecycleHelper.init(s);
        assertEquals(amf, s.getMessageFactory());
        assertTrue(s.getEncoder().currentMessageFactory() instanceof StubMessageFactory);
        assertEquals(amf, s.getEncoder().currentMessageFactory());
    } finally {
        LifecycleHelper.close(s);
    }
}
Also used : DefaultMessageFactory(com.adaptris.core.DefaultMessageFactory) AdaptrisMessageFactory(com.adaptris.core.AdaptrisMessageFactory) MockEncoder(com.adaptris.core.stubs.MockEncoder) StubMessageFactory(com.adaptris.core.stubs.StubMessageFactory) Test(org.junit.Test)

Example 3 with StubMessageFactory

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

the class BasicActiveMqProducerTest method testQueueProduceAndConsume_CustomMessageFactory.

@Test
public void testQueueProduceAndConsume_CustomMessageFactory() throws Exception {
    PtpConsumer consumer = new PtpConsumer().withQueue(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 PtpProducer().withQueue((getName())));
    execute(standaloneConsumer, standaloneProducer, createMessage(), jms);
    assertMessages(jms, 1);
    assertEquals(AdaptrisMessageStub.class, jms.getMessages().get(0).getClass());
}
Also used : PtpConsumer(com.adaptris.core.jms.PtpConsumer) StubMessageFactory(com.adaptris.core.stubs.StubMessageFactory) 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 StubMessageFactory

use of com.adaptris.core.stubs.StubMessageFactory 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 5 with StubMessageFactory

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

the class XpathSplitterTest method testSplit_AlternativeMessageFactory.

@Test
public void testSplit_AlternativeMessageFactory() throws Exception {
    AdaptrisMessage msg = new StubMessageFactory().newMessage(XML_MESSAGE, ENCODING_UTF8);
    String obj = "ABCDEFG";
    msg.addObjectHeader(obj, obj);
    XpathMessageSplitter splitter = new XpathMessageSplitter(ENVELOPE_DOCUMENT);
    int count = 0;
    try (CloseableIterable<AdaptrisMessage> closeable = splitter.splitMessage(msg)) {
        for (AdaptrisMessage m : closeable) {
            assertEquals(StubMessageFactory.class, m.getFactory().getClass());
            count++;
        }
    }
    assertEquals("Number of messages", 3, count);
}
Also used : StubMessageFactory(com.adaptris.core.stubs.StubMessageFactory) AdaptrisMessage(com.adaptris.core.AdaptrisMessage) Test(org.junit.Test) XpathMetadataServiceTest(com.adaptris.core.services.metadata.XpathMetadataServiceTest)

Aggregations

StubMessageFactory (com.adaptris.core.stubs.StubMessageFactory)8 Test (org.junit.Test)7 DefaultMessageFactory (com.adaptris.core.DefaultMessageFactory)4 AdaptrisMessage (com.adaptris.core.AdaptrisMessage)2 AdaptrisMessageFactory (com.adaptris.core.AdaptrisMessageFactory)2 StandaloneConsumer (com.adaptris.core.StandaloneConsumer)2 StandaloneProducer (com.adaptris.core.StandaloneProducer)2 MockEncoder (com.adaptris.core.stubs.MockEncoder)2 MockMessageListener (com.adaptris.core.stubs.MockMessageListener)2 Channel (com.adaptris.core.Channel)1 PasConsumer (com.adaptris.core.jms.PasConsumer)1 PasProducer (com.adaptris.core.jms.PasProducer)1 PtpConsumer (com.adaptris.core.jms.PtpConsumer)1 PtpProducer (com.adaptris.core.jms.PtpProducer)1 XpathMetadataServiceTest (com.adaptris.core.services.metadata.XpathMetadataServiceTest)1 MockMessageProducer (com.adaptris.core.stubs.MockMessageProducer)1 StaticMockMessageProducer (com.adaptris.core.stubs.StaticMockMessageProducer)1