1 19 20 25 26 package DataLoaderTests.DataObjectTest; 27 28 import org.openide.filesystems.Repository; 29 30 31 36 public class DataObjectTestsGenerator { 37 38 39 public DataObjectTestsGenerator() { 40 } 41 42 45 public static void main(String args[]) { 46 org.openide.filesystems.FileObject fo = Repository.getDefault() 47 .findResource(PACKAGE + "/" + DATAOBJECTS + "/" + "Backup"); 48 49 org.openide.loaders.DataFolder df = null; 50 try{ 51 if ( fo.isFolder() ) { 52 df = (org.openide.loaders.DataFolder) org.openide.loaders.DataFolder.find(fo); 53 org.openide.loaders.DataObject[] dobs = df.getChildren(); 55 56 60 for (int j = 0 ; j < CAT.length; j++) { 61 for (int i = 0 ; i < dobs.length ; i++) { 62 String name = dobs[i].getPrimaryFile().getName(); 64 String ext = dobs[i].getPrimaryFile().getExt(); 65 66 java.io.File d = new java.io.File (ROOT + "/" + CAT[j] + "/" + name + "/"); 67 d.mkdirs(); 68 69 java.io.File f = new java.io.File (ROOT + "/" + CAT[j] + "/" + name + "/" + name + "_" + CAT[j] + ".java"); 70 f.createNewFile(); 71 72 75 String clazz = 76 s1 + CAT[j] + "." +name + ";\n" + 77 s2 + name + "_" + CAT[j] + 78 s3 + CAT[j] + "{\n" + 79 s4 + name + "_" + CAT[j] + s4_1 + 80 s5 + name + "." + ext + 81 s6 + name + "_" + CAT[j] + 82 s7; 83 84 java.io.PrintWriter pv = new java.io.PrintWriter (new java.io.FileOutputStream (f)); 85 pv.print(clazz); 86 pv.flush(); 87 pv.close(); 88 89 94 } 96 } 97 } else { 100 System.out.println("Expecting 'DataObjects' folder in this package!"); 101 } 102 }catch(Exception ex){ 103 ex.printStackTrace(); 104 } 105 } 106 107 final static String PACKAGE = new DataObjectTestsGenerator().getClass().getPackage().getName().replace('.','/'); 108 109 final static String ROOT = org.openide.filesystems.FileUtil.toFile( 110 Repository.getDefault().findResource(PACKAGE)).getAbsolutePath(); 111 112 final static String DATAOBJECTS = "data"; 113 final static String MANIPULATION = "manipulation"; 114 final static String MODIFY = "modify"; 115 final static String VALIDITY = "validity"; 116 final static String DELEGATE = "delegate"; 117 final static String OTHERS = "others"; 118 119 final static String [] CAT = new String []{MANIPULATION,MODIFY,VALIDITY,DELEGATE,OTHERS}; 120 121 final static String s1 = "package DataLoaderTests.DataObjectTest."; 122 final static String s2 = "import junit.framework.*;\nimport org.netbeans.junit.*;\npublic class "; 123 final static String s3 = " extends DataLoaderTests.DataObjectTest.DataObjectTest_"; 124 final static String s4 = " public "; 125 final static String s4_1 = "(java.lang.String testName){\n super(testName);\n"; 126 final static String s5 = " NAME = \"/" + DATAOBJECTS + "/"; 127 final static String s6 = "\";\n }\npublic static Test suite() {\n NbTestSuite suite = new NbTestSuite("; 128 final static String s7 = ".class);\n return suite;\n }\n}"; 129 130 } 131 | Popular Tags |