1   /*
2    * $Id: XFireWsdlTestCase.java 7976 2007-08-21 14:26:13Z dirk.olmes $
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.extras.client.MuleClient;
15  import org.mule.impl.MuleEvent;
16  import org.mule.impl.MuleMessage;
17  import org.mule.impl.MuleSession;
18  import org.mule.impl.endpoint.MuleEndpoint;
19  import org.mule.providers.AbstractConnector;
20  import org.mule.tck.AbstractMuleTestCase;
21  import org.mule.umo.UMOMessage;
22  import org.mule.umo.UMOSession;
23  import org.mule.umo.endpoint.UMOEndpoint;
24  
25  import org.custommonkey.xmlunit.XMLAssert;
26  import org.w3c.dom.Document;
27  
28  public class XFireWsdlTestCase extends AbstractMuleTestCase
29  {
30      public static final String TEST_URL = "wsdl-xfire:http://localhost:63080/mule-tests-external-xfire/services/TestService?WSDL&method=getTest";
31      public static final String TEST_URL_NOWSDL = "wsdl-xfire:http://localhost:63080/mule-tests-external-xfire/services/TestService?method=getTest";
32      public static final String TEST_URL_WSDL = "http://localhost:63080/mule-tests-external-xfire/services/TestService?wsdl";
33  
34      public void testXFireWsdlService() throws Exception
35      {
36          MuleClient client = new MuleClient();
37  
38          UMOMessage message = new MuleMessage("test1");
39          UMOMessage reply = client.send(TEST_URL, message);
40          assertNotNull(reply);
41  
42          Document response = (Document)reply.getPayload();
43          assertNotNull(response);
44  
45          XMLAssert.assertXpathEvaluatesTo("test1", "//*[namespace-uri()='http://applications.external.tck.mule.org' and local-name()='key']", response);
46      }
47  
48      /**
49       * This tests the endpoint propery of wsdlUrl which specifies an alternative WSDL
50       * location (see MULE-1368)
51       */
52      public void testXFireWsdlServiceWithEndpointParam() throws Exception
53      {
54          // make sure the Mule is up when not using MuleClient
55          // TODO HH: track down why the dispatcher pool is derailed with an NPE
56          // without this - shouldn't it happen automatically?
57          MuleManager.getInstance().start();
58  
59          UMOEndpoint endpoint = MuleEndpoint.getOrCreateEndpointForUri(TEST_URL_NOWSDL,
60              UMOEndpoint.ENDPOINT_TYPE_SENDER);
61          endpoint.setProperty("wsdlUrl", TEST_URL_WSDL);
62  
63          UMOMessage message = new MuleMessage("test1");
64          UMOSession session = new MuleSession(message, ((AbstractConnector) endpoint.getConnector())
65              .getSessionHandler());
66          MuleEvent event = new MuleEvent(message, endpoint, session, true);
67          UMOMessage reply = session.sendEvent(event);
68  
69          assertNotNull(reply);
70  
71          Document response = (Document)reply.getPayload();
72          assertNotNull(response);
73  
74          XMLAssert.assertXpathEvaluatesTo("test1", "//*[namespace-uri()='http://applications.external.tck.mule.org' and local-name()='key']", response);
75      }
76  }