KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > springframework > aop > support > ClassFiltersTests


1
2 /*
3  * Copyright 2002-2005 the original author or authors.
4  *
5  * Licensed under the Apache License, Version 2.0 (the "License");
6  * you may not use this file except in compliance with the License.
7  * You may obtain a copy of the License at
8  *
9  * 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 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 /**
28  * @author Rod Johnson
29  */

30 public class ClassFiltersTests extends TestCase {
31     
32     private ClassFilter exceptionFilter = new RootClassFilter(Exception JavaDoc.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 JavaDoc.class));
40         assertFalse(exceptionFilter.matches(TestBean.class));
41         assertFalse(itbFilter.matches(Exception JavaDoc.class));
42         assertTrue(itbFilter.matches(TestBean.class));
43         ClassFilter union = ClassFilters.union(exceptionFilter, itbFilter);
44         assertTrue(union.matches(RuntimeException JavaDoc.class));
45         assertTrue(union.matches(TestBean.class));
46     }
47     
48     public void testIntersection() {
49         assertTrue(exceptionFilter.matches(RuntimeException JavaDoc.class));
50         assertTrue(hasRootCauseFilter.matches(NestedRuntimeException.class));
51         ClassFilter intersection = ClassFilters.intersection(exceptionFilter, hasRootCauseFilter);
52         assertFalse(intersection.matches(RuntimeException JavaDoc.class));
53         assertFalse(intersection.matches(TestBean.class));
54         assertTrue(intersection.matches(NestedRuntimeException.class));
55     }
56
57 }
58
Popular Tags