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