1
2
3
4
5
6
7
8
9
10
11 package org.mule.transport.http.functional;
12
13 import org.mule.api.MuleEventContext;
14 import org.mule.api.MuleMessage;
15 import org.mule.module.client.MuleClient;
16 import org.mule.tck.DynamicPortTestCase;
17 import org.mule.tck.functional.EventCallback;
18 import org.mule.tck.functional.FunctionalTestComponent;
19 import org.mule.transport.http.HttpConnector;
20 import org.mule.transport.http.HttpConstants;
21
22 import java.util.HashMap;
23 import java.util.Map;
24
25 public class HttpFunctionalTestCase extends DynamicPortTestCase
26 {
27 protected static String TEST_MESSAGE = "Test Http Request (R���dgr���d), 57 = \u06f7\u06f5 in Arabic";
28 protected boolean checkPathProperties = true;
29
30 protected String getConfigResources()
31 {
32 return "http-functional-test.xml";
33 }
34
35 public void testSend() throws Exception
36 {
37 FunctionalTestComponent testComponent = getFunctionalTestComponent("testComponent");
38 assertNotNull(testComponent);
39
40 if (checkPathProperties)
41 {
42 EventCallback callback = new EventCallback()
43 {
44 public void eventReceived(final MuleEventContext context, final Object component) throws Exception
45 {
46 MuleMessage msg = context.getMessage();
47 assertEquals("/", msg.getInboundProperty(HttpConnector.HTTP_REQUEST_PROPERTY));
48 assertEquals("/", msg.getInboundProperty(HttpConnector.HTTP_REQUEST_PATH_PROPERTY));
49 assertEquals("/", msg.getInboundProperty(HttpConnector.HTTP_CONTEXT_PATH_PROPERTY));
50 }
51 };
52
53 testComponent.setEventCallback(callback);
54 }
55
56 MuleClient client = new MuleClient(muleContext);
57 Map<String, String> props = new HashMap<String, String>();
58 props.put(HttpConstants.HEADER_CONTENT_TYPE, "text/plain;charset=UTF-8");
59 MuleMessage result = client.send("clientEndpoint", TEST_MESSAGE, props);
60 assertEquals(TEST_MESSAGE + " Received", result.getPayloadAsString());
61 }
62
63 @Override
64 protected int getNumPortsToFind()
65 {
66 return 1;
67 }
68 }