Package org.mule.api.transport

Examples of org.mule.api.transport.MuleMessageFactory.create()


    {
        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


    {
        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[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

                                         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);
    }

    public static MuleEvent getTestEvent(Object data, MuleSession session, MuleContext context)
View Full Code Here

            throws Exception
    {
        final InboundEndpoint endpoint = getTestInboundEndpoint("test1",
                                                                MessageExchangePattern.REQUEST_RESPONSE, context, null);
        final MuleMessageFactory factory = endpoint.getConnector().createMuleMessageFactory();
        final MuleMessage message = factory.create(data, endpoint.getEncoding(), context);

        return new DefaultMuleEvent(message, endpoint, getTestService(context), session);
    }

    public static MuleEventContext getTestEventContext(Object data,
View Full Code Here

    public void testAttachments() throws Exception
    {
        Message payload = createMimeMessageWithAttachment();

        MuleMessageFactory factory = createMuleMessageFactory();
        MuleMessage muleMessage = factory.create(payload, encoding, muleContext);
        assertEquals(2, muleMessage.getInboundAttachmentNames().size());
    }

    @Test
    public void testAddRecipientProperties() throws Exception
View Full Code Here

        payload.setFrom(new InternetAddress(TEST_FROM));
        payload.setReplyTo(new InternetAddress[]{new InternetAddress(TEST_REPLY_TO)});
        payload.setSentDate(now);

        MuleMessageFactory factory = createMuleMessageFactory();
        MuleMessage muleMessage = factory.create(payload, encoding, muleContext);

        assertEquals(TEST_TO, muleMessage.getInboundProperty(MailProperties.TO_ADDRESSES_PROPERTY));
        assertEquals(TEST_CC, muleMessage.getInboundProperty(MailProperties.CC_ADDRESSES_PROPERTY));
        assertEquals(TEST_BCC, muleMessage.getInboundProperty(MailProperties.BCC_ADDRESSES_PROPERTY));
        assertEquals(TEST_FROM, muleMessage.getInboundProperty(MailProperties.FROM_ADDRESS_PROPERTY));
View Full Code Here

        payload.setSubject(TEST_SUBJECT);
        payload.setHeader(MailProperties.CONTENT_TYPE_PROPERTY, invalid);
        payload.setHeader(customProperty, customProperty);

        MuleMessageFactory factory = createMuleMessageFactory();
        MuleMessage muleMessage = factory.create(payload, encoding, muleContext);

        assertEquals(TEST_TO, muleMessage.getInboundProperty(MailProperties.TO_ADDRESSES_PROPERTY));
        assertEquals(TEST_CC, muleMessage.getInboundProperty(MailProperties.CC_ADDRESSES_PROPERTY));
        assertEquals(TEST_BCC, muleMessage.getInboundProperty(MailProperties.BCC_ADDRESSES_PROPERTY));
        assertEquals(TEST_FROM, muleMessage.getInboundProperty(MailProperties.FROM_ADDRESS_PROPERTY));
View Full Code Here

    public void testAttachmentsWithSameName() throws Exception
    {
        Message payload = createMimeMessageWithSameAttachmentNames();

        MuleMessageFactory factory = createMuleMessageFactory();
        MuleMessage muleMessage = factory.create(payload, encoding, muleContext);
        assertEquals(3, muleMessage.getInboundAttachmentNames().size());
    }

    private Message createMimeMessageWithAttachment() throws Exception
    {
View Full Code Here

    @Override
    public void testValidPayload() throws Exception
    {
        MuleMessageFactory factory = createMuleMessageFactory();

        MuleMessage message = factory.create(getValidTransportMessage(), encoding, muleContext);
        assertNotNull(message);
        assertPayload(message);
        assertEquals(PORT, message.getInboundProperty(UdpConnector.PORT_PROPERTY));
        assertNotNull(message.getInboundProperty(UdpConnector.ADDRESS_PROPERTY));
    }
View Full Code Here

TOP
Copyright © 2018 www.massapi.com. 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.