KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > DataLoaderTests > DataObjectTest > DataObjectTest_validity


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
33 public class DataObjectTest_validity extends NbTestCase {
34
35     /** Creates new DataObjectTest_manipulation */
36     public DataObjectTest_validity(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(DataObjectTest_validity.class);
48         return suite;
49     }
50     
51 // boolean successful = true;
52
DataObjectTest DOT = null;
53     
54
55     /**
56      *Performs initializing before own tests starts
57      */

58      void prepare() {
59         try {
60             //when not in XTest harness -> woring directory will be under actual userdir
61
if (Manager.getWorkDirPath()==null) System.setProperty("nbjunit.workdir",System.getProperty("netbeans.user"));
62             //clearWorkDir();
63
String JavaDoc newname = NAME.substring(NAME.lastIndexOf('/')+1,((NAME.lastIndexOf('.')==-1)?NAME.length():NAME.lastIndexOf('.')));
64             DOT = new DataObjectTest(getName());
65             System.out.println("Name: " + DOT.getName());
66   // successful = true;
67
//next condition removes the last dot from folder
68
if (NAME.endsWith(".")) NAME = NAME.substring(0,NAME.length()-1);
69             DOT.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         DOT.clean();
82     }
83     
84     /**
85      *Performs waiting of current thread for time in millis
86      *@param millist integer number - time in millis to wait
87      */

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

99     public void testDOValidity() throws Exception JavaDoc {
100             prepare();
101             org.openide.loaders.DataObject testedDO = DataObjectTest.findResource(NAME);
102             DOT.checkValidity(testedDO);
103             clean();
104             //do not forget to merge the results!
105
// successful = successful && DOT.successful;
106
System.out.println("\n" + DOT.successful );
107             assertTrue("Validity test failed!",DOT.successful);
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 String JavaDoc NAME = "/DataObjects/JavaSourceObject.java";//null;
117
}
118
Popular Tags