View Javadoc
1   /*
2    * Copyright (c) MuleSoft, Inc.  All rights reserved.  http://www.mulesoft.com
3    * The software in this package is published under the terms of the CPAL v1.0
4    * license, a copy of which has been included with this distribution in the
5    * LICENSE.txt file.
6    */
7   package org.mule.module.cxf.client;
8   
9   import org.mule.api.MuleMessage;
10  import org.mule.module.client.MuleClient;
11  import org.mule.tck.junit4.FunctionalTestCase;
12  import org.mule.tck.junit4.rule.DynamicPort;
13  
14  import org.junit.Rule;
15  import org.junit.Test;
16  
17  import static org.junit.Assert.assertTrue;
18  
19  public class GeneratedClientTestCase extends FunctionalTestCase
20  {
21  
22      @Rule
23      public DynamicPort dynamicPort = new DynamicPort("port1");
24  
25      @Override
26      protected String getConfigResources()
27      {
28          return "proxy-conf.xml";
29      }
30  
31      @Test
32      public void testEchoService() throws Exception
33      {
34          // URL wsdl = getClass().getResource("/wsdl/hello_world.wsdl");
35          // assertNotNull(wsdl);
36          // SOAPService service = new SOAPService(wsdl, null);
37          // Greeter soapPort = service.getSoapPort();
38          //
39          String msg = "<soap:Envelope xmlns:soap=\"http://schemas.xmlsoap.org/soap/envelope/\">"
40                       + "<soap:Body>" + "<test> foo </test>" + "</soap:Body>" + "</soap:Envelope>";
41  
42          MuleClient client = new MuleClient(muleContext);
43          MuleMessage result = client.send("http://localhost:" + dynamicPort.getNumber() + "/services/Echo", msg, null);
44          byte[] res = (byte[]) result.getPayload();
45          String resString = new String(res);
46  
47          assertTrue(resString.indexOf("<test> foo </test>") != -1);
48      }
49  }