1
2
3
4
5
6
7
8
9
10
11 package org.mule.transport.http.functional;
12
13 import org.mule.DefaultMuleMessage;
14 import org.mule.api.MuleMessage;
15 import org.mule.module.client.MuleClient;
16 import org.mule.module.xml.transformer.XsltTransformer;
17 import org.mule.tck.FunctionalTestCase;
18 import org.mule.util.IOUtils;
19
20 import java.io.InputStream;
21
22 public class HttpContentLengthPropagationTestCase extends FunctionalTestCase
23 {
24
25 private static final String NAME_PAYLOAD = "test-xml-payload.xml";
26 private static final String NAME_STYLESHEET = "stylesheet.xsl";
27
28 protected String getConfigResources()
29 {
30 return "http-content-length-propagation-conf.xml";
31 }
32
33 public void testContentLengthPropagation() throws Exception
34 {
35 InputStream is = Thread.currentThread().getContextClassLoader().getResourceAsStream(NAME_PAYLOAD);
36 assertNotNull("Payload test file not found.", is);
37 byte[] fileContents = IOUtils.toByteArray(is);
38
39 MuleClient client = new MuleClient();
40 MuleMessage result = client.send("http://localhost:8085", new DefaultMuleMessage(fileContents));
41
42 XsltTransformer trans = new XsltTransformer();
43 trans.setXslFile(NAME_STYLESHEET);
44 final byte[] locallyTransformedBytes = (byte[]) trans.doTransform(fileContents, "UTF-8");
45
46 assertEquals(new String(locallyTransformedBytes), result.getPayloadAsString());
47 }
48
49 }