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 @Override
22 public Connector createConnector() throws Exception
23 {
24 SslConnector cnn = new SslConnector(muleContext);
25 cnn.setName("SslConnector");
26 cnn.setKeyStore("serverKeystore");
27 cnn.setClientKeyStore("clientKeystore");
28 cnn.setClientKeyStorePassword("mulepassword");
29 cnn.setKeyPassword("mulepassword");
30 cnn.setKeyStorePassword("mulepassword");
31 cnn.setTrustStore("trustStore");
32 cnn.setTrustStorePassword("mulepassword");
33 cnn.getDispatcherThreadingProfile().setDoThreading(false);
34 return cnn;
35 }
36
37 public void testClientConnector() throws Exception
38 {
39 SslConnector cnn = new SslConnector(muleContext);
40 cnn.setClientKeyStore("clientKeystore");
41 cnn.setClientKeyStorePassword("mulepassword");
42 cnn.getDispatcherThreadingProfile().setDoThreading(false);
43 }
44
45 public String getTestEndpointURI()
46 {
47 return "ssl://localhost:56801";
48 }
49
50 public Object getValidMessage() throws Exception
51 {
52 return "Hello".getBytes();
53 }
54
55 public void testValidListener() throws Exception
56 {
57 Service service = getTestService("orange", Orange.class);
58 Connector connector = getConnector();
59
60 InboundEndpoint endpoint2 = muleContext.getRegistry()
61 .lookupEndpointFactory()
62 .getInboundEndpoint("ssl://localhost:30303");
63
64 connector.registerListener(endpoint2, getSensingNullMessageProcessor(), service);
65 try
66 {
67 connector.registerListener(endpoint2, getSensingNullMessageProcessor(), service);
68 fail("cannot register on the same endpointUri");
69 }
70 catch (Exception e)
71 {
72
73 }
74 }
75
76 public void testProperties() throws Exception
77 {
78 SslConnector c = (SslConnector)getConnector();
79
80 c.setSendBufferSize(1024);
81 assertEquals(1024, c.getSendBufferSize());
82 c.setSendBufferSize(0);
83 assertEquals(SslConnector.DEFAULT_BUFFER_SIZE, c.getSendBufferSize());
84 }
85
86 }