1   /*
2    * $Id: MuleAxisSoapClientTestCase.java 11451 2008-03-20 13:19:22Z dirk.olmes $
3    * --------------------------------------------------------------------------------------
4    * Copyright (c) MuleSource, Inc.  All rights reserved.  http://www.mulesource.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.integration.client;
12  
13  import org.mule.api.MuleMessage;
14  import org.mule.module.client.MuleClient;
15  import org.mule.tck.FunctionalTestCase;
16  import org.mule.tck.testmodels.services.Person;
17  
18  public class MuleAxisSoapClientTestCase extends FunctionalTestCase
19  {
20  
21      public String getSoapProvider()
22      {
23          return "axis";
24      }
25  
26      protected String getConfigResources()
27      {
28          return "org/mule/test/integration/client/" + getSoapProvider() + "-client-test-mule-config.xml";
29      }
30  
31      public void testRequestResponse() throws Throwable
32      {
33          MuleClient client = new MuleClient();
34  
35          MuleMessage result = client.send(getSoapProvider()
36                  + ":http://localhost:38104/mule/services/mycomponent2?method=echo",
37                  "test", null);
38          assertNotNull(result);
39          assertEquals("test", result.getPayloadAsString());
40      }
41  
42      public void testRequestResponseComplex() throws Exception
43      {
44          MuleClient client = new MuleClient();
45  
46          MuleMessage result = client.send(
47                  getSoapProvider() + ":http://localhost:38104/mule/services/mycomponent3?method=getPerson",
48                  "Fred", null);
49          assertNotNull(result);
50          logger.debug(result.getPayload());
51          assertTrue(result.getPayload() instanceof Person);
52          assertEquals("Fred", ((Person) result.getPayload()).getFirstName());
53          assertEquals("Flintstone", ((Person) result.getPayload()).getLastName());
54      }
55  
56      public void testRequestResponseComplex2() throws Exception
57      {
58          MuleClient client = new MuleClient();
59  
60          String[] args = new String[]{"Betty", "Rubble"};
61          MuleMessage result = client.send(
62                  getSoapProvider() + ":http://localhost:38104/mule/services/mycomponent3?method=addPerson", args,
63                  null);
64          assertNotNull(result);
65          assertTrue(result.getPayload() instanceof Person);
66          assertEquals("Betty", ((Person) result.getPayload()).getFirstName());
67          assertEquals("Rubble", ((Person) result.getPayload()).getLastName());
68  
69          // do a receive
70          result = client.send(getSoapProvider()
71                  + ":http://localhost:38104/mule/services/mycomponent3?method=getPerson",
72                  "Betty", null);
73          assertNotNull(result);
74          assertTrue(result.getPayload() instanceof Person);
75          assertEquals("Betty", ((Person) result.getPayload()).getFirstName());
76          assertEquals("Rubble", ((Person) result.getPayload()).getLastName());
77  
78      }
79  }