1
2
3
4
5
6
7
8
9
10 package org.mule.module.atom;
11
12 import org.mule.api.MuleMessage;
13 import org.mule.api.client.LocalMuleClient;
14 import org.mule.tck.FunctionalTestCase;
15 import org.mule.transport.http.HttpConnector;
16 import org.mule.transport.http.HttpConstants;
17
18 import java.util.HashMap;
19 import java.util.Map;
20
21 public class FilterTest extends FunctionalTestCase
22 {
23 @Override
24 protected String getConfigResources()
25 {
26 return "filter-conf.xml";
27 }
28
29 public void testAcceptFilter() throws Exception
30 {
31 LocalMuleClient client = muleContext.getClient();
32
33 MuleMessage result;
34
35
36
37 result = client.send("http://localhost:9002/baz", "test", null);
38 assertEquals("test received", result.getPayloadAsString());
39 }
40
41 public void testUnAcceptFilter() throws Exception
42 {
43 LocalMuleClient client = muleContext.getClient();
44
45 Map<String, Object> props = new HashMap<String, Object>();
46 props.put(HttpConnector.HTTP_METHOD_PROPERTY, "HEAD");
47
48 MuleMessage result = client.send("http://localhost:9002/baz", "test", props);
49 assertEquals(new Integer(0), result.getInboundProperty(HttpConstants.HEADER_CONTENT_LENGTH, new Integer(-1)));
50 assertEquals(new Integer(HttpConstants.SC_NOT_ACCEPTABLE), result.getInboundProperty(HttpConnector.HTTP_STATUS_PROPERTY, new Integer(-1)));
51
52 result = client.send("http://localhost:9002/quo", "test", null);
53 assertEquals(new Integer(0), result.getInboundProperty(HttpConstants.HEADER_CONTENT_LENGTH, new Integer(-1)));
54 assertEquals(new Integer(HttpConstants.SC_NOT_ACCEPTABLE), result.getInboundProperty(HttpConnector.HTTP_STATUS_PROPERTY, new Integer(-1)));
55 }
56
57 }