View Javadoc

1   /*
2    * $Id: AxisConnectorHttpsTestCase.java 22542 2011-07-22 20:50:01Z dfeist $
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.soap.axis;
12  
13  import static org.junit.Assert.assertNotNull;
14  import static org.junit.Assert.assertTrue;
15  
16  import org.mule.DefaultMuleMessage;
17  import org.mule.api.MuleEvent;
18  import org.mule.api.MuleException;
19  import org.mule.api.MuleMessage;
20  import org.mule.api.endpoint.ImmutableEndpoint;
21  import org.mule.api.endpoint.InboundEndpoint;
22  import org.mule.api.processor.MessageProcessor;
23  import org.mule.endpoint.EndpointAware;
24  import org.mule.module.client.MuleClient;
25  import org.mule.tck.junit4.FunctionalTestCase;
26  import org.mule.tck.junit4.rule.DynamicPort;
27  import org.mule.transport.http.HttpsConnector;
28  
29  import org.junit.Rule;
30  import org.junit.Test;
31  
32  public class AxisConnectorHttpsTestCase extends FunctionalTestCase
33  {
34  
35      static ImmutableEndpoint endpoint;
36  
37      @Rule
38      public DynamicPort dynamicPort = new DynamicPort("port1");
39  
40      @Override
41      protected String getConfigResources()
42      {
43          return "axis-https-connector-config.xml";
44      }
45  
46      @Test
47      public void testHttpsConnection() throws Exception
48      {
49          MuleClient client = new MuleClient(muleContext);
50          MuleMessage m = client.send(
51              ((InboundEndpoint) client.getMuleContext().getRegistry().lookupObject("inTestUMO")).getAddress()
52                              + "?method=echo", new DefaultMuleMessage("hello", muleContext));
53          assertNotNull(m);
54  
55          // check that our https connector is being used
56          assertNotNull(endpoint);
57          assertTrue(endpoint.getConnector() instanceof HttpsConnector);
58          assertTrue(endpoint.getConnector().getName().equals("myHttpsConnector"));
59      }
60  
61      public static class AddConnectorMessageProperty implements MessageProcessor, EndpointAware
62      {
63          private ImmutableEndpoint endpoint;
64  
65          @Override
66          public MuleEvent process(MuleEvent event) throws MuleException
67          {
68              AxisConnectorHttpsTestCase.endpoint = endpoint;
69              return event;
70          }
71  
72          @Override
73          public void setEndpoint(ImmutableEndpoint ep)
74          {
75              endpoint = ep;
76          }
77      }
78  
79  }