1   /*
2    * $Id: CxfEchoTestCase.java 11569 2008-04-11 13:31:43Z 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.example.echo;
12  
13  import org.mule.api.MuleMessage;
14  import org.mule.module.client.MuleClient;
15  import org.mule.transport.NullPayload;
16  
17  import java.util.HashMap;
18  import java.util.Map;
19  
20  import org.custommonkey.xmlunit.XMLAssert;
21  
22  /**
23   * Tests the echo example using CXF.
24   */
25  public class CxfEchoTestCase extends AbstractEchoTestCase
26  {
27      public void testGetEcho() throws Exception
28      {
29          // CXF has built in support for understanding GET requests. They are of the form:
30          // http://host/service/OPERATION/PARAM_NAME/PARAM_VALUE
31          
32          MuleClient client = new MuleClient();
33          Map<String, String> props = new HashMap<String, String>();
34          props.put("http.method", "GET");
35          MuleMessage result = client.send("http://localhost:65082/services/EchoUMO/echo/text/hello", "", props);
36          assertNotNull(result);
37          assertFalse(result.getPayload() instanceof NullPayload);
38          XMLAssert.assertXMLEqual(expectedGetResponse, result.getPayloadAsString());
39      }
40      
41      public void testPostEcho() throws Exception
42      {
43          // This test doesn't apply to CXF, so we're making it empty.
44      }
45      
46      protected String getConfigResources()
47      {
48          return "echo-cxf-config.xml";
49      }
50  
51      protected String getExpectedGetResponseResource()
52      {
53          return "echo-cxf-response.xml";
54      }
55  
56      protected String getExpectedPostResponseResource()
57      {
58          return "echo-cxf-response.xml";
59      }
60  
61      protected String getProtocol()
62      {
63          return "cxf";
64      }
65  
66  }