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;
8   
9   import org.mule.DefaultMuleMessage;
10  import org.mule.api.MuleMessage;
11  import org.mule.module.client.MuleClient;
12  import org.mule.tck.junit4.FunctionalTestCase;
13  import org.mule.tck.junit4.rule.DynamicPort;
14  
15  import java.util.Properties;
16  
17  import org.junit.Rule;
18  import org.junit.Test;
19  
20  import static org.junit.Assert.assertEquals;
21  import static org.junit.Assert.assertNotNull;
22  
23  public class WebServiceWrapperWithCxfTestCase extends FunctionalTestCase
24  {
25      private String testString = "test";
26  
27      @Rule
28      public DynamicPort dynamicPort = new DynamicPort("port1");
29  
30      @Override
31      protected String getConfigResources()
32      {
33          return "mule-ws-wrapper-config.xml";
34      }
35  
36      @Test
37      public void testWsCall() throws Exception
38      {
39          MuleClient client = new MuleClient(muleContext);
40          MuleMessage result = client.send("vm://testin", new DefaultMuleMessage(testString, muleContext));
41          assertNotNull(result.getPayload());
42          assertEquals("Payload", testString, result.getPayloadAsString());
43      }
44      
45      @Test
46      public void testWsCallWithUrlFromMessage() throws Exception
47      {
48          MuleClient client = new MuleClient(muleContext);
49          Properties props = new Properties();
50          props.setProperty("ws.service.url", "http://localhost:" + dynamicPort.getNumber() + "/services/TestUMO?method=onReceive");
51          MuleMessage result = client.send("vm://testin2", testString, props);
52          assertNotNull(result.getPayload());
53          assertEquals("Payload", testString, result.getPayloadAsString());
54      }
55  }