Package org.mule.api.client

Examples of org.mule.api.client.MuleClient.send()


    @Test
    public void testAnonymous() throws Exception
    {
        MuleClient client = new DefaultLocalMuleClient(muleContext);
        MuleMessage result = client.send("anonymousReplyClientEndpoint", new DefaultMuleMessage("test", muleContext));
        assertEquals("Hello test", result.getPayloadAsString());
    }

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


    @Test
    public void testDecoupled() throws Exception
    {
        MuleClient client = new DefaultLocalMuleClient(muleContext);
        MuleMessage result = client.send("decoupledClientEndpoint", new DefaultMuleMessage("test", muleContext));
        assertEquals("Hello test", result.getPayloadAsString());
    }

}
View Full Code Here

    {
        MuleClient client = muleContext.getClient();
        Map<String, Object> props = new HashMap<String, Object>();
        props.put("Content-Type", "application/soap+xml");
        InputStream xml = getClass().getResourceAsStream("/direct/direct-request.xml");
        MuleMessage result = client.send(((InboundEndpoint) muleContext.getRegistry()
            .lookupObject("httpInbound")).getAddress(), xml, props);
        assertTrue(result.getPayloadAsString().contains("Hello!"));
        String ct = result.getInboundProperty(HttpConstants.HEADER_CONTENT_TYPE, "");
        assertEquals("text/xml; charset=UTF-8", ct);
    }
View Full Code Here

    public void testEchoServiceEncoding() throws Exception
    {
        MuleClient client = muleContext.getClient();
        String message = LocaleMessageHandler.getString("test-data",
            Locale.JAPAN, "CxfBasicTestCase.testEchoServiceEncoding", new Object[]{});
        MuleMessage result = client.send("cxf:" + ((InboundEndpoint) muleContext.getRegistry()
                        .lookupObject("httpInbound")).getAddress() + "?method=echo", message, null);
        String ct = result.getInboundProperty(HttpConstants.HEADER_CONTENT_TYPE, "");

        assertEquals(message, result.getPayload());
        assertEquals("text/xml; charset=UTF-8", ct);
View Full Code Here

    @Test
    public void testCustomProvider() throws Exception
    {
        MuleClient client = muleContext.getClient();
        client.send("vm://in", createOutboundMessage());

        Thread.sleep(1000);

        AbderaClient aClient = new AbderaClient();
        String url = "http://localhost:" + dynamicPort.getNumber() + "/events";
View Full Code Here

    public void testHttp10TransformerNotOnProtocol() throws Exception
    {
        MuleClient client = muleContext.getClient();

        Map<String,Object> props = new HashMap<String, Object>();
        MuleMessage result = client.send("cxfOutbound", "Dan", props);
        assertEquals("Hello Dan", result.getPayload());

        result = client.request("vm://out", 1000);
        assertFalse("chunked".equals(result.getOutboundProperty(HttpConstants.HEADER_TRANSFER_ENCODING)));
    }
View Full Code Here

    public void testHttp10TransformerOnProtocol() throws Exception
    {
        MuleClient client = muleContext.getClient();

        Map<String, Object> props = new HashMap<String, Object>();
        MuleMessage result = client.send("cxfOutbound2", "Dan", props);
        assertEquals("Hello Dan", result.getPayload());

        result = client.request("vm://out", 1000);
        assertFalse("chunked".equals(result.getOutboundProperty(HttpConstants.HEADER_TRANSFER_ENCODING)));
    }
View Full Code Here

        //
        String msg = "<soap:Envelope xmlns:soap=\"http://schemas.xmlsoap.org/soap/envelope/\">"
                     + "<soap:Body>" + "<test> foo </test>" + "</soap:Body>" + "</soap:Envelope>";

        MuleClient client = muleContext.getClient();
        MuleMessage result = client.send("http://localhost:" + dynamicPort.getNumber() + "/services/Echo", msg, null);
        byte[] res = (byte[]) result.getPayload();
        String resString = new String(res);

        assertTrue(resString.indexOf("<test> foo </test>") != -1);
    }
View Full Code Here

    protected MuleMessage sendRequest(String url,String payload) throws MuleException
    {
        MuleClient client = muleContext.getClient();
        Map<String, Object> props = new HashMap<String, Object>();
        props.put("http.method", "POST");
        MuleMessage replyMessage = client.send(url, payload, props);
        return replyMessage;
    }
}
View Full Code Here

    @Test
    public void testFaultInCxfService() throws Exception
    {
        MuleMessage request = new DefaultMuleMessage(requestFaultPayload, (Map<String,Object>)null, muleContext);
        MuleClient client = muleContext.getClient();
        MuleMessage response = client.send("http://localhost:" + dynamicPort.getNumber() + "/testServiceWithFault", request);
        assertNotNull(response);
        assertTrue(response.getPayloadAsString().contains("<faultstring>"));
        assertEquals(String.valueOf(HttpConstants.SC_INTERNAL_SERVER_ERROR), response.getInboundProperty(HttpConnector.HTTP_STATUS_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.