|
What this is
Other links
The source code/* * Sun Public License Notice * * The contents of this file are subject to the Sun Public License * Version 1.0 (the "License"). You may not use this file except in * compliance with the License. A copy of the License is available at * http://www.sun.com/ * * The Original Code is NetBeans. The Initial Developer of the Original * Code is Sun Microsystems, Inc. Portions Copyright 1997-2003 Sun * Microsystems, Inc. All Rights Reserved. */ /* * CopyTestCase.java * * Created on January 10, 2003, 4:59 PM */ package org.netbeans.test.java.gui.copypaste; import java.io.IOException; import org.netbeans.jellytools.JellyTestCase; import org.netbeans.jemmy.EventTool; import org.netbeans.junit.AssertionFailedErrorException; import org.netbeans.modules.java.Parsing; import org.netbeans.test.java.Utilities; import org.openide.cookies.SourceCookie; import org.openide.filesystems.FileObject; import org.openide.filesystems.Repository; import org.openide.loaders.DataFolder; import org.openide.loaders.DataObject; import org.openide.loaders.DataObjectNotFoundException; /** * * @author jb105785 */ public abstract class CopyTestCase extends JellyTestCase { protected static final int DELAY = 1000; protected static final String NAME_TEST_FILE = "Test"; protected static final String NAME_TEST2_FILE = "Test2"; protected static final String NAME_DATA_DIR = "org/netbeans/test/java/gui/copypaste/data/"; protected static final String DATA_PACKAGE = "org.netbeans.test.java.gui.copypaste.data"; protected static final String SRC_PACKAGE = "org.netbeans.test"; protected static final String DST_PACKAGE = "org.netbeans.test.java.testsources"; protected static final String INTERFACE_NAME = "NewInterface"; protected static final String INNER_CLASS_NAME = "InnerClass"; protected DataObject srcFile; protected DataObject srcFile2; protected DataFolder srcFolder; protected String testFSName; public CopyTestCase(String name){ super(name); } { try { srcFile = DataObject.find(Repository.getDefault().findResource(NAME_DATA_DIR + NAME_TEST_FILE + ".java")); srcFile2 = DataObject.find(Repository.getDefault().findResource(NAME_DATA_DIR + NAME_TEST2_FILE + ".java")); srcFolder = DataFolder.findFolder(Repository.getDefault().findResource(SRC_PACKAGE.replace('.','/'))); testFSName = Repository.getDefault().findResource(SRC_PACKAGE.replace('.', '/')).getFileSystem().getDisplayName(); } catch (Exception e) { e.printStackTrace(); } } /** setUp method */ public void setUp() { System.out.println("######## "+getName()+" #######"); try { srcFile.copy(srcFolder); srcFile2.copy(srcFolder); } catch (IOException e) { throw new AssertionFailedErrorException(e); } } /** tearDown method */ public void tearDown() { Utilities.saveAll(); Utilities.delete(SRC_PACKAGE.replace('.', '/') + "/" + NAME_TEST2_FILE + ".java"); Utilities.delete(SRC_PACKAGE.replace('.', '/') + "/" + NAME_TEST_FILE + ".java"); Utilities.delete(SRC_PACKAGE.replace('.', '/') + "/" + INTERFACE_NAME + ".java"); Utilities.delete(SRC_PACKAGE.replace('.', '/') + "/" + INNER_CLASS_NAME + ".java"); Utilities.delete(DST_PACKAGE.replace('.', '/') + "/" + NAME_TEST_FILE + ".java"); } public void waitFilesParsed(){ Repository repository; repository = Repository.getDefault(); waitParsed(SRC_PACKAGE.replace('.', '/') + "/" + NAME_TEST2_FILE + ".java"); waitParsed(SRC_PACKAGE.replace('.', '/') + "/" + NAME_TEST_FILE + ".java"); waitParsed(SRC_PACKAGE.replace('.', '/') + "/" + INTERFACE_NAME + ".java"); waitParsed(SRC_PACKAGE.replace('.', '/') + "/" + INNER_CLASS_NAME + ".java"); waitParsed(DST_PACKAGE.replace('.', '/') + "/" + NAME_TEST_FILE + ".java"); } public void waitParsed(String name){ try { new EventTool().waitNoEvent(500); FileObject file = Repository.getDefault().findResource(name); if (file==null) return; SourceCookie src = (SourceCookie) DataObject.find(file).getCookie(SourceCookie.class); src.getSource().prepare().waitFinished(); } catch (DataObjectNotFoundException e) { //if the file is not found, I don't need to wait } } } |
... this post is sponsored by my books ... | |
#1 New Release! |
FP Best Seller |
Copyright 1998-2021 Alvin Alexander, alvinalexander.com
All Rights Reserved.
A percentage of advertising revenue from
pages under the /java/jwarehouse
URI on this website is
paid back to open source projects.