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.module.client.MuleClient;
15 import org.mule.tck.FunctionalTestCase;
16 import org.mule.tck.functional.FunctionalTestComponent;
17
18 public class SslCertificateTestCase extends FunctionalTestCase
19 {
20
21 protected static String TEST_MESSAGE = "Test Request";
22 private static int NUM_MESSAGES = 100;
23
24 protected String getConfigResources()
25 {
26 return "ssl-certificate-test.xml";
27 }
28
29 public void testOnce() throws Exception
30 {
31 doTests(1);
32 }
33
34 public void testMany() throws Exception
35 {
36 doTests(NUM_MESSAGES);
37 }
38
39 protected void doTests(int n) throws Exception
40 {
41 FunctionalTestComponent ftc = (FunctionalTestComponent) getComponent("service");
42 assertNotNull(ftc);
43 assertNotNull(ftc.getEventCallback());
44
45 SaveCertificateCallback callback = (SaveCertificateCallback) ftc.getEventCallback();
46 callback.clear();
47
48 MuleClient client = new MuleClient();
49 for (int i = 0; i < n; ++i)
50 {
51 callback.clear();
52 String msg = TEST_MESSAGE + n;
53 MuleMessage result = client.send("in", msg, null);
54 assertTrue(callback.isCalled());
55 assertNotNull("Null certificates", callback.getCertificates());
56 assertEquals(msg + " Received", result.getPayloadAsString());
57 }
58 }
59
60 }