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.DynamicPortTestCase;
16 import org.mule.tck.FunctionalTestCase;
17 import org.mule.transport.http.HttpConnector;
18
19 import java.util.HashMap;
20 import java.util.Map;
21
22 import org.apache.commons.httpclient.HttpVersion;
23 import org.apache.commons.httpclient.params.HttpClientParams;
24 import org.apache.commons.lang.time.StopWatch;
25
26 public class HttpContinueFunctionalTestCase extends DynamicPortTestCase
27 {
28
29
30
31 private static final int DEFAULT_HTTP_CLIENT_CONTINUE_WAIT = 3000;
32
33 protected StopWatch stopWatch;
34
35 @Override
36 protected String getConfigResources()
37 {
38 return "http-functional-test.xml";
39 }
40
41 public void testSendWithContinue() throws Exception
42 {
43 stopWatch = new StopWatch();
44 MuleClient client = new MuleClient(muleContext);
45
46
47 HttpClientParams params = new HttpClientParams();
48 params.setVersion(HttpVersion.HTTP_1_1);
49 params.setBooleanParameter(HttpClientParams.USE_EXPECT_CONTINUE, true);
50
51 Map<String, Object> props = new HashMap<String, Object>();
52 props.put(HttpConnector.HTTP_PARAMS_PROPERTY, params);
53
54 stopWatch.start();
55 MuleMessage result = client.send("clientEndpoint", TEST_MESSAGE, props);
56 stopWatch.stop();
57
58 assertNotNull(result);
59 assertEquals(TEST_MESSAGE + " Received", result.getPayloadAsString());
60
61 if (stopWatch.getTime() > DEFAULT_HTTP_CLIENT_CONTINUE_WAIT)
62 {
63 fail("Server did not handle Expect=100-continue header properly,");
64 }
65 }
66
67 @Override
68 protected int getNumPortsToFind()
69 {
70
71 return 1;
72 }
73 }