alvinalexander.com | career | drupal | java | mac | mysql | perl | scala | uml | unix  

What this is

This file is included in the DevDaily.com "Java Source Code Warehouse" project. The intent of this project is to help you "Learn Java by Example" TM.

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.
 */

package org.netbeans.test.java.gui.copypaste;

import junit.textui.TestRunner;
import org.netbeans.jellytools.actions.PasteAction;
import org.netbeans.jellytools.nodes.FolderNode;
import org.netbeans.jellytools.nodes.JavaNode;
import org.netbeans.jemmy.EventTool;
import org.netbeans.junit.NbTestSuite;
import org.netbeans.test.java.Utilities;
import org.openide.filesystems.Repository;


public class JavaNodeTest extends CopyTestCase {
    
    /** Need to be defined because of JUnit */
    public JavaNodeTest(String name) {
        super(name);
    }
    
    public static NbTestSuite suite() {
        NbTestSuite suite = new NbTestSuite();
        suite.addTest(new JavaNodeTest("testCopyPaste"));
        suite.addTest(new JavaNodeTest("testCutPaste"));
        return suite;
    }
    
    /** Use for execution inside IDE */
    public static void main(java.lang.String[] args) {
        TestRunner.run(suite());
    }
    
    
    
    public void testCopyPaste() {
        
        JavaNode srcNode = new JavaNode(testFSName + "|" + SRC_PACKAGE.replace('.', '|') + "|" + NAME_TEST_FILE);
        srcNode.copy();
        
        FolderNode dstNode = new FolderNode(testFSName + "|" + DST_PACKAGE.replace('.', '|'));
        dstNode.pasteCopy();
        waitFilesParsed();
        
        ref(Utilities.getAsString(DST_PACKAGE.replace('.', '/') + "/" + NAME_TEST_FILE + ".java"));
        compareReferenceFiles();
    }

    public void testCutPaste() {
        
        JavaNode srcNode = new JavaNode(testFSName + "|" + SRC_PACKAGE.replace('.', '|') + "|" + NAME_TEST_FILE);
        srcNode.cut();
        
        FolderNode dstNode = new FolderNode(testFSName + "|" + DST_PACKAGE.replace('.', '|'));
        dstNode.select();
        new PasteAction().perform();
        waitFilesParsed();
        
        ref(Utilities.getAsString(DST_PACKAGE.replace('.', '/') + "/" + NAME_TEST_FILE + ".java"));
        
        assertNull(Repository.getDefault().findResource(SRC_PACKAGE.replace('.', '/') + "/" + NAME_TEST_FILE + ".java"));
        compareReferenceFiles();
    }
}
... this post is sponsored by my books ...

#1 New Release!

FP Best Seller

 

new blog posts

 

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.