Package org.mule.api.transport

Examples of org.mule.api.transport.MuleMessageFactory


    }
   
    @Test
    public void testNullPayload() throws Exception
    {
        MuleMessageFactory factory = createMuleMessageFactory();
       
        MuleMessage message = factory.create(null, encoding, muleContext);
        assertNotNull(message);
        assertEquals(NullPayload.getInstance(), message.getPayload());
    }
View Full Code Here


    }

    @Test
    public void testValidPayload() throws Exception
    {
        MuleMessageFactory factory = createMuleMessageFactory();
   
        Object payload = getValidTransportMessage();
        MuleMessage message = factory.create(payload, encoding, muleContext);
        assertNotNull(message);
        assertEquals(payload, message.getPayload());
    }
View Full Code Here

        if (runUnsuppoprtedTransportMessageTest == false)
        {
            return;
        }
       
        MuleMessageFactory factory = createMuleMessageFactory();
       
        Object invalidPayload = getUnsupportedTransportMessage();
        try
        {
            factory.create(invalidPayload, encoding, muleContext);
            fail("Creating a MuleMessageFactory from an invalid transport message must fail");
        }
        catch (MessageTypeNotSupportedException mtnse)
        {
            // this one was expected
View Full Code Here

        }
    }

    protected MuleMessageFactory createMuleMessageFactory()
    {
        MuleMessageFactory factory = doCreateMuleMessageFactory();
        assertNotNull(factory);
        return factory;
    }
View Full Code Here

    }

    @Override
    public void testValidPayload() throws Exception
    {
        MuleMessageFactory factory = createMuleMessageFactory();
       
        Object payload = getValidTransportMessage();
        MuleMessage message = factory.create(payload, encoding, muleContext);
        assertNotNull(message);
        assertEquals("/services/Echo", message.getPayload());
        // note that on this level it's only message factory, and it adds messages from http request to the inbound scope
        assertEquals(HttpConstants.METHOD_GET, message.getInboundProperty(HttpConnector.HTTP_METHOD_PROPERTY));
        assertEquals("foo-value", message.getInboundProperty("foo-header"));
View Full Code Here

    public void testHttpMethodGet() throws Exception
    {
        InputStream body = new ByteArrayInputStream("/services/Echo".getBytes());
        HttpMethod method = createMockHttpMethod(HttpConstants.METHOD_GET, body, URI, HEADERS);
       
        MuleMessageFactory factory = createMuleMessageFactory();
        MuleMessage message = factory.create(method, encoding, muleContext);
        assertNotNull(message);
        assertEquals("/services/Echo", message.getPayloadAsString());
        assertEquals(HttpConstants.METHOD_GET, message.getInboundProperty(HttpConnector.HTTP_METHOD_PROPERTY));
        assertEquals(HttpVersion.HTTP_1_1.toString(), message.getInboundProperty(HttpConnector.HTTP_VERSION_PROPERTY));
        assertEquals("200", message.getInboundProperty(HttpConnector.HTTP_STATUS_PROPERTY));
View Full Code Here

    public void testHttpMethodPost() throws Exception
    {
        InputStream body = new ByteArrayInputStream(TEST_MESSAGE.getBytes());
        HttpMethod method = createMockHttpMethod(HttpConstants.METHOD_POST, body, "http://localhost/services/Echo", HEADERS);

        MuleMessageFactory factory = createMuleMessageFactory();
        MuleMessage message = factory.create(method, encoding, muleContext);
        assertNotNull(message);
        assertEquals(TEST_MESSAGE, message.getPayloadAsString());
        assertEquals(HttpConstants.METHOD_POST, message.getInboundProperty(HttpConnector.HTTP_METHOD_PROPERTY));
        assertEquals(HttpVersion.HTTP_1_1.toString(), message.getInboundProperty(HttpConnector.HTTP_VERSION_PROPERTY));
        assertEquals("200", message.getInboundProperty(HttpConnector.HTTP_STATUS_PROPERTY));
View Full Code Here

    public void testQueryParamProperties() throws Exception
    {
        InputStream body = new ByteArrayInputStream(REQUEST.getBytes());
        HttpMethod method = createMockHttpMethod(HttpConstants.METHOD_GET, body, "http://localhost" + REQUEST, HEADERS);

        MuleMessageFactory factory = createMuleMessageFactory();
        MuleMessage message = factory.create(method, encoding, muleContext);
        Map<String, Object> queryParams = (Map<String, Object>) message.getInboundProperty(HttpConnector.HTTP_QUERY_PARAMS);
        assertNotNull(queryParams);
        assertEquals("John", queryParams.get("name"));
        assertEquals("John", message.getInboundProperty("name"));
        assertEquals("Galt", queryParams.get("lastname"));
View Full Code Here

        headers[1] = new Header("User-Agent", "Mozilla/5.0 (compatible; MSIE 9.0; Windows NT 6.1; WOW64; Trident/5.0)");
        headers[2] = new Header("Host", "localhost");

        HttpMethod method = createMockHttpMethod(HttpConstants.METHOD_GET, body, URI, headers);

        MuleMessageFactory factory = createMuleMessageFactory();
        MuleMessage message = factory.create(method, encoding, muleContext);
        Map<String, Object> httpHeaders = message.getInboundProperty(HttpConnector.HTTP_HEADERS);
        assertNotNull(headers);
        assertEquals("foo-value", httpHeaders.get("foo-header"));
        assertEquals("Mozilla/5.0 (compatible; MSIE 9.0; Windows NT 6.1; WOW64; Trident/5.0)", httpHeaders.get("User-Agent"));
        assertEquals("localhost", httpHeaders.get("Host"));
View Full Code Here

                                         InboundEndpoint endpoint,
                                         MuleContext context) throws Exception
    {
        final MuleSession session = getTestSession(flowConstruct, context);

        final MuleMessageFactory factory = endpoint.getConnector().createMuleMessageFactory();
        final MuleMessage message = factory.create(data, endpoint.getEncoding(), context);

        return new DefaultMuleEvent(message, endpoint, flowConstruct, session);
    }
View Full Code Here

TOP

Related Classes of org.mule.api.transport.MuleMessageFactory

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.