|
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-2002 Sun * Microsystems, Inc. All Rights Reserved. */ /* * Tests for JSP Execution */ package org.netbeans.test.gui.web.JSP_Compilation_and_Execution; import org.netbeans.junit.NbTestSuite; import org.netbeans.junit.NbTestCase; import java.awt.Robot; import java.awt.event.*; import java.awt.*; import java.net.URL; import javax.swing.*; import javax.accessibility.*; import org.netbeans.jellytools.*; import org.netbeans.jellytools.nodes.*; import org.netbeans.jellytools.actions.*; import org.netbeans.jellytools.properties.*; import org.netbeans.jemmy.*; import org.netbeans.jemmy.operators.*; public class JSP_Exec extends NbTestCase { String workDir=null; ExplorerOperator explorer=null; private String delim="|"; EditorOperator editor= null; private static boolean mwm=true; private JavaNode node=null; private NbDialogOperator dop=null; private WizardOperator wop=null; private String value=null; String serverType = "no server"; // NOI18N String serverName = "no server"; // NOI18N String serverHost = "no server"; // NOI18N public JSP_Exec(String testName) { super(testName); } /** Use for execution inside IDE */ public static void main(java.lang.String[] args) { junit.textui.TestRunner.run(new NbTestSuite(JSP_Exec.class)); } public void setUp() { serverType=System.getProperty("serverType"); serverName=System.getProperty("serverName"); serverHost=System.getProperty("serverHost"); String fSep = System.getProperty("file.separator"); // NOI18N workDir = (java.lang.System.getProperty("jsptests.workdir")+"/testSystem").replace('/',fSep.charAt(0)); // NOI18N if(mwm) { mwm=false; try { dop=new NbDialogOperator(org.netbeans.jellytools.Bundle.getString("org.netbeans.modules.web.context.Bundle", "CTL_TITLE")); dop.close(); dop=new NbDialogOperator(org.netbeans.jellytools.Bundle.getString("org.netbeans.modules.web.context.Bundle", "CTL_TITLE")); dop.close(); } catch(Exception e) { System.out.println("'Mount Web Module' dialog not found "+e); } new ActionNoBlock("Tools|Setup Wizard", null).perform(); wop=new WizardOperator("Setup Wizard"); String localLabel = org.netbeans.jellytools.Bundle.getString("org.netbeans.core.ui.Bundle", "CTL_BrowserLabel"); // NOI18N JComboBoxOperator cb=new JComboBoxOperator(wop, 0); waitFor(5000); cb.selectItem(2); wop.finish(); explorer = ExplorerOperator.invoke(); explorer.selectPageRuntime(); try { Node node=new Node(new RuntimeTabOperator().tree(),"Server Registry"+delim+"Installed Servers"+delim+serverType+delim+serverName+delim+serverHost); new ActionNoBlock(null,"Set As Default").performPopup(node); }catch(Exception e) { fail("Default server is not found"); } } explorer = ExplorerOperator.invoke(); explorer.selectPageFilesystems(); } private JavaNode getNode(String path) { try { node=new JavaNode(workDir+delim+path); }catch(Exception e) { fail(path+" not found"); } return node; } private void checkDialog(String name) { try { dop=new NbDialogOperator(name); } catch(Exception ex) { fail("No '"+name+"' dialog appears"); } dop.close(); } private void waitFor(int ms) { // On W2k k=1, on Solaris/Linux it's better to set k=2-3 int k=2; new EventTool().waitNoEvent(ms*k); } private boolean checkExecution(String output) { try { dop=new NbDialogOperator("Information"); dop.close(); } catch(Exception ex) { } NbFrameOperator nfo = new NbFrameOperator("Web Browser"); String result=new JTextComponentOperator(nfo, 0).getText(); if (-1==result.indexOf(output)) { nfo.close(); return false; } else { nfo.close(); return true; } } //1 Execute simple JSP in default package via popup menu public void test_JSP_in_defpkg_via_popup() { node=getNode("SimpleJSPpopup"); // NOI18N new ExecuteAction().performPopup(node); waitFor(10000); if (!checkExecution("Test test_JSP_in_defpkg_via_popup() Passed")) { // NOI18N fail("Invalid JSP."); } } //2 Execute simple JSP in default package via F6 shortcut public void test_JSP_in_defpkg_via_F6() { node=getNode("SimpleJSPf9"); // NOI18N new ExecuteAction().performShortcut(node); waitFor(10000); if (!checkExecution("Test test_JSP_in_defpkg_via_F9() Passed")) { // NOI18N fail("Invalid JSP."); } } //3 Execute simple JSP in default package via main menu public void test_JSP_in_defpkg_via_main() { node=getNode("SimpleJSPmain"); // NOI18N new ExecuteAction().performMenu(node); waitFor(10000); if (!checkExecution("Test test_JSP_in_defpkg_via_main() Passed")) { // NOI18N fail("Invalid JSP."); } } //4 Execute simple JSP in non default package via main menu public void test_JSP_in_nondefpkg() { node=getNode("jsps"+delim+"simple"+delim+"TestJSP"); // NOI18N new ExecuteAction().performMenu(node); waitFor(10000); if (!checkExecution("Test test_JSP_in_nondefpkg() Passed")) { // NOI18N fail("Invalid JSP."); } } //5 Execute JSP returning some (404) error code public void test_JSP_with_404_error() { node=getNode("jsps"+delim+"errors"+delim+"TestError"); // NOI18N new ExecuteAction().performMenu(node); try { dop=new NbDialogOperator("Information"); dop.close(); } catch(Exception ex) { } NbFrameOperator nfo = new NbFrameOperator("Web Browser"); JComboBoxOperator o=new JComboBoxOperator(nfo, 0); o.addItem(new String("http://"+serverHost+"/File.jsp")); // NOI18N o.selectItem("http://"+serverHost+"/File.jsp"); // NOI18N waitFor(10000); if (!checkExecution("Test test_JSP_with_404_error() Passed")) { // NOI18N fail("Invalid JSP."); } } //6 Execute JSP throwing some exception; public void test_JSP_with_exception() { node=getNode("jsps"+delim+"errors"+delim+"Exception"); // NOI18N new ExecuteAction().performMenu(node); waitFor(10000); if (!checkExecution("Test test_JSP_with_exception() Passed")) { // NOI18N fail("Invalid JSP."); } } //7 Execute JSP redirecting to another JSP public void test_JSP_with_redirect() { node=getNode("jsps"+delim+"jsp"+delim+"Redirect"); // NOI18N new ExecuteAction().performMenu(node); waitFor(10000); if (!checkExecution("Test test_JSP_with_redirect() Passed")) { // NOI18N fail("Invalid JSP."); } } //8 Execute JSP including another JSPs public void test_JSP_including_JSP() { node=getNode("jsps"+delim+"jsp"+delim+"Include"); // NOI18N new ExecuteAction().performMenu(node); waitFor(10000); if (!checkExecution("Test test_JSP_including_JSP() Passed")) { // NOI18N fail("Invalid JSP."); } } //9 Execute JSP with nonempty request parameters public void test_JSP_with_request_parameters() { node=getNode("jsps"+delim+"param"+delim+"Request"); // NOI18N new ExecuteAction().performMenu(node); waitFor(10000); if (!checkExecution("Test test_JSP_with_request_parameters() Passed")) { // NOI18N fail("Invalid JSP."); } } //10 Execute JSP using initial parameter public void test_JSP_with_initial_parameters() { node=getNode("jsps"+delim+"param"+delim+"Initial"); // NOI18N new ExecuteAction().performMenu(node); waitFor(10000); if (!checkExecution("Test test_JSP_with_initial_parameters() Passed")) { // NOI18N fail("Invalid JSP."); } } //11 Execute JSP using context paramter public void test_JSP_with_context_parameters() { node=getNode("jsps"+delim+"param"+delim+"Context"); // NOI18N new ExecuteAction().performMenu(node); waitFor(10000); if (!checkExecution("Test test_JSP_with_context_parameters() Passed")) { // NOI18N fail("Invalid JSP."); } } //12 Execute JSP using Environment Entry reference public void test_JSP_with_Environment_Entry_reference() { node=getNode("jsps"+delim+"refs"+delim+"EnvEntryRef"); // NOI18N new ExecuteAction().performMenu(node); waitFor(10000); if (!checkExecution("Test test_JSP_with_Environment_Entry_reference() Passed")) { // NOI18N fail("Invalid JSP."); } } //13 Execute JSP with fixed URL pattern mapping public void test_JSP_with_fixed_URL_pattern_map() { node=getNode("jsps"+delim+"map"+delim+"TestFixedMapping"); // NOI18N new ExecuteAction().performMenu(node); waitFor(10000); try { dop=new NbDialogOperator("Information"); dop.close(); } catch(Exception ex) { } NbFrameOperator nfo = new NbFrameOperator("Web Browser"); JComboBoxOperator o=new JComboBoxOperator(nfo, 0); o.addItem(new String("http://"+serverHost+"/Fixed")); // NOI18N o.selectItem("http://"+serverHost+"/Fixed"); // NOI18N waitFor(10000); if (!checkExecution("Test test_JSP_with_fixed_URL_pattern_map() Passed")) { // NOI18N fail("Invalid JSP."); } } //14 Execute JSP with non-fixed (using '*') URL pattern mapping public void test_JSP_with_non_fixed_URL_pattern_map() { node=getNode("jsps"+delim+"map"+delim+"TestPath"); // NOI18N new ExecuteAction().performMenu(node); waitFor(10000); try { dop=new NbDialogOperator("Information"); dop.close(); } catch(Exception ex) { } NbFrameOperator nfo = new NbFrameOperator("Web Browser"); JComboBoxOperator o=new JComboBoxOperator(nfo, 0); o.addItem(new String("http://"+serverHost+"/WildCard/fdg")); // NOI18N o.selectItem("http://"+serverHost+"/WildCard/fdg"); // NOI18N waitFor(10000); if (!checkExecution("Test test_JSP_with_non_fixed_URL_pattern_map() Passed")) { // NOI18N fail("Invalid JSP."); } } //15 Execute JSP after Copy(Cut)-Paste (as copy) operation public void test_JSP_after_Copy_Paste() { node=getNode("jsps"+delim+"CopyPaste"); // NOI18N new CopyAction().performMenu(node); waitFor(1000); node=getNode("jsps"+delim+"simple"); // NOI18N new PasteCopyAction().performMenu(node); waitFor(2000); node=getNode("jsps"+delim+"simple"+delim+"CopyPaste"); // NOI18N new ExecuteAction().performMenu(node); waitFor(10000); if (!checkExecution("Test test_JSP_after_Copy_Paste() Passed")) { // NOI18N fail("Invalid JSP."); } } //16 Execute JSP after Copy(Cut)-Paste (as link) operation public void test_JSP_after_Copy_Paste_link() { node=getNode("jsps"+delim+"CopyPasteLink"); // NOI18N new CopyAction().performMenu(node); waitFor(1000); node=getNode("jsps"+delim+"simple"); // NOI18N new PasteLinkAction().performMenu(node); waitFor(2000); node=getNode("jsps"+delim+"simple"+delim+"CopyPasteLink"); // NOI18N new ExecuteAction().performMenu(node); waitFor(10000); if (!checkExecution("Test test_JSP_after_Copy_Paste_link() Passed")) { // NOI18N fail("Invalid JSP."); } } //17 Execute JSP with extension (using '*.') pattern mapping public void test_JSP_with_extension_pattern_map() { node=getNode("jsps"+delim+"map"+delim+"TestExtension"); // NOI18N new ExecuteAction().performMenu(node); waitFor(10000); try { dop=new NbDialogOperator("Information"); dop.close(); } catch(Exception ex) { } NbFrameOperator nfo = new NbFrameOperator("Web Browser"); JComboBoxOperator o=new JComboBoxOperator(nfo, 0); o.addItem(new String("http://"+serverHost+"/File.test")); // NOI18N o.selectItem("http://"+serverHost+"/File.test"); // NOI18N waitFor(10000); if (!checkExecution("Test test_JSP_with_extension_pattern_map() Passed")) { // NOI18N fail("Invalid JSP."); } } //18 Execute JSP using packed bean class public void test_JSP_with_packed_bean() { node=getNode("jsps"+delim+"beans"+delim+"xPackedBean"); // NOI18N new ExecuteAction().performMenu(node); waitFor(10000); if (!checkExecution("Test test_JSP_with_packed_bean() Passed")) { // NOI18N fail("Invalid JSP."); } } //19 Execute JSP using nonpacked bean class public void test_JSP_with_non_packed_bean() { node=getNode("jsps"+delim+"beans"+delim+"NonPackedBean"); // NOI18N new ExecuteAction().performMenu(node); waitFor(10000); if (!checkExecution("Test test_JSP_with_non_packed_bean() Passed")) { // NOI18N fail("Invalid JSP."); } } //20 Execute JSP using packed tag library public void test_JSP_with_packed_taglib() { node=getNode("jsps"+delim+"taglibs"+delim+"xPackedTagLib"); // NOI18N new ExecuteAction().performMenu(node); waitFor(10000); if (!checkExecution("Test test_JSP_with_packed_taglib() Passed")) { // NOI18N fail("Invalid JSP."); } } //21 Execute JSP using nonpacked tag library public void test_JSP_with_non_packed_taglib() { node=getNode("jsps"+delim+"taglibs"+delim+"NonPackedTagLib"); // NOI18N new ExecuteAction().performMenu(node); waitFor(10000); if (!checkExecution("Test test_JSP_with_non_packed_taglib() Passed")) { // NOI18N fail("Invalid JSP."); } } //22 Execute JSP with Context Root web module property set to non-empty value public void test_JSP_with_non_empty_CR() { node=getNode("WEB-INF"); // NOI18N new PropertiesAction().perform(node); PropertySheetOperator pw = new PropertySheetOperator(PropertySheetOperator.MODE_PROPERTIES_OF_ONE_OBJECT,"WEB-INF"); // NOI18N PropertySheetTabOperator psto = pw.getPropertySheetTabOperator("Properties"); TextFieldProperty tf=new TextFieldProperty(psto,"Context Root"); value=tf.getValue(); tf.setValue("/test-wm"); // NOI18N node=getNode("jsps"+delim+"ContextRoot"); // NOI18N new ExecuteAction().performMenu(node); waitFor(10000); if (!checkExecution("Test test_JSP_with_non_empty_CR() Passed")) { // NOI18N node=getNode("WEB-INF"); // NOI18N new PropertiesAction().perform(node); explorer.selectPageFilesystems(); pw = new PropertySheetOperator(PropertySheetOperator.MODE_PROPERTIES_OF_ONE_OBJECT,"WEB-INF"); // NOI18N psto = pw.getPropertySheetTabOperator("Properties"); tf=new TextFieldProperty(psto,"Context Root"); value=tf.getValue(); tf.setValue(""); // NOI18N pw.close(); fail("Invalid JSP."); } explorer.selectPageFilesystems(); pw = new PropertySheetOperator(PropertySheetOperator.MODE_PROPERTIES_OF_ONE_OBJECT,"WEB-INF"); // NOI18N psto = pw.getPropertySheetTabOperator("Properties"); tf=new TextFieldProperty(psto,"Context Root"); value=tf.getValue(); tf.setValue(""); // NOI18N pw.close(); } } |
... 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.