1
2
3
4
5
6
7
8
9
10
11 package org.mule.transport.ssl;
12
13 import org.mule.api.MuleMessage;
14 import org.mule.api.service.Service;
15 import org.mule.module.client.MuleClient;
16 import org.mule.tck.FunctionalTestCase;
17 import org.mule.tck.functional.CounterCallback;
18 import org.mule.tck.functional.EventCallback;
19 import org.mule.tck.functional.FunctionalTestComponent;
20 import org.mule.tck.testmodels.mule.TestSedaService;
21
22 public class SslFunctionalTestCase extends FunctionalTestCase
23 {
24
25 protected static String TEST_MESSAGE = "Test Request";
26 private static int NUM_MESSAGES = 100;
27
28 protected String getConfigResources()
29 {
30 return "ssl-functional-test.xml";
31 }
32
33 public void testSend() throws Exception
34 {
35 MuleClient client = new MuleClient();
36 MuleMessage result = client.send("sendEndpoint", TEST_MESSAGE, null);
37 assertEquals(TEST_MESSAGE + " Received", result.getPayloadAsString());
38 }
39
40 public void testSendMany() throws Exception
41 {
42 MuleClient client = new MuleClient();
43 for (int i = 0; i < NUM_MESSAGES; ++i)
44 {
45 MuleMessage result = client.send("sendManyEndpoint", TEST_MESSAGE, null);
46 assertEquals(TEST_MESSAGE + " Received", result.getPayloadAsString());
47 }
48
49 Service c = muleContext.getRegistry().lookupService("testComponent2");
50 assertTrue("Service should be a TestSedaService", c instanceof TestSedaService);
51 Object ftc = getComponent(c);
52 assertNotNull("Functional Test Service not found in the model.", ftc);
53 assertTrue("Service should be a FunctionalTestComponent", ftc instanceof FunctionalTestComponent);
54
55 EventCallback cc = ((FunctionalTestComponent) ftc).getEventCallback();
56 assertNotNull("EventCallback is null", cc);
57 assertTrue("EventCallback should be a CounterCallback", cc instanceof CounterCallback);
58 assertEquals(NUM_MESSAGES, ((CounterCallback) cc).getCallbackCount());
59 }
60
61 public void testAsynchronous() throws Exception
62 {
63 MuleClient client = new MuleClient();
64 client.dispatch("asyncEndpoint", TEST_MESSAGE, null);
65
66 Thread.sleep(100);
67 MuleMessage response = client.request("asyncEndpoint", 5000);
68 assertNotNull("Response is null", response);
69 assertEquals(TEST_MESSAGE + " Received Async", response.getPayloadAsString());
70 }
71
72 }