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.junit4.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 import org.junit.Test;
22
23 import static org.junit.Assert.assertEquals;
24
25 public class FilterTest extends FunctionalTestCase
26 {
27
28 @Override
29 protected String getConfigResources()
30 {
31 return "filter-conf.xml";
32 }
33
34 @Test
35 public void testAcceptFilter() throws Exception
36 {
37 LocalMuleClient client = muleContext.getClient();
38
39 MuleMessage result;
40
41
42
43 result = client.send("http://localhost:9002/baz", "test", null);
44 assertEquals("test received", result.getPayloadAsString());
45 }
46
47 @Test
48 public void testUnAcceptFilter() throws Exception
49 {
50 LocalMuleClient client = muleContext.getClient();
51
52 Map<String, Object> props = new HashMap<String, Object>();
53 props.put(HttpConnector.HTTP_METHOD_PROPERTY, "HEAD");
54
55 MuleMessage result = client.send("http://localhost:9002/baz", "test", props);
56
57 assertEquals(new Integer(HttpConstants.SC_NOT_ACCEPTABLE), result.getInboundProperty(HttpConnector.HTTP_STATUS_PROPERTY, new Integer(-1)));
58
59 result = client.send("http://localhost:9002/quo", "test", null);
60
61 assertEquals(new Integer(HttpConstants.SC_NOT_ACCEPTABLE), result.getInboundProperty(HttpConnector.HTTP_STATUS_PROPERTY, new Integer(-1)));
62 }
63
64 }