View Javadoc

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