View Javadoc

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