|
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.compilation; import org.netbeans.jellytools.actions.BuildAction; import org.netbeans.jellytools.actions.BuildAllAction; import org.netbeans.jellytools.actions.CleanAction; import org.netbeans.jellytools.actions.CleanAllAction; 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.web.test.nodes.ServletNode; import org.netbeans.jellytools.JellyTestCase; import org.netbeans.jellytools.Bundle; import org.netbeans.junit.NbTestSuite; import org.netbeans.web.test.util.Utils; public class Compilation extends JellyTestCase { private static String propertiesText = null; private static String executionTabName = null; private static String compilerPropName = null; private static String externalCompilationValue = null; private static String internalCompilationValue = null; private static String wmName = "wm1"; private static String webInf = "WEB-INF"; private static String classes = "Classes"; private static String defaultPackage = "compilation"; private static String cleanPackage1 = "clean"; private static String cleanPackage2 = "clean2"; private static String buildPackage1 = "buildAll1"; private static String buildPackage2 = "buildAll2"; private static String servlet = "Servlet_0"; private static String servlet1 = "Servlet_1"; private static String servlet2 = "Servlet_2"; private static String servlet3 = "Servlet_3"; private static String servlet4 = "Servlet_4"; private static String servlet5 = "Servlet_5"; private static String servlet6 = "Servlet_6"; private static String servlet7 = "Servlet_7"; private static String servlet8 = "Servlet_8"; private static String bServlet1 = "Builded_1"; private static String bServlet2 = "Builded_2"; private static String bServlet3 = "Builded_3"; private static String bServlet4 = "Builded_4"; private static String bServlet5 = "Builded_5"; private static String bServlet6 = "Builded_6"; private static String servletForClean = "ServletForClean"; private static String servletForBuildViaToolbar = "ServletForBuildViaToolbar"; private static String servletForDontCompile = "ServletForDontCompile"; 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 String pkgForClean1 = null; private static String pkgForClean2 = null; private static String pkgForBuild1 = null; private static String pkgForBuild2 = null; private static boolean first = true; public Compilation(String testName) { super(testName); } /** Use for execution inside IDE */ public static void main(java.lang.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; pkgForClean1 = webModule + iSep + webInf + iSep + classes + iSep + cleanPackage1; pkgForClean2 = webModule + iSep + webInf + iSep + classes + iSep + cleanPackage2; pkgForBuild1 = webModule + iSep + webInf + iSep + classes + iSep + buildPackage1; pkgForBuild2 = webModule + iSep + webInf + iSep + classes + iSep + buildPackage2; 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(Compilation.class); } public void testCleanViaMain() { String node = pkg + iSep + servletForClean; try { new ServletNode(node).select(); }catch(Exception e) { e.printStackTrace(); fail("Please check, that all mounts are done properly"); } cleanViaMain(node); isFail(Utils.checkResultOfJavaFileClean(node)); } public void testCleanAllViaMain() { try { new FolderNode(pkgForClean1).select(); }catch(Exception e) { e.printStackTrace(); fail("Please check, that all mounts are done properly"); } cleanAllViaMain(pkgForClean1); isFail(Utils.checkResultOfCleanAll(pkgForClean1)); } public void testBuildAllViaMain() { try { new FolderNode(pkgForBuild1).select(); }catch(Exception e) { e.printStackTrace(); fail("Please check, that all mounts are done properly"); } buildAllViaMain(pkgForBuild1); isFail(Utils.checkResultOfBuildAll(pkgForBuild1)); } public void testExternalViaMain() { String node = pkg + iSep + servlet; try { new ServletNode(node).select(); }catch(Exception e) { e.printStackTrace(); fail("Please check, that all mounts are done properly"); } selectExternalCompilation(node); compileViaMain(node); isFail(Utils.checkResultOfJavaFileCompilation(node)); } public void testExternalViaPopup() { String node = pkg + iSep + servlet1; try { new ServletNode(node).select(); }catch(Exception e) { e.printStackTrace(); fail("Please check, that all mounts are done properly"); } selectExternalCompilation(node); compileViaPopup(node); isFail(Utils.checkResultOfJavaFileCompilation(node)); } public void testExternalViaHotKey() { String node = pkg + iSep + servlet2; try { new ServletNode(node).select(); }catch(Exception e) { e.printStackTrace(); fail("Please check, that all mounts are done properly"); } selectExternalCompilation(node); compileViaHotKey(node); isFail(Utils.checkResultOfJavaFileCompilation(node)); } public void testBuildExternalViaMain() { String node = pkg + iSep + bServlet1; try { new ServletNode(node).select(); }catch(Exception e) { e.printStackTrace(); fail("Please check, that all mounts are done properly"); } selectExternalCompilation(node); buildViaMain(node); isFail(Utils.checkResultOfJavaFileCompilation(node)); } public void testBuildExternalViaHotKey() { String node = pkg + iSep + bServlet2; try { new ServletNode(node).select(); }catch(Exception e) { e.printStackTrace(); fail("Please check, that all mounts are done properly"); } selectExternalCompilation(node); buildViaHotKey(node); isFail(Utils.checkResultOfJavaFileCompilation(node)); } /* Internal section */ public void testInternalViaMain() { String node = pkg + iSep + servlet3; try { new ServletNode(node).select(); }catch(Exception e) { e.printStackTrace(); fail("Please check, that all mounts are done properly"); } selectInternalCompilation(node); compileViaMain(node); isFail(Utils.checkResultOfJavaFileCompilation(node)); } public void testInternalViaPopup() { String node = pkg + iSep + servlet4; try { new ServletNode(node).select(); }catch(Exception e) { e.printStackTrace(); fail("Please check, that all mounts are done properly"); } selectInternalCompilation(node); compileViaPopup(node); isFail(Utils.checkResultOfJavaFileCompilation(node)); } public void testInternalViaHotKey() { String node = pkg + iSep + servlet5; try { new ServletNode(node).select(); }catch(Exception e) { e.printStackTrace(); fail("Please check, that all mounts are done properly"); } selectInternalCompilation(node); compileViaHotKey(node); isFail(Utils.checkResultOfJavaFileCompilation(node)); } public void testBuildInternalViaMain() { String node = pkg + iSep + bServlet3; try { new ServletNode(node).select(); }catch(Exception e) { e.printStackTrace(); fail("Please check, that all mounts are done properly"); } selectInternalCompilation(node); buildViaMain(node); isFail(Utils.checkResultOfJavaFileCompilation(node)); } public void testBuildInternalViaHotKey() { String node = pkg + iSep + bServlet4; try { new ServletNode(node).select(); }catch(Exception e) { e.printStackTrace(); fail("Please check, that all mounts are done properly"); } selectInternalCompilation(node); buildViaHotKey(node); isFail(Utils.checkResultOfJavaFileCompilation(node)); } //Private methods private void selectExternalCompilation(String node) { String servlet = node.substring(node.lastIndexOf(iSep)+1); ServletNode node1 = new ServletNode(node); node1.select(); new PropertiesAction().perform(node1); PropertySheetOperator pso = new PropertySheetOperator(PropertySheetOperator.MODE_PROPERTIES_OF_ONE_OBJECT, servlet); PropertySheetTabOperator psto = pso.getPropertySheetTabOperator(executionTabName); ComboBoxProperty pr = new ComboBoxProperty(psto, compilerPropName); pr.setValue(externalCompilationValue); pso.close(); } private void selectInternalCompilation(String node) { String servlet = node.substring(node.lastIndexOf(iSep)+1); ServletNode node1 = new ServletNode(node); node1.select(); new PropertiesAction().perform(node1); PropertySheetOperator pso = new PropertySheetOperator(PropertySheetOperator.MODE_PROPERTIES_OF_ONE_OBJECT, servlet); PropertySheetTabOperator psto = pso.getPropertySheetTabOperator(executionTabName); ComboBoxProperty pr = new ComboBoxProperty(psto, compilerPropName); pr.setValue(internalCompilationValue); pso.close(); } private void compileViaMain(String node1) { try { ServletNode node = new ServletNode(node1); node.select(); new CompileAction().performMenu(node); }catch(Exception e) { e.printStackTrace(); fail("Exception while try to compile servlet via Main menu: " + e); } } private void compileViaPopup(String node1) { try { new CompileAction().performPopup(new ServletNode(node1)); }catch(Exception e) { e.printStackTrace(); fail("Exception while try to compile servlet via Popup menu: " + e); } } private void compileViaHotKey(String node1) { try{ ServletNode node = new ServletNode(node1); node.select(); new CompileAction().performShortcut(node); }catch(Exception e) { e.printStackTrace(); fail("Exception while try to compile servlet via Hotkey: " + e); } } private void buildViaHotKey(String node1) { try{ ServletNode node = new ServletNode(node1); node.select(); new BuildAction().performShortcut(node); }catch(Exception e) { e.printStackTrace(); fail("Exception while try to compile servlet via Hotkey: " + e); } } private void buildViaMain(String node1) { try { ServletNode node = new ServletNode(node1); node.select(); new BuildAction().performMenu(node); }catch(Exception e) { e.printStackTrace(); fail("Exception while try to compile servlet via Main menu: " + e); } } private void cleanViaMain(String node1) { try { ServletNode node = new ServletNode(node1); node.select(); new CleanAction().performMenu(node); }catch(Exception e) { e.printStackTrace(); fail("Exception while try to clean servlet via Main menu: " + e); } } private void cleanAllViaMain(String pkg) { try { ServletNode node = new ServletNode(pkg); node.select(); new CleanAllAction().performMenu(node); }catch(Exception e) { e.printStackTrace(); fail("Exception while try to clean all in " + pkg + " via Main menu: " + e); } } private void buildAllViaMain(String pkg) { try { ServletNode node = new ServletNode(pkg); node.select(); new BuildAllAction().performMenu(node); }catch(Exception e) { e.printStackTrace(); fail("Exception while try to build all in " + pkg + " via Main menu: " + e); } } /*Other private methods */ private void isFail(String res) { if(res != null) { fail(res); } } private void wa() { try { Thread.sleep(5000); }catch(Exception e) { } } static { try { propertiesText = "Properties"; //NOI18N executionTabName = "Execution"; //NOI18N compilerPropName = Bundle.getString("org.openide.compiler.Bundle", "PROP_compilerType"); externalCompilationValue = Bundle.getString("org.netbeans.modules.java.Bundle","Services/CompilerType/JavaExternalCompiler.settings"); internalCompilationValue = Bundle.getString("org.netbeans.modules.java.Bundle","Services/CompilerType/JavaInternalCompiler.settings"); }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.