1   /*
2    * $Id: CxfConnectorHttpFunctionalTestCase.java 11649 2008-04-25 23:51:05Z dandiep $
3    * --------------------------------------------------------------------------------------
4    * Copyright (c) MuleSource, Inc.  All rights reserved.  http://www.mulesource.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.cxf;
12  
13  import org.mule.api.MuleMessage;
14  import org.mule.module.client.MuleClient;
15  import org.mule.tck.providers.soap.AbstractSoapUrlEndpointFunctionalTestCase;
16  
17  import java.util.HashMap;
18  import java.util.Iterator;
19  import java.util.List;
20  import java.util.Map;
21  
22  import org.dom4j.Document;
23  import org.dom4j.DocumentHelper;
24  import org.dom4j.Element;
25  
26  public class CxfConnectorHttpFunctionalTestCase extends AbstractSoapUrlEndpointFunctionalTestCase
27  {
28  
29      protected String getTransportProtocol()
30      {
31          return "http";
32      }
33  
34      protected String getSoapProvider()
35      {
36          return "cxf";
37      }
38      
39      @Override
40      public void testRequest() throws Throwable
41      {
42          // Fails on build server, but not locally... so do nothing for now.
43      }
44  
45      /**
46       * @throws Exception
47       */
48      @SuppressWarnings("unchecked")
49      public void testBinding() throws Exception
50      {
51          String url = "http://localhost:62108/";
52          String folder = "mule/";
53          String componentName = "mycomponent";
54          String fullPath = url + folder + componentName;
55  
56          MuleClient client = new MuleClient();
57          Map<String, Object> props = new HashMap<String, Object>();
58          props.put("http.method", "GET");
59          MuleMessage reply = client.send(fullPath + "?wsdl", folder + componentName + "?wsdl", props);
60  
61          assertNotNull(reply);
62          assertNotNull(reply.getPayload());
63  
64          Document document = DocumentHelper.parseText(reply.getPayloadAsString());
65          List nodes;
66  
67          nodes = document.selectNodes("//wsdl:definitions/wsdl:service");
68  
69          Element element = (Element) nodes.get(0);
70          assertEquals("TestServiceComponent", element.attribute("name").getStringValue());
71  
72          nodes = document.selectNodes("//wsdl:definitions/wsdl:service/wsdl:port");
73  
74          for (Iterator i = nodes.iterator(); i.hasNext();)
75          {
76              element = (Element) i.next();
77  
78              if ((element.attribute("name").getStringValue().compareTo(componentName + "MulePort") == 0)
79                  || (element.attribute("name").getStringValue().compareTo(componentName + "LocalPort") == 0))
80              {
81                  Element tempElement = (Element) element.elements().get(0);
82                  String mulePort = tempElement.attribute("location").getStringValue();
83                  assertEquals(fullPath, mulePort);
84              }
85          }
86      }
87  
88      public String getConfigResources()
89      {
90          return getTransportProtocol() + "-mule-config.xml";
91      }
92  
93  }