1 package filter; 2 3 import junit.framework.TestCase; 4 5 public abstract class AbstractTestFilter extends TestCase { 6 7 public void testFilterNull() { 8 Exception err = null; 9 try { 10 getIFilter().filter(null, null); 11 } catch (NullPointerException npe) { 12 err = npe; 13 } 14 assertNull(err); 15 } 16 17 20 public abstract IFilter getIFilter() ; 21 22 public void testFilterNullValues() { 23 Exception err = null; 24 try { 25 getIFilter().filter(null, "test"); 26 } catch (NullPointerException npe) { 27 err = npe; 28 } 29 assertNull(err); 30 } 31 32 public void testFilterNullPrefix() { 33 Exception err = null; 34 try { 35 getIFilter().filter(new String []{"test"}, null); 36 } catch (NullPointerException npe) { 37 err = npe; 38 } 39 assertNull(err); 40 } 41 42 public void testFilter() { 43 String [] result = getIFilter().filter(new String []{"test", "nogood", "mustbe filtered"}, "t"); 44 assertNotNull(result); 45 assertEquals(result.length, 1); 46 } 47 48 public void testFilterWithNullValues() { 49 String [] result = getIFilter().filter(new String []{"test", null, "mustbe filtered"}, "t"); 50 assertNotNull(result); 51 assertEquals(result.length, 1); 52 } 53 } 54 | Popular Tags |