Search in sources :

Example 91 with DefaultMessageFactory

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

the class ConfiguredContentTypeProviderTest method testGetContentType_ConfiguredCharset.

@Test
public void testGetContentType_ConfiguredCharset() throws Exception {
    ConfiguredContentTypeProvider provider = new ConfiguredContentTypeProvider("text/complicated; charset=ISO-8859-1");
    AdaptrisMessage msg = new DefaultMessageFactory().newMessage("");
    msg.addMetadata(testName.getMethodName(), "text/complicated");
    String contentType = provider.getContentType(msg);
    assertEquals("text/complicated; charset=ISO-8859-1", contentType);
}
Also used : DefaultMessageFactory(com.adaptris.core.DefaultMessageFactory) AdaptrisMessage(com.adaptris.core.AdaptrisMessage) Test(org.junit.Test)

Example 92 with DefaultMessageFactory

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

the class ConfiguredContentTypeProviderTest method testGetContentType_ConfiguredWithCrapParams.

@Test
public void testGetContentType_ConfiguredWithCrapParams() throws Exception {
    ConfiguredContentTypeProvider provider = new ConfiguredContentTypeProvider("text/complicated; shouldbreak=");
    AdaptrisMessage msg = new DefaultMessageFactory().newMessage("");
    msg.setContentEncoding("UTF-8");
    String contentType = provider.getContentType(msg);
    assertEquals("text/complicated; shouldbreak=; charset=UTF-8", contentType);
}
Also used : DefaultMessageFactory(com.adaptris.core.DefaultMessageFactory) AdaptrisMessage(com.adaptris.core.AdaptrisMessage) Test(org.junit.Test)

Example 93 with DefaultMessageFactory

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

the class ConfiguredContentTypeProviderTest method testGetContentType_ConfiguredWithCharset.

@Test
public void testGetContentType_ConfiguredWithCharset() throws Exception {
    ConfiguredContentTypeProvider provider = new ConfiguredContentTypeProvider("text/complicated; charset=ISO-8859-1");
    AdaptrisMessage msg = new DefaultMessageFactory().newMessage("");
    msg.setContentEncoding("UTF-8");
    String contentType = provider.getContentType(msg);
    assertEquals("text/complicated; charset=ISO-8859-1", contentType);
}
Also used : DefaultMessageFactory(com.adaptris.core.DefaultMessageFactory) AdaptrisMessage(com.adaptris.core.AdaptrisMessage) Test(org.junit.Test)

Example 94 with DefaultMessageFactory

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

the class ConfiguredContentTypeProviderTest method testGetContentType_WithCharset.

@Test
public void testGetContentType_WithCharset() throws Exception {
    ConfiguredContentTypeProvider provider = new ConfiguredContentTypeProvider("text/complicated");
    AdaptrisMessage msg = new DefaultMessageFactory().newMessage("");
    msg.setContentEncoding("UTF-8");
    String contentType = provider.getContentType(msg);
    assertEquals("text/complicated; charset=UTF-8", contentType);
}
Also used : DefaultMessageFactory(com.adaptris.core.DefaultMessageFactory) AdaptrisMessage(com.adaptris.core.AdaptrisMessage) Test(org.junit.Test)

Example 95 with DefaultMessageFactory

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

the class BlobMessageTranslatorTest method testBug895.

@Test
public void testBug895() throws Exception {
    MessageTypeTranslatorImp trans = new BlobMessageTranslator();
    JmsConnection conn = null;
    try {
        conn = activeMqBroker.getJmsConnection(new BasicActiveMqImplementation());
        start(conn);
        AdaptrisMessage msg = AdaptrisMessageFactory.getDefaultInstance().newMessage();
        msg.addMetadata(JmsConstants.JMS_PRIORITY, "9");
        msg.addMetadata(JmsConstants.JMS_TYPE, "idaho");
        Session session = conn.createSession(false, Session.CLIENT_ACKNOWLEDGE);
        trans.setMoveJmsHeaders(true);
        trans.registerSession(session);
        trans.registerMessageFactory(new DefaultMessageFactory());
        start(trans);
        Message jmsMsg = trans.translate(msg);
        assertNotSame("JMS Priorities should be different", jmsMsg.getJMSPriority(), 9);
        assertEquals("JMSType should be equal", "idaho", jmsMsg.getJMSType());
    } finally {
        stop(trans);
        stop(conn);
    }
}
Also used : DefaultMessageFactory(com.adaptris.core.DefaultMessageFactory) AdaptrisMessage(com.adaptris.core.AdaptrisMessage) Message(javax.jms.Message) AdaptrisMessage(com.adaptris.core.AdaptrisMessage) MessageTypeTranslatorImp(com.adaptris.core.jms.MessageTypeTranslatorImp) JmsConnection(com.adaptris.core.jms.JmsConnection) Session(javax.jms.Session) ActiveMQSession(org.apache.activemq.ActiveMQSession) Test(org.junit.Test)

Aggregations

DefaultMessageFactory (com.adaptris.core.DefaultMessageFactory)170 Test (org.junit.Test)163 AdaptrisMessage (com.adaptris.core.AdaptrisMessage)158 Channel (com.adaptris.core.Channel)37 MockMessageProducer (com.adaptris.core.stubs.MockMessageProducer)36 HttpConsumerTest (com.adaptris.core.http.jetty.HttpConsumerTest)30 JettyHelper.createChannel (com.adaptris.core.http.jetty.JettyHelper.createChannel)30 StandaloneProducer (com.adaptris.core.StandaloneProducer)27 ServiceException (com.adaptris.core.ServiceException)26 File (java.io.File)26 ServiceList (com.adaptris.core.ServiceList)18 HttpConnection (com.adaptris.core.http.jetty.HttpConnection)18 JettyMessageConsumer (com.adaptris.core.http.jetty.JettyMessageConsumer)18 StandardResponseProducer (com.adaptris.core.http.jetty.StandardResponseProducer)18 GuidGenerator (com.adaptris.util.GuidGenerator)18 StandaloneRequestor (com.adaptris.core.StandaloneRequestor)15 ValidationStage (com.adaptris.transform.validate.ValidationStage)15 ConfiguredRequestMethodProvider (com.adaptris.core.http.client.ConfiguredRequestMethodProvider)12 PayloadFromTemplateService (com.adaptris.core.services.metadata.PayloadFromTemplateService)11 StandardWorkflow (com.adaptris.core.StandardWorkflow)10