View Javadoc
1   /*
2    * Licensed to the Apache Software Foundation (ASF) under one or more
3    * contributor license agreements.  See the NOTICE file distributed with
4    * this work for additional information regarding copyright ownership.
5    * The ASF licenses this file to You under the Apache License, Version 2.0
6    * (the "License"); you may not use this file except in compliance with
7    * the License.  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.apache.bcel;
19  
20  import static org.junit.jupiter.api.Assertions.assertEquals;
21  
22  import org.apache.bcel.classfile.JavaClass;
23  import org.junit.jupiter.api.Test;
24  
25  public class CounterVisitorTestCase extends AbstractCounterVisitorTestCase {
26      @Override
27      protected JavaClass getTestClass() throws ClassNotFoundException {
28          return getTestJavaClass(PACKAGE_BASE_NAME + ".data.MarkedType");
29      }
30  
31      @Test
32      public void testAnnotationDefaultCount() {
33          assertEquals(0, getVisitor().annotationDefaultCount, "annotationDefaultCount");
34      }
35  
36      @Test
37      public void testAnnotationEntryCount() {
38          assertEquals(2, getVisitor().annotationEntryCount, "annotationEntryCount");
39      }
40  
41      @Test
42      public void testAnnotationsCount() {
43          assertEquals(2, getVisitor().annotationCount, "annotationCount");
44      }
45  
46      @Test
47      public void testCodeCount() {
48          assertEquals(1, getVisitor().codeCount, "codeCount");
49      }
50  
51      @Test
52      public void testCodeExceptionCount() {
53          assertEquals(0, getVisitor().codeExceptionCount, "codeExceptionCount");
54      }
55  
56      @Test
57      public void testConstantClassCount() {
58          assertEquals(2, getVisitor().constantClassCount, "constantClassCount");
59      }
60  
61      @Test
62      public void testConstantDoubleCount() {
63          assertEquals(0, getVisitor().constantDoubleCount, "constantDoubleCount");
64      }
65  
66      @Test
67      public void testConstantFieldrefCount() {
68          assertEquals(0, getVisitor().constantFieldrefCount, "constantFieldrefCount");
69      }
70  
71      @Test
72      public void testConstantFloatCount() {
73          assertEquals(0, getVisitor().constantFloatCount, "constantFloatCount");
74      }
75  
76      @Test
77      public void testConstantIntegerCount() {
78          assertEquals(0, getVisitor().constantIntegerCount, "constantIntegerCount");
79      }
80  
81      @Test
82      public void testConstantInterfaceMethodrefCount() {
83          assertEquals(0, getVisitor().constantInterfaceMethodrefCount, "constantInterfaceMethodrefCount");
84      }
85  
86      @Test
87      public void testConstantLongCount() {
88          assertEquals(0, getVisitor().constantLongCount, "constantLongCount");
89      }
90  
91      @Test
92      public void testConstantMethodrefCount() {
93          assertEquals(1, getVisitor().constantMethodrefCount, "constantMethodrefCount");
94      }
95  
96      @Test
97      public void testConstantNameAndTypeCount() {
98          assertEquals(1, getVisitor().constantNameAndTypeCount, "constantNameAndTypeCount");
99      }
100 
101     @Test
102     public void testConstantPoolCount() {
103         assertEquals(1, getVisitor().constantPoolCount, "constantPoolCount");
104     }
105 
106     @Test
107     public void testConstantStringCount() {
108         assertEquals(0, getVisitor().constantStringCount, "constantStringCount");
109     }
110 
111     @Test
112     public void testConstantValueCount() {
113         assertEquals(0, getVisitor().constantValueCount, "constantValueCount");
114     }
115 
116     @Test
117     public void testDeprecatedCount() {
118         assertEquals(0, getVisitor().deprecatedCount, "deprecatedCount");
119     }
120 
121     @Test
122     public void testEnclosingMethodCount() {
123         assertEquals(0, getVisitor().enclosingMethodCount, "enclosingMethodCount");
124     }
125 
126     @Test
127     public void testExceptionTableCount() {
128         assertEquals(0, getVisitor().exceptionTableCount, "exceptionTableCount");
129     }
130 
131     @Test
132     public void testFieldCount() {
133         assertEquals(0, getVisitor().fieldCount, "fieldCount");
134     }
135 
136     @Test
137     public void testInnerClassCount() {
138         assertEquals(0, getVisitor().innerClassCount, "innerClassCount");
139     }
140 
141     @Test
142     public void testInnerClassesCount() {
143         assertEquals(0, getVisitor().innerClassesCount, "innerClassesCount");
144     }
145 
146     @Test
147     public void testJavaClassCount() {
148         assertEquals(1, getVisitor().javaClassCount, "javaClassCount");
149     }
150 
151     @Test
152     public void testLineNumberCount() {
153         assertEquals(1, getVisitor().lineNumberCount, "lineNumberCount");
154     }
155 
156     @Test
157     public void testLineNumberTableCount() {
158         assertEquals(1, getVisitor().lineNumberTableCount, "lineNumberTableCount");
159     }
160 
161     @Test
162     public void testLocalVariableCount() {
163         assertEquals(1, getVisitor().localVariableCount, "localVariableCount");
164     }
165 
166     @Test
167     public void testLocalVariableTableCount() {
168         assertEquals(1, getVisitor().localVariableTableCount, "localVariableTableCount");
169     }
170 
171     @Test
172     public void testLocalVariableTypeTableCount() {
173         assertEquals(0, getVisitor().localVariableTypeTableCount, "localVariableTypeTableCount");
174     }
175 
176     @Test
177     public void testMethodCount() {
178         assertEquals(1, getVisitor().methodCount, "methodCount");
179     }
180 
181     @Test
182     public void testParameterAnnotationCount() {
183         assertEquals(0, getVisitor().parameterAnnotationCount, "parameterAnnotationCount");
184     }
185 
186     @Test
187     public void testSignatureCount() {
188         assertEquals(0, getVisitor().signatureAnnotationCount, "signatureAnnotationCount");
189     }
190 
191     @Test
192     public void testSourceFileCount() {
193         assertEquals(1, getVisitor().sourceFileCount, "sourceFileCount");
194     }
195 
196     @Test
197     public void testStackMapCount() {
198         assertEquals(0, getVisitor().stackMapCount, "stackMapCount");
199     }
200 
201     @Test
202     public void testStackMapEntryCount() {
203         assertEquals(0, getVisitor().stackMapEntryCount, "stackMapEntryCount");
204     }
205 
206     @Test
207     public void testStackMapTypeCount() {
208         assertEquals(0, getVisitor().stackMapTypeCount, "stackMapTypeCount");
209     }
210 
211     @Test
212     public void testSyntheticCount() {
213         assertEquals(0, getVisitor().syntheticCount, "syntheticCount");
214     }
215 
216     @Test
217     public void testUnknownCount() {
218         assertEquals(0, getVisitor().unknownCount, "unknownCount");
219     }
220 }