Search in sources :

Example 6 with StubMessageFactory

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

the class LineCountSplitterTest method testSetMessageFactory.

@Override
public void testSetMessageFactory() throws Exception {
    MessageSplitterImp splitter = createSplitterForTests();
    assertNull(splitter.getMessageFactory());
    assertEquals(DefaultMessageFactory.class, splitter.selectFactory(new DefaultMessageFactory().newMessage()).getClass());
    splitter.setMessageFactory(new StubMessageFactory());
    assertEquals(StubMessageFactory.class, splitter.getMessageFactory().getClass());
    assertEquals(StubMessageFactory.class, splitter.selectFactory(new DefaultMessageFactory().newMessage()).getClass());
    splitter.setMessageFactory(null);
    assertEquals(DefaultMessageFactory.class, splitter.selectFactory(new DefaultMessageFactory().newMessage()).getClass());
    assertEquals(StubMessageFactory.class, splitter.selectFactory(new StubMessageFactory().newMessage()).getClass());
}
Also used : DefaultMessageFactory(com.adaptris.core.DefaultMessageFactory) StubMessageFactory(com.adaptris.core.stubs.StubMessageFactory)

Example 7 with StubMessageFactory

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

the class SplitterCase method testSetMessageFactory.

@Test
public void testSetMessageFactory() throws Exception {
    MessageSplitterImp splitter = createSplitterForTests();
    assertNull(splitter.getMessageFactory());
    assertEquals(DefaultMessageFactory.class, splitter.selectFactory(new DefaultMessageFactory().newMessage()).getClass());
    assertEquals(StubMessageFactory.class, splitter.selectFactory(new StubMessageFactory().newMessage()).getClass());
    splitter.setMessageFactory(new StubMessageFactory());
    assertEquals(StubMessageFactory.class, splitter.getMessageFactory().getClass());
    assertEquals(StubMessageFactory.class, splitter.selectFactory(new DefaultMessageFactory().newMessage()).getClass());
    splitter.setMessageFactory(new DefaultMessageFactory());
    assertEquals(DefaultMessageFactory.class, splitter.selectFactory(new StubMessageFactory().newMessage()).getClass());
    splitter.setMessageFactory(null);
    assertEquals(DefaultMessageFactory.class, splitter.selectFactory(new DefaultMessageFactory().newMessage()).getClass());
    assertEquals(StubMessageFactory.class, splitter.selectFactory(new StubMessageFactory().newMessage()).getClass());
}
Also used : DefaultMessageFactory(com.adaptris.core.DefaultMessageFactory) StubMessageFactory(com.adaptris.core.stubs.StubMessageFactory) Test(org.junit.Test)

Example 8 with StubMessageFactory

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

the class HttpConsumerTest method testBasicConsumeWithCustomMessageImpl.

@Test
public void testBasicConsumeWithCustomMessageImpl() throws Exception {
    HttpConnection connection = createConnection(null);
    MockMessageProducer mockProducer = new MockMessageProducer();
    JettyMessageConsumer consumer = JettyHelper.createConsumer(URL_TO_POST_TO);
    Channel adapter = JettyHelper.createChannel(connection, consumer, mockProducer);
    try {
        consumer.setMessageFactory(new StubMessageFactory());
        adapter.requestStart();
        AdaptrisMessage msg = AdaptrisMessageFactory.getDefaultInstance().newMessage(XML_PAYLOAD);
        msg.addMetadata(CONTENT_TYPE_METADATA_KEY, "text/xml");
        httpProducer.setUrl(createProduceDestinationUrl(connection.getPort()));
        start(httpProducer);
        AdaptrisMessage reply = httpProducer.request(msg);
        assertEquals("Reply Payloads", XML_PAYLOAD, reply.getContent());
        doAssertions(mockProducer);
        assertEquals("Consumed Message Java Class", AdaptrisMessageStub.class, mockProducer.getMessages().get(0).getClass());
    } finally {
        stop(httpProducer);
        adapter.requestClose();
        PortManager.release(connection.getPort());
    }
}
Also used : MockMessageProducer(com.adaptris.core.stubs.MockMessageProducer) StaticMockMessageProducer(com.adaptris.core.stubs.StaticMockMessageProducer) StubMessageFactory(com.adaptris.core.stubs.StubMessageFactory) AdaptrisMessage(com.adaptris.core.AdaptrisMessage) Channel(com.adaptris.core.Channel) Test(org.junit.Test)

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