01: /*
02: * Licensed to the Apache Software Foundation (ASF) under one or more
03: * contributor license agreements. See the NOTICE file distributed with
04: * this work for additional information regarding copyright ownership.
05: * The ASF licenses this file to You under the Apache License, Version 2.0
06: * (the "License"); you may not use this file except in compliance with
07: * the License. You may obtain a copy of the License at
08: *
09: * http://www.apache.org/licenses/LICENSE-2.0
10: *
11: * Unless required by applicable law or agreed to in writing, software
12: * distributed under the License is distributed on an "AS IS" BASIS,
13: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14: * See the License for the specific language governing permissions and
15: * limitations under the License.
16: *
17: */
18: package filter;
19:
20: import junit.framework.TestCase;
21:
22: public abstract class AbstractTestFilter extends TestCase {
23:
24: public void testFilterNull() {
25: Exception err = null;
26: try {
27: getIFilter().filter(null, null);
28: } catch (NullPointerException npe) {
29: err = npe;
30: }
31: assertNull(err);
32: }
33:
34: /**
35: * @return
36: */
37: public abstract IFilter getIFilter();
38:
39: public void testFilterNullValues() {
40: Exception err = null;
41: try {
42: getIFilter().filter(null, "test");
43: } catch (NullPointerException npe) {
44: err = npe;
45: }
46: assertNull(err);
47: }
48:
49: public void testFilterNullPrefix() {
50: Exception err = null;
51: try {
52: getIFilter().filter(new String[] { "test" }, null);
53: } catch (NullPointerException npe) {
54: err = npe;
55: }
56: assertNull(err);
57: }
58:
59: public void testFilter() {
60: String[] result = getIFilter().filter(
61: new String[] { "test", "nogood", "mustbe filtered" },
62: "t");
63: assertNotNull(result);
64: assertEquals(result.length, 1);
65: }
66:
67: public void testFilterWithNullValues() {
68: String[] result = getIFilter().filter(
69: new String[] { "test", null, "mustbe filtered" }, "t");
70: assertNotNull(result);
71: assertEquals(result.length, 1);
72: }
73: }
|