KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > DataLoaderTests > DataObjectTest > DataObjectTest_delegate


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  * DataObjectTest_manipulation.java
22  *
23  * Tests ...
24  *
25  * Created on June 26, 2001, 3:39 PM
26  */

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

59      void prepare() {
60         try {
61             //when not in XTest harness -> woring directory will be under actual userdir
62
if (Manager.getWorkDirPath()==null) System.setProperty("nbjunit.workdir",System.getProperty("netbeans.user"));
63             //clearWorkDir();
64
String JavaDoc newname = NAME.substring(NAME.lastIndexOf('/')+1,((NAME.lastIndexOf('.')==-1)?NAME.length():NAME.lastIndexOf('.')));
65             DOT = new DataObjectTest(getName());
66             System.out.println("Name: " + DOT.getName());
67   // successful = true;
68
//next condition removes the last dot from folder
69
if (NAME.endsWith(".")) NAME = NAME.substring(0,NAME.length()-1);
70             DOT.prepare();
71         } catch (Exception JavaDoc e) {
72             e.printStackTrace();
73             e.printStackTrace(getRef());
74             assertTrue("Initialization of test failed! ->" + e,false);
75         }
76     }
77     
78     /**
79      *Performs clean up
80      */

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

89      void dummyWait(int millis) {
90         try {
91             Thread.sleep(millis);
92         } catch (Exception JavaDoc ex) {
93             DOT.printException(ex);
94         }
95     }
96     
97     /**
98      *Own test
99      */

100     public void testDODelegate() {
101         
102         try{
103             prepare();
104        // org.openide.filesystems.FileObject fo = DOT.rep.findResource(new DataObjectTest("x").getClass().getPackage().getName().replace('.','/')
105
// + NAME);
106
DataObject testedDO = DataObjectTest.findResource(NAME);
107 // org.openide.loaders.DataObject testedDO = org.openide.loaders.DataObject.find(fo);
108
DOT.testDelegate(testedDO);
109             clean();
110             //do not forget to merge the results!
111
// successful = successful && DOT.successful;
112
System.out.println("\n" + DOT.successful );
113         }catch(Throwable JavaDoc ee){
114             ee.printStackTrace(getRef());
115             ee.printStackTrace();
116             DOT.writeRef("Delegate test failed!",FAILED);
117         }
118         assertTrue("Delegate test failed!",DOT.successful);
119     }
120     
121     //if you want print exceptions into log file, put here true.
122
public static final boolean PRINT_EXCEPTIONS = true;
123     
124     public static final String JavaDoc PASSED = "passed.\n";
125     public static final String JavaDoc FAILED = "failed.\n";
126     
127     protected String JavaDoc NAME = "/DataObjects/JavaSourceObject.java";//null;
128
}
129
Popular Tags