1   /*
2    * $Id: HttpContentLengthPropagationTestCase.java 8037 2007-08-24 07:59:13Z 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.providers.http.functional;
12  
13  import org.mule.extras.client.MuleClient;
14  import org.mule.impl.MuleMessage;
15  import org.mule.tck.FunctionalTestCase;
16  import org.mule.transformers.xml.XsltTransformer;
17  import org.mule.umo.UMOMessage;
18  import org.mule.util.IOUtils;
19  
20  import java.io.InputStream;
21  
22  public class HttpContentLengthPropagationTestCase extends FunctionalTestCase
23  {
24      private static final String NAME_PAYLOAD = "test-xml-payload.xml";
25      private static final String NAME_STYLESHEET = "stylesheet.xsl";
26  
27      public HttpContentLengthPropagationTestCase()
28      {
29          super();
30          this.setDisposeManagerPerSuite(true);
31      }
32  
33      protected String getConfigResources()
34      {
35          return "http-content-length-propagation-conf.xml";
36      }
37  
38      public void testContentLengthPropagation() throws Exception
39      {
40          InputStream is = Thread.currentThread().getContextClassLoader().getResourceAsStream(NAME_PAYLOAD);
41          assertNotNull("Payload test file not found.", is);
42          byte[] fileContents = IOUtils.toByteArray(is);
43  
44  
45  
46          MuleClient client = new MuleClient();
47          UMOMessage result = client.send("http://localhost:8085", new MuleMessage(fileContents));
48  
49          XsltTransformer trans = new XsltTransformer();
50          trans.setXslFile(NAME_STYLESHEET);
51          final byte[] locallyTransformedBytes = (byte[]) trans.doTransform(fileContents, "UTF-8");
52  
53          assertEquals(new String(locallyTransformedBytes), result.getPayloadAsString());
54  
55      }
56  
57  }