1
2
3
4
5
6
7
8
9
10
11 package org.mule.transport.ssl;
12
13 import org.mule.api.endpoint.InboundEndpoint;
14 import org.mule.api.service.Service;
15 import org.mule.api.transport.Connector;
16 import org.mule.tck.testmodels.fruit.Orange;
17 import org.mule.transport.AbstractConnectorTestCase;
18
19 public class SslConnectorTestCase extends AbstractConnectorTestCase
20 {
21
22 public Connector createConnector() throws Exception
23 {
24 SslConnector cnn = new SslConnector();
25 cnn.setMuleContext(muleContext);
26 cnn.setName("SslConnector");
27 cnn.setKeyStore("serverKeystore");
28 cnn.setClientKeyStore("clientKeystore");
29 cnn.setClientKeyStorePassword("mulepassword");
30 cnn.setKeyPassword("mulepassword");
31 cnn.setKeyStorePassword("mulepassword");
32 cnn.setTrustStore("trustStore");
33 cnn.setTrustStorePassword("mulepassword");
34 cnn.getDispatcherThreadingProfile().setDoThreading(false);
35 return cnn;
36 }
37
38 public void testClientConnector() throws Exception
39 {
40 SslConnector cnn = new SslConnector();
41 cnn.setMuleContext(muleContext);
42 cnn.setClientKeyStore("clientKeystore");
43 cnn.setClientKeyStorePassword("mulepassword");
44 cnn.getDispatcherThreadingProfile().setDoThreading(false);
45 }
46
47 public String getTestEndpointURI()
48 {
49 return "ssl://localhost:56801";
50 }
51
52 public Object getValidMessage() throws Exception
53 {
54 return "Hello".getBytes();
55 }
56
57 public void testValidListener() throws Exception
58 {
59 Service service = getTestService("orange", Orange.class);
60 Connector connector = getConnector();
61
62 InboundEndpoint endpoint2 = muleContext.getRegistry()
63 .lookupEndpointFactory()
64 .getInboundEndpoint("ssl://localhost:30303");
65
66 connector.registerListener(service, endpoint2);
67 try
68 {
69 connector.registerListener(service, endpoint2);
70 fail("cannot register on the same endpointUri");
71 }
72 catch (Exception e)
73 {
74
75 }
76 }
77
78 public void testProperties() throws Exception
79 {
80 SslConnector c = (SslConnector)getConnector();
81
82 c.setSendBufferSize(1024);
83 assertEquals(1024, c.getSendBufferSize());
84 c.setSendBufferSize(0);
85 assertEquals(SslConnector.DEFAULT_BUFFER_SIZE, c.getSendBufferSize());
86 }
87
88 }