1
2
3
4
5
6
7
8
9
10
11 package org.mule.test.integration.client;
12
13
14 import org.mule.api.MuleMessage;
15 import org.mule.module.client.MuleClient;
16 import org.mule.module.client.RemoteDispatcher;
17 import org.mule.tck.FunctionalTestCase;
18
19 public abstract class AbstractClientRemotingTestCase extends FunctionalTestCase
20 {
21 public abstract String getRemoteEndpointUri();
22
23 public void testClientSendToRemoteComponent() throws Exception
24 {
25
26 MuleClient client = new MuleClient();
27
28 RemoteDispatcher dispatcher = client.getRemoteDispatcher(getRemoteEndpointUri());
29 MuleMessage message = dispatcher.sendToRemoteComponent("TestReceiverUMO", "Test Client Send message", null);
30 assertNotNull(message);
31 assertEquals("Test Client Send message Received", message.getPayload());
32 }
33
34 public void testClientRequestResponseOnEndpoint() throws Exception
35 {
36
37 MuleClient client = new MuleClient();
38
39 RemoteDispatcher dispatcher = client.getRemoteDispatcher(getRemoteEndpointUri());
40 MuleMessage message = dispatcher.sendRemote("vm://remote.endpoint?connector=vmRemoteConnector", "foo",
41 null);
42 assertNotNull(message);
43 assertEquals("received from remote component", message.getPayloadAsString());
44 }
45
46
47
48
49
50
51 public void testClientSendAndReceiveRemote() throws Exception
52 {
53 String remoteEndpoint = "vm://remote.queue?connector=vmRemoteQueueConnector";
54
55 MuleClient client = new MuleClient();
56
57 RemoteDispatcher dispatcher = client.getRemoteDispatcher(getRemoteEndpointUri());
58
59 MuleMessage message = dispatcher.receiveRemote(remoteEndpoint, RECEIVE_TIMEOUT * 2);
60 assertNull(message);
61
62
63 dispatcher.sendRemote(remoteEndpoint, "Test Remote Message 2", null);
64
65
66 message = dispatcher.receiveRemote(remoteEndpoint, RECEIVE_TIMEOUT * 2);
67 assertNotNull(message);
68 assertEquals("Test Remote Message 2", message.getPayload());
69 }
70
71 }