View Javadoc
1   /*
2    * Copyright (c) MuleSoft, Inc.  All rights reserved.  http://www.mulesoft.com
3    * The software in this package is published under the terms of the CPAL v1.0
4    * license, a copy of which has been included with this distribution in the
5    * LICENSE.txt file.
6    */
7   package org.mule.transport.soap.axis;
8   
9   import org.mule.api.MuleEvent;
10  import org.mule.api.endpoint.OutboundEndpoint;
11  import org.mule.tck.junit4.AbstractMuleContextTestCase;
12  
13  import javax.xml.namespace.QName;
14  
15  import org.junit.Test;
16  
17  import static org.junit.Assert.assertEquals;
18  
19  public class SoapActionTemplateTestCase extends AbstractMuleContextTestCase
20  {
21  
22      @Test
23      public void testHostInfoReplace() throws Exception
24      {
25          OutboundEndpoint ep = muleContext.getEndpointFactory().getOutboundEndpoint(
26              "axis:http://mycompany.com:8080/services/myService?method=foo");
27          
28          AxisMessageDispatcher dispatcher = new AxisMessageDispatcher(ep);
29          MuleEvent event = getTestEvent("test,", ep);
30          String result = dispatcher.parseSoapAction("#[hostInfo]/#[method]", new QName("foo"), event);
31  
32          assertEquals("http://mycompany.com:8080/foo", result);
33      }
34  
35      @Test
36      public void testHostReplace() throws Exception
37      {
38          OutboundEndpoint ep = muleContext.getEndpointFactory().getOutboundEndpoint(
39              "axis:http://mycompany.com:8080/services/myService?method=foo");
40          AxisMessageDispatcher dispatcher = new AxisMessageDispatcher(ep);
41          MuleEvent event = getTestEvent("test,", ep);
42          String name = event.getFlowConstruct().getName();
43          String result = dispatcher.parseSoapAction("#[scheme]://#[host]:#[port]/#[serviceName]/#[method]",
44              new QName("foo"), event);
45  
46          assertEquals("http://mycompany.com:8080/" + name + "/foo", result);
47      }
48  }