Package org.mule.api

Examples of org.mule.api.MuleMessage


        {

            @Override
            public boolean validate(MessageHasElementAssertionCommand command)
            {
                MuleMessage message = mock(MuleMessage.class);
                when(message.getProperty("param", PropertyScope.INBOUND)).thenReturn(new Object());

                return command.messageHas("param", message);
            }
        })));
        verify(context).declareFunction(eq("messageHasInboundPropertyCalled"), argThat(functionMatcher(MessageHasElementAssertionMelFunction.class, new CommandValidator<MessageHasElementAssertionCommand>()
        {

            @Override
            public boolean validate(MessageHasElementAssertionCommand command)
            {
                MuleMessage message = mock(MuleMessage.class);
                when(message.getInboundProperty("param")).thenReturn(new Object());

                return command.messageHas("param", message) && !command.messageHas("param2", message);
            }
        })));
        verify(context).declareFunction(eq("messageHasOutboundPropertyCalled"), argThat(functionMatcher(MessageHasElementAssertionMelFunction.class, new CommandValidator<MessageHasElementAssertionCommand>()
        {

            @Override
            public boolean validate(MessageHasElementAssertionCommand command)
            {
                MuleMessage message = mock(MuleMessage.class);
                when(message.getOutboundProperty("param")).thenReturn(new Object());

                return command.messageHas("param", message) && !command.messageHas("param2", message);
            }
        })));
        verify(context).declareFunction(eq("messageHasSessionPropertyCalled"), argThat(functionMatcher(MessageHasElementAssertionMelFunction.class, new CommandValidator<MessageHasElementAssertionCommand>()
        {

            @Override
            public boolean validate(MessageHasElementAssertionCommand command)
            {
                MuleMessage message = mock(MuleMessage.class);
                when(message.getProperty("param", PropertyScope.SESSION)).thenReturn(new Object());

                return command.messageHas("param", message) && !command.messageHas("param2", message);
            }
        })));
        verify(context).declareFunction(eq("messageHasInvocationPropertyCalled"), argThat(functionMatcher(MessageHasElementAssertionMelFunction.class, new CommandValidator<MessageHasElementAssertionCommand>()
        {

            @Override
            public boolean validate(MessageHasElementAssertionCommand command)
            {
                MuleMessage message = mock(MuleMessage.class);
                when(message.getInvocationProperty("param")).thenReturn(new Object());

                return command.messageHas("param", message) && !command.messageHas("param2", message);
            }
        })));
        verify(context).declareFunction(eq("messageHasInboundAttachmentCalled"), argThat(functionMatcher(MessageHasElementAssertionMelFunction.class, new CommandValidator<MessageHasElementAssertionCommand>()
        {

            @Override
            public boolean validate(MessageHasElementAssertionCommand command)
            {
                MuleMessage message = mock(MuleMessage.class);
                when(message.getInboundAttachment("param")).thenReturn(new DataHandler(new Object(), "url"));

                return command.messageHas("param", message) && !command.messageHas("param2", message);
            }
        })));
        verify(context).declareFunction(eq("messageHasOutboundAttachmentCalled"), argThat(functionMatcher(MessageHasElementAssertionMelFunction.class, new CommandValidator<MessageHasElementAssertionCommand>()
        {

            @Override
            public boolean validate(MessageHasElementAssertionCommand command)
            {
                MuleMessage message = mock(MuleMessage.class);
                when(message.getOutboundAttachment("param")).thenReturn(new DataHandler(new Object(), "url"));

                return command.messageHas("param", message) && !command.messageHas("param2", message);
            }
        })));
        verify(context).declareFunction(eq("messageInboundProperty"), argThat(assertMatcher(MessageMatchingAssertionMelFunction.class, new CommandValidator<ElementMatcherFactory>()
        {

            @Override
            public boolean validate(ElementMatcherFactory command)
            {
                MuleMessage message = mock(MuleMessage.class);
                command.build("param", message);

                verify(message).getInboundProperty("param");

                return true;
            }
        })));
        verify(context).declareFunction(eq("messageOutboundProperty"), argThat(assertMatcher(MessageMatchingAssertionMelFunction.class, new CommandValidator<ElementMatcherFactory>()
        {

            @Override
            public boolean validate(ElementMatcherFactory command)
            {
                MuleMessage message = mock(MuleMessage.class);
                command.build("param", message);

                verify(message).getOutboundProperty("param");

                return true;
            }
        })));
        verify(context).declareFunction(eq("messageInvocationProperty"), argThat(assertMatcher(MessageMatchingAssertionMelFunction.class, new CommandValidator<ElementMatcherFactory>()
        {

            @Override
            public boolean validate(ElementMatcherFactory command)
            {
                MuleMessage message = mock(MuleMessage.class);
                command.build("param", message);

                verify(message).getInvocationProperty("param");

                return true;
            }
        })));
        verify(context).declareFunction(eq("messageInboundAttachment"), argThat(assertMatcher(MessageMatchingAssertionMelFunction.class, new CommandValidator<ElementMatcherFactory>()
        {

            @Override
            public boolean validate(ElementMatcherFactory command)
            {
                MuleMessage message = mock(MuleMessage.class);
                command.build("param", message);

                verify(message).getInboundAttachment("param");

                return true;
            }
        })));
        verify(context).declareFunction(eq("messageOutboundAttachment"), argThat(assertMatcher(MessageMatchingAssertionMelFunction.class, new CommandValidator<ElementMatcherFactory>()
        {

            @Override
            public boolean validate(ElementMatcherFactory command)
            {
                MuleMessage message = mock(MuleMessage.class);
                command.build("param", message);

                verify(message).getOutboundAttachment("param");

                return true;
View Full Code Here


    {
        // Will connect to the server using remote endpoint
        MuleClient client = new MuleClient(muleContext);
        RemoteDispatcher dispatcher = client.getRemoteDispatcher(getRemoteEndpointUri());
        MuleMessage message = dispatcher.sendToRemoteComponent("TestReceiverUMO", "Test Client Send message", null);
        assertNotNull(message);
        assertEquals("Test Client Send message Received", message.getPayload());
    }
View Full Code Here

    {
        // Will connect to the server using tcp://localhost:60504
        MuleClient client = new MuleClient(muleContext);
        RemoteDispatcher dispatcher = client.getRemoteDispatcher(getRemoteEndpointUri());
        MuleMessage message = dispatcher.sendRemote("vm://remote.endpoint?connector=vmRemoteConnector", "foo",
                null);
        assertNotNull(message);
        assertEquals("received from remote component", message.getPayloadAsString());
    }
View Full Code Here

        MuleClient client = new MuleClient(muleContext);

        RemoteDispatcher dispatcher = client.getRemoteDispatcher(getRemoteEndpointUri());
        // Doubling timeout see MULE-3000
        // Use TIMEOUT_NOT_SET_VALUE as we need respective remoteDispatcherEndpoint to you timeout as defined on the endpoint. 
        MuleMessage message = dispatcher.receiveRemote(remoteEndpoint,MuleEvent.TIMEOUT_NOT_SET_VALUE);
        assertNull(message);
        // We do a send instead of a dispatch here so the operation is
        // synchronous thus eaiser to test
        dispatcher.sendRemote(remoteEndpoint, "Test Remote Message 2", null);

        // Doubling timeout see MULE-3000
        message = dispatcher.receiveRemote(remoteEndpoint, RECEIVE_TIMEOUT * 2);
        assertNotNull(message);
        assertEquals("Test Remote Message 2", message.getPayload());
    }
View Full Code Here

    // }

    public void testVmSync() throws Exception
    {
        MuleClient client = new MuleClient(muleContext);
        MuleMessage message = client.send("vm://sync", "request", null);
        assertNotNull(message);
        assertEquals("request" + VM_OUT_IN_RESP, message.getPayloadAsString());
    }
View Full Code Here

    {
        MuleClient client = new MuleClient(muleContext);
        Map props = new HashMap();
        // This will disable the transformers configured in the VM connector's service-overrides.
        props.put(MuleProperties.MULE_DISABLE_TRANSPORT_TRANSFORMER_PROPERTY, "true");
        MuleMessage message = client.send("vm://syncResponseTransformer", "request", props);
        assertNotNull(message);
        assertEquals("request" + CUSTOM_RESPONSE, message.getPayloadAsString());
    }
View Full Code Here

    }

    public void testHttpSync() throws Exception
    {
        MuleClient client = new MuleClient(muleContext);
        MuleMessage message = client.send("http://localhost:4446", "request", null);
        assertNotNull(message);
        // Ensure MuleMessageToHttpResponse was used before sending response

        String server = message.getInboundProperty(HttpConstants.HEADER_SERVER);
        assertTrue(server.startsWith("Mule"));

        String dateStr = message.getInboundProperty(HttpConstants.HEADER_DATE);
        SimpleDateFormat format = new SimpleDateFormat(HttpConstants.DATE_FORMAT, Locale.US);
        Date msgDate = format.parse(dateStr);
        assertTrue(new Date().after(msgDate));
       
        assertEquals("request", message.getPayloadAsString());
    }
View Full Code Here

    }

    public void testHttpSyncResponseTransformer() throws Exception
    {
        MuleClient client = new MuleClient(muleContext);
        MuleMessage message = client.send("http://localhost:4447", "request", null);
        assertNotNull(message);

        String server = message.getInboundProperty(HttpConstants.HEADER_SERVER);
        assertTrue(server.startsWith("Mule"));

        String dateStr = message.getInboundProperty(HttpConstants.HEADER_DATE);
        SimpleDateFormat format = new SimpleDateFormat(HttpConstants.DATE_FORMAT, Locale.US);
        Date msgDate = format.parse(dateStr);
        assertTrue(new Date().after(msgDate));
       
        assertEquals("request" + CUSTOM_RESPONSE, message.getPayloadAsString());
    }
View Full Code Here

    // Applied by ReplyToHandler

    public void testJmsSyncResponseTransformer() throws Exception
    {
        MuleClient client = new MuleClient(muleContext);
        MuleMessage message = client.send("jms://sync", "request", null);
        assertNotNull(message);
        assertEquals("request" + CUSTOM_RESPONSE, message.getPayloadAsString());
    }
View Full Code Here

    // Applied by DefaultMuleSession once result message is received from remote endpoint.

    public void testVmSyncOutboundEndpointResponseTransformer() throws Exception
    {
        MuleClient client = new MuleClient(muleContext);
        MuleMessage message = client.send("vm://syncOutboundEndpointResponseTransformer", "request", null);
        assertNotNull(message);
         assertEquals("request" + VM_OUTBOUND + VM_INBOUND + VM_OUT_IN_RESP + CUSTOM_RESPONSE + VM_RESPONSE,
         message.getPayloadAsString());
    }
View Full Code Here

TOP

Related Classes of org.mule.api.MuleMessage

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.