1
2
3
4
5
6
7
8
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 }