KickJava   Java API By Example, From Geeks To Geeks.

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


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.Identity;
27
28 import org.openide.filesystems.FileObject;
29 import org.openide.filesystems.FileUtil;
30 //import org.openide.src.ClassElement;
31
//import org.openide.src.Identifier;
32

33
34 /** <B>Java Module Integrity API Test: Identity</B>
35  * <BR><BR><I>What it tests:</I><BR>
36  * ClassElement.forName() should return the same class, no matter how many times you call it,
37  * even if System.gc() is called between two calls of ClassElement.forName.
38  * <BR><BR><I>How it works:</I><BR>
39  * This test is only simple loop, which body has ClassElement.forName() and System.gc() calls.
40  * Result from ClassElement.forName() is logged and then compared with golden file.
41  * <BR><BR><I>Output:</I><BR>
42  * Log file produced by ClassElelemnt.forName()
43  * <BR><BR><I>Possible reasons of failure:</I><BR>
44  * <BR><BR><U>Some call of forName returns bad class (or null)</U><BR>
45  * See .diff file which one.
46  * <BR><BR><U>Exception occured:</U><BR>
47  * See .out or .diff file for StackTrace
48  *
49  * @author Jan Becicka <Jan.Becicka@sun.com>
50  * @version
51  */

52
53
54 public class Identity extends org.netbeans.test.java.LogTestCase {
55     
56     
57     public void testRun() {
58         
59         try {
60             _testIt();
61         } catch (Exception JavaDoc e) {
62             assertTrue(e.toString(), false);
63         }
64     }
65     
66     public Identity(java.lang.String JavaDoc testName) {
67         super(testName);
68     }
69     
70     public static void main(java.lang.String JavaDoc[] args) {
71         junit.textui.TestRunner.run(Identity.class);
72     }
73     
74     static int LOOPCOUNT = 10;
75     
76     public void _testIt() throws Exception JavaDoc {
77         FileObject artefact=FileUtil.toFileObject(classPathWorkDir);
78 // ClassElement ce = ClassElement.forName("org.netbeans.test.java.testsources.TopLevelClass$InnerClass", artefact);
79
// for (int i=0;i < LOOPCOUNT;i++){
80
// if (ce==ClassElement.forName("org.netbeans.test.java.testsources.TopLevelClass$InnerClass", artefact)){
81
// ref("forName returned right reference");
82
// } else {
83
// ref("forName returned wrong reference!");
84
// }
85
// System.gc();
86
// Thread.currentThread().sleep(i*500);
87
// }
88

89     }
90     
91 }
92
Popular Tags