1
2
3
4
5
6
7
8
9
10
11 package org.mule.transport.http.filters;
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 import org.mule.transport.http.HttpConstants;
18
19 import java.util.HashMap;
20 import java.util.Map;
21
22 public class HttpRequestWildcardFilterTestCase extends FunctionalTestCase
23 {
24
25 protected String getConfigResources()
26 {
27 return "http-wildcard-filter-test.xml";
28 }
29
30 private static final String HTTP_ENDPOINT = "http://localhost:60201";
31 private static final String REF_ENDPOINT = "http://localhost:60199";
32 private static final String TEST_MESSAGE = "Hello=World";
33 private static final String TEST_BAD_MESSAGE = "xyz";
34
35
36 public void testReference() throws Exception
37 {
38 MuleClient client = new MuleClient();
39 MuleMessage result = client.send(REF_ENDPOINT, TEST_MESSAGE, null);
40
41 assertEquals(TEST_MESSAGE, result.getPayloadAsString());
42 }
43
44 public void testHttpPost() throws Exception
45 {
46 MuleClient client = new MuleClient();
47 MuleMessage result = client.send(HTTP_ENDPOINT, TEST_MESSAGE, null);
48
49 assertEquals(TEST_MESSAGE, result.getPayloadAsString());
50 }
51
52 public void testHttpGetNotFilter() throws Exception
53 {
54 Map props = new HashMap();
55 props.put(HttpConstants.METHOD_GET, "true");
56 MuleClient client = new MuleClient();
57 MuleMessage result = client.send(HTTP_ENDPOINT, TEST_MESSAGE, props);
58
59 assertEquals(TEST_MESSAGE, result.getPayloadAsString());
60 }
61
62 public void testHttpGetFilter() throws Exception
63 {
64 Map props = new HashMap();
65 props.put(HttpConstants.METHOD_GET, "true");
66 MuleClient client = new MuleClient();
67 MuleMessage result = client.send(HTTP_ENDPOINT, TEST_BAD_MESSAGE, props);
68 assertEquals(HttpConstants.SC_NOT_ACCEPTABLE, result.getIntProperty(HttpConnector.HTTP_STATUS_PROPERTY, 0));
69 assertNotNull(result.getExceptionPayload());
70 }
71
72 }