1 2 17 18 package org.springframework.aop.support; 19 20 import junit.framework.TestCase; 21 22 import org.springframework.aop.ClassFilter; 23 import org.springframework.beans.ITestBean; 24 import org.springframework.beans.TestBean; 25 import org.springframework.core.NestedRuntimeException; 26 27 30 public class ClassFiltersTests extends TestCase { 31 32 private ClassFilter exceptionFilter = new RootClassFilter(Exception .class); 33 34 private ClassFilter itbFilter = new RootClassFilter(ITestBean.class); 35 36 private ClassFilter hasRootCauseFilter = new RootClassFilter(NestedRuntimeException.class); 37 38 public void testUnion() { 39 assertTrue(exceptionFilter.matches(RuntimeException .class)); 40 assertFalse(exceptionFilter.matches(TestBean.class)); 41 assertFalse(itbFilter.matches(Exception .class)); 42 assertTrue(itbFilter.matches(TestBean.class)); 43 ClassFilter union = ClassFilters.union(exceptionFilter, itbFilter); 44 assertTrue(union.matches(RuntimeException .class)); 45 assertTrue(union.matches(TestBean.class)); 46 } 47 48 public void testIntersection() { 49 assertTrue(exceptionFilter.matches(RuntimeException .class)); 50 assertTrue(hasRootCauseFilter.matches(NestedRuntimeException.class)); 51 ClassFilter intersection = ClassFilters.intersection(exceptionFilter, hasRootCauseFilter); 52 assertFalse(intersection.matches(RuntimeException .class)); 53 assertFalse(intersection.matches(TestBean.class)); 54 assertTrue(intersection.matches(NestedRuntimeException.class)); 55 } 56 57 } 58 | Popular Tags |