View Javadoc

1   /*
2    * $Id: SoapActionTemplateTestCase.java 22387 2011-07-12 03:53:36Z dirk.olmes $
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 org.mule.api.MuleEvent;
14  import org.mule.api.endpoint.OutboundEndpoint;
15  import org.mule.tck.junit4.AbstractMuleContextTestCase;
16  
17  import javax.xml.namespace.QName;
18  
19  import org.junit.Test;
20  
21  import static org.junit.Assert.assertEquals;
22  
23  public class SoapActionTemplateTestCase extends AbstractMuleContextTestCase
24  {
25  
26      @Test
27      public void testHostInfoReplace() throws Exception
28      {
29          OutboundEndpoint ep = muleContext.getEndpointFactory().getOutboundEndpoint(
30              "axis:http://mycompany.com:8080/services/myService?method=foo");
31          
32          AxisMessageDispatcher dispatcher = new AxisMessageDispatcher(ep);
33          MuleEvent event = getTestEvent("test,");
34          String result = dispatcher.parseSoapAction("#[hostInfo]/#[method]", new QName("foo"), event);
35  
36          assertEquals("http://mycompany.com:8080/foo", result);
37      }
38  
39      @Test
40      public void testHostReplace() throws Exception
41      {
42          OutboundEndpoint ep = muleContext.getEndpointFactory().getOutboundEndpoint(
43              "axis:http://mycompany.com:8080/services/myService?method=foo");
44          AxisMessageDispatcher dispatcher = new AxisMessageDispatcher(ep);
45          MuleEvent event = getTestEvent("test,");
46          String name = event.getFlowConstruct().getName();
47          String result = dispatcher.parseSoapAction("#[scheme]://#[host]:#[port]/#[serviceName]/#[method]",
48              new QName("foo"), event);
49  
50          assertEquals("http://mycompany.com:8080/" + name + "/foo", result);
51      }
52  }