|
What this is
Other links
The source code/* * Sun Public License Notice * * The contents of this file are subject to the Sun Public License * Version 1.0 (the "License"). You may not use this file except in * compliance with the License. A copy of the License is available at * http://www.sun.com/ * * The Original Code is NetBeans. The Initial Developer of the Original * Code is Sun Microsystems, Inc. Portions Copyright 1997-2004 Sun * Microsystems, Inc. All Rights Reserved. */ package org.netbeans.jmi.javamodel.getters; import junit.textui.TestRunner; import org.netbeans.jmi.javamodel.*; import org.netbeans.jmi.javamodel.codegen.Utility; import org.netbeans.junit.NbTestCase; import org.netbeans.junit.NbTestSuite; import org.netbeans.modules.javacore.ClassIndex; /** * Test for javaClass creation with creaJavaClass() method without parameters. * It is connected also with classIndex, where the class should be added. * * todo (#pf): We still need to solve situation, when class is not added to * resource. Such a class is never removed from the index. There is no guarantee * that jmi user adds it. * * @author Pavel Flaska */ public class JavaClassCreationTest extends NbTestCase { JavaClass clazz; JavaModelPackage pkg; /** Creates a new instance of JavaClassCreationTest */ public JavaClassCreationTest() { super("JavaClassCreationTest"); } public static NbTestSuite suite() { NbTestSuite suite = new NbTestSuite(JavaClassCreationTest.class); return suite; } protected void setUp() { clazz = (JavaClass) Utility.findClass("examples.colorpicker.ColorPicker"); pkg = (JavaModelPackage) clazz.refImmediatePackage(); } /** * Create javaClass model element. Use proxy method createJavaClass() * without parameters. */ public void testJavaClassCreation() { boolean fail = true; Utility.beginTrans(true); try { clazz = pkg.getJavaClass().createJavaClass(); clazz.setName("SetTheNameOnClassWhichHadNotNameYet"); fail = false; } finally { Utility.endTrans(fail); } } /** * Look for class created in previous test. If such a class is not in index, * something is wrong. */ public void testLookForCreatedClassInIndex() { ClassIndex index = ClassIndex.getIndex(pkg); clazz = index.getClassByFqn("SetTheNameOnClassWhichHadNotNameYet"); assertNotNull(clazz); } /** * @param args the command line arguments */ public static void main(String[] args) { TestRunner.run(suite()); } } |
... this post is sponsored by my books ... | |
#1 New Release! |
FP Best Seller |
Copyright 1998-2021 Alvin Alexander, alvinalexander.com
All Rights Reserved.
A percentage of advertising revenue from
pages under the /java/jwarehouse
URI on this website is
paid back to open source projects.