KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > filter > AbstractTestFilter


1 package filter;
2
3 import junit.framework.TestCase;
4
5 public abstract class AbstractTestFilter extends TestCase {
6     
7     public void testFilterNull() {
8         Exception JavaDoc err = null;
9         try {
10             getIFilter().filter(null, null);
11         } catch (NullPointerException JavaDoc npe) {
12             err = npe;
13         }
14         assertNull(err);
15     }
16
17     /**
18      * @return
19      */

20     public abstract IFilter getIFilter() ;
21     
22     public void testFilterNullValues() {
23         Exception JavaDoc err = null;
24         try {
25             getIFilter().filter(null, "test");
26         } catch (NullPointerException JavaDoc npe) {
27             err = npe;
28         }
29         assertNull(err);
30     }
31     
32     public void testFilterNullPrefix() {
33         Exception JavaDoc err = null;
34         try {
35             getIFilter().filter(new String JavaDoc[]{"test"}, null);
36         } catch (NullPointerException JavaDoc npe) {
37             err = npe;
38         }
39         assertNull(err);
40     }
41     
42     public void testFilter() {
43         String JavaDoc[] result = getIFilter().filter(new String JavaDoc[]{"test", "nogood", "mustbe filtered"}, "t");
44         assertNotNull(result);
45         assertEquals(result.length, 1);
46     }
47     
48     public void testFilterWithNullValues() {
49         String JavaDoc[] result = getIFilter().filter(new String JavaDoc[]{"test", null, "mustbe filtered"}, "t");
50         assertNotNull(result);
51         assertEquals(result.length, 1);
52     }
53 }
54
Popular Tags