FeaturesPluginsDocs & SupportCommunityPartners

JSP Editor Test Specification

Author: Jindrich Sedek
Version: 1.8
Last update: 14.06.2006
Introduction: This document contains procedures for testing JSP editor. The module provides syntax highlighting, indentation, code completion, tag matching, various settings and some more functionality in editor.
Comment: The test specification does not cover JSP documents in XML syntax (*.jspx files).

Table of Contents

Test suite 1: Syntax highlighting

Purpose: This test suite checks that syntax highlighting in JSP editor is correct.
Setup: No preparation is necessary for this test suite.

#Test caseDescription
1JSP syntax highlighting
  1. Use File | New Project... to create new Web Application project located in your home directory.
  2. Right click Libraries node and select Add Library....
  3. Select JSTL 1.1 library and click Add Library button.
  4. Replace contents of index.jsp with this file and compare the colors with this picture.
RESULT: Proper colors should be used. See ui specification
2TAG syntax highlighting
  1. Right click Web Pages node and select New | File/Folder....
  2. Select Web category and Tag File file type and press Next >.
  3. Setup test as Tag File Name and press Finish.
  4. Replace contents of test.tag with this file and compare the colors with this picture.
RESULT: Tag file editor supports exactly the same syntax color highlighting as JSP editor. See previous test case.

Test suite 2: Indentation

Purpose: This test suite checks that auto indentation in JSP editor is working correctly.
Setup: No preparation is necessary for this test suite except having web project open with one JSP and one tag file.

#Test caseDescription
1Basic indentation
  1. Place the cursor at end of index.jsp or test.tag file and press Enter.
  2. Press Tab and type <a>| where | denotes cursor.
  3. End tag </a> should be completed by editor.
  4. Press Enter. New line is created and cursor is indented two TABs right (i.e. 22:9).
RESULT: New line is created and cursor inherits column position of text at previous line. In this case it will be two TABs size indented to right i.e. 22:9.
2Reformat code
  1. In both index.jsp or test.tag editors press CTRL+A.
  2. Press Shift+TAB at least 3 times so that whole text is shifted to left.
  3. Right click in editor area and select Reformat Code from popup menu.
  4. Select a piece of code and press Shift+Tab few times to break the code formating again.
  5. Change the selection to another lines and repeat step 3.
RESULT: The whole source code is reformated according to JSP indentation engine settings. By default, everything inside an element is shifted one TAB to right.
3Scriptlets indentation
  1. Type <% somewhere in both index.jsp and test.tag files to create a scriptlet block.
  2. Type if (true) { and press Enter.
  3. Type switch (age) { and press Enter.
  4. Type case 10: and press Enter.
  5. Type a = b; and press Enter.
  6. Type default: and press Enter.
  7. Type sayHello();
  8. Press Arrow Down twice and type%>to close the scriptlet.
RESULT:
Java code should follow Java indentation engine settings. By default, everything inside { } block or below any line ending with : character should be shifted one TAB to right. On the other hand pressing } should shift current line to left. Here you can see how it should look like:

Test suite 3: Code completion

Purpose: This test suite checks that automatic code completion in JSP editor is working correctly.
Setup: No preparation is necessary for this test suite except having web project open with one JSP and one tag file.

#Test caseDescription
1Directives
  1. Open index.jsp page and type somewhere in the code <%@.
  2. Wait 500 ms or press CTRL+Space to invoke code completion.
  3. 3 directives must be offered: include, page and taglib.
  4. Repeat steps 1 and 2 but with test.tag tag file this time.
RESULT: 5 directives must be offered in tag files: attribute, include, tag, taglib and variable.
2Attributes
  1. Type <%@page | in index.jsp file and invoke code completion.
  2. 13 attributes should be offered initially. Type i which should reduce the list to 5 items including import. Press Enter.
  3. Now you should have <%@page import="|" in the JSP editor.
  4. Repeat steps 1 and 2 in test.tag file with <%@tag | directive.
RESULT: Code completion must offer relevant attributes for directives based on file type and context - used attributes are not suggested again. Specifically, autoFlush, buffer, contentType, errorPage, extends, import, info, isELIgnored, isErrorPage, isThreadSafe, language, pageEncoding and session for page directive and body-content, description, display-name, dynamic-attributes, example, import, isELIgnored, large-icon, language, pageEncoding and small-icon for tag directive.
3Values
  1. Type <%@page isELIgnored="|"%> in index.jsp and press CTRL+Space.
  2. Two options false and true will be suggested. Press Enter to select the first one.
  3. Repeat steps 1 and 2 in test.tag file with <%@tag isELIgnored="|"%>.
RESULT: Where appropriate (i.e. set of attribute values is limited) these values should be offered by code completion.
4Entities
  1. Type & and wait for code completion or press CTRL+Space.
  2. A long list of items will be suggested. Type q character.
  3. This should reduce the list to only 1 suggestion &quot;. Press Enter.
RESULT:&quot; should be automatically completed.
5Page encoding
  1. Type <%@page pageEncoding="|"%> in index.jsp and press CTRL+Space.
  2. List of all known encodings will show up.
  3. Type K which reduces the list to KOI8-R and KOI8-U. Press Enter to select the first one.
  4. Repeat steps 1 and 3 in test.tag file with <%@tag pageEncoding="|"%>.
RESULT: Auto completion must suggest all possible character encodings in both JSP and Tag editors.
6Import
  1. Type <%@page import="|"%> in index.jsp and press CTRL+Space.
  2. Four root packages should be offered initially: com, java, javax and org.
  3. Type o, press Enter and type . char.
  4. Now you should have <%@page import="org.|"%>. Press CTRL+Space again.
  5. This way use code completion to import e.g. org.xml.sax.SAXException class.
  6. Repeat the same in test.tag file with <%@tag import="|"%>.
RESULT: Auto completion must help with selecting any j2se or j2ee package or class as value of import attribute.
7Include
  1. Type <%@include file="|"%> in test.tag and press CTRL+Space.
  2. Only two items show up: ../ and test.tag. Type / char.
  3. Completion suggests META-INF/, WEB-INF/ and index.jsp. Press Enter and CTRL+Space.
  4. Now you should have <%@include file="/META-INF/context.xml|"%>
  5. Repeat the same in index.jsp file with <jsp:include page="|"%>.
RESULT: Code completion allows to select any file as value of file attribute. If path starts with / char, completion should offer files in document root directory (i.e. Web Pages node) whereas path without leading / offers files from the same directory as edited file initially.
8Scriptlets
  1. Type <% String var;
    var.|
    somewhere in both index.jsp and test.tag files.
  2. Press CTRL+Space. Appropriate fields and methogs of java.lang.String class must be suggested.
  3. Type %> <!-- comment --> <% var.| to close the scriptlet and start another one.
  4. Repeat step 2.
  5. Type %> <% "hello".| and press CTRL+Space again.
  6. Repeat step 2.
  7. Type %> <% | and press CTRL+Space again.
RESULT: Implicit objects application, config, out, page, pageContext, request, response and session will show up. Besides normal Java code completion must be provided inside scriptlets. Declared variables must be available across more scriptlet blocks.
9HTML tags
  1. Type < char somewhere in both index.jsp and test.tag files.
  2. Press CTRL+Space to invoke code completion. Type ht which should narrow selection only to 1 item.
  3. Press Enter. This should auto complete <html> tag.
  4. Verify that other HTML tags and their appropriate attributes are available in code completion.
RESULT: Code completion offers all HTML tags like <body>, <table>, <form> etc.
10JSP tags
  1. Type <jsp:| in both index.jsp and press CTRL+Space.
  2. The following JSP tags are offered by default: attribute, body, element, expression, fallback, forward, getProperty, include, param, params, plugin, setProperty, text and useBean.
  3. Repeat step 1 in test.tag file editor.
RESULT: The same set of JSP tags is offered in tag file editor plus two more tags: doBody and invoke.
11Implicit objects
  1. Type <% response.| somewhere in both index.jsp and test.tag files and press CTRL+Space.
  2. Code completion offers relevant fields and methods of javax.servlet.http.HttpServletResponse class.
  3. In both files replace response by session.getServletContext().| and press CTRL+Space again.
RESULT: Code completion offers relevant fields and methods of javax.servlet.ServletContext class.
12Java beans
  1. Type <jsp:useBean id="myDate" scope="request" class="| in both index.jsp and test.tag files and press CTRL+Space.
  2. Java packages and classes will be offered. Use code completion to select java.util.Date and finish the tag by "/>.
  3. Type <% myD| and press CTRL+Space.
  4. myDate will be automatically completed. Type . and press CTRL+Space.
RESULT: Code completion offers all fields and methods of java.util.Date class.
13Declarations
  1. Type <%! | in both index.jsp and test.tag files and press CTRL+Space.
  2. Java packages and classes will be offered except implicit objects.
  3. Type void hello() { this.| and press CTRL+Space.
RESULT: Code completion offers only appropriate fields and methods of servlet i.e. no packages or classes or implicit objects.
14Expressions
  1. Type <%= re| in both index.jsp and test.tag files and press CTRL+Space.
  2. Both request and response are suggested. Press Enter and type .
  3. Press CTRL+Space to invoke code completion.
RESULT: Code completion offers relevant fields and methods of javax.servlet.http.HttpServletRequest class.
15Library tags
  1. Right click Web Pages node and select New | File/Folder....
  2. Select Web category and Tag Library Descriptor... file type and press Next >.
  3. Setup library as TLD Name and press Finish.
  4. Repeat steps 1 and 2 but select Tag File as file type.
  5. Setup example as Tag File Name and check Add Tag File to Tag Library Descriptor option.
  6. Use Browse button to select WEB-INF/tlds/library.tld as TLD File and push Finish.
  7. In example.tag delete lines 9 and 13 to uncomment declaration of attributes. Press CTRL+S.
  8. Type <%@taglib prefix="ex" uri="/WEB-INF/tlds/library.tld"%> in index.jsp.
  9. Type <ex| somewhere below and press CTRL+Space.
  10. It will get expanded to <ex:example|. Press Space and CTRL+Space.
RESULT: Code completion offers three attributes title, author and price_info declared in example.tag tag file.
16Help window
  1. Type <%@| and press CTRL+Space.
  2. Code completion will show up together with help window. Use arrows to browse through items.
  3. Verify that help window displays appropriate description for selected directive. Press Esc.
  4. Press CTRL+Shift+Space which will open help window only.
  5. Press Shift+Arrow Down which will scroll down the contents of help window.
  6. Verify that help window is available for all JSP, custom or HTML tags and their attributes.
RESULT: Help window is opened on each code completion invocation or alone if needed. The contents must be scrollable.

Test suite 4: Code folding

Purpose: This test suite checks that code folding in JSP editor is working correctly.
Setup: No preparation is necessary for this test suite except having web project open with one JSP and one tag file.
test / JspFoldingTest.java

#Test caseDescription
1Folds creation
  1. Open JSP document created in the first test suite.
  2. Type <%! String getBestIDE() {
    return "NetBeans 5.5"; } %>
    somewhere into JSP body.
RESULT: Code folds must be created for all tags occupying more than one line and JSP/HTML comments. Besides, also each directive/scriptlet/declaration section has one fold.
2Folds collapsing
  1. Put cursor somewhere into JSP document and press CTRL+NumPad-.
  2. Verify that current tag fold was collapsed.
  3. Right click editor area and select Code Folds | Collapse Fold from popup menu.
RESULT: Code folds must get collapsed/expanded on appropriate demand via shortcut, menu or mouse click. Collapsed fold is represented by [+] icon and expanded by [-] icon in the stripe next to line numbers. Besides, collapsed fold is replaced by rectangle with appropriate identification e.g. <%@...%> in case of directives. If user moves mouse over the box, window with content of tag fold is displayed.
3Folds actions
  1. Press CTRL+Shift+NumPad- to collapse all folds in JSP document.
  2. Invoke View | Code Folds | Expand All from main menu to see whole file again.
  3. Right click in editor and choose Code Folds | Collapse All Comments from popup menu.
RESULT: All multiline tags or JSP/HTML comments should be collapsed/expanded on appropriate demand.
Comment: Test all 3 test cases both in index.jsp and test.tag files.

Test suite 5: Expression language

Purpose: This test suite checks that expression language support provides code completion, syntax highlighting and hyperlinking.
Setup: No preparation is necessary for this test suite except having web project open with one JSP file.

#Test caseDescription
1Basic code completion
  1. Create new el.jsp JSP file and type <jsp:useBean id="integer" class="java.lang.Integer" scope="page"/> at line 11 and ${ at next new line.
  2. Press CTRL+Space to invoke code completion. Type i to reduce suggestions to two items. Select initParam and press Enter. The statement gets expanded to ${initParam[] and cursor remains between square brackets.
  3. Press CTRL+Z twice to undo previous usage of completion. Press CTRL+Space again and select pageContext item.
  4. In ${pageContext type . (dot). Code completion shows up automatically. Type r, select response and press Enter.
RESULT:The statement is expanded to ${pageContext.response
2Other code completion
  1. Right click your web project root node and select Properties from popup menu. Select Frameworks category node and click Add.... Select Java Server Faces and push OK button twice.
  2. Invoke File|New File... from main menu. Select Web category, JSF Managed Bean file type and push Next >. Type inquiry (with lower case i) into Class Name and Finish buttons.
  3. Expand inquiry.java and inquiry nodes. Right click Bean Patterns and select Add|Property from popup menu. Type name to Name field and push OK.
  4. Right click Methods and select Add Method... from popup menu. Setup Return Type to String and push OK.
  5. Switch to el.jsp editor tab, create new line and type #{i| . Press CTRL+Space. The new JSF bean must be one of the three suggested items.
  6. Select inquiry and press Enter. Type . (dot). Code completion shows up automatically suggesting name property and newMethod method.
  7. Type <%@taglib uri="http://java.sun.com/jsp/jstl/functions" prefix="f"%> at line 12 and ${f:c at next new line. Press CTRL+Space.
RESULT: Code completion offers all functions defined in JSTL tag library starting with c char.

Test suite 6: Miscellaneous

Purpose: This test suite checks that tag matching, hyperlinking and some other small features are working correctly.
Setup: No preparation is necessary for this test suite except having web project open with one JSP and one tag file.

#Test caseDescription
1Tag matching
  1. Place cursor behind some opening tag e.g. <head> at line 6.
  2. Matching end tag (at line 8 in this case) should be highlighted in purple color.
  3. Press CTRL+[ which must move cursor to the </head> closing tag at line 8.
  4. Press CTRL+A and Delete in both index.jsp and test.tag files and type there what you see in the following picture. Verify that matching for all tags and brackets works.
RESULT: When cursor is placed in opening tag, editor highlights corresponding closing tag and vice versa. Besides, it is possible to jump between them via CTRL+[ shortcut.
2Hyperlinking
  1. Hold down CTRL key and move your mouse pointer on WEB-INF/web.xml at line 2.
  2. It will change to hyperlink WEB-INF/web.xml. Click it.
  3. Deployment descriptor web.xml will be opened in editor. Switch back to index.jsp.
  4. Type <jsp:forward page="WEB-INF/tags/example.tag"/> somewhere in index.jsp.
  5. Use this new hyperlink to get to example.tag file.
  6. Type <jsp:include page="../../index.jsp"/> somewhere in example.tag.
  7. Use this new hyperlink to get back to index.jsp file.
  8. Hold down CTRL key and move your mouse pointer on ex:example custom tag. Click the hyperlink.
RESULT: JSP/Tag editor allows by CTRL key to quickly jump to files referenced in the source.
3Go to source
  1. Type <% String str; %> somewhere in the editor of index.jsp.
  2. Hold down CTRL and move your mouse pointer on String. It should change to hyperlink and you can click it.
RESULT:New editor window with source code of String class should be opened.
4Go to declaration
  1. Type <% if (str="") str="HALLO WORLD!"; %> on the last line of index.jsp .
  2. Hold down CTRL and move your mouse pointer on str . It should change to hyperlink and you can click it.
RESULT:The focus should be moved to the declaration of str.
5Abbreviations
  1. Invoke Tools | Options from main menu, click Advanced Options and select Editing | Editor Settings | JSP Editor node.
  2. Click ... button of Abbreviations to invoke it's customizer.
  3. Click Add..., type ext as Abbreviation and <ex:example title=" as Expansion. Push OK button twice and Close.
  4. Press Enter to create new line, type ext and press Space.
  5. It is replaced by <ex:example title=".
  6. Verify that tglb gets expanded to <%@taglib uri=""%>.
RESULT: Editor allows to use predefined and user specified abbreviations in both index.jsp and test.tag files.

Test suite 7: Internationalization

Purpose: This test suite checks that it is possible to use national characters in JSP editor.
Setup: No preparation is necessary for this test suite except having web project open with one JSP and one tag file.

#Test caseDescription
1Attribute pageEncoding
  1. Type <%@page pageEncoding="ISO-8859-2"%> as the first line in both index.jsp and test.tag.
  2. Extend the page tag with info attribute and use some Czech characters in its value e.g.:
  3. Save the file. Close it and Open again.
RESULT: National characters are preserved in JSP file if pageEncoding attribute is set accordingly.
2Attribute contentType
  1. Use contentType="text/html;charset=ISO-8859-2" instead of pageEncoding="ISO-8859-2" in both index.jsp and test.tag files.
  2. Do not modify info attribute and Save the file. Close it and Open again.
RESULT: National characters are preserved in JSP file if contentType attribute is set accordingly.
3Invalid encoding
  1. Replace ISO-8859-2 with ASCII and press CTRL+S.
  2. Warning about possible loss of used characters will show up. Press No.
  3. Change the charset to invalid ASCIII and press CTRL+S again.
  4. Similar warning will show up proposing to save the file using UTF-8 encoding. Press Yes.
  5. Close the file and Open it again.
  6. Question about unknown ASCIII encoding will show up proposing to open file using UTF-8. Press Yes.
  7. Delete whole contentType attribute with its value but leave the info one with Czech characters. Press CTRL+S.
  8. Similar dialog as in step 4 will open but proposing default ISO-8859-1 encoding this time.
RESULT: JSP editor warns user if document contains characters that are not contained in specified encoding. Besides, it suggests to use UTF-8 if unknown charset is declared or ISO-8859-1 if no charset is given at all.

Test suite 8: Development

Purpose: This test suite checks that it is possible to compile JSP, run it, view its servlet or errors.
Setup: No preparation is necessary for this test suite except having web project open with one JSP and one tag file.

#Test caseDescription
1Compile JSP
  1. Use File | New File... to create new test.jsp JSP file.
  2. Replace its content with this file.
  3. Right click Libraries node and select Add Library....
  4. Select JSTL 1.1 and press Add Library button.
  5. Right click editor area of test.jsp and select Run File.
RESULT: The test.jsp file gets compiled, Tomcat is started and once the web application is deployed successfully new browser window opens with Example JSP title and current date printed.
2View servlet
  1. Right click editor area of test.jsp and select View Servlet.
RESULT: Appropriate servlet file opens in editor. In this case it is test_jsp.java located in your home Tomcat subdirectory by default.
3Errors reporting
  1. Replace content of test.jsp file with this file. It contains 8 errors in total.
  2. Invoke Build | Compile "test.jsp" from main menu or press F9 key.
  3. Complain about unterminated page tag will show up in the output window. Click the ...WebApplication1/build/web/test.jsp(2,0) link which takes the cursor to line 2.
  4. Correct the error and repeat step 2.
  5. Go after each error and fix it according to hints mentioned in the comment above the error line.
  6. Once you are done with all errors, right click editor area and select Run File.
RESULT: JSP editor supports error annotations and compile action offers links to appropriate lines in output window. Errors are displayed in status bar and tooltips on particular lines. In the end browser will open with Example JSP title and current date.

Test suite 9: Settings

Purpose: This test suite checks that JSP editor specific settings are working correctly and are persistent.
Setup: No preparation is necessary for this test suite except having web project open with one JSP and one tag file.

#Test caseDescription
1Folding switch
  1. Invoke Tools | Options from main menu.
  2. Select Editor category in the left panel.
  3. Uncheck Use Code Folding option.
  4. Push OK button.
RESULT:An extra stripe for folding widgets gets removed and code can't be folded.
2Completion options
  1. Invoke Tools | Options from main menu.
  2. Select Editor category in the left panel.
  3. Uncheck Auto Popup Completion Window, Insert Single Proposals Automatically and Case Sensitive Code Completion options.
  4. Push OK button.
  5. Type < which does not invoke code completion.
  6. Type j and press CTRL+Space. Code completion suggests all 14 jsp: tags.
  7. Press ESC and type <jsp:u. Press CTRL+Space again.
RESULT: Code completion offers single item jsp:useBean and does not perform instant substitution.
3Indentation
  1. Invoke Tools | Options from main menu.
  2. Select Editor category in the left panel and Indentation tab.
  3. Set Number of Spaces per Indent to 2 and click OK button.
  4. Invoke File | Exit from main menu and restart NetBeans.
  5. Right click editor area and choose Reformat Code from popup menu.
RESULT: Content of index.jsp file is reformated according to new indentation i.e. content of each tag is indented two spaces right.

Generated: 2006 07 20 09:04
Companion
Projects:
MySQL Database Server   Open JDK: an Open SourceJDK   GlassFish Community: an Open Source Application Server    Mobile & Embedded Community    Open Solaris   java.net - The Source for Java Technology Collaboration   Virtual Box - full virtualizer  Open ESB - The Open Enterprise Service Bus Powered by