01: package com.ecyrd.jspwiki.filters;
02:
03: import junit.framework.*;
04: import java.util.*;
05:
06: import org.apache.log4j.*;
07:
08: import com.ecyrd.jspwiki.*;
09:
10: public class FilterManagerTest extends TestCase {
11: Properties props = new Properties();
12:
13: TestEngine engine;
14:
15: public FilterManagerTest(String s) {
16: super (s);
17: }
18:
19: public void setUp() throws Exception {
20: props.load(TestEngine.findTestProperties());
21: PropertyConfigurator.configure(props);
22: engine = new TestEngine(props);
23: }
24:
25: public void tearDown() {
26: }
27:
28: public void testInitFilters() throws Exception {
29: FilterManager m = new FilterManager(engine, props);
30:
31: List l = m.getFilterList();
32:
33: assertEquals("Wrong number of filters", 2, l.size());
34:
35: Iterator i = l.iterator();
36: PageFilter f1 = (PageFilter) i.next();
37:
38: assertTrue("Not a Profanityfilter",
39: f1 instanceof ProfanityFilter);
40:
41: PageFilter f2 = (PageFilter) i.next();
42:
43: assertTrue("Not a Testfilter", f2 instanceof TestFilter);
44: }
45:
46: public void testInitParams() throws Exception {
47: FilterManager m = new FilterManager(engine, props);
48:
49: List l = m.getFilterList();
50:
51: Iterator i = l.iterator();
52: i.next();
53: TestFilter f2 = (TestFilter) i.next();
54:
55: Properties p = f2.m_properties;
56:
57: assertEquals("no foobar", "Zippadippadai", p
58: .getProperty("foobar"));
59:
60: assertEquals("no blatblaa", "5", p.getProperty("blatblaa"));
61: }
62:
63: public static Test suite() {
64: return new TestSuite(FilterManagerTest.class);
65: }
66:
67: }
|