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.integration.transport.cxf;
8   
9   import org.mule.api.MuleMessage;
10  import org.mule.module.client.MuleClient;
11  import org.mule.tck.junit4.FunctionalTestCase;
12  
13  import org.custommonkey.xmlunit.XMLAssert;
14  import org.junit.Test;
15  
16  import static org.junit.Assert.assertNotNull;
17  
18  public class CxfEnvelopePayloadWithWsdlTestCase extends FunctionalTestCase
19  {
20  
21      private static final String msg = "<soapenv:Envelope xmlns:soapenv=\"http://schemas.xmlsoap.org/soap/envelope/\" "
22                         + "xmlns:emop=\"http://www.wcs.com/2010/07/14/emop\">"
23                         + "  <soapenv:Header>\n"
24                         + "    <header UserName=\"nothing\" Password=\"important\"/>\n"
25                         + "  </soapenv:Header>\n"
26                         + "  <soapenv:Body>\n"
27                         + "    <emop:ScratchcardValidateAndPayRequestBody>\n"
28                         + "       <ScratchcardNumber>1</ScratchcardNumber>\n"
29                         + "       <VirnNumber>2</VirnNumber>\n"
30                         + "    </emop:ScratchcardValidateAndPayRequestBody>\n"
31                         + "  </soapenv:Body>\n"
32                         + "</soapenv:Envelope>";
33  
34      @Override
35      protected String getConfigResources()
36      {
37          return "org/mule/test/integration/transport/cxf/scratchcard-service-config.xml";
38      }
39  
40      @Test
41      public void testEnvelopePayloadIsProcessedWhenMessageAndWsdlContainsHeaders() throws Exception
42      {
43          MuleClient client = new MuleClient(muleContext);
44  
45          MuleMessage result = client.send("http://localhost:28182/ScratchCardServiceV1", msg, null);
46  
47          assertNotNull("The result shouln't have been null", result);
48          final String payloadAsString = result.getPayloadAsString();
49          XMLAssert.assertXMLEqual(msg, payloadAsString);
50      }
51  }