001: /*
002: * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
003: *
004: * Copyright 1997-2007 Sun Microsystems, Inc. All rights reserved.
005: *
006: * The contents of this file are subject to the terms of either the GNU
007: * General Public License Version 2 only ("GPL") or the Common
008: * Development and Distribution License("CDDL") (collectively, the
009: * "License"). You may not use this file except in compliance with the
010: * License. You can obtain a copy of the License at
011: * http://www.netbeans.org/cddl-gplv2.html
012: * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
013: * specific language governing permissions and limitations under the
014: * License. When distributing the software, include this License Header
015: * Notice in each file and include the License file at
016: * nbbuild/licenses/CDDL-GPL-2-CP. Sun designates this
017: * particular file as subject to the "Classpath" exception as provided
018: * by Sun in the GPL Version 2 section of the License file that
019: * accompanied this code. If applicable, add the following below the
020: * License Header, with the fields enclosed by brackets [] replaced by
021: * your own identifying information:
022: * "Portions Copyrighted [year] [name of copyright owner]"
023: *
024: * Contributor(s):
025: *
026: * The Original Software is NetBeans. The Initial Developer of the Original
027: * Software is Sun Microsystems, Inc. Portions Copyright 1997-2006 Sun
028: * Microsystems, Inc. All Rights Reserved.
029: *
030: * If you wish your version of this file to be governed by only the CDDL
031: * or only the GPL Version 2, indicate your decision by adding
032: * "[Contributor] elects to include this software in this distribution
033: * under the [CDDL or GPL Version 2] license." If you do not indicate a
034: * single choice of license, a recipient has the option to distribute
035: * your version of this file under either the CDDL, the GPL Version 2 or
036: * to extend the choice of license to its licensees as provided above.
037: * However, if you add GPL Version 2 code and therefore, elected the GPL
038: * Version 2 license, then the option applies only if the new code is
039: * made subject to such option by the copyright holder.
040: */
041:
042: /*
043: * DataObjectTest_manipulation.java
044: *
045: * Tests ...
046: *
047: * Created on June 26, 2001, 3:39 PM
048: */
049:
050: package DataLoaderTests.DataObjectTest;
051:
052: import junit.framework.*;
053: import org.netbeans.junit.*;
054:
055: public class DataObjectTest_manipulation extends NbTestCase {
056:
057: /** Creates new DataObjectTest_manipulation */
058: public DataObjectTest_manipulation(java.lang.String testName) {
059: super (testName);
060: }
061:
062: /**Allows this test to be executed inside ide*/
063: public static void main(java.lang.String[] args) {
064: junit.textui.TestRunner.run(suite());
065: }
066:
067: /**This suite*/
068: public static Test suite() {
069: NbTestSuite suite = new NbTestSuite(
070: DataObjectTest_manipulation.class);
071: return suite;
072: }
073:
074: // boolean successful = true;
075: DataObjectTest DOT = null;
076:
077: /**
078: *Performs initializing before own tests starts
079: */
080: void prepare() {
081: try {
082: //when not in XTest harness -> woring directory will be under actual userdir
083: // if (Manager.getWorkDirPath()==null) System.setProperty("nbjunit.workdir",System.getProperty("netbeans.user"));
084: //clearWorkDir();
085: // String newname = NAME.substring(NAME.lastIndexOf('/')+1,((NAME.lastIndexOf('.')==-1)?NAME.length():NAME.lastIndexOf('.')));
086: DOT = new DataObjectTest(getName());
087: System.out.println("Name: " + DOT.getName());
088: // successful = true;
089: //next condition removes the last dot from folder
090: if (NAME.endsWith(".")) {
091: NAME = NAME.substring(0, NAME.length() - 1);
092: }
093: DOT.prepare();
094: } catch (Exception e) {
095: e.printStackTrace();
096: e.printStackTrace(getRef());
097: assertTrue("Initialization of test failed! ->" + e, false);
098: }
099: }
100:
101: /**
102: *Performs clean up
103: */
104: void clean() {
105: DOT.clean();
106: }
107:
108: /**
109: *Performs waiting of current thread for time in millis
110: *@param millist integer number - time in millis to wait
111: */
112: void dummyWait(int millis) {
113: try {
114: Thread.sleep(millis);
115: } catch (Exception ex) {
116: DOT.printException(ex);
117: }
118: }
119:
120: /**Own test:
121: *
122: */
123: public void testDOManipulation() throws Exception {
124:
125: prepare();
126: log("dataDir " + getDataDir());
127: // org.openide.filesystems.FileObject fo = DOT.rep.findResource(new DataObjectTest("x").getClass().getPackage().getName().replace('.','/')
128: // + NAME);
129: // org.openide.loaders.DataObject testedDO = org.openide.loaders.DataObject.find(fo);
130: log("resource:" + NAME);
131: DOT.checkManipulationOperations(DataObjectTest
132: .findResource(NAME));
133: clean();
134: //do not forget to merge the results!
135: // successful = successful && DOT.successful;
136: // System.out.println("\n" + successful );
137:
138: assertTrue("Manipulation test failed!", DOT.successful);
139: }
140:
141: //if you want print exceptions into log file, put here true.
142: public static final boolean PRINT_EXCEPTIONS = true;
143:
144: public static final String PASSED = "passed.\n";
145: public static final String FAILED = "failed.\n";
146:
147: protected String NAME = "/DataObjects/JavaSourceObject.java";//null;
148: }
|