1 19 package org.netbeans.jmi.javamodel.getters; 20 21 import junit.textui.TestRunner; 22 import org.netbeans.jmi.javamodel.*; 23 import org.netbeans.jmi.javamodel.codegen.Utility; 24 import org.netbeans.junit.NbTestCase; 25 import org.netbeans.junit.NbTestSuite; 26 import org.netbeans.modules.javacore.ClassIndex; 27 28 38 public class JavaClassCreationTest extends NbTestCase { 39 40 JavaClass clazz; 41 JavaModelPackage pkg; 42 43 44 public JavaClassCreationTest() { 45 super("JavaClassCreationTest"); 46 } 47 48 public static NbTestSuite suite() { 49 NbTestSuite suite = new NbTestSuite(JavaClassCreationTest.class); 50 return suite; 51 } 52 53 protected void setUp() { 54 clazz = (JavaClass) Utility.findClass("examples.colorpicker.ColorPicker"); 55 pkg = (JavaModelPackage) clazz.refImmediatePackage(); 56 } 57 58 62 public void testJavaClassCreation() { 63 boolean fail = true; 64 Utility.beginTrans(true); 65 try { 66 clazz = pkg.getJavaClass().createJavaClass(); 67 clazz.setName("SetTheNameOnClassWhichHadNotNameYet"); 68 fail = false; 69 } 70 finally { 71 Utility.endTrans(fail); 72 } 73 } 74 75 79 public void testLookForCreatedClassInIndex() { 80 ClassIndex index = ClassIndex.getIndex(pkg); 81 clazz = index.getClassByFqn("SetTheNameOnClassWhichHadNotNameYet"); 82 assertNotNull(clazz); 83 } 84 85 88 public static void main(String [] args) { 89 TestRunner.run(suite()); 90 } 91 92 } 93 | Popular Tags |