|
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. */ package org.netbeans.test.java.gui.javawizard; import java.io.File; import junit.textui.TestRunner; import org.netbeans.jellytools.Bundle; import org.netbeans.jellytools.JellyTestCase; import org.netbeans.jellytools.NbDialogOperator; import org.netbeans.jellytools.nodes.JavaNode; import org.netbeans.junit.NbTestSuite; import org.netbeans.test.java.Utilities; import org.netbeans.test.oo.gui.jelly.java.wizard.Page1; import org.openide.actions.SaveAllAction; public class NewJavaPackage extends JellyTestCase { private static final String sampleDir = Utilities.getSampleDir().getDisplayName(); private static final String JAVA_PACKAGE = Bundle.getStringTrimmed("org.openide.actions.Bundle", "NewFromTemplate") + "|" + Bundle.getString("org.netbeans.modules.java.Bundle", "Templates/Package"); private static final String CONFIRM = Bundle.getString("org.openide.explorer.Bundle", "MSG_ConfirmDeleteObjectTitle"); private static final String INFO = Bundle.getString("org.openide.Bundle", "NTF_InformationTitle"); /** Need to be defined because of JUnit */ public NewJavaPackage(String name) { super(name); } public static NbTestSuite suite() { NbTestSuite suite = new NbTestSuite(); suite.addTest(new NewJavaPackage("testNewFromFSRootSingle")); suite.addTest(new NewJavaPackage("testNewFromFSRootMulti")); suite.addTest(new NewJavaPackage("testNewFromFolderSingle")); suite.addTest(new NewJavaPackage("testNewFromFolderMulti")); suite.addTest(new NewJavaPackage("testInvalidPackage")); return suite; } /** Use for execution inside IDE */ public static void main(java.lang.String[] args) { TestRunner.run(suite()); } public void setUp() { System.out.println("######## "+getName()+" #######"); } public void tearDown() { ((SaveAllAction) SaveAllAction.findObject(SaveAllAction.class, true)).performAction(); } private void create(String where, String what) { String first = what.indexOf('|') == -1? what: what.substring(0, what.indexOf('|')); JavaNode node = new JavaNode(where); node.performPopupActionNoBlock(JAVA_PACKAGE); Page1 wizard = new Page1(); wizard.setName(what.replace('|', '.')); wizard.finish(); JavaNode newNode = new JavaNode(where + "|" + what); assertNotNull(newNode); JavaNode toDel = new JavaNode(where + "|" + first); assertNotNull(toDel); toDel.delete(); new NbDialogOperator(CONFIRM).yes(); } public void testNewFromFSRootSingle() { create(sampleDir, "org"); } public void testNewFromFSRootMulti() { create(sampleDir, "org|netbeans|test"); } public void testNewFromFolderSingle() { create(sampleDir + "|examples" , "org"); } public void testNewFromFolderMulti() { create(sampleDir + "|examples" , "org|netbeans|test"); } public void testInvalidPackage() { JavaNode node = new JavaNode(sampleDir); node.performPopupActionNoBlock(JAVA_PACKAGE); Page1 wizard = new Page1(); wizard.setName("test/abcd"); wizard.finish(); new NbDialogOperator(INFO).ok(); wizard = new Page1(); wizard.cancel(); } } |
... 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.