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.transport.soap.axis.functional;
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  import static org.junit.Assert.assertTrue;
23  
24  public class WebServiceWrapperWithAxisTestCase extends FunctionalTestCase
25  {
26      private String testString = "test";
27  
28      @Rule
29      public DynamicPort dynamicPort1 = new DynamicPort("port1");
30  
31      @Rule
32      public DynamicPort dynamicPort2 = new DynamicPort("port2");
33  
34      @Override
35      protected String getConfigResources()
36      {
37          return "mule-ws-wrapper-config.xml";
38      }
39  
40      @Test
41      public void testWsCall() throws Exception
42      {
43          MuleClient client = new MuleClient(muleContext);
44          MuleMessage result = client.send("vm://testin", new DefaultMuleMessage(testString, muleContext));
45          assertNotNull(result.getPayload());
46          assertEquals("Payload", "Received: " + testString, result.getPayloadAsString());
47      }
48  
49      @Test
50      public void testWsCallWithUrlFromMessage() throws Exception
51      {
52          MuleClient client = new MuleClient(muleContext);
53          Properties props = new Properties();
54          props.setProperty("ws.service.url", "http://localhost:" + dynamicPort1.getNumber() + "/services/TestUMO?method=receive");
55          MuleMessage result = client.send("vm://testin2", testString, props);
56          assertNotNull(result.getPayload());
57          assertEquals("Payload", "Received: "+ testString, result.getPayloadAsString());
58      }
59  
60      @Test
61      public void testWsCallWithComplexParameters() throws Exception
62      {
63          MuleClient client = new MuleClient(muleContext);
64          client.dispatch("vm://queue.in", new Object[]{new Long(3), new Long(3)},null);
65          MuleMessage result = client.request("vm://queue.out", RECEIVE_TIMEOUT);
66          assertNotNull(result.getPayload());
67          assertTrue(result.getPayload() instanceof Long);
68          assertEquals("Payload", 6, ((Long)result.getPayload()).intValue());
69      }
70  }