TS 71 JavaEditor

Java Editor

Author:Jiri Prox
Version:7.1
Last update:2011/09/27
Introduction:

Contents

Test suite: Start New Line and Split Line

Setup: Type String str = "abcde 123456"; inside a method's body

  1. Smart Enter inside strings
    1. Move caret behind the "abcde"
    2. Press Enter
    • EXPECTED RESULT: If Enter is pressed inside of a string, the string is smartly divided using '+' operator above strings so that there are no errors in code
      Other info:
      - indentation works normally
      - all white characters are preserved
      - caret is moved behind the opening quote
  2. Undo,Redo and a smart Enter
    1. Follow previous testcase
    2. Invoke Undo and Redo several times
    • EXPECTED RESULT: Undo and Redo is working properly.
  3. Start new line
    1. Move the caret behind "abcde"
    2. Press Shift+Enter.
  4. Undo/Redo start new line
    1. Try to use Undo and Redo
    • EXPECTED RESULT: Undo/Redo works properly.
  5. Split line
    1. Move caret behind "abcde"
    2. Press Ctrl+Enter
  6. Undo/Redo split line
    1. Try to use Undo and Redo
    • EXPECTED RESULT: Undo/Redo works properly

Test suite: Erroneous Code

  1. Show tooltip
    1. Paste this incorrect field declaration inside a class body: public private int a0;
    2. Hover with mouse cursor over error annotation mark in gutter for a while (wait for tooltip to appear).
    3. Place caret on marked line and press Alt+Enter
    • EXPECTED RESULT:
      - Erroneous code should be underlined
      - A red annotation mark shows up in the gutter
      - A tooltip should be displayed after you hover above the annotation mark and after you press Alt+Enter, tooltip contains error "Illegal combination of modifiers: private and public"
  2. Cycling through annotations
    1. Use the incorrect field declaration public private int a0; from the previous test case
    2. Place caret on the line with the incorrect code and press Ctrl+F8 (toggle breakpoint→breakpoint is inserted)
    3. Press Ctrl+Shift+M (toggle bookmark→bookmark is inserted)
    4. You should see a little arrow by the annotation in the gutter - click it a few times
    5. Press Ctrl+F8 (toggle breakpoint→breakpoint is removed)
    6. Press Ctrl+Shift+M (toggle bookmark→bookmark is removed)
    • EXPECTED RESULT: The arrow is used for cycling among multiple annotations, so that you can see all annotations. In this case there should be 3 annotations: the bookmark, the breakpoint and error annotation.

Test suite: Java Abbreviations

Purpose:

Setup:

    1. Check if abbreviations work properly (you can check the list of all abb. in main window, Tools|Options| Editor| Code Templates)
    2. Try using of abbreviation inside comments
    3. Try abbrev inside string literal
    • EXPECTED RESULT: Abbreviation should work inside comments and strings literal as well
  1. Adding Abbreviation
    1. Add an abbreviation using Tools|Option|Editor, select Java Language, click on New.
    2. In the "Abbreviation:" field, fill "myabb" in, confirm , and type "System.out.println("myAbbreviation");" inside text area labeled "Expanded Text:" for newly created abbreviation.
    3. Close options
    • EXPECTED RESULT: The 'myabb' abbrev should be replaced by 'System.out.println("myAbbreviation");'
  2. Change Abbreviation
    1. Change name of an abbreviation
    2. Change its text
    3. Try using this altered abbreviation
    • EXPECTED RESULT: Name and text should be altered properly
  3. Remove Abbreviation
    1. Remove some abbreviations from the abbreviations list
    2. Try to use them in editor
    • EXPECTED RESULT: All abbreviations should be deleted properly.
  4. Abbreviation With Cursor
    1. Add an abbreviation with cursor position specified. (e.g the expanded text contains '${cursor}' text )
    • EXPECTED RESULT: Abbrev should be inserted properly, with caret positioned on place specified in its description.
  5. Abbreviation - Negative cases
    1. Try to add an abbreviation with existing name
    • EXPECTED RESULT: User is informed that abbreviation with this name already exists and action is blocked

Test suite: Code Templates

Purpose: Tests the code templates functionality inside NetBeans editor.

Setup: Opened any file in editor and focus should be in editor window.

  1. Code Template Invocation from Abbreviation
    1. Type into editor "fori".
    2. Press tab.
    • EXPECTED RESULT: Code template for the for() cycle with iteration variable i should appear.
  2. Code Template Invocation from Code Completion
    1. Type into editor "for".
    2. Press Ctrl-Space to invoke code completion.
    • EXPECTED RESULT: Several variants of for cycle should appear (over array and over collection). It is possible to choose one of them and cycle using tab through the editable fields.
  3. Traversing through Code Templates
    1. Invoke the fori code template.
    2. Cycle through the editable fields by pressing Tab.
    3. Cycle back through editable fields by pressing Shift-Tab.
    4. Try to edit various fields from code template.
    5. Once outside code template try to edit the code inside the for cycle.
    • EXPECTED RESULT: It should be possible to cycle through the template in both directions. Editing should work properly and shared variable should be changed in all appropriate places.
  4. Defining Custom Code Templates
    1. Open new Options dialog and go to Editor | Code Templates.
    2. Add a code template called forx with code: TBD
    3. Try to invoke the new code template by both code completion and as an abbreviation.
    • EXPECTED RESULT: In both cases the template should be filled in and should work properly.
  5. Code Template Keywords
    1. Try to create a custom code template.
    2. Use any abbreviations and take advantage of as many parameters as possible. Parameters are described here: http://editor.netbeans.org/doc/UISpecs/CodeTemplates/spec.html
    • EXPECTED RESULT: Newly defined code templates work properly. All parameters work as expected.
  6. Standard Abbreviations
    1. Type into editor "wh" and press Ctrl-Space to invoke code completion.
    2. Try invoking all available abbreviations from code completion.
    3. Try all these abbreviations by typing the abbreviation and pressing tab.
    • EXPECTED RESULT: All abbreviations should be filled in properly.
  7. Types in code templates
    1. Declare 3 arrays - a1 of type String, a2 of type Integer and a3 of different type
    2. Below declaration type fori and press key for expanding code template -> the name of one array is inserted into teplate
    3. Press tab to get to array name and change to to different existing name (a3 -> a2, etc...) -> the template is changed, reflecting type of arrays element
    4. Change the array name to non-existing name or not compatible type -> cast is added
    • EXPECTED RESULT: Results are inline.
  8. Change Expand key
    1. Open Tools -> Editor -> Code Templates
    2. Change Expand Key to space
    • EXPECTED RESULT: The abbreviations are now expanded by space and not tab
  9. Block templates
    1. Select part of code (have to be complete statement, e.g. one line inside method body)
    2. Press alt-enter
    3. Select some template and confirm by enter
    • EXPECTED RESULT: The selected code is wrapped by specific template
  10. Block templates - custom template
    1. Create new template containing ${selection}, define description for it
    2. Select part of code (needn't to be complete statement as in previous test case)
    3. Press alt-enter
    4. Select new template and confirm by enter
    • EXPECTED RESULT: The selected code is wrapped by specific template

Test suite: Commenting code

  1. Toggle line comment
    1. Open any java file
    2. Try to comment and uncomment several lines by pressing CTRL+'/'
    • EXPECTED RESULT:
      - The selected lines should be commented by //.
      - If only commented lines are selected the action will uncomment them.
  2. Comment/Uncomment line
    1. Try to comment/uncomment lines using comment and uncomment buttons in editor toolbar
    • EXPECTED RESULT: Comment button should add '//' at the beginning of line, the uncomment button will remove it.

Test suite: Error stripe

Purpose: Error stripe is stripe right to the editor, it provides quick status of the opened file (small color box at the top of the error stripe) and highlights significant lines (lines with error, bookmark, caret position). It also provides quick navigation to the highlighted lines.

Setup: Opened any java file in editor

  1. File is OK
    1. Open java file without any errors or warnings.
    2. Remove all bookmarks, breakpoints, mark occurrences etc...
    • EXPECTED RESULT: The status box is green, the error stripe
  2. File with errors
    1. Open java file from the previous testcase
    2. Add code with warning (e.g. override toString method w/o @Override annotatino)
    3. Add another warning (e.g unused import)
    4. Add some code with error
    5. Remove all warnings/errors
    • EXPECTED RESULT: When file contains warning the status box is yellow, in the error stripe is yellow mark. When there is error in the file the status box is red and there is red mark in the errors stripe. Whenever mouse is hovering over the status box the info about status is shoew (e.g. "1 error(s) 2 warning(s)"). After removing the
  3. Caret position
    1. Open file which is longer than editor window
    2. Try scroll to beginning and end of the document (by arrows, pg up/down and scroll wheel)
    • EXPECTED RESULT: The caret symbol in error stripe (thin line with little square in the middle) moves to proper places when scrolling. When the caret is in the beginning of the document the symbol is in the top of error stripe, when the caret is at the end, the symbol is at the bottom.
  4. Error stripe navigation
    1. Open java file
    2. Put several bookmarks in the file and/or use mark occurrences feature
    3. Click on marks in error stripe
    • EXPECTED RESULT: The file is scrolled to show related place in editor, when hovering over the mark the mouse cursor is changed to tooltip informs about the type of the mark
  5. Error stripe navigation
    1. Open java file
    2. Put bookmark in it
    3. Put break point in it
    4. Add code with warning
    5. Add code with error
    6. Change line, add line, remove some lines (if the document is under version control)
    7. Turn on mark occurrences and put cart over identifier with more occurrences
    • EXPECTED RESULT: All this actions adds mark in error stripe, these marks differ by color - errors are red, warnings yellow, bookmarks dark gray, changed lines blue, removed lines ping, new lines green, etc...

Test suite: Java Macros

Purpose:

Setup:

  1. Create Macro
    1. Start macro recording (Ctrl+J S or from editor toolbar)
    2. Write some text in editor, move cursor and try to invoke some formatting actions (Shift Line, Comment etc.)
    3. Finish recording macro (Ctrl+J E or in editor toolbar)
    4. Inside appeared dialog, type new macro's name and choose some keybindings for it.
    5. Open java source file into editor and try using new macro's keybinding.
    • EXPECTED RESULT: Macro should be added to the list and properly works.
  2. Create Macro in Options
    1. Open Tools|Options|Editor|Macros
    2. Click to Add button and create new macro
    3. Set shortcut for the new macro
    4. Open Tools|Options|Editor|Macros
    5. Change the shortcut of macro created in previous testcase to Alt-P
    6. Change the shortcut of macro created in previous testcase to Alt-M (or other free shortcut)
    • EXPECTED RESULT: User is warned if trying to set already used shortcut. The shortcut is changed after 3. step and macro can be invoked by new shortcut in editor (the old one is not working any more)
   
}}

Test suite: Line tools

Purpose: This suite tests tool for manipulating with whole line or several lines.

Setup: Opened any file in editor

  1. Move one line
    1. Put caret in document
    2. Press Alt-(Shift)-Up / Alt-(Shift)-Down (Netbeans 6.0 use Shift, NB 5.5 don't)
    • EXPECTED RESULT: Actual line is moved one line up/down
  2. Move selection
    1. Put caret in document
    2. Select several lines
    3. Press Alt-Up / Alt-Down
    • EXPECTED RESULT: Whole selected block (including the lines which are not selected whole but at least partially) is moved
  3. Copy line
    1. Put caret in document
    2. Press Ctrl-Shift-Up / Ctrl-Shift-Down
    • EXPECTED RESULT: The actual line is duplicated below/above current line
  4. Copy block
    1. Put caret in document
    2. Select several lines
    3. Press Ctrl-Shift-Up / Ctrl-Shift-Down
    • EXPECTED RESULT: The whole selection (including whole partly selected lines) is duplicated below/above current selected block

Test suite: Smart Brackets

  1. Smart pairs
    1. Type private String[[ in body of class
    2. Push Backspace key
    3. Type private String S = new String( in body of class
    4. Push Backspace key
    5. Type if((11=11) & (2==3|) in an empty body of a method (place caret as suggested by '|')
    6. Press ')' key twice
    • EXPECTED RESULT:
      - When you press ')' for the first time, a new bracket is inserted after '3', so that brackets are correctly balanced. When you press ')' for the second time, the bracket is skipped (again - in order to keep number of closing/opening brackets balanced).
  2. Enter after opening curly bracket
    1. Move caret inside a method.
    2. Type if (true) {
    3. Push Enter key
    • EXPECTED RESULT: The closing bracket should be added automatically and indented properly
  3. Undo with bracket completion
    1. Try to Undo actions from previous test cases.
    • EXPECTED RESULT: Undo is working exactly in the opposite direction for all of these actions.
  4. Brackets highlighting
    1. Type in editor: if(true) {

      }
    2. Put caret just behind the some of the closing bracket - '}', ')' or ']'
    3. Press Ctrl+'[['
    4. Repeat with other types of brackets
    • {{result|EXPECTED RESULT: The matching bracket is highlighted, shortcut Ctrl-'[[' moves caret to matching bracket. }}

Test suite: Syntax Coloring

Purpose: This suite test syntax highlighting.

  1. Class Members
    1. Open class coloring.Colors from sample project
    2. Check coloring of class members
    • EXPECTED RESULT: Image:members_TS_70_Java.png
  2. Static Members
    1. Open class coloring.Colors2 from sample project
    2. Check coloring of static members
    3. Delete static keyword
    4. Open class coloring.ColorsPrivateUnused from sample project
    5. Check colors
    6. Replace modifier private with other modifier and put the change back
    7. Write method which uses private members
    • EXPECTED RESULT: The private unused members are gray underlined. It the member is used or changed to non-private it gets its original color (as shown in previous two testcases)
  3. Method Parameters and Variables
    1. Open class coloring.ColorsParameters from sample project
    2. Check colors
    3. Try to make unused variables and parameters used and vice versa
    • EXPECTED RESULT: Image:parameters_TS_70_Java.png
  4. Unused Imports
    1. Open class coloring.Imports from sample project
    2. Make sure that hints are turned off (Tools -> Options -> Editor -> Hints -> Import -> Unused Import) otherwise the underline color will be yellow - default color for fixable hints
    3. Check colors
    • EXPECTED RESULT: Unused imports are gray underlined
  5. Javadoc Colors
    1. Open class coloring.JavaDoc from sample project
    2. Check colors
    • EXPECTED RESULT: Image:javadoc_TS_70_Java.png

Test suite: Camel case setting

Purpose: This suite test camel case navigation in java editor
Setup:

  1. Jump next/prev
    1. Open java class in editor and type DefaultTableModel s;
    2. Use ctrl-left/right to jump over the declaration
    3. In options disable 'Enable Camel Case Navigation for Java' (Options->Editor->General)
    • EXPECTED RESULT: When options is enabled the cursor jumps also between upper case letter in identifier. If it is of the cursor jump among whole words only.
  2. Delete next/prev
    1. Put cursor in the middle of 'DefaultTableModel'
    2. Use ctrl-delte/backspace
    3. In options toggle 'Enable Camel Case Navigation for Java' (Options->Editor->General)
    • EXPECTED RESULT: The part for current position to next/prev upper case letter is deleted when the option is enabled, the patr to the end/beginning of word is deleted when the option is off.

Test suite: Fix Imports

Purpose:

Setup:

  1. Simple Fix Import
    1. Open fiximports.FixImports from the sample project
    2. Delete all import statements
    3. Call Fix Imports (context menu or Ctrl-Shift-I)
    4. Select right classes in comboboxes and confirm
    • EXPECTED RESULT: 3 imports are properly added, one import is marked as <cannot be resolved> in the dialog. Correct the typo from FireReader to FileReader and try it again. All class can be resolved now.
  2. Unresolved Class
    1. Open fiximports.FixImports from the sample project
    2. Add line LoremIpsumDolorSitAmet variable;
    3. Call Fix Import
    • EXPECTED RESULT: The dialog contains <cannot be resolved>
  3. Fast Import
    1. Open fiximports.FixImports from the sample project
    2. Delete all import statements
    3. Put caret on unresolved symbol and press Alt-Shift-I
    4. Select required class from list and confirm by Enter
    • EXPECTED RESULT: Selected class is imported
  4. Fast Import - package
    1. Open fiximports.FixImports from the sample project
    2. Delete all import statements
    3. Put caret on unresolved symbol and press Alt-Shift-I
    4. Select required class from list and confirm by Alt-Enter
    • EXPECTED RESULT: Whole package is imported
  5. Fast Import - FQN
    1. Open fiximports.FixImports from the sample project
    2. Delete all import statements
    3. Put caret on unresolved symbol and press Alt-Shift-I
    4. Select required class from list and confirm by Shift-Enter
    • EXPECTED RESULT: The identifier is replaced with FQN
  6. Fix Import Hint
    1. Open fiximports.FixImports from the sample project
    2. Delete all import statements
    3. At each line with unresolved symbol use hint to add import statement
    • EXPECTED RESULT: All imports are added
  7. Popup
    1. Open new file, type 'File f;'
    2. press Alt-Shift-I
    3. put caret on line with File and press space
    • EXPECTED RESULT: Combobox popup is expanded

Test suite: Mark Occurrences

Purpose:

Setup:

  1. Show Usages
    1. Open occurrences.MarkOccurrences from the sample project
    2. Put cursor on name of variable/field/method/parameter (eg. variable on line 40, field on line 31, method on line 33, param on line 33)
    • EXPECTED RESULT: All occurrences of selected element is highlighted in editor and error stripe.
  2. Return Points
    1. Open occurrences.MarkOccurrences from the sample project
    2. Put caret on return type of method at line 33
    3. Put caret on exception in throws clause statement at line 33
    • EXPECTED RESULT: In step 2 all exit point from method are highlighted (4 occurrences). In next step only places where the selected exception is thrown are highlighted (2 occurrences).
  3. Show Usages - Class
    1. Open occurrences.MarkOccurrences from the sample project
    2. Put caret on String at line 31
    • EXPECTED RESULT: All usages of java.lang.String in current class are highlighted
  4. Options - On/Off
    1. Open options and disable Mark Occurrences Of Symbol Under Caret
    2. Go back to editor, put caret on any identifier (method name, class name, field)
    3. Enable MarkOccurrences again
    • EXPECTED RESULT: While MO (Mark Occurrences) is disabled, no occurrences are highlighted.
  5. Mark Occurrences - Types, Methods
    1. Open options and disable Types and Methods
    2. Put caret on line 33 word method or line 31 word String
    3. Enable options again
    • EXPECTED RESULT: Occurrences on lines 31,33, 40 (for class) and 31,44 (for method) are not highlighted when options are disabled
  6. Mark Occurrences - Constant, Fields, Variables
    1. Open options and disable Constants , Fields and Local Variables
    2. Put caret on line 85 word KONST ,on line 31 word field or on line 40 word variable
    3. Enable options again
    • EXPECTED RESULT: No occurrences of actual element is highlighted in step 2
  7. Mark Occurrences - Exceptions, Exit Points
    1. Open options and disable Exceptions Throwing Points
    2. Put caret on line 33 word String
    3. Put caret on line 33 word IOException
    4. Enable the option again and disable Exit Point From Method
    5. Put caret on line 33 word String
    6. Put caret on line 33 word IOException
    7. Enable the option
    • EXPECTED RESULT: In step 2) the editor highlights both exit point from method (return and throw - 4 occurrences). In step 3) occurrences of class IOException are marked (3 occurrences, watch the Keep Marks option). In step 5) all occurrences of String are highlighted (3) and in step 6) 2 places where can be thrown selected exception are marked
  8. Mark Occurrences - Implementing/Overriding methods
    1. Open options and disable Implementing Metohod and Overriding Metohod
    2. Put caret on line 29 word DefaultTableModel or Runnable
    3. Enable the options again and repeat step 2
    • EXPECTED RESULT: When cursor is located over superclass name in extends statement or over implemented interface in implements statement the methods from selected superclass/interface are highlighted. In step 2) this feature is disabled.
  9. Mark Occurrences - Label
    1. Open options and disable Targets of Break and Continue statements
    2. Put caret on words break and continue on lines 63,64 and 65
    3. Enable the option again and repeat step 2)
    • EXPECTED RESULT: When option is ON the label and closing bracket of the related loop is highlighted, e.g. when caret is placed over break on line 74, the label L1 on line 66 and } on line 82 are marked.
  10. Mark Occurrences - Keep marks
    1. Open options and disable Keep Marks
    2. Select several elements, which can be highlighted
    3. Enable the option again and repeat step 2
    • EXPECTED RESULT: When option is disabled the actual mark occurrences marks are discarded when the location of caret is changed, regardless if another highlights are created or not. When enabled, the old marks are removed only in new set of marks is created.
  11. Browsing
    1. Select element which has more occurrences (e.g class String)
    2. Press Alt-Up, Alt-Down
    • EXPECTED RESULT: The caret jumps among the marks

Test suite: Syntax tree selection

Purpose: This suite test selection of upper/lover node in AST
Setup:

  1. Moving to root
    1. Open java class in editor put cursor somewhere in code
    2. Press alt-shift-comma several times
    • EXPECTED RESULT: The selection is enlarge to contain whole parent node in syntax tree -> e.g identifier->method call->block-> method -> class.
  2. Moving to leaf
    1. Just after previous testcase press alt-shift-period
    2. Try to mix this two testcases
    • EXPECTED RESULT: The selection is reduced to lower node in AST. It ends when identifier around original cursor position is selected

Test suite: Node tooltips

Purpose:

Setup:

  1. Contains main method
    1. Create class with main method
    2. Make sure Compile on save is disabled
    3. Edit some file and save it
    4. Compile edited file
    5. Make an error in the class and save it
    6. Correct the error
    • EXPECTED RESULT: The class containing the error is marked with the error badge, the badge is propagated to package, source root and project. The tooltis says 'Error parsing file' for file, and 'Contains files with error' for the other nodes. Once the error is corrected the badges disappears


}}

Test suite: Miscellaneous

Purpose: This test minor features

  1. Add semicolon
    1. Open java file
    2. On non-empty line press ctrl-;
    3. On non-empty line press ctrl-shift-;
    • EXPECTED RESULT: The ';' is added to the end of line, in the second case the cursor is also moved to next line


Not logged in. Log in, Register

By use of this website, you agree to the NetBeans Policies and Terms of Use. © 2012, Oracle Corporation and/or its affiliates. Sponsored by Oracle logo