1
2
3
4
5
6
7
8
9
10
11 package org.mule.transport.http.functional;
12
13 import org.mule.api.MuleMessage;
14 import org.mule.module.client.MuleClient;
15 import org.mule.tck.FunctionalTestCase;
16 import org.mule.transport.http.HttpConnector;
17
18 import java.util.HashMap;
19 import java.util.Map;
20
21 import org.apache.commons.httpclient.HttpVersion;
22 import org.apache.commons.httpclient.params.HttpClientParams;
23 import org.apache.commons.lang.time.StopWatch;
24
25 public class HttpContinueFunctionalTestCase extends FunctionalTestCase
26 {
27
28 public static final String TEST_MESSAGE = "Foo Bar";
29
30 protected String getConfigResources()
31 {
32 return "http-functional-test.xml";
33 }
34
35
36
37
38 public static final int DEFAULT_HTTP_CLIENT_CONTINUE_WAIT = 3000;
39
40 protected StopWatch stopWatch;
41
42 public void testSendWithContinue() throws Exception
43 {
44 MuleClient client = new MuleClient();
45 Map props = new HashMap();
46
47 HttpClientParams params = new HttpClientParams();
48 params.setVersion(HttpVersion.HTTP_1_1);
49 params.setBooleanParameter(HttpClientParams.USE_EXPECT_CONTINUE, true);
50 props.put(HttpConnector.HTTP_PARAMS_PROPERTY, params);
51 stopWatch = new StopWatch();
52 stopWatch.start();
53 MuleMessage result = client.send("clientEndpoint", TEST_MESSAGE, props);
54 stopWatch.stop();
55
56 assertNotNull(result);
57 assertEquals(TEST_MESSAGE + " Received", result.getPayloadAsString());
58
59 if (stopWatch.getTime() > DEFAULT_HTTP_CLIENT_CONTINUE_WAIT)
60 {
61 fail("Server did not handle Expect=100-continue header properly,");
62 }
63 }
64 }