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 
19 package org.apache.bcel;
20 
21 import org.apache.bcel.classfile.JavaClass;
22 
23 public class AnonymousClassTestCase extends AbstractTestCase
24 {
testRegularClassIsNotAnonymous()25     public void testRegularClassIsNotAnonymous() throws ClassNotFoundException
26     {
27         final JavaClass clazz = getTestClass(PACKAGE_BASE_NAME+".data.AnonymousClassTest");
28         assertFalse("regular outer classes are not anonymous", clazz
29                 .isAnonymous());
30         assertFalse("regular outer classes are not nested", clazz.isNested());
31     }
32 
testNamedInnerClassIsNotAnonymous()33     public void testNamedInnerClassIsNotAnonymous()
34             throws ClassNotFoundException
35     {
36         final JavaClass clazz = getTestClass(PACKAGE_BASE_NAME+".data.AnonymousClassTest$X");
37         assertFalse("regular inner classes are not anonymous", clazz
38                 .isAnonymous());
39         assertTrue("regular inner classes are nested", clazz.isNested());
40     }
41 
testStaticInnerClassIsNotAnonymous()42     public void testStaticInnerClassIsNotAnonymous()
43             throws ClassNotFoundException
44     {
45         final JavaClass clazz = getTestClass(PACKAGE_BASE_NAME+".data.AnonymousClassTest$Y");
46         assertFalse("regular static inner classes are not anonymous", clazz
47                 .isAnonymous());
48         assertTrue("regular static inner classes are nested", clazz.isNested());
49     }
50 
testAnonymousInnerClassIsAnonymous()51     public void testAnonymousInnerClassIsAnonymous()
52             throws ClassNotFoundException
53     {
54         final JavaClass clazz = getTestClass(PACKAGE_BASE_NAME+".data.AnonymousClassTest$1");
55         assertTrue("anonymous inner classes are anonymous", clazz.isAnonymous());
56         assertTrue("anonymous inner classes are anonymous", clazz.isNested());
57     }
58 }
59