1   /*
2    * $Id: CxfBasicTestCase.java 11405 2008-03-18 00:13:00Z 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.transport.cxf;
12  
13  import org.mule.api.MuleMessage;
14  import org.mule.module.client.MuleClient;
15  import org.mule.module.xml.util.XMLUtils;
16  import org.mule.tck.FunctionalTestCase;
17  import org.mule.util.IOUtils;
18  
19  import javax.xml.transform.TransformerFactoryConfigurationError;
20  
21  import org.custommonkey.xmlunit.XMLUnit;
22  
23  public class CxfBasicTestCase extends FunctionalTestCase
24  {
25      private String echoWsdl;
26  
27      @Override
28      protected void doSetUp() throws Exception
29      {
30          super.doSetUp();
31          echoWsdl = IOUtils.getResourceAsString("xfire-echo-service.wsdl", getClass());
32          XMLUnit.setIgnoreWhitespace(true);
33          try
34          {
35              XMLUnit.getTransformerFactory();
36          }
37          catch (TransformerFactoryConfigurationError e)
38          {
39              XMLUnit.setTransformerFactory(XMLUtils.TRANSFORMER_FACTORY_JDK5);
40          }
41      }
42  
43      public void testEchoService() throws Exception
44      {
45          MuleClient client = new MuleClient();
46          MuleMessage result = client.send("cxf:http://localhost:63081/services/Echo?method=echo", "Hello!",
47              null);
48          assertEquals("Hello!", result.getPayload());
49      }
50  
51      public void testEchoServiceSynchronous() throws Exception
52      {
53          MuleClient client = new MuleClient();
54          MuleMessage result = client.send("cxf:http://localhost:63083/services/Echo3?method=echo", "Hello!",
55              null);
56          assertEquals("Hello!", result.getPayload());
57      }
58  
59      public void testEchoWsdl() throws Exception
60      {
61          MuleClient client = new MuleClient();
62          MuleMessage result = client.request("http://localhost:63081/services/Echo?wsdl", 5000);
63          assertNotNull(result.getPayload());
64          XMLUnit.compareXML(echoWsdl, result.getPayloadAsString());
65      }
66  
67      protected String getConfigResources()
68      {
69          return "basic-conf.xml";
70      }
71  
72  }