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.test.usecases.axis;
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  import org.mule.transport.soap.axis.AxisConnector;
14  
15  import java.util.HashMap;
16  import java.util.Map;
17  
18  import org.junit.Rule;
19  import org.junit.Test;
20  
21  import static org.junit.Assert.assertEquals;
22  import static org.junit.Assert.assertNotNull;
23  
24  public class AxisClientWithComplexTypesTestCase extends FunctionalTestCase
25  {
26      
27      private Trade trade = null;
28      private String uri = null;
29  
30      @Rule
31      public DynamicPort dynamicPort = new DynamicPort("port1");
32  
33      @Override
34      protected String getConfigResources()
35      {
36          return "org/mule/test/usecases/routing/axis/axis-client-test.xml";
37      }
38  
39      @Override
40      protected void doSetUp() throws Exception
41      {
42          trade = new Trade();
43          trade.setAccountID(11);
44          trade.setCusip("33");
45          trade.setCurrency(22);
46          trade.setTradeID(22);
47          trade.setTransaction(11);
48          uri = "axis:http://localhost:" + dynamicPort.getNumber() + "/services/BackOfficeImplBindingImplUMO?method=submitTrade";
49      }
50  
51      @Test
52      public void testSendComplexDOCLIT() throws Exception
53      {
54          MuleClient client = new MuleClient(muleContext);
55          Map props = new HashMap();
56          props.put(AxisConnector.STYLE, "Document");
57          props.put(AxisConnector.USE, "Literal");
58  
59          SubmitTrade submittrade = new SubmitTrade();
60          submittrade.setArg0(trade);
61  
62          // We need to name the parameters weh using Doc/Lit
63          // SoapMethod method = new SoapMethod(new QName("submitTrade"),
64          // SubmitTradeResponse.class);
65          // method.addNamedParameter(new NamedParameter(new QName("submitTrade"),
66          // NamedParameter.createQName("Object"), ParameterMode.IN));
67          // props.put(MuleProperties.MULE_SOAP_METHOD, method);
68          MuleMessage result = client.send(uri, submittrade, props);
69          assertNotNull(result);
70          SubmitTradeResponse response = (SubmitTradeResponse)result.getPayload();
71          assertEquals("RECEIVED", response.get_return().getStatus());
72      }
73  
74      @Test
75      public void testSendComplexRPCENC() throws Exception
76      {
77          MuleClient client = new MuleClient(muleContext);
78  
79          MuleMessage result = client.send(uri, trade, null);
80          assertNotNull(result);
81          TradeStatus status = (TradeStatus)result.getPayload();
82          assertEquals("RECEIVED", status.getStatus());
83      }
84  
85  }