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: * @author Evgueni V. Brevnov, Roman S. Bushmanov
20: * @version $Revision$
21: */package java.lang;
22:
23: import java.io.Serializable;
24: import java.security.Permission;
25:
26: import junit.framework.TestCase;
27:
28: /**
29: * tested class: java.lang.Class
30: * tested method: toString
31: */
32: public class ClassTestToString extends TestCase {
33:
34: /**
35: * only the class name should be returned in the case of primitive type.
36: */
37: public void test1() {
38: assertEquals(void.class.toString(), void.class.toString());
39: }
40:
41: /**
42: * The string "interface" should be followed by the class name if this class
43: * represents an interface.
44: */
45: public void test2() {
46: assertEquals("interface " + Cloneable.class.getName(),
47: Cloneable.class.toString());
48: }
49:
50: /**
51: * The string "class" should be followed by the class name
52: * if this is a class.
53: */
54: public void test3() {
55: assertEquals("class " + Class.class.getName(), Class.class
56: .toString());
57: }
58:
59: /**
60: * The string "class" should be followed by the class name
61: * if this is a class.
62: */
63: public void test4() {
64: Serializable[] c = new Permission[0];
65: assertEquals("class " + c.getClass().getName(), c.getClass()
66: .toString());
67: }
68: }
|