KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > netbeans > api > java > source > gen > FieldTest2


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 package org.netbeans.api.java.source.gen;
20
21 import com.sun.source.tree.VariableTree;
22 import java.io.IOException JavaDoc;
23 import junit.textui.TestRunner;
24 import org.netbeans.api.java.source.transform.Transformer;
25 import org.netbeans.junit.NbTestSuite;
26
27 /**
28  *
29  * @author Pavel Flaska
30  */

31 public class FieldTest2 extends GeneratorTest {
32
33     /** Creates a new instance of FieldTest2 */
34     public FieldTest2(String JavaDoc name) {
35         super(name);
36     }
37
38     public static NbTestSuite suite() {
39         NbTestSuite suite = new NbTestSuite(FieldTest2.class);
40         return suite;
41     }
42     
43     protected void setUp() throws Exception JavaDoc {
44         super.setUp();
45         testFile = getFile(getSourceDir(), getSourcePckg() + "FieldTest2.java");
46     }
47
48     /**
49      * Test move field from field group to the single field declaration.
50      */

51     public void testMoveField() throws IOException JavaDoc {
52         System.err.println("testMoveField");
53         process(
54             new Transformer<Void JavaDoc, Object JavaDoc>() {
55                 public Void JavaDoc visitVariable(VariableTree node, Object JavaDoc p) {
56                     if ("nerudova".contentEquals(node.getName())) {
57                         System.err.println(node);
58                     }
59                     /*
60                 Field nerudova = null;
61                 for (Iterator fIt = clazz.getContents().iterator(); fIt.hasNext(); ) {
62                     Object feature = fIt.next();
63                     if (feature instanceof FieldGroup) {
64                         FieldGroup group = (FieldGroup) feature;
65                         nerudova = (Field) group.getFields().remove(2);
66                         nerudova.setTypeName((TypeReference) ((TypeReferenceImpl) group.getTypeName()).duplicate());
67                         nerudova.setModifiers(Modifier.PRIVATE);
68                     }
69                 }
70                 clazz.getFeatures().add(nerudova);*/

71                     return null;
72                 }
73             }
74         );
75         assertFiles("FieldTest2.pass");
76     }
77     
78     /**
79      * @param args the command line arguments
80      */

81     public static void main(String JavaDoc[] args) {
82         TestRunner.run(suite());
83     }
84     
85     String JavaDoc getSourcePckg() {
86         return "org/netbeans/test/codegen/";
87     }
88
89     String JavaDoc getGoldenPckg() {
90         return "org/netbeans/jmi/javamodel/codegen/FieldTest2/";
91     }
92 }
93
Popular Tags