View Javadoc

1   /*
2    * $Id: SoapRequestNoMethodParamTestCase.java 22474 2011-07-20 12:18:20Z justin.calleja $
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.module.cxf;
12  
13  import static org.junit.Assert.assertEquals;
14  import static org.junit.Assert.assertNotNull;
15  
16  import java.util.Arrays;
17  import java.util.Collection;
18  
19  import org.junit.Rule;
20  import org.junit.Test;
21  import org.junit.runners.Parameterized.Parameters;
22  import org.mule.DefaultMuleMessage;
23  import org.mule.api.MuleMessage;
24  import org.mule.api.endpoint.InboundEndpoint;
25  import org.mule.module.client.MuleClient;
26  import org.mule.tck.AbstractServiceAndFlowTestCase;
27  import org.mule.tck.junit4.rule.DynamicPort;
28  
29  public class SoapRequestNoMethodParamTestCase extends AbstractServiceAndFlowTestCase
30  {
31      private static final String request = "<soap:Envelope xmlns:soap=\"http://schemas.xmlsoap.org/soap/envelope/\" xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\"><soap:Body><receive xmlns=\"http://www.muleumo.org\"><src xmlns=\"http://www.muleumo.org\">Test String</src></receive></soap:Body></soap:Envelope>";
32      private static final String response = "<soap:Envelope xmlns:soap=\"http://schemas.xmlsoap.org/soap/envelope/\"><soap:Body><ns1:receiveResponse xmlns:ns1=\"http://services.testmodels.tck.mule.org/\"><ns1:return>Received: null</ns1:return></ns1:receiveResponse></soap:Body></soap:Envelope>";
33  
34      @Rule
35      public DynamicPort port1 = new DynamicPort("port1");
36  
37      public SoapRequestNoMethodParamTestCase(ConfigVariant variant, String configResources)
38      {
39          super(variant, configResources);
40      }
41  
42      @Parameters
43      public static Collection<Object[]> parameters()
44      {
45          return Arrays.asList(new Object[][]{
46              {ConfigVariant.SERVICE, "soap-request-conf-service.xml"},
47              {ConfigVariant.FLOW, "soap-request-conf-flow.xml"}});
48      }
49  
50      @Test
51      public void testCXFSoapRequest() throws Exception
52      {
53          MuleClient client = new MuleClient(muleContext);
54  
55          MuleMessage msg = client.send(
56              ((InboundEndpoint) client.getMuleContext().getRegistry().lookupObject("httpInbound")).getAddress(),
57              new DefaultMuleMessage(request, muleContext));        
58  
59          assertNotNull(msg);
60          assertNotNull(msg.getPayload());
61          assertEquals(response, msg.getPayloadAsString());
62      }
63  
64  }