KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > alt > jiapi > InstrumentationDescriptorTest


1 /*
2  * Copyright(C) 2002 Mika Riekkinen, Joni Suominen
3  *
4  * This library is free software; you can redistribute it and/or
5  * modify it under the terms of the GNU Lesser General Public
6  * License as published by the Free Software Foundation; either
7  * version 2.1 of the License, or(at your option) any later version.
8  *
9  * This library is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12  * Lesser General Public License for more details.
13  *
14  * You should have received a copy of the GNU Lesser General Public
15  * License along with this library; if not, write to the Free Software
16  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17  */

18
19 package alt.jiapi;
20
21 import junit.framework.TestCase;
22
23 /**
24  * A JUnit test case for Rule.
25  *
26  * @author Mika Riekkinen
27  * @author Joni Suominen
28  * @version $Revision: 1.2 $ $Date: 2004/03/29 10:10:24 $
29  */

30 public class InstrumentationDescriptorTest extends TestCase {
31     private InstrumentationDescriptor descriptor1;
32     private InstrumentationDescriptor descriptor2;
33     private InstrumentationDescriptor descriptor3;
34     private String JavaDoc className1;
35     private String JavaDoc className2;
36     private String JavaDoc className3;
37     private String JavaDoc className4;
38
39     public InstrumentationDescriptorTest(String JavaDoc name) {
40         super(name);
41     }
42
43     public String JavaDoc getName() {
44         return "InstrumentationDescriptorTest: " + super.getName();
45     }
46
47
48     protected void setUp() {
49         try {
50             descriptor1 = new InstrumentationDescriptor();
51             descriptor1.addInclusionRule("com.*");
52             descriptor1.addExclusionRule("com.example.*");
53             descriptor1.addInclusionRule("com.example.Foo");
54
55             descriptor2 = new InstrumentationDescriptor();
56             descriptor2.addExclusionRule("com.*");
57             descriptor2.addInclusionRule("com.example.*");
58             descriptor2.addExclusionRule("com.example.Foo");
59
60             descriptor3 = new InstrumentationDescriptor();
61             descriptor3.addInclusionRule("com.example.Foo");
62             descriptor3.addExclusionRule("com.example.Foo");
63
64             className1 = "com.foobar.Foo";
65             className2 = "com.example.Bar";
66             className3 = "com.example.bar.Bar";
67             className4 = "com.example.Foo";
68         } catch (Exception JavaDoc e) {
69             e.printStackTrace();
70         }
71     }
72
73     public void testMatch() {
74         assertTrue(descriptor1.match(className1));
75         assertTrue(!descriptor1.match(className2));
76         assertTrue(!descriptor1.match(className3));
77         assertTrue(descriptor1.match(className4));
78
79         assertTrue(!descriptor2.match(className1));
80         assertTrue(descriptor2.match(className2));
81         assertTrue(descriptor2.match(className3));
82         assertTrue(!descriptor2.match(className4));
83
84         assertTrue(!descriptor3.match(className1));
85     }
86 }
87
Popular Tags