KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > jzonic > jlo > filter > TextFilterTest


1 /*
2  * TextFilterTest.java
3  * JUnit based test
4  *
5  * Created on 31. August 2003, 22:48
6  */

7
8 package org.jzonic.jlo.filter;
9
10 import junit.framework.Test;
11 import junit.framework.TestCase;
12 import junit.framework.TestSuite;
13
14 import java.util.HashMap JavaDoc;
15 import java.util.Map JavaDoc;
16 /**
17  *
18  * @author Administrator
19  */

20 public class TextFilterTest extends TestCase {
21     
22     public TextFilterTest(java.lang.String JavaDoc testName) {
23         super(testName);
24     }
25     
26     public static void main(java.lang.String JavaDoc[] args) {
27         junit.textui.TestRunner.run(suite());
28     }
29     
30     public static Test suite() {
31         TestSuite suite = new TestSuite(TextFilterTest.class);
32         return suite;
33     }
34     
35     public void testFilter() {
36         LogFilter textFilter = new TextFilter();
37         Map JavaDoc params = new HashMap JavaDoc();
38         params.put("expression","exception");
39         textFilter.setParameters(params);
40         String JavaDoc text = "This is an exception";
41         boolean match = textFilter.match(text);
42         assertEquals(true, match);
43         text = "no word matches";
44         match = textFilter.match(text);
45         assertEquals(false, match);
46         text = "no EXCEption matches";
47         match = textFilter.match(text);
48         assertEquals(true, match);
49     }
50     
51     
52 }
53
Popular Tags