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.cxf;
8   
9   import org.mule.DefaultMuleMessage;
10  import org.mule.api.MuleMessage;
11  import org.mule.module.client.MuleClient;
12  import org.mule.tck.junit4.FunctionalTestCase;
13  import org.mule.tck.junit4.rule.DynamicPort;
14  
15  import java.util.HashMap;
16  import java.util.List;
17  import java.util.Map;
18  
19  import org.dom4j.Document;
20  import org.dom4j.DocumentHelper;
21  import org.dom4j.Element;
22  import org.junit.Rule;
23  import org.junit.Test;
24  
25  import static org.junit.Assert.assertEquals;
26  import static org.junit.Assert.assertNotNull;
27  
28  public class ServiceUsingAxisEndpointTestCase extends FunctionalTestCase
29  {
30  
31      @Rule
32      public DynamicPort dynamicPort = new DynamicPort("port1");
33      
34      @Test
35      public void testCXF() throws Exception
36      {
37          MuleClient client = new MuleClient(muleContext);
38          MuleMessage reply = client.send("vm://cxf.in", new DefaultMuleMessage("Testing String", muleContext));
39  
40          assertNotNull(reply);
41          assertNotNull(reply.getPayload());
42          assertEquals("Received: Testing String", reply.getPayloadAsString());
43      }
44  
45      @Test
46      public void testRequestWsdl() throws Exception
47      {
48          MuleClient client = new MuleClient(muleContext);
49          Map<String, String> props = new HashMap<String, String>();
50          props.put("http.method", "GET");
51          MuleMessage reply = client.send("http://localhost:" + dynamicPort.getNumber() + "/services/CxfService?wsdl",
52              "/services/CxfService?wsdl", props);
53  
54          assertNotNull(reply);
55          assertNotNull(reply.getPayload());
56  
57          Document document = DocumentHelper.parseText(reply.getPayloadAsString());
58          
59          List<?> nodes = document.selectNodes("//wsdl:definitions/wsdl:service");
60          assertEquals("CxfService", ((Element) nodes.get(0)).attribute("name").getStringValue());
61      }
62  
63      @Override
64      protected String getConfigResources()
65      {
66          return "using-axis-conf.xml";
67      }
68  
69  }