View Javadoc

1   /*
2    * $Id: GeneratedClientTestCase.java 22530 2011-07-22 14:10:10Z justin.calleja $
3    * --------------------------------------------------------------------------------------
4    * Copyright (c) MuleSoft, 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.client;
12  
13  import org.mule.api.MuleMessage;
14  import org.mule.module.client.MuleClient;
15  import org.mule.tck.junit4.FunctionalTestCase;
16  import org.mule.tck.junit4.rule.DynamicPort;
17  
18  import org.junit.Rule;
19  import org.junit.Test;
20  
21  import static org.junit.Assert.assertTrue;
22  
23  public class GeneratedClientTestCase extends FunctionalTestCase
24  {
25  
26      @Rule
27      public DynamicPort dynamicPort = new DynamicPort("port1");
28  
29      @Override
30      protected String getConfigResources()
31      {
32          return "proxy-conf-service.xml";
33      }
34  
35      @Test
36      public void testEchoService() throws Exception
37      {
38          // URL wsdl = getClass().getResource("/wsdl/hello_world.wsdl");
39          // assertNotNull(wsdl);
40          // SOAPService service = new SOAPService(wsdl, null);
41          // Greeter soapPort = service.getSoapPort();
42          //
43          String msg = "<soap:Envelope xmlns:soap=\"http://schemas.xmlsoap.org/soap/envelope/\">"
44                       + "<soap:Body>" + "<test> foo </test>" + "</soap:Body>" + "</soap:Envelope>";
45  
46          MuleClient client = new MuleClient(muleContext);
47          MuleMessage result = client.send("http://localhost:" + dynamicPort.getNumber() + "/services/Echo", msg, null);
48          byte[] res = (byte[]) result.getPayload();
49          String resString = new String(res);
50  
51          assertTrue(resString.indexOf("<test> foo </test>") != -1);
52      }
53  }