View Javadoc

1   /*
2    * $Id: CxfContentTypeTestCase.java 20320 2010-11-24 15:03:31Z dfeist $
3    * --------------------------------------------------------------------------------------
4    * Copyright (c) MuleSource, Inc.  All rights reserved.  http://www.mulesoft.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.module.cxf.functional;
12  
13  import org.mule.DefaultMuleMessage;
14  import org.mule.api.MuleMessage;
15  import org.mule.module.client.MuleClient;
16  import org.mule.tck.DynamicPortTestCase;
17  
18  import java.util.Map;
19  
20  public class CxfContentTypeTestCase extends DynamicPortTestCase
21  {
22      private static final String requestPayload =
23          "<soap:Envelope xmlns:soap=\"http://schemas.xmlsoap.org/soap/envelope/\"\n" +
24              "           xmlns:hi=\"http://example.org/\">\n" +
25              "<soap:Body>\n" +
26              "<hi:sayHi>\n" +
27              "    <arg0>Hello</arg0>\n" +
28              "</hi:sayHi>\n" +
29              "</soap:Body>\n" +
30              "</soap:Envelope>";
31  
32  
33      @Override
34      protected int getNumPortsToFind()
35      {
36          return 1;
37      }
38  
39      @Override
40      protected String getConfigResources()
41      {
42          return "cxf-echo-service-conf.xml";
43      }
44  
45      public void testCxfService() throws Exception
46      {
47          MuleMessage request = new DefaultMuleMessage(requestPayload, (Map<String,Object>)null, muleContext);
48          MuleClient client = new MuleClient(muleContext);
49          MuleMessage received = client.send("http://localhost:" + getPorts().get(0) + "/hello", request);
50          String contentType = received.getInboundProperty("content-type");
51          assertNotNull(contentType);
52          assertTrue(contentType.contains("charset"));
53      }
54  
55      public void testCxfClient() throws Exception
56      {
57          MuleMessage request = new DefaultMuleMessage("hello", (Map<String,Object>)null, muleContext);
58          MuleClient client = new MuleClient(muleContext);
59          MuleMessage received = client.send("vm://helloClient", request);
60          String contentType = received.getInboundProperty("contentType");
61          assertNotNull(contentType);
62          assertTrue(contentType.contains("charset"));
63      }
64  
65  }