KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > jeantessier > classreader > TestLoadListenerVisitorAdapter


1 /*
2  * Copyright (c) 2001-2005, Jean Tessier
3  * All rights reserved.
4  *
5  * Redistribution and use in source and binary forms, with or without
6  * modification, are permitted provided that the following conditions
7  * are met:
8  *
9  * * Redistributions of source code must retain the above copyright
10  * notice, this list of conditions and the following disclaimer.
11  *
12  * * Redistributions in binary form must reproduce the above copyright
13  * notice, this list of conditions and the following disclaimer in the
14  * documentation and/or other materials provided with the distribution.
15  *
16  * * Neither the name of Jean Tessier nor the names of his contributors
17  * may be used to endorse or promote products derived from this software
18  * without specific prior written permission.
19  *
20  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
21  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
22  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
23  * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR
24  * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
25  * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
26  * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
27  * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
28  * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
29  * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
30  * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
31  */

32
33 package com.jeantessier.classreader;
34
35 import java.io.*;
36 import java.util.*;
37
38 import junit.framework.*;
39
40 public class TestLoadListenerVisitorAdapter extends TestCase implements Visitor {
41     public static final String JavaDoc TEST_DIR = "tests" + File.separator + "JarJarDiff";
42     public static final String JavaDoc TEST_CLASS = "test";
43     public static final String JavaDoc TEST_FILENAME = "classes" + File.separator + "test.class";
44
45     private LinkedList classfiles;
46
47     private ClassfileLoader loader;
48     private LoadListenerVisitorAdapter adapter;
49
50     protected void setUp() throws Exception JavaDoc {
51         classfiles = new LinkedList();
52
53         adapter = new LoadListenerVisitorAdapter(this);
54         loader = new AggregatingClassfileLoader();
55         loader.addLoadListener(adapter);
56     }
57
58     public void testOneFile() {
59         loader.load(TEST_FILENAME);
60
61         assertEquals("First class", TEST_CLASS, ((Classfile) classfiles.getFirst()).getClassName());
62         assertEquals("Nb visited classes", 1, classfiles.size());
63     }
64
65     public void testManyFiles() {
66         loader.load(TEST_DIR);
67
68         assertEquals("Nb visited classes", 136, classfiles.size());
69     }
70
71     public void visitClassfiles(Collection classfiles) {
72         this.classfiles.addAll(classfiles);
73     }
74     
75     public void visitClassfile(Classfile classfile) {
76         classfiles.add(classfile);
77     }
78
79     public void visitConstantPool(ConstantPool constantPool) {
80         // Do nothing
81
}
82     
83     public void visitClass_info(Class_info entry) {
84         // Do nothing
85
}
86     
87     public void visitFieldRef_info(FieldRef_info entry) {
88         // Do nothing
89
}
90     
91     public void visitMethodRef_info(MethodRef_info entry) {
92         // Do nothing
93
}
94     
95     public void visitInterfaceMethodRef_info(InterfaceMethodRef_info entry) {
96         // Do nothing
97
}
98     
99     public void visitString_info(String_info entry) {
100         // Do nothing
101
}
102     
103     public void visitInteger_info(Integer_info entry) {
104         // Do nothing
105
}
106     
107     public void visitFloat_info(Float_info entry) {
108         // Do nothing
109
}
110     
111     public void visitLong_info(Long_info entry) {
112         // Do nothing
113
}
114     
115     public void visitDouble_info(Double_info entry) {
116         // Do nothing
117
}
118     
119     public void visitNameAndType_info(NameAndType_info entry) {
120         // Do nothing
121
}
122     
123     public void visitUTF8_info(UTF8_info entry) {
124         // Do nothing
125
}
126     
127     public void visitField_info(Field_info entry) {
128         // Do nothing
129
}
130     
131     public void visitMethod_info(Method_info entry) {
132         // Do nothing
133
}
134     
135     public void visitConstantValue_attribute(ConstantValue_attribute attribute) {
136         // Do nothing
137
}
138     
139     public void visitCode_attribute(Code_attribute attribute) {
140         // Do nothing
141
}
142     
143     public void visitExceptions_attribute(Exceptions_attribute attribute) {
144         // Do nothing
145
}
146     
147     public void visitInnerClasses_attribute(InnerClasses_attribute attribute) {
148         // Do nothing
149
}
150     
151     public void visitSynthetic_attribute(Synthetic_attribute attribute) {
152         // Do nothing
153
}
154     
155     public void visitSourceFile_attribute(SourceFile_attribute attribute) {
156         // Do nothing
157
}
158     
159     public void visitLineNumberTable_attribute(LineNumberTable_attribute attribute) {
160         // Do nothing
161
}
162     
163     public void visitLocalVariableTable_attribute(LocalVariableTable_attribute attribute) {
164         // Do nothing
165
}
166     
167     public void visitDeprecated_attribute(Deprecated_attribute attribute) {
168         // Do nothing
169
}
170     
171     public void visitCustom_attribute(Custom_attribute attribute) {
172         // Do nothing
173
}
174     
175     public void visitExceptionHandler(ExceptionHandler helper) {
176         // Do nothing
177
}
178     
179     public void visitInnerClass(InnerClass helper) {
180         // Do nothing
181
}
182     
183     public void visitLineNumber(LineNumber helper) {
184         // Do nothing
185
}
186     
187     public void visitLocalVariable(LocalVariable helper) {
188         // Do nothing
189
}
190     
191 }
192
Popular Tags