KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > netbeans > modules > java > source > parsing > PerfResolveTest


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 package org.netbeans.modules.java.source.parsing;
21 import com.sun.source.tree.CompilationUnitTree;
22 import java.io.File JavaDoc;
23 import java.net.URL JavaDoc;
24 import junit.framework.*;
25 import org.netbeans.api.java.classpath.ClassPath;
26 import org.netbeans.modules.java.source.StopWatch;
27 import org.netbeans.modules.java.source.TestUtil;
28 import org.netbeans.spi.java.classpath.support.ClassPathSupport;
29 import org.openide.filesystems.FileUtil;
30 /** Tests for basic JDK operations
31  *
32  * @author Petr Hrebejk
33  */

34 public class PerfResolveTest extends TestCase {
35
36     private File JavaDoc workDir;
37     private File JavaDoc rtJar;
38     private ClassPath bootPath;
39     private ClassPath classPath;
40     private final String JavaDoc SOURCE =
41                 "package some;" +
42                 "import javax.swing.JTable;" +
43                 "import javax.swing.JLabel;" +
44                 "public class MemoryFile<K,V> extends JTable {" +
45                 " public java.util.Map.Entry<K,V> entry;" +
46                 " public JLabel label;" +
47                 " public JTable table = new JTable();" +
48                 " public MemoryFile() {}" +
49                 "}";
50                 
51     public PerfResolveTest(String JavaDoc testName) {
52         super(testName);
53     }
54
55     protected void setUp() throws Exception JavaDoc {
56         workDir = TestUtil.createWorkFolder();
57         TestUtil.copyFiles( workDir, TestUtil.RT_JAR, "jdk/JTable.java" );
58         rtJar = new File JavaDoc( workDir, TestUtil.RT_JAR );
59         URL JavaDoc url = FileUtil.getArchiveRoot (rtJar.toURI().toURL());
60         this.bootPath = ClassPathSupport.createClassPath (new URL JavaDoc[] {url});
61         this.classPath = ClassPathSupport.createClassPath(new URL JavaDoc[0]);
62     }
63
64     protected void tearDown() throws Exception JavaDoc {
65         TestUtil.removeWorkFolder( workDir );
66     }
67
68     /*
69     public void testExtendsJTable() throws Exception {
70         resolve( "MemoryFile.java", SOURCE );
71     }
72     */

73     
74     /*
75     public void testJTable() throws Exception {
76         String source = TestUtil.fileToString( new File( workDir, "jdk/JTable.java" ) );
77         resolve( "JTable.java", source );
78     }
79     */

80     
81     
82     public void resolve( String JavaDoc fileName, String JavaDoc source ) throws Exception JavaDoc {
83 // JavacInterface ji;
84
//
85
// StopWatch swatch = new StopWatch();
86
//
87
//
88
// for( int i = 0; i < 10; i++ ) {
89
//
90
// System.out.println("---------- (" + i + ")" );
91
//
92
// swatch.start();
93
// ji = JavacInterface.create( bootPath, classPath, null);
94
// swatch.stop( "JI create done" );
95
//
96
// swatch.start();
97
// CompilationUnitTree cu = ji.parse( FileObjects.memoryFileObject( SOURCE, "MemoryFile.java"), null );
98
// swatch.stop( "Parsing done" );
99
//
100
// swatch.start();
101
// ji.resolveElements( cu );
102
// swatch.stop( "Resolution done " );
103
// }
104

105     }
106
107 }
108
Popular Tags