KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > netbeans > jmi > javamodel > codegen > Positions > InterfacePositionsTest


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.jmi.javamodel.codegen.Positions;
20
21 import java.lang.reflect.Modifier JavaDoc;
22 import java.util.Iterator JavaDoc;
23 import java.util.List JavaDoc;
24 import org.netbeans.jmi.javamodel.*;
25 import org.netbeans.junit.NbTestSuite;
26 import junit.textui.TestRunner;
27 import org.netbeans.jmi.javamodel.Parameter;
28 import org.netbeans.jmi.javamodel.Type;
29 import org.netbeans.jmi.javamodel.codegen.CodegenTestCase;
30 import org.netbeans.jmi.javamodel.codegen.Utility;
31
32 /**
33  * Tests the method generator.
34  *
35  * @author Pavel Flaska
36  */

37 public class InterfacePositionsTest extends CodegenTestCase {
38     
39     /** Need to be defined because of JUnit */
40     public InterfacePositionsTest(String JavaDoc name) {
41         super(name, "InterfacePositionsTest");
42     }
43     
44     public static NbTestSuite suite() {
45         NbTestSuite suite = new NbTestSuite(InterfacePositionsTest.class);
46         return suite;
47     }
48     
49     JavaClass clazz;
50     JavaModelPackage pkg;
51     String JavaDoc sourceText;
52     
53     protected void setUp() {
54         clazz = Utility.findClass("org.netbeans.test.codegen.InterfacePositionTest");
55         pkg = (JavaModelPackage) clazz.refImmediatePackage();
56         sourceText = clazz.getResource().getSourceText();
57     }
58
59     public void testName() {
60         Utility.beginTrans(false);
61         try {
62             int nameSO = clazz.getPartStartOffset(ElementPartKindEnum.NAME);
63             int nameEO = clazz.getPartEndOffset(ElementPartKindEnum.NAME);
64             assertEquals("Interface name does not match.", "InterfacePositionTest", sourceText.substring(nameSO, nameEO));
65         }
66         finally {
67             Utility.endTrans();
68         }
69     }
70
71     /**
72      * @param args the command line arguments
73      */

74     public static void main(String JavaDoc[] args) {
75         TestRunner.run(suite());
76     }
77 }
78
Popular Tags