1 19 20 27 28 package DataLoaderTests.LoaderPoolTest; 29 30 import junit.framework.*; 31 import org.netbeans.junit.*; 32 33 public class DataLoaderPoolTest_find extends NbTestCase { 34 35 36 public DataLoaderPoolTest_find(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_find.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 testDLPFind() { 104 105 String file1 = new LoaderPoolTest("x").getClass().getPackage().getName().replace('.','/') + "/textfile3.txt"; 106 String file2 = new LoaderPoolTest("x").getClass().getPackage().getName().replace('.','/') + "/textfile4.txt"; 107 System.out.println("file1:" + file1); 108 System.out.println("file2:" + file2); 109 try{ 110 prepare(); 111 LPT.writeRef(new LoaderPoolTest("x").getClass().getName()); 112 LPT.existDataObject(file1); 113 LPT.recognizedAs(file1,textdl.getDisplayName()); 114 LPT.removeDataLoader(textdl); 115 dummyWait(5000); 116 if ( LPT.noOfChanges != 1 ) { 117 LPT.writeRef("Not registered change event over DataLoaderPool!",FAILED); 118 } 120 LPT.existDataObject(file1); 121 LPT.notRecognizedAs(file1,textdl.getDisplayName()); 123 LPT.existDataObject(file2); 125 LPT.notRecognizedAs(file2,textdl.getDisplayName()); 126 LPT.addDataLoader("org.netbeans.modules.text"); 127 dummyWait(5000); 128 if ( LPT.noOfChanges != 2 ) { 129 LPT.writeRef("Not registered change event over DataLoaderPool!",FAILED); 130 } 132 LPT.existDataObject(file1); 133 LPT.recognizedAs(file1,textdl.getDisplayName()); 134 LPT.recognizedAs(file2,textdl.getDisplayName()); 135 clean(); 136 successful = successful && LPT.successful; 138 System.out.println("\n" + successful ); 139 }catch(Throwable ee){ 140 ee.printStackTrace(getRef()); 141 ee.printStackTrace(); 142 LPT.writeRef(FAILED); 143 } 144 145 assertTrue("Find test failed!",successful); 146 147 } 148 149 public static final boolean PRINT_EXCEPTIONS = true; 151 152 public static final String PASSED = "passed.\n"; 153 public static final String FAILED = "failed.\n"; 154 } 155 | Popular Tags |