01: /*
02: * Copyright 2001-2007 Geert Bevin <gbevin[remove] at uwyn dot com>
03: * Distributed under the terms of either:
04: * - the common development and distribution license (CDDL), v1.0; or
05: * - the GNU Lesser General Public License, v2.1 or later
06: * $Id: TestEngineFilter.java 3634 2007-01-08 21:42:24Z gbevin $
07: */
08: package com.uwyn.rife.engine;
09:
10: import com.uwyn.rife.TestCaseServerside;
11: import com.uwyn.rife.tools.HttpUtils;
12: import java.net.InetAddress;
13:
14: public class TestEngineFilter extends TestCaseServerside {
15: public TestEngineFilter(String name) {
16: super (SITE_FILTER, name);
17: }
18:
19: public void testServedThroughTheFilter() throws Exception {
20: setupSite("site/filter.xml");
21:
22: HttpUtils.Page page = HttpUtils
23: .retrievePage("http://localhost:8181/simple/html");
24:
25: // Get the host name
26: String hostname = InetAddress.getByName("127.0.0.1")
27: .getHostName();
28:
29: assertEquals("text/html; charset=UTF-8", page.getContentType());
30: assertEquals("Just some text 127.0.0.1:" + hostname
31: + ":.SIMPLEHTML:", page.getContent());
32: }
33:
34: public void testDefaultServletFallthrough() throws Exception {
35: setupSite("site/filter.xml");
36:
37: HttpUtils.Page page = HttpUtils
38: .retrievePage("http://localhost:8181/simple/served_by_default_servlet.txt");
39: assertEquals(
40: "This is in it, served by the default file servlet.",
41: page.getContent());
42: }
43:
44: public void testDefer() throws Exception {
45: setupSite("site/filter.xml");
46:
47: HttpUtils.Page page = HttpUtils
48: .retrievePage("http://localhost:8181/defer");
49: assertEquals(
50: "This 'defer', served by the default file servlet.\n",
51: page.getContent());
52: }
53: }
|