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 import java.util.Iterator;
19
20
21
22
23
24 public class SslCertificatesTestCase extends FunctionalTestCase
25 {
26
27 protected static String TEST_MESSAGE = "Test Request";
28 private static int NUM_MESSAGES = 100;
29
30 protected String getConfigResources()
31 {
32 return "ssl-certificates-test.xml";
33 }
34
35 public void testOnce() throws Exception
36 {
37 doTests(1);
38 }
39
40 public void testMany() throws Exception
41 {
42 doTests(NUM_MESSAGES);
43 }
44
45 protected void doTests(int n) throws Exception
46 {
47 FunctionalTestComponent ftc = (FunctionalTestComponent) getComponent("service");
48 assertNotNull(ftc);
49 assertNotNull(ftc.getEventCallback());
50
51 SaveCertificatesCallback callback = (SaveCertificatesCallback) ftc.getEventCallback();
52 callback.clear();
53
54 MuleClient client = new MuleClient();
55 for (int i = 0; i < n; ++i)
56 {
57 String msg = TEST_MESSAGE + n;
58 MuleMessage result = client.send("in", msg, null);
59 assertEquals(msg + " Received", result.getPayloadAsString());
60 }
61 Iterator certificates = callback.getCertificates().iterator();
62 for (int i = 0; i < n; ++i)
63 {
64 assertTrue("No cert at " + i, certificates.hasNext());
65 assertNotNull("Null cert at " + i, certificates.next());
66 }
67 }
68
69 }