1 19 20 27 28 package DataLoaderTests.LoaderPoolTest; 29 30 import junit.framework.*; 31 import org.netbeans.junit.*; 32 33 public class DataLoaderPoolTest_create extends NbTestCase { 34 35 36 public DataLoaderPoolTest_create(java.lang.String testName) { 37 super(testName); 38 } 39 40 41 public static void main(java.lang.String [] args) { 42 junit.textui.TestRunner.run(suite()); 43 } 44 45 46 public static Test suite() { 47 NbTestSuite suite = new NbTestSuite(DataLoaderPoolTest_create.class); 48 return suite; 49 } 50 51 static boolean successful = true; 52 static org.openide.loaders.DataLoader textdl = null; 53 LoaderPoolTest LPT = null; 54 55 58 void prepare() { 59 try { 60 if (Manager.getWorkDirPath()==null) System.setProperty("nbjunit.workdir",System.getProperty("netbeans.user")); 62 LPT = new LoaderPoolTest(getName()); 64 LPT.work = ""+ 67 Manager.getWorkDirPath()+ 68 java.io.File.separator + this.getClass().getName().replace('.',java.io.File.separatorChar)+ 69 java.io.File.separator + getName(); 70 LPT.prepare(); 71 textdl = LPT.getDataLoader("Textual"); 72 LPT.textdl = textdl; 73 } catch (Exception e) { 74 e.printStackTrace(); 75 e.printStackTrace(getRef()); 76 assertTrue("Initialization of test failed! ->" + e,false); 77 } 78 } 79 80 83 void clean() { 84 LPT.clean(); 85 } 86 87 91 void dummyWait(int millis) { 92 try { 93 Thread.sleep(millis); 94 } catch (Exception ex) { 95 LPT.printException(ex); 96 } 97 } 98 99 103 public void testDLPCreate() { 104 105 String file1 = new LoaderPoolTest("x").getClass().getPackage().getName().replace('.','/') + "/textfile1.txt"; 106 String file2 = new LoaderPoolTest("x").getClass().getPackage().getName().replace('.','/') + "/textfile2.txt"; 107 108 try{ 109 prepare(); 110 LPT.writeRef(new LoaderPoolTest("x").getClass().getName()); 111 LPT.createDataObject(file1,textdl); 112 LPT.notCreateDataObject(file1,textdl); 113 LPT.removeDataLoader(textdl); 114 dummyWait(5000); 115 if ( LPT.noOfChanges != 1 ) { 116 LPT.writeRef("Not registered change event over DataLoaderPool!",FAILED); 117 } 119 LPT.eatMemory(2000); 120 LPT.sweepMemory(); 121 122 LPT.createDataObject(file1,textdl); 126 127 LPT.createDataObject(file2,textdl); 128 LPT.addDataLoader("org.netbeans.modules.text"); 129 dummyWait(5000); 130 if ( LPT.noOfChanges != 2 ) { 131 LPT.writeRef("Not registered change event over DataLoaderPool!",FAILED); 132 } 134 LPT.eatMemory(2000); 135 LPT.sweepMemory(); 136 137 LPT.createDataObject(file1,textdl); 141 LPT.createDataObject(file2,textdl); 142 143 clean(); 144 successful = successful && LPT.successful; 146 System.out.println("\n" + successful ); 147 }catch(Throwable ee){ 148 ee.printStackTrace(getRef()); 149 ee.printStackTrace(); 150 LPT.writeRef(FAILED); 151 } 152 153 assertTrue("Create test failed!",successful); 154 155 } 156 157 public static final boolean PRINT_EXCEPTIONS = true; 159 160 public static final String PASSED = "passed.\n"; 161 public static final String FAILED = "failed.\n"; 162 } 163 | Popular Tags |