Package org.mule.api.client

Examples of org.mule.api.client.MuleClient


        ScheduledDispatchJobConfig jobConfig = new ScheduledDispatchJobConfig();
        jobConfig.setMuleContext(muleContext);
        jobConfig.setEndpointRef("vm://quartz.in");

        MuleClient client = muleContext.getClient();
        client.dispatch("vm://quartz.scheduler2", jobConfig, null);
        assertTrue(count.await(7000));

        // now that the scheduler sent the event, null out the event callback to avoid CountdownCallback
        // report more messages than requested during shutdown of the test/Mule server
        component.setEventCallback(null);
View Full Code Here


    }

    @Override
    public void testSend() throws Exception
    {
        MuleClient client = muleContext.getClient();

        Map<String, Object> messageProperties = new HashMap<String, Object>();
        messageProperties.put(HttpConstants.HEADER_CONTENT_TYPE, getSendEncoding());

        MuleMessage reply = client.send("clientEndpoint", TEST_MESSAGE, messageProperties);
        assertNotNull(reply);
        assertEquals("200", reply.getInboundProperty(HttpConnector.HTTP_STATUS_PROPERTY));
        assertEquals("text/baz;charset=UTF-16BE", reply.<String>getInboundProperty(HttpConstants.HEADER_CONTENT_TYPE));
        assertEquals("UTF-16BE", reply.getEncoding());
        assertEquals(TEST_MESSAGE + " Received", reply.getPayloadAsString());
View Full Code Here

    private MuleMessage runEncodingTest(String encoding, String payload, String httpMethod) throws Exception
    {
        Map<String, Object> messageProperties = createMessageProperties(encoding, httpMethod);

        MuleClient client = muleContext.getClient();
        String endpointUri = "clientEndpoint." + encoding;
        MuleMessage reply = client.send(endpointUri, payload, messageProperties);

        assertNotNull(reply);
        assertEquals("200", reply.getInboundProperty(HttpConnector.HTTP_STATUS_PROPERTY));

        Object contentTypeHeader = reply.getInboundProperty(HttpConstants.HEADER_CONTENT_TYPE);
View Full Code Here

   
    public void testSendFeed() throws Exception
    {
        InputStream input = getFeedInput();
       
        MuleClient client = muleContext.getClient();
        client.dispatch("vm://fromTest", input, null);
       
        assertTrue(receiveLatch.await(RECEIVE_TIMEOUT, TimeUnit.MILLISECONDS));
       
        Object payload = message.getPayload();
        assertTrue(payload instanceof Feed);
View Full Code Here

  @Inject
  MuleContext context;
 
  public void flow(String flowName, DelegateExecution execution) throws MuleException {
   
    MuleClient client = context.getClient();
   
    client.dispatch("vm://" + flowName, execution.getVariables(), null);

    // if we want to be able to write return values back into the
    // result-variable in fox, we could alternatively use "request-respond"
    // pattern and call/ return client.send(url, message) here. In the flow,
    // we would then have to set exchange-pattern="request-response"
View Full Code Here

        doRequest(url, Message.Type.chat);
    }

    protected void doRequest(String url, Message.Type expectedType) throws Exception
    {
        MuleClient client = muleContext.getClient();
        MuleMessage muleMessage = client.request(url, RECEIVE_TIMEOUT);
        assertNotNull(muleMessage);

        Message xmppMessage = (Message)muleMessage.getPayload();
        assertEquals(expectedType, xmppMessage.getType());
        assertEquals(TEST_MESSAGE, xmppMessage.getBody());
View Full Code Here

    }

    @Test
    public void testNamedParameters() throws Exception
    {
        MuleClient client = muleContext.getClient();
        // The service itself will throw an exception if the parameters in the
        // request SOAP message are not named
        MuleMessage result = client.send("vm://mycomponent1", "Hello Named", null);
        assertEquals("Hello Named", result.getPayload());
    }
View Full Code Here

    }

    @Test
    public void testNamedParametersViaClient() throws Exception
    {
        MuleClient client = muleContext.getClient();

        Map<String, Object> props = new HashMap<String, Object>();
        // create the soap method passing in the method name and return type
        SoapMethod soapMethod = new SoapMethod(new QName("echo"), NamedParameter.XSD_STRING);
        // add one or more parameters
        soapMethod.addNamedParameter(new QName("value"), NamedParameter.XSD_STRING, ParameterMode.IN);
        // set the soap method as a property and pass the properties
        // when making the call
        props.put(MuleProperties.MULE_SOAP_METHOD, soapMethod);

        MuleMessage result = client.send("axis:http://localhost:" + dynamicPort.getNumber() + "/mule/mycomponent2?method=echo",
            "Hello Named", props);
        assertEquals("Hello Named", result.getPayload());
    }
View Full Code Here

    @Test
    public void jaxWsClientReadsMuleMethodPropertySetByJaxWsService() throws Exception
    {
        String url = "cxf:http://localhost:" + port.getNumber() + "/hello?method=sayHi";
        MuleClient client = muleContext.getClient();

        MuleMessage result = client.send(url, TEST_MESSAGE, null);

        assertEquals("Hello\u2297 " + TEST_MESSAGE, result.getPayloadAsString());
    }
View Full Code Here

    @Test
    public void testCxfClientExceptionStrategy() throws Exception
    {
        MuleMessage request = new DefaultMuleMessage("hello", (Map<String,Object>)null, muleContext);

        MuleClient client = muleContext.getClient();
        client.dispatch("vm://helloClient", request);

        MuleMessage out = client.request("vm://out", FunctionalTestCase.RECEIVE_TIMEOUT);

        assertNotNull(out);
        assertTrue(out.getPayload() instanceof ExceptionMessage);
        assertTrue(((String)((ExceptionMessage) out.getPayload()).getPayload()).contains("APPEND"));
    }
View Full Code Here

TOP

Related Classes of org.mule.api.client.MuleClient

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.