KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > DataLoaderTests > DataObjectTest > DataObjectTest_others


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_others extends NbTestCase {
35
36     /** Creates new DataObjectTest_manipulation */
37     public DataObjectTest_others(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_others.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 testDOOthers() throws Exception JavaDoc {
101         
102 // try{
103
prepare();
104 // org.openide.filesystems.FileObject fo = DOT.rep.findResource(new DataObjectTest("x").getClass().getPackage().getName().replace('.','/')
105
// + NAME);
106
// org.openide.loaders.DataObject testedDO = org.openide.loaders.DataObject.find(fo);
107
DataObject testedDO = DataObjectTest.findResource(NAME );
108 // try{
109
DOT.shadowMe(testedDO).delete();
110 // }catch(Exception ex){
111
// DOT.writeRef("\nDeleting of shadowed object failed!");
112
// DOT.printException(ex);
113
// DOT.writeRef(FAILED);
114
// }
115
DOT.checkTemplate(testedDO);
116             DOT.testHelpCtx(testedDO);
117             clean();
118             //do not forget to merge the results!
119
// successful = successful && DOT.successful;
120
System.out.println("\n" + DOT.successful );
121 // }catch(Throwable ee){
122
// ee.printStackTrace(getRef());
123
// ee.printStackTrace();
124
// DOT.writeRef("Others test failed!",FAILED);
125
// }
126
assertTrue("Others test failed!",DOT.successful);
127     }
128     
129     //if you want print exceptions into log file, put here true.
130
public static final boolean PRINT_EXCEPTIONS = true;
131     
132     public static final String JavaDoc PASSED = "passed.\n";
133     public static final String JavaDoc FAILED = "failed.\n";
134     
135     protected String JavaDoc NAME = null;//"/DataObjects/JavaSourceObject.java";
136
}
137
Popular Tags