1   /*
2    * $Id: XFireMessageReceiverFunctionalTestCase.java 9522 2007-10-31 16:18:38Z holger $
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.providers.soap.xfire;
12  
13  import org.mule.MuleManager;
14  import org.mule.components.simple.EchoService;
15  import org.mule.providers.AbstractConnector;
16  import org.mule.tck.FunctionalTestCase;
17  import org.mule.util.IOUtils;
18  
19  import java.lang.reflect.Field;
20  import java.util.Map;
21  
22  import javax.xml.namespace.QName;
23  
24  import org.codehaus.xfire.client.XFireProxyFactory;
25  import org.codehaus.xfire.service.Service;
26  import org.codehaus.xfire.service.binding.ObjectServiceFactory;
27  import org.custommonkey.xmlunit.XMLUnit;
28  
29  // MULE-2608: Change XFireMessageReceiver to allow a custom portType to be converted from
30  // a raw string to a QName
31  public class XFireMessageReceiverFunctionalTestCase extends FunctionalTestCase
32  {
33      protected String echoWsdl;
34  
35      protected String getConfigResources()
36      {
37          return "xfire-advanced-conf.xml";
38      }
39  
40      protected void doPostFunctionalSetUp() throws Exception
41      {
42          super.doPostFunctionalSetUp();
43          echoWsdl = IOUtils.getResourceAsString("xfire-advanced-echo-service.wsdl", getClass());
44          XMLUnit.setIgnoreWhitespace(true);
45      }
46  
47      public void testQname() throws Exception
48      {
49          MuleManager.getInstance().start();
50  
51          AbstractConnector umoConnector = (AbstractConnector) MuleManager.getInstance().lookupConnector(
52              "xfireConnector");
53          Map map = umoConnector.getReceivers();
54          XFireMessageReceiver receiver = (XFireMessageReceiver) map.get("http://localhost:63081/services/echoServiceWsdlPortType");
55          Field field = XFireMessageReceiver.class.getDeclaredField("service");
56          field.setAccessible(true);
57          Service service = (Service) field.get(receiver);
58          QName qname = (QName) service.getProperty(ObjectServiceFactory.PORT_TYPE);
59          assertNotNull(qname);
60          assertTrue(qname.getNamespaceURI().indexOf("echoServiceCustomPortType") > -1);
61      }
62  
63      public void testExternalXFireInvocation() throws Exception
64      {
65          Service serviceModel = new ObjectServiceFactory().create(EchoService.class);
66          EchoService echoService = (EchoService) new XFireProxyFactory().create(serviceModel,
67              "http://localhost:63081/services/echoServiceWsdlPortType");
68          String response = echoService.echo("hello world");
69          assertEquals("hello world", response);
70      }
71  
72  }