View Javadoc

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