View Javadoc

1   /*
2    * $Id: HttpsConnectorTestCase.java 19191 2010-08-25 21:05:23Z tcarlson $
3    * --------------------------------------------------------------------------------------
4    * Copyright (c) MuleSoft, Inc.  All rights reserved.  http://www.mulesoft.com
5    *
6    * The software in this package is published under the terms of the CPAL v1.0
7    * license, a copy of which has been included with this distribution in the
8    * LICENSE.txt file.
9    */
10  
11  package org.mule.transport.http;
12  
13  import org.mule.api.MuleContext;
14  import org.mule.api.endpoint.InboundEndpoint;
15  import org.mule.api.lifecycle.InitialisationException;
16  import org.mule.api.service.Service;
17  import org.mule.api.transport.Connector;
18  import org.mule.tck.testmodels.fruit.Orange;
19  import org.mule.transport.AbstractConnectorTestCase;
20  import org.mule.transport.tcp.TcpConnector;
21  
22  import java.io.IOException;
23  
24  
25  public class HttpsConnectorTestCase extends AbstractConnectorTestCase
26  {
27  
28      @Override
29      public Connector createConnector() throws Exception
30      {
31          return createConnector(muleContext, false);
32      }
33  
34      public static HttpsConnector createConnector(MuleContext context, boolean initialised)
35          throws IOException, InitialisationException
36      {
37          HttpsConnector cnn = new HttpsConnector(muleContext);
38          cnn.setName("HttpsConnector");
39          cnn.setKeyStore("serverKeystore");
40          cnn.setClientKeyStore("clientKeystore");
41          cnn.setClientKeyStorePassword("mulepassword");
42          cnn.setKeyPassword("mulepassword");
43          cnn.setKeyStorePassword("mulepassword");
44          cnn.setTrustStore("trustStore");
45          cnn.setTrustStorePassword("mulepassword");
46          cnn.getDispatcherThreadingProfile().setDoThreading(false);
47  
48          if (initialised)
49          {
50              cnn.initialise();
51          }
52          return cnn;
53      }
54  
55      public String getTestEndpointURI()
56      {
57          return "https://localhost:60127";
58      }
59  
60      public Object getValidMessage() throws Exception
61      {
62          return "Hello".getBytes();
63      }
64  
65      public void testValidListener() throws Exception
66      {
67          Service service = getTestService("orange", Orange.class);
68          InboundEndpoint endpoint = muleContext.getRegistry().lookupEndpointFactory().getInboundEndpoint(
69              getTestEndpointURI());
70  
71          getConnector().registerListener(endpoint, getSensingNullMessageProcessor(), service);
72      }
73  
74      public void testProperties() throws Exception
75      {
76          HttpsConnector c = (HttpsConnector)getConnector();
77  
78          c.setSendBufferSize(1024);
79          assertEquals(1024, c.getSendBufferSize());
80          c.setSendBufferSize(0);
81          assertEquals(TcpConnector.DEFAULT_BUFFER_SIZE, c.getSendBufferSize());
82  
83          // all kinds of timeouts are tested in TcpConnectorTestCase now
84      }
85  }