KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > DataLoaderTests > LoaderPoolTest > DataLoaderPoolTest_explore


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  * DataLoaderPoolTest_explore.java
22  *
23  * Tests basic asking operations over LoaderPool
24  *
25  * Created on June 22, 2001, 12:32 PM
26  */

27
28 package DataLoaderTests.LoaderPoolTest;
29
30 import junit.framework.*;
31 import org.netbeans.junit.*;
32
33 public class DataLoaderPoolTest_explore extends NbTestCase {
34
35     /** Creates new DataLoaderPoolTest_explore */
36     public DataLoaderPoolTest_explore(java.lang.String JavaDoc testName) {
37         super(testName);
38     }
39
40     /**Allows this test to be executed inside ide*/
41     public static void main(java.lang.String JavaDoc[] args) {
42         junit.textui.TestRunner.run(suite());
43     }
44     
45     /**This suite*/
46     public static Test suite() {
47         NbTestSuite suite = new NbTestSuite(DataLoaderPoolTest_explore.class);
48         return suite;
49     }
50     
51     static boolean successful = true;
52     LoaderPoolTest LPT = null;
53         
54     /**
55      *Performs initializing before own tests starts
56      */

57     void prepare() {
58         try{
59             //when not in XTest harness -> woring directory will be under actual userdir
60
if (Manager.getWorkDirPath()==null) System.setProperty("nbjunit.workdir",System.getProperty("netbeans.user"));
61             //clearWorkDir();
62
LPT = new LoaderPoolTest(getName());
63             //now setting workdir - this class will write nothing into the logs, only the utility class should,
64
//however into location for this class
65
LPT.work = ""+
66                 Manager.getWorkDirPath()+
67                 java.io.File.separator + this.getClass().getName().replace('.',java.io.File.separatorChar)+
68                 java.io.File.separator + getName();
69             LPT.prepare();
70         }catch(Exception JavaDoc e){
71             e.printStackTrace();
72             e.printStackTrace(getRef());
73             assertTrue("Initialization of test failed! ->" + e,false);
74         }
75     }
76     
77     /**
78      *Performs clean up
79      */

80     void clean() {
81         //getRef().flush();
82
//getRef().close();
83
LPT.clean();
84     }
85     
86     /**
87      *Performs waiting of current thread for time in millis
88      *@param millist integer number - time in millis to wait
89      */

90     void dummyWait(int millis) {
91         try {
92             Thread.sleep(millis);
93         } catch (Exception JavaDoc ex) {
94             LPT.printException(ex);
95         }
96     }
97     
98     /** Own test:
99      *Asks for all Loaders, Preferred Loader etc.
100      */

101     public void testDLPExplore() {
102         
103         try{
104             prepare();
105             LPT.writeRef(new LoaderPoolTest("x").getClass().getName());
106             LPT.exploreDataLoaderPool();
107             LPT.compareTest();
108             LPT.printExtensions( (org.openide.loaders.UniFileLoader) LPT.textdl );
109             clean();
110             //do not forget to merge the results!
111
successful = successful && LPT.successful;
112             System.out.println("\n" + successful );
113         }catch(Throwable JavaDoc ee){
114             ee.printStackTrace(getRef());
115             ee.printStackTrace();
116             LPT.writeRef(FAILED);
117         }
118         
119         assertTrue("Exploration of DataLoaderPool failed!",successful);
120     }
121     
122     //if you want print exceptions into log file, put here true.
123
public static final boolean PRINT_EXCEPTIONS = true;
124     
125     public static final String JavaDoc PASSED = "passed.\n";
126     public static final String JavaDoc FAILED = "failed.\n";
127 }
128
Popular Tags