01: /*
02: * Licensed to the Apache Software Foundation (ASF) under one or more
03: * contributor license agreements. See the NOTICE file distributed with
04: * this work for additional information regarding copyright ownership.
05: * The ASF licenses this file to You under the Apache License, Version 2.0
06: * (the "License"); you may not use this file except in compliance with
07: * the License. You may obtain a copy of the License at
08: *
09: * 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: * tested class: java.lang.Class
20: * tested method: GetClasses
21: *
22: * @author Evgueni V. Brevnov
23: * @version $Revision$
24: */package java.lang;
25:
26: import junit.framework.TestCase;
27:
28: /**
29: * @tested class: java.lang.Class
30: * @tested method: getClasses
31: */
32: public class ClassTestGetClasses extends TestCase {
33:
34: /**
35: * java.lang.Class class does not declare any public inner class.
36: *
37: */
38: public void test1() {
39: Class[] classes = Class.class.getClasses();
40: assertNotNull("Unexpected null", classes);
41: assertEquals("array length:", 0, classes.length);
42: }
43:
44: /**
45: * Only public inner class must be returned.
46: *
47: */
48: public void test2() {
49: Class[] classes = ClassTestGetClasses.class.getClasses();
50: assertNotNull("Unexpected null", classes);
51: assertEquals("There must be one class in the list", 1,
52: classes.length);
53: assertSame("Objects differ", Helper1.class, classes[0]);
54: }
55:
56: public class Helper1 {
57: public class Inner {
58: }
59: }
60:
61: protected class Helper2 {
62: }
63:
64: class Helper3 {
65: }
66: }
|