1
2
3
4
5
6
7
8
9
10
11 package org.mule.providers.tcp;
12
13 import org.mule.extras.client.MuleClient;
14 import org.mule.tck.FunctionalTestCase;
15 import org.mule.umo.UMOMessage;
16
17 import java.util.HashMap;
18 import java.util.Map;
19
20 public class TcpFunctionalTestCase extends FunctionalTestCase
21 {
22
23 protected static String TEST_MESSAGE = "Test TCP Request";
24
25 public TcpFunctionalTestCase()
26 {
27 setDisposeManagerPerSuite(true);
28 }
29
30 protected String getConfigResources()
31 {
32 return "tcp-functional-test.xml";
33 }
34
35 public void testSend() throws Exception
36 {
37 MuleClient client = new MuleClient();
38 Map props = new HashMap();
39 UMOMessage result = client.send("clientEndpoint", TEST_MESSAGE, props);
40 assertEquals(TEST_MESSAGE + " Received", result.getPayloadAsString());
41 }
42
43 public void timeMultipleSend() throws Exception
44 {
45 MuleClient client = new MuleClient();
46 Map props = new HashMap();
47 long now = System.currentTimeMillis();
48 int count = 1000;
49 for (int i = 0; i < count; i++)
50 {
51 UMOMessage result = client.send("clientEndpoint", TEST_MESSAGE, props);
52 assertEquals(TEST_MESSAGE + " Received", result.getPayloadAsString());
53 }
54 long later = System.currentTimeMillis();
55 double speed = count * 1000.0 / (later - now);
56 logger.error(speed + " messages per second");
57 }
58
59 }