KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > netbeans > test > java > integrity > GetClass


1 /*
2  * The contents of this file are subject to the terms of the Common Development
3  * and Distribution License (the License). You may not use this file except in
4  * compliance with the License.
5  *
6  * You can obtain a copy of the License at http://www.netbeans.org/cddl.html
7  * or http://www.netbeans.org/cddl.txt.
8  *
9  * When distributing Covered Code, include this CDDL Header Notice in each file
10  * and include the License file at http://www.netbeans.org/cddl.txt.
11  * If applicable, add the following below the CDDL Header, with the fields
12  * enclosed by brackets [] replaced by your own identifying information:
13  * "Portions Copyrighted [year] [name of copyright owner]"
14  *
15  * The Original Software is NetBeans. The Initial Developer of the Original
16  * Software is Sun Microsystems, Inc. Portions Copyright 1997-2006 Sun
17  * Microsystems, Inc. All Rights Reserved.
18  */

19
20 /*
21  * ForName.java
22  *
23  * Created on September 19, 2000, 1:39 PM
24  */

25
26 package org.netbeans.test.java.integrity.GetClass;
27
28 import org.openide.filesystems.FileUtil;
29 //import org.openide.src.ClassElement;
30
//import org.openide.src.Identifier;
31

32
33 /** <B>Java Module Integrity API Test: GetClass</B>
34  * <BR><BR><I>What it tests:</I><BR>
35  * Capability of module to find class (inner or outer) in .java file.
36  * <BR><BR><I>What has to be set:</I><BR>
37  * testbase/testfs has to be mounted.
38  * <BR><BR><I>How it works:</I><BR>
39  * Test tries to find known classes using ClassElement.getClass() and SourceElement.getClass();
40  * <BR><BR><I>Output:</I><BR>
41  * Places, where were known classes found. This is compared with golden file.
42  * <BR><BR><I>Possible reasons of failure:</I><BR>
43  * <BR><BR><U>Some classes were not found</U><BR>
44  * See .diff file which ones.
45  * <BR><BR><U>Exception occured:</U><BR>
46  * See .out or .diff file for StackTrace
47  *
48  * @author Jan Becicka <Jan.Becicka@sun.com>
49  * @version
50  */

51
52
53 public class GetClass extends org.netbeans.test.java.LogTestCase {
54     
55     
56     public void testRun() {
57         
58         try {
59             _testIt();
60         } catch (Exception JavaDoc e) {
61             assertTrue(e.toString(), false);
62         }
63     }
64     
65     public GetClass(java.lang.String JavaDoc testName) {
66         super(testName);
67     }
68     
69     public static void main(java.lang.String JavaDoc[] args) {
70         junit.textui.TestRunner.run(GetClass.class);
71     }
72     
73     public void _testIt() throws Exception JavaDoc {
74         
75         
76 // ClassElement ce = ClassElement.forName("org.netbeans.test.java.testsources.GetClassTest", FileUtil.toFileObject(classPathWorkDir));
77
// org.openide.src.SourceElement se = ce.getSource();
78
//
79
// ClassElement ce1, ce2;
80
//
81
// //SN
82
// ce1 = se.getClass(Identifier.create("GetClassTest"));
83
// ce2 = ce1.getClass(Identifier.create("InnerClass2"));
84
// if (ce1==null){
85
// ref("null: GetClassTest not found!");
86
// } else {
87
// ref(ce1.getName().getFullName());
88
// }
89
// if (ce2==null){
90
// ref("null: NewClass2 not found!");
91
// } else {
92
// ref(ce2.getName().getFullName());
93
// }
94
//
95
//
96
// //FQN
97
// ce1 = se.getClass(Identifier.create("org.netbeans.test.java.testsources.NewClass3","NewClass3"));
98
// ce2 = ce1.getClass(Identifier.create("org.netbeans.test.java.testsources.NewClass3.InnerClass1","InnerClass1"));
99
// if (ce1 == null){
100
// ref("null: GetClassTest not found!");
101
// } else {
102
// ref(ce1.getName().getFullName());
103
// }
104
// if (ce2==null){
105
// ref("null: NewClass3 not found!");
106
// } else {
107
// ref(ce2.getName().getFullName());
108
// }
109
//
110
// //FQN is bad! => should return null
111
// ce1 = se.getClass(Identifier.create("org.netbeans.test.java.testsources.GetClssTest","GetClassTest"));
112
// ce2 = ce.getClass(Identifier.create("org.netbeans.test.java.testsources.GetClssTest.InnerClass1","InnerClass1"));
113
//
114
// if (ce1 == null){
115
// ref("null - OK");
116
// } else {
117
// ref("Not null! but should be null!");
118
// }
119
// if (ce2==null){
120
// ref("null - OK");
121
// } else {
122
// ref("Not null! but should be null!");
123
// }
124
}
125     
126 }
127
Popular Tags