KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > DataLoaderTests > LoaderPoolTest > EXT


1 /*
2  * The contents of this file are subject to the terms of the Common Development
3  * and Distribution License (the License). You may not use this file except in
4  * compliance with the License.
5  *
6  * You can obtain a copy of the License at http://www.netbeans.org/cddl.html
7  * or http://www.netbeans.org/cddl.txt.
8  *
9  * When distributing Covered Code, include this CDDL Header Notice in each file
10  * and include the License file at http://www.netbeans.org/cddl.txt.
11  * If applicable, add the following below the CDDL Header, with the fields
12  * enclosed by brackets [] replaced by your own identifying information:
13  * "Portions Copyrighted [year] [name of copyright owner]"
14  *
15  * The Original Software is NetBeans. The Initial Developer of the Original
16  * Software is Sun Microsystems, Inc. Portions Copyright 1997-2006 Sun
17  * Microsystems, Inc. All Rights Reserved.
18  */

19
20 /*
21  * EXT.java
22  *
23  * Tests registered extensions of specified DataLoader.
24  *
25  * Created on May 30, 2001, 4:57 PM
26  */

27
28 package DataLoaderTests.LoaderPoolTest;
29
30 import org.openide.loaders.UniFileLoader;
31
32 public class EXT{
33
34     /** Creates new EXT */
35     public EXT() {
36     }
37
38     private static java.io.PrintWriter JavaDoc log = null;
39     private static java.io.PrintWriter JavaDoc ref = null;
40     static boolean successful = true;
41     LoaderPoolTest LPT = null;
42
43
44     /**This methods write an output to log stream*/
45     public static void writeLog(String JavaDoc text) {
46         log.println(text);
47         System.out.println(text);
48         if (text.equals(FAILED)) successful = false;
49     }
50     
51     /**This methods write an output to reference stream*/
52     public static void writeRef(String JavaDoc text) {
53         ref.println(text);
54         System.out.println(text);
55         if (text.equals(FAILED)) successful = false;
56     }
57     
58     /**If enabled, prints exception to the output and to the ref stream*/
59     static void printException(Exception JavaDoc e) {
60         if(PRINT_EXCEPTIONS){
61             e.printStackTrace();
62             e.printStackTrace(ref);
63         }
64     }
65     
66     /**
67      *Performs initializing before own tests starts
68      */

69     void prepare() {
70         LPT = new LoaderPoolTest("x");
71         LPT.prepare();
72     }
73     
74     /**
75      *Performs clean up
76      */

77     void clean() {
78         LPT.clean();
79     }
80     
81     /**
82      *Performs waiting of current thread for time in millis
83      *@param millist integer number - time in millis to wait
84      */

85     static void dummyWait(int millis) {
86         try {
87             Thread.sleep(millis);
88         } catch (Exception JavaDoc ex) {
89             printException(ex);
90         }
91     }
92
93     public static void main (String JavaDoc args[]) {
94         log = new java.io.PrintWriter JavaDoc(System.err);
95         ref = new java.io.PrintWriter JavaDoc(System.out);
96
97         EXT ext = new EXT();
98         
99         ext.prepare();
100         
101         //LoaderPoolTest.printExtensions( (UniFileLoader) LoaderPoolTest.getDataLoader(LOADER));
102
ext.successful = ext.LPT.refPrintExtensions(ext.LPT.getDataLoader(LOADER));
103         
104         ext.clean();
105         
106         //test if all test passed, if yes, then return passed, if any of all test failed, return failed.
107
//if(successful) return Status.passed(""); else return Status.failed("");
108
}
109
110     //if you want print exceptions into log file, put here true.
111
public static final boolean PRINT_EXCEPTIONS = true;
112     
113     public static final String JavaDoc PASSED = "passed.\n";
114     public static final String JavaDoc FAILED = "failed.\n";
115     
116     protected static String JavaDoc LOADER = null;
117 }
118
Popular Tags