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