1 19 package org.netbeans.jmi.javamodel.codegen; 20 21 import java.util.List ; 22 import junit.textui.TestRunner; 23 import org.netbeans.jmi.javamodel.*; 24 import org.netbeans.junit.NbTestCase; 25 import org.netbeans.junit.NbTestSuite; 26 import org.openide.filesystems.FileStateInvalidException; 27 28 34 public class FieldTest3 extends NbTestCase { 35 36 37 public FieldTest3() { 38 super("FieldTest3"); 39 } 40 41 public static NbTestSuite suite() { 42 NbTestSuite suite = new NbTestSuite(FieldTest3.class); 43 return suite; 44 } 45 46 JavaClass clazz; 47 JavaModelPackage pkg; 48 49 protected void setUp() { 50 clazz = Utility.findClass("org.netbeans.test.codegen.FieldTest3"); 51 pkg = (JavaModelPackage) clazz.refImmediatePackage(); 52 } 53 54 57 public void testGroupInitValues() throws java.io.IOException , FileStateInvalidException { 58 boolean fail = true; 59 Utility.beginTrans(true); 60 try { 61 FieldGroup group = (FieldGroup) clazz.getContents().get(2); 62 List fields = group.getFields(); 63 ((Field) fields.get(0)).setInitialValueText("\"prvni\""); 64 ((Field) fields.get(2)).setInitialValueText("\"treti\""); 65 fail = false; 66 } finally { 67 Utility.endTrans(fail); 68 } 69 assertFile("File is not correctly generated.", 70 Utility.getFile(getDataDir(), "org/netbeans/test/codegen/FieldTest3.java"), 71 getGoldenFile("testGroupInitValues_FieldTest3.pass"), 72 getWorkDir() 73 ); 74 } 75 76 79 public void testGroupSeparation() throws java.io.IOException , FileStateInvalidException { 80 boolean fail = true; 81 Utility.beginTrans(true); 82 try { 83 Field second = (Field) clazz.getFeatures().remove(3); 84 Field third = (Field) clazz.getFeatures().remove(3); 85 clazz.getFeatures().add(second); 86 clazz.getFeatures().add(third); 87 fail = false; 88 } finally { 89 Utility.endTrans(fail); 90 } 91 assertFile("File is not correctly generated.", 92 Utility.getFile(getDataDir(), "org/netbeans/test/codegen/FieldTest3.java"), 93 getGoldenFile("testGroupSeparation_FieldTest3.pass"), 94 getWorkDir() 95 ); 96 } 97 98 101 public static void main(String [] args) { 102 TestRunner.run(suite()); 103 } 104 105 } 106 | Popular Tags |