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: import org.openide.loaders.DataObject;
055:
056: public class DataObjectTest_delegate extends NbTestCase {
057:
058: /** Creates new DataObjectTest_manipulation */
059: public DataObjectTest_delegate(java.lang.String testName) {
060: super (testName);
061: }
062:
063: /**Allows this test to be executed inside ide*/
064: public static void main(java.lang.String[] args) {
065: junit.textui.TestRunner.run(suite());
066: }
067:
068: /**This suite*/
069: public static Test suite() {
070: NbTestSuite suite = new NbTestSuite(
071: DataObjectTest_delegate.class);
072: return suite;
073: }
074:
075: // boolean successful = true;
076: DataObjectTest DOT = null;
077:
078: /**
079: *Performs initializing before own tests starts
080: */
081: void prepare() {
082: try {
083: //when not in XTest harness -> woring directory will be under actual userdir
084: if (Manager.getWorkDirPath() == null)
085: System.setProperty("nbjunit.workdir", System
086: .getProperty("netbeans.user"));
087: //clearWorkDir();
088: String newname = NAME.substring(NAME.lastIndexOf('/') + 1,
089: ((NAME.lastIndexOf('.') == -1) ? NAME.length()
090: : NAME.lastIndexOf('.')));
091: DOT = new DataObjectTest(getName());
092: System.out.println("Name: " + DOT.getName());
093: // successful = true;
094: //next condition removes the last dot from folder
095: if (NAME.endsWith("."))
096: NAME = NAME.substring(0, NAME.length() - 1);
097: DOT.prepare();
098: } catch (Exception e) {
099: e.printStackTrace();
100: e.printStackTrace(getRef());
101: assertTrue("Initialization of test failed! ->" + e, false);
102: }
103: }
104:
105: /**
106: *Performs clean up
107: */
108: void clean() {
109: DOT.clean();
110: }
111:
112: /**
113: *Performs waiting of current thread for time in millis
114: *@param millist integer number - time in millis to wait
115: */
116: void dummyWait(int millis) {
117: try {
118: Thread.sleep(millis);
119: } catch (Exception ex) {
120: DOT.printException(ex);
121: }
122: }
123:
124: /**
125: *Own test
126: */
127: public void testDODelegate() {
128:
129: try {
130: prepare();
131: // org.openide.filesystems.FileObject fo = DOT.rep.findResource(new DataObjectTest("x").getClass().getPackage().getName().replace('.','/')
132: // + NAME);
133: DataObject testedDO = DataObjectTest.findResource(NAME);
134: // org.openide.loaders.DataObject testedDO = org.openide.loaders.DataObject.find(fo);
135: DOT.testDelegate(testedDO);
136: clean();
137: //do not forget to merge the results!
138: // successful = successful && DOT.successful;
139: System.out.println("\n" + DOT.successful);
140: } catch (Throwable ee) {
141: ee.printStackTrace(getRef());
142: ee.printStackTrace();
143: DOT.writeRef("Delegate test failed!", FAILED);
144: }
145: assertTrue("Delegate test failed!", DOT.successful);
146: }
147:
148: //if you want print exceptions into log file, put here true.
149: public static final boolean PRINT_EXCEPTIONS = true;
150:
151: public static final String PASSED = "passed.\n";
152: public static final String FAILED = "failed.\n";
153:
154: protected String NAME = "/DataObjects/JavaSourceObject.java";//null;
155: }
|