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-2002 Sun
 * Microsystems, Inc. All Rights Reserved.
 */

package org.netbeans.test.gui.web.JSPServletDebug;  

import java.io.File;
import java.awt.event.InputEvent;

import org.netbeans.junit.NbTestSuite; 
import org.netbeans.junit.NbTestCase; 
import junit.framework.Test;
import junit.framework.TestSuite;

import org.netbeans.jellytools.ExplorerOperator; 
import org.netbeans.jellytools.EditorOperator; 
import org.netbeans.jellytools.EditorWindowOperator; 
import org.netbeans.jellytools.JellyTestCase;
import org.netbeans.jellytools.MainWindowOperator;
import org.netbeans.jellytools.nodes.FilesystemNode;
import org.netbeans.jellytools.nodes.FormNode;

import org.netbeans.jemmy.operators.JPopupMenuOperator;

import org.netbeans.web.test.actions.AddBreakpointAction;
import org.netbeans.jellytools.actions.CompileAllAction;

import org.netbeans.test.gui.web.util.CompilationUtils;
import org.netbeans.web.test.util.Utils;



import org.netbeans.jellytools.Bundle;
import org.netbeans.jellytools.NbDialogOperator;
import org.netbeans.jemmy.operators.JComboBoxOperator;
import org.netbeans.jemmy.operators.JTextFieldOperator;


/**
 * Collection of tests corresponding "Java-Breakpoints for generated servlet" part of JSP/Servlet Debug specification.
 * @author Vladimir Strigun
 */
public class JavaBreakpoints extends JellyTestCase { 

    private static ExplorerOperator explorer= null;
    private EditorOperator editor = null;
    private static String workDir = null;
    private static String webModule = null;
    private static String wmName = "wm";
    private static String testWMDir = "uncompiled";
    public static final String delim = "|";
    private String jsp1 = "jsp1";


    public JavaBreakpoints(String testName) { 
        super(testName); 
    } 

    public static void main(String[] args) {
        junit.textui.TestRunner.run(suite());
    }

    public static Test suite(){
        TestSuite suite = new NbTestSuite(JavaBreakpoints.class);
	workDir = System.getProperty("jspservletdebug.workdir").replace('/', File.separatorChar);
	webModule = workDir + File.separatorChar + wmName;
        workDir = webModule+delim+testWMDir;
        explorer = ExplorerOperator.invoke();
        explorer.selectPageFilesystems();
        FilesystemNode tmpNode = null;
        Utils.handleDialogAfterNewWebModule();
        tmpNode = new FilesystemNode(workDir);
        FormNode fNode = new FormNode(tmpNode, "jsp1");
        (new CompileAllAction()).performMenu();
        String res = CompilationUtils.checkResultOfBuildAll(workDir, testWMDir);
        if(res!=null)
            System.out.println("FAILED: cannot compile all jsp's!!! "+res);

        return suite;
    }



    /** 
        Add Java Breakpoint to current method
    */

    public void testAddBreakpointToMethod() {
        editor = Utils.openFile(workDir, jsp1);
        editor.setCaretPositionToLine(2);
        editor.clickForPopup(100, 30);
        new JPopupMenuOperator().pushMenu("Show code in Servlet", "|");
        EditorWindowOperator editorWindow = new EditorWindowOperator("Servlet for "+jsp1);
        editor = editorWindow.selectPage("Servlet for "+jsp1);
        (new AddBreakpointAction()).performMenu(); 
        Utils.fillAddBreakpointMethod(null, null, null, false);
        if(!Utils.isExplorerItemExist("Debugger|Breakpoints|Method org.apache.jsp."+jsp1+"$jsp._jspService")){
            fail("Breakpoint do not added");
        }
    }


    /**
        Add breakpoint to not-current method
    */

    public void testAddBreakpointToAnyMethod() {
        editor = Utils.openFile(workDir, jsp1);
        editor.setCaretPositionToLine(2);
        editor.clickForPopup(100, 30);
        new JPopupMenuOperator().pushMenu("Show code in Servlet", "|");
        EditorWindowOperator editorWindow = new EditorWindowOperator("Servlet for "+jsp1);
        editor = editorWindow.selectPage("Servlet for "+jsp1);
        (new AddBreakpointAction()).performMenu(); 
        Utils.fillAddBreakpointMethod(null, null, "_jspx_init", false);
        if(!Utils.isExplorerItemExist("Debugger|Breakpoints|Method org.apache.jsp."+jsp1+"$jsp._jspx_init")){
            fail("Breakpoint do not added");
        }
    }


    /**
        Add breakpoint to all methods
    */

    public void testAddBreakpointToAllMethods() {
        editor = Utils.openFile(workDir, jsp1);
        editor.setCaretPositionToLine(2);
        editor.clickForPopup(100, 30);
        new JPopupMenuOperator().pushMenu("Show code in Servlet", "|");
        EditorWindowOperator editorWindow = new EditorWindowOperator("Servlet for "+jsp1);
        editor = editorWindow.selectPage("Servlet for "+jsp1);
        (new AddBreakpointAction()).performMenu(); 
        Utils.fillAddBreakpointMethod(null, null, null, true);
        if(!Utils.isExplorerItemExist("Debugger|Breakpoints|Methods in org.apache.jsp."+jsp1+"$jsp")){
            fail("Breakpoint do not added");
        }
    }


    /**
        Add breakpoint to exception uncaught
    */

    public void testAddBreakpointToExceptionUncaught() {
        editor = Utils.openFile(workDir, jsp1);
        editor.setCaretPositionToLine(2);
        editor.clickForPopup(100, 30);
        new JPopupMenuOperator().pushMenu("Show code in Servlet", "|");
        EditorWindowOperator editorWindow = new EditorWindowOperator("Servlet for "+jsp1);
        editor = editorWindow.selectPage("Servlet for "+jsp1);
        (new AddBreakpointAction()).performMenu(); 
        Utils.fillAddBreakpointException(null, "ArrayIndexOutOfBoundsException", 1);
        if(!Utils.isExplorerItemExist("Debugger|Breakpoints|Exception java.lang.ArrayIndexOutOfBoundsException uncaught")){
            fail("Breakpoint do not added");
        }
    }


    /**
        Add breakpoint to exception caught
    */

    public void testAddBreakpointToExceptionCaught() {
        editor = Utils.openFile(workDir, jsp1);
        editor.setCaretPositionToLine(2);
        editor.clickForPopup(100, 30);
        new JPopupMenuOperator().pushMenu("Show code in Servlet", "|");
        EditorWindowOperator editorWindow = new EditorWindowOperator("Servlet for "+jsp1);
        editor = editorWindow.selectPage("Servlet for "+jsp1);
        (new AddBreakpointAction()).performMenu(); 
        Utils.fillAddBreakpointException(null, "ArrayIndexOutOfBoundsException", 0);
        if(!Utils.isExplorerItemExist("Debugger|Breakpoints|Exception java.lang.ArrayIndexOutOfBoundsException caught")){
            fail("Breakpoint do not added");
        }
    }


    /**
        Add breakpoint to exception caught or uncaught
    */

    public void testAddBreakpointToExceptionCaughtOrUncaught() {
        editor = Utils.openFile(workDir, jsp1);
        editor.setCaretPositionToLine(2);
        editor.clickForPopup(100, 30);
        new JPopupMenuOperator().pushMenu("Show code in Servlet", "|");
        EditorWindowOperator editorWindow = new EditorWindowOperator("Servlet for "+jsp1);
        editor = editorWindow.selectPage("Servlet for "+jsp1);
        (new AddBreakpointAction()).performMenu(); 
        Utils.fillAddBreakpointException(null, "ArrayIndexOutOfBoundsException", 0);
        if(!Utils.isExplorerItemExist("Debugger|Breakpoints|Exception java.lang.ArrayIndexOutOfBoundsException")){
            fail("Breakpoint do not added");
        }
    }


    /**
        Add breakpoint to all exception from one package
    */

    public void testAddBreakpointToExceptionPackage() {
        editor = Utils.openFile(workDir, jsp1);
        editor.setCaretPositionToLine(2);
        editor.clickForPopup(100, 30);
        new JPopupMenuOperator().pushMenu("Show code in Servlet", "|");
        EditorWindowOperator editorWindow = new EditorWindowOperator("Servlet for "+jsp1);
        editor = editorWindow.selectPage("Servlet for "+jsp1);
        (new AddBreakpointAction()).performMenu(); 
        Utils.fillAddBreakpointException(null, "*", 0);
        if(!Utils.isExplorerItemExist("Debugger|Breakpoints|Exception java.lang.ArrayIndexOutOfBoundsException caught")){
            fail("Breakpoint do not added");
        }
    }


    /**
        Add breakpoint to class prepare
    */

    public void testAddBreakpointToClassPrepare() {
        editor = Utils.openFile(workDir, jsp1);
        editor.setCaretPositionToLine(2);
        editor.clickForPopup(100, 30);
        new JPopupMenuOperator().pushMenu("Show code in Servlet", "|");
        EditorWindowOperator editorWindow = new EditorWindowOperator("Servlet for "+jsp1);
        editor = editorWindow.selectPage("Servlet for "+jsp1);
        (new AddBreakpointAction()).performMenu(); 
        Utils.fillAddBreakpointClass(null, null, 0);
        if(!Utils.isExplorerItemExist("Debugger|Breakpoints|Class org.apache.jsp."+jsp1+"$jsp prepare")){
            fail("Breakpoint do not added");
        }
    }


    /**
        Add breakpoint to class unload
    */

    public void testAddBreakpointToClassUnload() {
        editor = Utils.openFile(workDir, jsp1);
        editor.setCaretPositionToLine(2);
        editor.clickForPopup(100, 30);
        new JPopupMenuOperator().pushMenu("Show code in Servlet", "|");
        EditorWindowOperator editorWindow = new EditorWindowOperator("Servlet for "+jsp1);
        editor = editorWindow.selectPage("Servlet for "+jsp1);
        (new AddBreakpointAction()).performMenu(); 
        Utils.fillAddBreakpointClass(null, null, 1);
        if(!Utils.isExplorerItemExist("Debugger|Breakpoints|Class org.apache.jsp."+jsp1+"$jsp unload")){
            fail("Breakpoint do not added");
        }
    }



    /**
        Add breakpoint to class prepare & unload
    */

    public void testAddBreakpointToClassPrepareAndUnload() {
        editor = Utils.openFile(workDir, jsp1);
        editor.setCaretPositionToLine(2);
        editor.clickForPopup(100, 30);
        new JPopupMenuOperator().pushMenu("Show code in Servlet", "|");
        EditorWindowOperator editorWindow = new EditorWindowOperator("Servlet for "+jsp1);
        editor = editorWindow.selectPage("Servlet for "+jsp1);
        (new AddBreakpointAction()).performMenu(); 
        Utils.fillAddBreakpointClass(null, null, 2);
        if(!Utils.isExplorerItemExist("Debugger|Breakpoints|Class org.apache.jsp."+jsp1+"$jsp prepare / unload")){
            fail("Breakpoint do not added");
        }
    }


    /**
        Add breakpoint to thread start
    */

    public void testAddBreakpointToThreadStart() {
        editor = Utils.openFile(workDir, jsp1);
        editor.setCaretPositionToLine(2);
        editor.clickForPopup(100, 30);
        new JPopupMenuOperator().pushMenu("Show code in Servlet", "|");
        EditorWindowOperator editorWindow = new EditorWindowOperator("Servlet for "+jsp1);
        editor = editorWindow.selectPage("Servlet for "+jsp1);
        (new AddBreakpointAction()).performMenu(); 
        Utils.fillAddBreakpointThread(0);
        if(!Utils.isExplorerItemExist("Debugger|Breakpoints|Thread start")){
            fail("Breakpoint do not added");
        }
    }


    /**
        Add breakpoint to thread death
    */

    public void testAddBreakpointToThreadDeath() {
        editor = Utils.openFile(workDir, jsp1);
        editor.setCaretPositionToLine(2);
        editor.clickForPopup(100, 30);
        new JPopupMenuOperator().pushMenu("Show code in Servlet", "|");
        EditorWindowOperator editorWindow = new EditorWindowOperator("Servlet for "+jsp1);
        editor = editorWindow.selectPage("Servlet for "+jsp1);
        (new AddBreakpointAction()).performMenu(); 
        Utils.fillAddBreakpointThread(1);
        if(!Utils.isExplorerItemExist("Debugger|Breakpoints|Thread death")){
            fail("Breakpoint do not added");
        }
    }


    /**
        Add breakpoint to thread start & death
    */

    public void testAddBreakpointToThreadStartAndDeath() {
        editor = Utils.openFile(workDir, jsp1);
        editor.setCaretPositionToLine(2);
        editor.clickForPopup(100, 30);
        new JPopupMenuOperator().pushMenu("Show code in Servlet", "|");
        EditorWindowOperator editorWindow = new EditorWindowOperator("Servlet for "+jsp1);
        editor = editorWindow.selectPage("Servlet for "+jsp1);
        (new AddBreakpointAction()).performMenu(); 
        Utils.fillAddBreakpointThread(2);
        if(!Utils.isExplorerItemExist("Debugger|Breakpoints|Thread start / death")){
            fail("Breakpoint do not added");
        }
    }


    /**
        Add breakpoint to variable modification
    */

    public void testAddBreakpointToVariable() {
        editor = Utils.openFile(workDir, jsp1);
        editor.setCaretPositionToLine(2);
        editor.clickForPopup(100, 30);
        new JPopupMenuOperator().pushMenu("Show code in Servlet", "|");
        EditorWindowOperator editorWindow = new EditorWindowOperator("Servlet for "+jsp1);
        editor = editorWindow.selectPage("Servlet for "+jsp1);
        (new AddBreakpointAction()).performMenu(); 
        Utils.fillAddBreakpointVariable("org.apache.jsp", jsp1+".jsp", "response", -1);
        if(!Utils.isExplorerItemExist("Debugger|Breakpoints|Variable org.apache.jsp."+jsp1+"$jsp.response modification")){
            fail("Breakpoint do not added");
        }
    }


    /**
        Add breakpoint to selected variable
    */

    public void testAddBreakpointToSelectedVariable() {
        editor = Utils.openFile(workDir, jsp1);
        editor.setCaretPositionToLine(2);
        editor.clickForPopup(100, 30);
        new JPopupMenuOperator().pushMenu("Show code in Servlet", "|");
        EditorWindowOperator editorWindow = new EditorWindowOperator("Servlet for "+jsp1);
        editor = editorWindow.selectPage("Servlet for "+jsp1);
        editor.setCaretPositionToLine(48);
        editor.select(48, 13, 23);
        (new AddBreakpointAction()).performMenu(); 
        Utils.fillAddBreakpointVariable(null, null, null, -1);
        if(!Utils.isExplorerItemExist("Debugger|Breakpoints|Variable org.apache.jsp."+jsp1+"$jsp.application modification")){
            fail("Breakpoint do not added");
        }
    }


    /**
        Add breakpoint to variable access
    */

    public void testAddBreakpointToVariableAccess() {
        editor = Utils.openFile(workDir, jsp1);
        editor.setCaretPositionToLine(2);
        editor.clickForPopup(100, 30);
        new JPopupMenuOperator().pushMenu("Show code in Servlet", "|");
        EditorWindowOperator editorWindow = new EditorWindowOperator("Servlet for "+jsp1);
        editor = editorWindow.selectPage("Servlet for "+jsp1);
        (new AddBreakpointAction()).performMenu(); 
        Utils.fillAddBreakpointVariable("org.apache.jsp", jsp1+".jsp", "response", 0);
        if(!Utils.isExplorerItemExist("Debugger|Breakpoints|Variable org.apache.jsp."+jsp1+"$jsp.response access")){
            fail("Breakpoint do not added");
        }
    }


} 





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