|
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. */ package org.netbeans.test.gui.web.servletexec.properties; import org.netbeans.jellytools.actions.CompileAction; import org.netbeans.jellytools.actions.PropertiesAction; import org.netbeans.jellytools.properties.PropertySheetTabOperator; import org.netbeans.jellytools.properties.PropertySheetOperator; import org.netbeans.jellytools.properties.ComboBoxProperty; import org.netbeans.jellytools.nodes.JavaNode; import org.netbeans.jellytools.nodes.FolderNode; import org.netbeans.jellytools.properties.TextFieldProperty; import org.netbeans.jellytools.properties.ComboBoxProperty; import org.netbeans.jellytools.properties.PropertySheetOperator; import org.netbeans.jellytools.properties.PropertySheetTabOperator; import org.netbeans.jellytools.RepositoryTabOperator; import org.netbeans.jellytools.NewWizardOperator; import org.netbeans.jellytools.TargetLocationStepOperator; import org.netbeans.jellytools.JellyTestCase; import org.netbeans.jellytools.Bundle; import org.netbeans.junit.NbTestSuite; import org.netbeans.jemmy.Waiter; import org.netbeans.jemmy.operators.JTreeOperator; import org.netbeans.web.test.util.Utils; import org.netbeans.web.test.util.RepositoryNodeWaitable; import org.netbeans.test.gui.web.util.EditorPageWaitable; public class ServletProperties extends JellyTestCase { private static String wmName = "wm2"; private static String webInf = "WEB-INF"; private static String classes = "Classes"; private static String fSep = System.getProperty("file.separator"); private static String iSep = "|"; private static String workDir = null; private static String webModule = null; private static String pkg = null; private static boolean first = true; private static String defaultPackage = "properties"; private static String propsServlet = "PropertiesServlet"; private static String propsServletTemplate = "PropertiesTemplate"; private static String pnameName = null; private static String pnameTemplate = null; private static String pnameWebModule = null; private static String pnameURI = null; private static String pnameRP = null; private static String propertiesText = null; public ServletProperties(String testName) { super(testName); } public static void main(String[] args) { junit.textui.TestRunner.run(suite()); } public static junit.framework.Test suite() { workDir = System.getProperty("servletexec.workdir").replace('/', fSep.charAt(0)); webModule = workDir + fSep + wmName; pkg = webModule + iSep + webInf + iSep + classes + iSep + defaultPackage; String wmc = System.getProperty("servletexec.mountcount"); int count = 0; if(wmc != null) { count = new Integer(wmc).intValue(); } if(first) { while(count >0) { Utils.handleDialogAfterNewWebModule(); count--; } first = false; } return new NbTestSuite(ServletProperties.class); } public void testPropertiesName () { String node = pkg + iSep + propsServlet; JavaNode node1 = null; try { node1 = new JavaNode(node); node1.select(); }catch(Exception e) { e.printStackTrace(); fail("Please check, that all mounts are done properly"); } new PropertiesAction().perform(node1); PropertySheetOperator pso = new PropertySheetOperator(PropertySheetOperator.MODE_PROPERTIES_OF_ONE_OBJECT, propsServlet); PropertySheetTabOperator psto = new PropertySheetTabOperator(pso); TextFieldProperty tf = new TextFieldProperty(psto,pnameName); if(!tf.getValue().equals(propsServlet)) { fail("Default name in properties is wrong. " + tf.getValue() + " instead of " + propsServlet); return; } pso.close(); } public void testPropertiesTemplateFalse () { String node = pkg + iSep + propsServlet; JavaNode node1 = null; try { node1 = new JavaNode(node); node1.select(); }catch(Exception e) { e.printStackTrace(); fail("Please check, that all mounts are done properly"); } new PropertiesAction().perform(node1); PropertySheetOperator pso = new PropertySheetOperator(PropertySheetOperator.MODE_PROPERTIES_OF_ONE_OBJECT, propsServlet); PropertySheetTabOperator psto = new PropertySheetTabOperator(pso); ComboBoxProperty pr = new ComboBoxProperty(psto, pnameTemplate); if(!pr.getValue().equals("False")) { pso.close(); fail("Default value in properties is wrong. "); } click(node,2); //Servlet must be opened in editor EditorPageWaitable epw = new EditorPageWaitable(propsServlet); Waiter w = new Waiter(epw); try { w.waitAction(epw); } catch (Exception e) { e.printStackTrace(); fail("Not opened in editor after doubleclick"); } epw.getEditorOperator().close(false); //Close opened file pso.close(); //PASS } public void testPropertiesTemplateTrue () { String node = pkg + iSep + propsServletTemplate; NewWizardOperator wizard = null; JavaNode node1 = null; try { node1 = new JavaNode(node); node1.select(); }catch(Exception e) { e.printStackTrace(); fail("Please check, that all mounts are done properly"); } new PropertiesAction().perform(node1); PropertySheetOperator pso = new PropertySheetOperator(PropertySheetOperator.MODE_PROPERTIES_OF_ONE_OBJECT, propsServletTemplate); PropertySheetTabOperator psto = new PropertySheetTabOperator(pso); ComboBoxProperty pr = new ComboBoxProperty(psto, pnameTemplate); if(!pr.getValue().equals("True")) { pso.close(); fail("Default value in properties is wrong. "); } pso.close(); try { click(node,2); //Wizard must start wizard = new NewWizardOperator(); //TargetLocationStepOperator tlso = new TargetLocationStepOperator(); //tlso.setName("SrvlFromTemplate"); //tlso.selectLocation(pkg); wizard.finish(); }catch (Exception e) { if(wizard != null) wizard.cancel(); e.printStackTrace(); if(e instanceof org.netbeans.jemmy.TimeoutExpiredException) { fail("Wizard window not opened."); }else { fail("Exception during handling Templatre=true"); } } checkResultOfFromTemplateCreation(pkg + iSep + "Servlet"); } public void testPropertiesWebModule () { String node = pkg + iSep + propsServlet; JavaNode node1 = null; try { node1 = new JavaNode(node); node1.select(); }catch(Exception e) { e.printStackTrace(); fail("Please check, that all mounts are done properly"); } new PropertiesAction().perform(node1); PropertySheetOperator pso = new PropertySheetOperator(PropertySheetOperator.MODE_PROPERTIES_OF_ONE_OBJECT, propsServlet); PropertySheetTabOperator psto = new PropertySheetTabOperator(pso); ComboBoxProperty pr = new ComboBoxProperty(psto, pnameWebModule); if(!pr.getValue().equals(webModule)) { pso.close(); fail("Default value in properties is wrong. "); } //TODO: Check for list of modules pso.close(); } private void checkResultOfFromTemplateCreation(String explorerPath) { String name = explorerPath.substring(explorerPath.lastIndexOf(iSep)+1); //1)Check that it is created RepositoryNodeWaitable rnw = new RepositoryNodeWaitable(explorerPath); Waiter w1 = new Waiter(rnw); try { w1.waitAction(rnw); } catch (Exception e) { e.printStackTrace(); fail("Listener node not created in repository"); } //2)Check that it is opened in the editor EditorPageWaitable epw = new EditorPageWaitable(name); Waiter w = new Waiter(epw); try { w.waitAction(epw); } catch (Exception e) { e.printStackTrace(); fail("Not opened in editor"); } epw.getEditorOperator().close(false); //Close opened file //3)Check that code is "compilable" JavaNode node1 = new JavaNode(explorerPath); node1.compile(); isFail(Utils.checkResultOfJavaFileCompilation(explorerPath)); } private void isFail(String res) { if(res != null) { fail(res); } } private void click(String node, int count) { JTreeOperator to = new RepositoryTabOperator().tree(); to.clickOnPath(to.findPath(node, "|"), count); } static { try { pnameName = Bundle.getString("org.openide.loaders.Bundle", "PROP_name"); pnameTemplate = Bundle.getString("org.openide.loaders.Bundle", "PROP_template"); pnameWebModule = Bundle.getString("org.netbeans.modules.web.core.jsploader.Bundle" ,"PROP_item_name"); pnameURI = Bundle.getString("org.netbeans.modules.web.core.jsploader.Bundle" ,"PROP_URITitle"); pnameRP = Bundle.getString("org.netbeans.modules.web.core.jsploader.Bundle" ,"PROP_requestParams"); propertiesText = Bundle.getStringTrimmed("org.openide.actions.Bundle", "Properties"); }catch(Exception e) { e.printStackTrace(); fail("Error during static initialization"); } } } |
... 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.