KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > DataLoaderTests > DataObjectTest > DataObjectTest_manipulation


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_manipulation extends NbTestCase {
34
35     /** Creates new DataObjectTest_manipulation */
36     public DataObjectTest_manipulation(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_manipulation.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 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(".")) {
69                 NAME = NAME.substring(0,NAME.length()-1);
70             }
71             DOT.prepare();
72         } catch (Exception JavaDoc e) {
73             e.printStackTrace();
74             e.printStackTrace(getRef());
75             assertTrue("Initialization of test failed! ->" + e,false);
76         }
77     }
78     
79     /**
80      *Performs clean up
81      */

82      void clean() {
83         DOT.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             DOT.printException(ex);
95         }
96     }
97     
98     /**Own test:
99      *
100      */

101     public void testDOManipulation() throws Exception JavaDoc {
102
103             prepare();
104             log("dataDir " + getDataDir());
105 // org.openide.filesystems.FileObject fo = DOT.rep.findResource(new DataObjectTest("x").getClass().getPackage().getName().replace('.','/')
106
// + NAME);
107
// org.openide.loaders.DataObject testedDO = org.openide.loaders.DataObject.find(fo);
108
log("resource:" + NAME);
109             DOT.checkManipulationOperations(DataObjectTest.findResource(NAME));
110             clean();
111             //do not forget to merge the results!
112
// successful = successful && DOT.successful;
113
// System.out.println("\n" + successful );
114

115         assertTrue("Manipulation test failed!",DOT.successful);
116     }
117     
118     //if you want print exceptions into log file, put here true.
119
public static final boolean PRINT_EXCEPTIONS = true;
120     
121     public static final String JavaDoc PASSED = "passed.\n";
122     public static final String JavaDoc FAILED = "failed.\n";
123     
124     protected String JavaDoc NAME = "/DataObjects/JavaSourceObject.java";//null;
125
}
126
Popular Tags