Package org.mule.module.client

Examples of org.mule.module.client.MuleClient


   * @return mule client
   */
  public MuleClient getMuleClient() throws MuleException {
    if (muleContext!=null)
      // in case Mule server not embedded with the JAllInOne web app
      return new MuleClient(muleContext);
    else
      return new MuleClient();
  }
View Full Code Here


    }

    public void testRequestWithComplexArg() throws Exception
    {
        MuleClient client = new MuleClient(muleContext);
        Person person = new Person("Joe", "Blow");
        String uri = getMuleAddress(client, "inMyComponent3") + "/mycomponent3?method=addPerson";
        client.send(uri, person, null);
        uri = getMuleAddress(client, "inMyComponent3") "/mycomponent3?method=getPerson";
        MuleMessage result = client.send(uri, "Joe", null);
        assertNotNull(result);
        assertTrue(result.getPayload() instanceof Person);
        assertEquals("Joe", ((Person)result.getPayload()).getFirstName());
        assertEquals("Blow", ((Person)result.getPayload()).getLastName());
    }
View Full Code Here

    public abstract String getRemoteEndpointUri();

    public void testClientSendToRemoteComponent() throws Exception
    {
        // 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

    }

    public void testClientRequestResponseOnEndpoint() throws Exception
    {
        // 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

     */
    public void testClientSendAndReceiveRemote() throws Exception
    {
        String remoteEndpoint = "vm://remote.queue?connector=vmRemoteQueueConnector";
        // Will connect to the server using The Server endpoint
        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
View Full Code Here

    // assertEquals("request" + "customResponse", message.getPayloadAsString());
    // }

    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

        assertEquals("request" + VM_OUT_IN_RESP, message.getPayloadAsString());
    }

    public void testVmSyncResponseTransformer() throws Exception
    {
        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

        return "org/mule/test/integration/client/remote-exception-config.xml";
    }

    public void testClientTransformerException() throws Exception
    {
        MuleClient client = new MuleClient(muleContext);
        RemoteDispatcher dispatcher = client.getRemoteDispatcher("tcp://localhost:25551");
        MuleMessage result = dispatcher.sendRemote("vm://test.queue.1", new Date(), null);
        assertNotNull(result);
        ExceptionPayload exceptionPayload = result.getExceptionPayload();
        assertNotNull(exceptionPayload);
        assertTrue(exceptionPayload.getException().getCause().getCause() instanceof TransformerMessagingException);
View Full Code Here

        assertTrue(exceptionPayload.getRootException() instanceof Exception);
    }

    public void testClientMalformedEndpointException() throws Exception
    {
        MuleClient client = new MuleClient(muleContext);
        RemoteDispatcher dispatcher = client.getRemoteDispatcher("tcp://localhost:25551");
        MuleMessage result = dispatcher.sendRemote("test.queue.2", new Date(), null);
        assertNotNull(result);
        ExceptionPayload exceptionPayload = result.getExceptionPayload();
        assertNotNull(exceptionPayload);
        assertTrue(exceptionPayload.getRootException() instanceof MalformedEndpointException);
View Full Code Here

        assertEquals("request" + CUSTOM_RESPONSE, message.getPayloadAsString());
    }

    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"));
View Full Code Here

TOP

Related Classes of org.mule.module.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.