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.Constructor; 24 import org.netbeans.jmi.javamodel.JavaClass; 25 import org.netbeans.jmi.javamodel.JavaModelPackage; 26 import org.netbeans.jmi.javamodel.MultipartId; 27 import org.netbeans.jmi.javamodel.Parameter; 28 import org.netbeans.junit.NbTestCase; 29 import org.netbeans.junit.NbTestSuite; 30 import org.openide.filesystems.FileStateInvalidException; 31 32 36 public class ParDimCountTest extends NbTestCase { 37 38 JavaClass clazz; 39 JavaModelPackage pkg; 40 List parameters; 41 42 43 public ParDimCountTest() { 44 super("ParDimCountTest"); 45 } 46 47 public static NbTestSuite suite() { 48 NbTestSuite suite = new NbTestSuite(ParDimCountTest.class); 49 return suite; 50 } 51 52 protected void setUp() { 53 clazz = (JavaClass) Utility.findClass("org.netbeans.test.codegen.ParDimCount"); 54 pkg = (JavaModelPackage) clazz.refImmediatePackage(); 55 parameters = ((Constructor) clazz.getContents().get(0)).getParameters(); 56 } 57 58 public void testParDim1To2() throws java.io.IOException , FileStateInvalidException { 59 boolean fail = true; 60 Utility.beginTrans(true); 61 try { 62 ((Parameter) parameters.get(0)).setDimCount(2); 63 fail = false; 64 } 65 finally { 66 Utility.endTrans(fail); 67 } 68 assertFile("File is not correctly generated.", 69 Utility.getFile(getDataDir(), "org/netbeans/test/codegen/ParDimCount.java"), 70 getGoldenFile("testParDim1To2_ParDimCountTest.pass"), 71 getWorkDir() 72 ); 73 } 74 75 public void testParDim1To0() throws java.io.IOException , FileStateInvalidException { 76 boolean fail = true; 77 Utility.beginTrans(true); 78 try { 79 ((Parameter) parameters.get(1)).setDimCount(0); 80 fail = false; 81 } 82 finally { 83 Utility.endTrans(fail); 84 } 85 assertFile("File is not correctly generated.", 86 Utility.getFile(getDataDir(), "org/netbeans/test/codegen/ParDimCount.java"), 87 getGoldenFile("testParDim1To0_ParDimCountTest.pass"), 88 getWorkDir() 89 ); 90 } 91 92 public void testCreateDimPar() throws java.io.IOException , FileStateInvalidException { 93 boolean fail = true; 94 Utility.beginTrans(true); 95 try { 96 MultipartId id = pkg.getMultipartId().createMultipartId("java.util.List", null, null); 97 parameters.add(pkg.getParameter().createParameter("l", null, false, id, 2, false)); 98 fail = false; 99 } 100 finally { 101 Utility.endTrans(fail); 102 } 103 assertFile("File is not correctly generated.", 104 Utility.getFile(getDataDir(), "org/netbeans/test/codegen/ParDimCount.java"), 105 getGoldenFile("testCreateDimPar_ParDimCountTest.pass"), 106 getWorkDir() 107 ); 108 } 109 110 113 public static void main(String [] args) { 114 TestRunner.run(suite()); 115 } 116 117 } 118 | Popular Tags |