TS 74 Refactoring

Refactoring Test Specification

Author: Tomáš Tököly, Jiří Prox
Version:
Last update:2013/07/15
Introduction:This document contains some of usual/typical scenarios that can be encountered by user which want to test a refactoring functionality included in the NetBeans IDE. That means Find Usages, Rename, Move Class, Change Method Parameters, Encapsulate Fields, some miscellaneous tests and some tests from JDK 1.5.

Contents

Test suite: Find Usages

Purpose: To verify if this part of refactoring functionality corresponds with design and works right
Setup: Project [media:Default_TS_60_Refactoring.zip default] is needed in this test suite. Scope of all find usages is current project, unless is written something else

  1. Class - Usages
    1. Select org.netbeans.tests.examples.packa.Bean class in the Projects view.
    2. Invoke Find Usages action from the popup menu.
    3. In the dialog select Find Usages choice, unselect other options and confirm it by the Find button.
    • EXPECTED RESULT: "Usages of class Bean [33 occurrences]"
      should be displayed in the first line of Usages window.
      35 occurrences are found if 'Search in Comments' is checked.
  2. Class - All Subtypes
    1. Select org.netbeans.tests.examples.packa.Bean class in the Project view.
    2. Invoke Find Usages action from the popup menu.
    3. In the dialog select Find All Subtypes choice and confirm it by the Find button.
    • EXPECTED RESULT: "Find All SubTypes of class Bean [8 occurrences]"
      should be displayed in the first line of Usages window.
      8 occurrences are found if 'Search in Comments' is checked.
  3. Class - Direct Subtypes
    1. Select org.netbeans.tests.examples.packa.Bean class in the Project view.
    2. Invoke Find Usages action from the popup menu.
    3. In the dialog select Find Direct Subtypes Only choice and confirm it by the Find button.
    • EXPECTED RESULT: "Find Direct SubTypes of class Bean [2 occurrences]"
      should be displayed in the first line of Usages window.
      2 occurrences are found if 'Search in Comments' is checked.
  4. Interface - Usages
    1. Select org.netbeans.tests.examples.packc.Makable class in the Project view.
    2. Invoke Find Usages action from the popup menu.
    3. In the dialog select Find Usages choice and confirm it by the Find button.
    • EXPECTED RESULT:"Usages of interface Makable [17 occurrences]"
      should be displayed in the first line of Usages window.
      18 occurrences are found if 'Search in Comments' is checked.
  5. Interface - All Subtypes
    1. Select org.netbeans.tests.examples.packc.Makable class in the Project view.
    2. Invoke Find Usages action from the popup menu.
    3. In the dialog select Find All Subtypes choice and confirm it by the Find button.
    • EXPECTED RESULT: "Find All SubTypes of interface Makable [7 occurrences]"
      should be displayed in the first line of Usages window.
      7 occurrences are found if 'Search in Comments' is checked.
  6. Interface - Direct Subtypes
    1. Select org.netbeans.tests.examples.packc.Makable class in the Project view.
    2. Invoke Find Usages action from the popup menu.
    3. In the dialog select Find Direct Subtypes Only choice and confirm it by the Find button.
    • EXPECTED RESULT: "Find Direct SubTypes of interface Makable [3 occurrences]"
      should be displayed in the first line of Usages window.
      3 occurrences are found if 'Search in Comments' is checked.
  7. Constructor
    1. Put caret on constructor BeanB() in the org.netbeans.tests.examples.packb.BeanB class on 26th line.
    2. Invoke Find Usages action from the popup menu.
    3. Select Find Usages check box in dialog and press Find button.
    • EXPECTED RESULT: "Usages of BeanB [5 occurrences]"
      should be displayed in the first line of Usages window.
      5 occurrences are found if 'Search in Comments' is checked.
  8. Method - Usages
    1. Put caret over make(int, String, Bean) method in the org.netbeans.tests.examples.packc.Makable class on 18th line.
    2. Invoke Find Usages action from the popup menu.
    3. In the dialog select only Find Usages checkbox and confirm it by Find button.
    • EXPECTED RESULT: "Usages of Makable.make [4 occurrences]"
      should be displayed in the first line of Usages window.
      4 occurrences are found if 'Search in Comments' is checked.
  9. Method - Overriding Methods
    1. Put caret over make(int, String, Bean) in the org.netbeans.tests.examples.packc.Makable class on 18th line.
    2. Invoke Find Usages action from the popup menu.
    3. In the dialog select only Find Overriding Methods checkbox and confirm it by Find button.
    • EXPECTED RESULT: "Overriding Methods of Makable.make [5 occurrences]"
      should be displayed in the first line of Usages window.
      5 occurrences are found if 'Search in Comments' is checked.
  10. Method - Search from Base Class
    1. Put caret over make(int index, java.lang.String s, org.netbeans.tests.examples.packa.Bean bean) in the org.netbeans.tests.examples.packb.BeanB class on 73th line.
    2. Invoke Find Usages action from the popup menu.
    3. In the dialog select only Find Usages and from the From: combobox select Makable and confirm it by Find button.
    • EXPECTED RESULT: "Usages of Makable.make [4 occurrences]"
      should be displayed in the first line of Usages window.
      4 occurrences are found if 'Search in Comments' is checked.
  11. Method - Overloaded
    1. Open Overloaded.java
    2. Call Find Usages on method test()
    3. In the dialog, keep defaults, only select Included overloaded methods
    4. Confirm by Find button
    • EXPECTED RESULT:Two usages are found
  12. Field
    1. Put caret over refID in the org.netbeans.tests.examples.packa.Bean class on 27th line.
    2. Invoke Find Usages action from the popup menu.
    3. Confirm dialog by Find button.
    • EXPECTED RESULT: "Usages of refID [13 occurrences]"
      should be displayed in the first line of Usages window.
      16 occurrences are found if 'Search in Comments' is checked.
  13. Java Class - String
    1. Open org.netbeans.tests.examples.packc.Makable.
    2. Put caret over String in declaration of method make(...) on 18th line.
    3. Invoke Find Usages action from the popup menu.
    4. Select Find Usages radio button and set Scope to project Current Project (default), confirm it by Find button.
    • EXPECTED RESULT: "Usages of class String [39 occurrences]"
      should be displayed in the first line of Usages window.
      40 occurrences are found if Search in Comments is checked.
  14. Java Class - scope
    1. Open at least one another project.
    2. Open org.netbeans.tests.examples.packc.Makable.
    3. Put caret over String in declaration of method make(...) on 18th line.
    4. Invoke Find Usages action from the popup menu.
    5. Select Find Usages radio button and set Scope to Open Projects, confirm it by Find button.
    • EXPECTED RESULT: Usages of class String are found in all opened projects.
  15. Java Class - custom scope
    1. Call Find Usages on org.netbeans.tests.examples.packa.Bean
    2. In the scope combobox select Custom
    3. In the scope dialog select only org.netbeans.tests.examples.packc
    4. Confirm the scope and continue in Find usages
    • EXPECTED RESULT:2 occurrences of class Bean are found. Both in the selected package
  16. Filters - field
    1. Call Find Usages on field name in Property class
    2. Select Search in Comments and confirm dialog
    3. Try filter button in the right part of result window
    • EXPECTED RESULT:By default, 5 occurrences are found. There are 3 buttons active - Read filter, Write filter, Comment filter. Pressing one of them will filter out related type of usage. Every time a number of filtered usages is announced in the first line of result tree
  17. Filters - class
    1. Call Find Usages on field Makable class
    2. Select Search in Comments and confirm dialog
    3. Try filter button in the right part of result window
    • EXPECTED RESULT:By default, 18 occurrences are found. There are 2 buttons active - Import filter and Comment filter. Filters work as described in previous test case
  18. Reuse tab
    1. Call Find Usages on some element
    2. Call Find Usages for the second time
    3. In the dialog unselect Open In the new tab and confirm the dialog
    • EXPECTED RESULT:The result is displayed in the window where was result of the previous search

Test suite: Rename

Purpose: To verify if this part of refactoring functionality corresponds with design and works right.

Setup: Project Default_TS_74_Refactoring.zip is needed in this test suite.

  1. Package
    1. Select org.netbeans.tests.examples.packa package node in the Project view and invoke Refactor | Rename action from the popup menu.
    2. Fill a new package name org.netbeans.tests.examples.packarenamed in the Rename dialog, confirm this dialog by Preview button.
    3. If you agree with these changes press Do Refactoring button and changes will be performed.
    • EXPECTED RESULT: Rename org.netbeans.tests.examples.packa to org.netbeans.tests.examples.packarenamed [23 occurrences]
      should be displayed in Refactoring window.
      23 occurrences are updated if 'Apply Rename on Comments' is checked.
  2. Package in Files view
    1. Switch to the Files tab and select default/src/org package node.
    2. Click to the node to activate its inplace rename.
    3. Fill a new package name com and confirm by enter key.
    4. The Rename org dialog should be displayed. Confirm by Preview button.
    5. Press Do Refactoring button and changes will be performed.
    • EXPECTED RESULT: Rename org to com [51 occurrences]
      should be displayed in Refactoring window.
      51 occurrences are updated if 'Apply Rename on Comments' is checked.
  3. Class
    1. Select org.netbeans.tests.examples.packa.Bean class node in the Project view and invoke Refactor | Rename action from the popup menu.
    2. Fill a new class name BeanRenamed and confirm it by Preview button.
    3. If you agree with these changes press Do Refactoring button and changes will be performed
    • EXPECTED RESULT: Rename Bean to BeanRenamed [36 occurrences]
      should be displayed in Refactoring window.
      38 occurrences are updated if 'Apply Rename on Comments' is checked.
  4. Class - non-primary top level
    1. Put caret over name in declaration of org.netbeans.tests.examples.packb.BeansD.BeanD class and invoke Refactor | Rename action from the popup menu.
    2. Fill a new class name BeanDRenamed and confirm it by Preview button.
    3. If you agree with these changes press Do Refactoring button and changes will be performed.
    • EXPECTED RESULT: Rename BeanD to BeanDRenamed [4 occurrences]
      should be displayed in Refactoring window.
      4 occurrences are updated if 'Apply Rename on Comments' is checked.
  5. Class - inline
    1. Select org.netbeans.tests.examples.packa.Bean class node in the Project view and click to the node to activate its inplace rename.
    2. Fill a new class name BeanRenamed and confirm by enter key
    3. The rename dialog should be displayed. Confirm the dialog by Preview button.
    4. If you agree with these changes press Do Refactoring button and changes will be performed.
    • EXPECTED RESULT: Rename Bean to BeanRenamed [36 occurrences]
      should be displayed in Refactoring window.
      38 occurrences are updated if 'Apply Rename on Comments' is checked.
  6. Interface
    1. Select org.netbeans.tests.examples.packc.Makable interface node in the Project view and invoke Refactor | Rename action from the popup menu.
    2. Fill a new interface name MakableRenamed and confirm this dialog by Preview button.
    3. If you agree with these changes press Do Refactoring button and changes will be performed.
    • EXPECTED RESULT: Rename Makable to MakableRenamed [19 occurrences]
      should be displayed in Refactoring window.
      20 occurrences are updated if 'Apply Rename on Comments' is checked.
  7. Rename Method
    1. Put caret over getProtectedProperty() of the org.netbeans.tests.examples.packb.BeanA class and invoke Refactor | Rename action from the popup menu.
    2. There should be displayed two warnings:
      O There are methods in subclasses/implementors of BeanA that override or implement this method. They will also be renamed.
      O The methods in subclasses/implementors of getProtectedProperty() that override or implement this method, also override or implement the method in super classes/interfaces. The sources will not compile after refactoring!
    3. Press Next button.
    4. Fill a new method name getProtectedPropertyRenamed and confirm this dialog.
    5. If you agree with these changes press Do Refactoring button and changes will be performed.
    • EXPECTED RESULT: Rename getProtectedProperty to getProtectedPropertyRenamed [14 occurrences]
      should be displayed in Refactoring window.
      14 occurrences are updated if 'Apply Rename on Comments' is checked.
  8. Rename Field
    1. Put caret on field protectedProperty of the org.netbeans.tests.examples.packb.BeanA class in the Project view and invoke Refactor | Rename action from the popup menu.
    2. Fill a new field name protectedPropertyRenamed, uncheck checkbox 'Rename Getters and Setters' and confirm this dialog.
    3. If you agree with these changes press Do Refactoring button and changes will be performed.
    • EXPECTED RESULT: Rename protectedProperty to protectedPropertyRenamed [19 occurrences]
      should be displayed in Refactoring window.
      24 occurrences are updated if 'Apply Rename on Comments' is checked.
  9. Rename Field with Getters and Setters
    1. Put caret on field protectedProperty of the org.netbeans.tests.examples.packb.BeanA class in the Project view and invoke Refactor | Rename action from the popup menu.
    2. Fill a new field name protectedPropertyRenamed, check checkbox 'Rename Getters and Setters' and confirm this dialog.
      There should be displayed a warning:
      O There are methods in subclasses/implementors of BeanA that override or implement this method. They will also be renamed.
    3. If you agree with these changes press Do Refactoring button and changes will be performed.
    • EXPECTED RESULT: Rename protectedProperty to protectedPropertyRenamed [37 occurrences]
      should be displayed in Refactoring window.
      42 occurrences are updated if 'Apply Rename on Comments' is checked.
  10. Rename Local Field
    1. Open class org.netbeans.tests.examples.packc.BeanE in the source editor.
    2. Move cursor to attribute v1 of the method public double count(double[[ | ]] v1, double[[ | ]] v2) and invoke Refactor | Rename action from the popup menu.
    3. Fill a new field name vector1 and and confirm this dialog
    4. If you agree with these changes press Do Refactoring button and changes will be performed.
    • EXPECTED RESULT: Rename v1 to vector1 [9 occurrences]
      should be displayed in Refactoring window.
      9 occurrences are updated if 'Apply Rename on Comments' is checked.
  11. Label
    1. Open Label.java
    2. Put cursor on label LABEL
    3. Call Rename from refactoring menu
    4. In the dialog type new name
    • EXPECTED RESULT:The all occurrences of LABEL is changed

Test suite: Move Class

Purpose: To verify if this part of refactoring functionality corresponds to design and works right.

Setup: Project Default_TS_74_Refactoring.zip is needed in this test suite.

  1. Move class
    1. Select org.netbeans.tests.examples.packa.Bean class in the Project view and invoke Refactor | Move... action from the popup menu.
    2. Select org.netbeans.tests.examples.packb in To Package combobox and confirm it by Preview button.
    3. If you agree with these changes press Do Refactoring button and changes will be performed.
    • EXPECTED RESULT: Move class Bean to org.netbeans.tests.examples.packb package [15 occurrences]
      should be displayed in Refactoring window. After Do Refactoring project should be compilable.
  2. Package private field
    1. Select org.netbeans.tests.examples.packb.BeanA class in the Project view and invoke Refactor | Move... action from the popup menu
    2. Select org.netbeans.tests.examples.packa in To Package combobox and and confirm it by Preview button.
    3. There should be displayed a warning:
      O Class "BeanB" within the same package is using feature "protectedProperty" of class you want to move("BeanA"). Continue by Preview button.
    4. If you agree with these changes press Do Refactoring button and changes will be performed.
    • EXPECTED RESULT: Move class BeanA to org.netbeans.tests.examples.packa package [6 occurrences]
      should be displayed in Refactoring window. After Do Refactoring project will not be compilable because of using of package private field protectedProperty by classes in org.netbeans.tests.examples.packb.
  3. Default package
    1. Select org.netbeans.tests.examples.packb.BeanB class in the Project view and invoke Refactor | Move... action from the popup menu.
    2. Select <default package> in To Package combobox and select Preview All Changes checkbox in the Move Class dialog and confirm it by Preview button.
    3. There should be displayed two warnings:
      O If the class is moved to the default package, classes in other packages will not be able to import the moved class.
      O Class you want to move ("BeanB") is using feature "protectedProperty" of class "BeanA" within the same package. Continue by Preview button.
    4. If you agree with these changes press Do Refactoring button and changes will be performed
    • EXPECTED RESULT: Move class BeanB to <default> package [2 occurrences]
      should be displayed in Refactoring window. After Do Refactoring project will not be compilable because of errors in classes BeanB, packa.Bean, packb.BeanC and packb.BeansD.
  4. Drag and Drop
    1. Select AbstractBean and Makable in the org.netbaens.tests.examples.packc , drag them and drop into org.netbeans.tests.examples.packa.
    2. Move dialog will be displayed. List of Classes contains both selected classes. Confirm dialog by the Preview button.
    3. If you agree with these changes press Do Refactoring button and changes will be performed
    • EXPECTED RESULT: Move Classes [16 occurrences]
      should be displayed in Refactoring window. After Do Refactoring project should be compilable.
  5. To Test Packages
    1. Switch to Files view and add test/org/netbeans/tests folder into root folder of default project.
    2. Select org.netbeans.tests.examples.packc.BeanE class in Source Packages in Projects view.
    3. Invoke Refactor | Move... action from the popup menu
    4. Select Test Packages in Location combobox, select org.netbeans.tests in To Package combobox and confirm it by Preview button.
    5. If you agree with these changes press Do Refactoring button and changes will be performed.
    • EXPECTED RESULT: Move class BeanE to org.netbeans.tests package [2 occurrences]
      should be displayed in Refactoring window. After Do Refactoring project should be compilable.

Test suite: Move element

Purpose: This test suite is focused on move method and move field refactoring
Setup: Open sample project encapsulate_TS_74_Refactoring.zip

  1. Move Static Method
    1. Open moveMethod.OriginalClass
    2. Put cursor at staticMethod and call Move refactoring
    3. In the dialog select moveTarget.Target as a destination
    4. Perform Move
    • EXPECTED RESULT:The method is moved to the designed place. The javadoc is not changed. All necessary imports are added. All usages of the moved method are changed, to reflect the new position of the method
  2. Move Instance Method
    1. Open moveMethod.OriginalClass
    2. Put cursor at instanceMethod and call Move refactoring
    3. In the dialog select moveTarget.Target as a destination
    4. Perform Move
    • EXPECTED RESULT:The method is moved to the new place. All usages are updated. In the OriginalClass the instanceMethod() is replaced with t.instanceMethod().
  3. Instance Method - not accessible
    1. Remove Target t from the usage method, and repeat previous test case
    2. Undo the parameter deletion
    • EXPECTED RESULT:The refactoring cannot be performed No accessor found to invoke the method from: D:\tst\refactoring1\Encapsulate\src\moveMethod\OriginalClass.java:38.
  4. Visibility
    1. Open moveMethod.OriginalClass
    2. Invoke Move Refactoring on instanceMethod
    3. In the dialog, try changing visibility. Use following values: As si, Private, default, Protected, Public
    4. Perform the refactoring, check the result and undo the refactoring
    • EXPECTED RESULT:The visibility modifier of moved method is changed as desired. (This may introduce compilation errors)
  5. Visibility - Escalate
    1. Call Move on instanceMethod as in previous testcase
    2. In the dialog select Escalate
    3. Move the method to: class Target, LocalTarget and InnerTarget
    • EXPECTED RESULT:The visibility modifier is updater to weaker restrictive, so the method is always accessible (public for Target class, default for LocalTarget, private for InnerTarget)
  6. Javadoc update
    1. Open moveMethod.OriginalClass
    2. Delete javadoc comment for staticMethod
    3. Call Move on staticMethod
    4. In the dialog, select javadoc: update
    5. Perform refactoring
    • EXPECTED RESULT:Javadoc stub is added to the moved method
  7. Keep original method and deprecate
    1. Open moveMethod.OriginalClass
    2. Put cursor at instanceMethod and call Move refactoring
    3. In the dialog check Keep Original Method and delegate to the moved method and Deprecate the old method
    4. Select Javadoc: Update
    5. Move the method to Target class
    • EXPECTED RESULT:The original method is not removed, now it delegates to the new method (t.instanceMethod). The @Deprecated tag is added to javadoc and @Deprecated annotation is added. (When removing the filed Target t from the OriginalClass the refactoring cannot be performed)
  8. UI
    1. Call move refactoring on some element
    2. In the dialog try filter button in the elements list
    • EXPECTED RESULT:The buttons works as expected, each has tooltip. The element which, was under carted when refactoring was invoked, is preselected
  9. Moving field
    1. Open moveMethod.OriginalClass
    2. Call move refactoring in field Target t
    3. Move it to Target class
    • EXPECTED RESULT:The field is moved in the same way as instance method. The usages are updated.
  10. Moving more elements at once
    1. Open originalClass
    2. call Move refactoring
    3. Select more elements and perform refactoring
    • EXPECTED RESULT:All elements are moved correctly
  11. Overridden method
    1. Open InvalidCases
    2. Call move refactoring on Super.method or Sub.method
    • EXPECTED RESULT:In both cases, a dialog is opened, but it says Cannot move polymorphic method
  12. Annotation, interface
    1. Open InvalidCases
    2. Try invoke move refactoring on method in annotation or interface
    • EXPECTED RESULT:Dialog announcing Can only move members of class is opened, refactoring cannot be performed
  13. Abstract
    1. Open InvalidCases
    2. Call move refactoring on absMethod
    • EXPECTED RESULT:Move dialog is opened, but it says Cannot move abstract method

Test suite: Change Method Parameters

Purpose: To verify if this part of refactoring functionality corresponds to design and works right.

Setup: Project Default_TS_74_Refactoring.zip is needed in this test suite.

  1. Constructor
    1. Put caret over constructor BeanA() from the org.netbeans.tests.examples.packb.BeanA class and invoke Refactor | Change Method Parameters... action from the popup menu.
    2. In the Change Method Parameters dialog press the Add button and fill Type, Name and Default Value for new created parameter as java.lang.String, name and "".
    3. Press Preview button.
    4. If you agree with these changes press Do Refactoring button and changes will be performed.
    • EXPECTED RESULT: Change parameters of constructor to public (java.lang.String name) [4 occurrences]
      should be displayed on the first line of Refactoring window. All occurrences of this constructor should be changed to BeanA("").
  2. Add parameter
    1. Put caret over method abc() from the org.netbeans.tests.examples.packa.Bean class and invoke Refactor | Change Method Parameters... action from the popup menu.
    2. In the Change Method Parameters dialog press the Add button and fill Type and Name for the new created parameter as int and id. Leave Default Value field empty.
    3. There should be displayed an error notice "Error: You have to provide default values for all new parameters." Fill Default Value as 0.
    4. Press Preview button.
    5. If you agree with these changes press Do Refactoring button and changes will be performed
    • EXPECTED RESULT: Change parameters of abc method to public org.netbeans.tests.examples.packa.Bean abc(int id) [12 occurrences]
      should be displayed on the first line of Refactoring window. All occurrences of this method should be changed to abc(0).
  3. Visibility Modifier
    1. Put caret over method abc() from the org.netbeans.tests.examples.packa.Bean class and invoke Refactor | Change Method Parameters... action from the popup menu.
    2. In the Change Method Parameters dialog select protected in the Access Modifier checkbox.
    3. Press Preview button.
    4. If you agree with these changes press Do Refactoring button and changes will be performed.
    • EXPECTED RESULT: Change parameters of abc method to protected org.netbeans.tests.examples.packa.Bean abc() [4 occurrences]
      should be displayed on the first line of Refactoring window.
  4. Remove parameter
    1. Select method make(int index, String s, Bean bean) from the org.netbeans.tests.examples.packc.Makable class and invoke Refactor | Change Method Parameters... action from the popup menu.
    2. In the Change Method Parameters dialog select "bean" parameter and press the Remove button.
    3. Notice that Access Modifier combobox is disabled for interfaces.
    4. Press Preview button.
    5. If you agree with these changes press Do Refactoring button and changes will be performed.
    • EXPECTED RESULT: Change parameters of make method to public abstract void make(int index, java.lang.String s) [10 occurrences]
      should be displayed on the first line of Refactoring window.
  5. Parameter position
    1. Put caret over make(int index, String s, Bean bean) in the org.netbeans.tests.examples.packc.Makable class and invoke Refactor | Change Method Parameters... action from the popup menu.
    2. In the Change Method Parameters dialog select "s" parameter and press the Move Up button.
    3. Press Preview button.
    4. If you agree with these changes press Do Refactoring button and changes will be performed.
    • EXPECTED RESULT: Change parameters of make method to public abstract void make(String s, int index, Bean bean) [24 occurrences]
      should be displayed on the first line of Refactoring window. Project should be compilable.
  6. Vararg
    1. Put caret over make(int index, String s, Bean bean) in the org.netbeans.tests.examples.packc.Makable class and invoke Refactor | Change Method Parameters action from the popup menu.
    2. Add new argument of type int..., set name to vararguments and enter 1,2,3 as default value.
    3. Try to move it to the different position than last.
    4. Press Preview and perform refactoring.
    • EXPECTED RESULT: Change parameters of make method to public abstract void make(String s, int index, Bean bean, int... vararguments) [10 occurrences]
      should be displayed on the first line of Refactoring window. The refactoring cannot continue if vararg parameter is not at the last position. If refactoring is performed method declaration is modified as expected and provided default values are added to all calls of refactored method. Project should be compilable.

Test suite: Encapsulate Fields

Purpose: To verify if this part of refactoring functionality corresponds to design and works right.

Setup: Project Encapsulate_TS_74_Refactoring.zip is needed in this test suite.

  1. Encapsulate field
    1. Put caret over field field from the MainClass.
    2. Invoke Refactor | Encapsulate Fields... action from the popup menu.
    3. Leave all options at default, press Preview button.
    4. If you agree with these changes press Do Refactoring button and changes will be performed.
    • EXPECTED RESULT: Encapsulate fields in class encapsulate.MainClass [8 occurrences]
      should be displayed on the first line of Refactoring window. The getter/setter are generated, modifier of the field is changed to desired value (private by default) and all usages are replaced by calls of getter or setters. Project should be compilable.
  2. Change getter, setter name, modifier
    1. Put caret over field field from the MainClass.
    2. Invoke Refactor | Encapsulate Fields... action from the popup menu.
    3. Change getter/setter name and its modifier.
    4. Press Preview button.
    5. If you agree with these changes press Do Refactoring button.
    • EXPECTED RESULT: Encapsulate fields in class encapsulate.MainClass [8 occurrences]
      should be displayed on the first line of Refactoring window. The getter/setter has correct name and the modifiers are as specified in dialog.
  3. Use Accessors if needed
    1. Call Encapsulate field on field x in class Access.
    2. Change visibility modifier to protected.
    3. Uncheck "Use Accessors Even When Field Is Accessible" checkbox.
    4. Press Preview and inspect proposed changeds.
    5. Preform refactoring.
    • EXPECTED RESULT: Encapsulate fields in class encapsulate.Access [4 occurrences]
      should be displayed on the first line of Refactoring window. Getter and setter are generated, visibility modifier is changed. Accessors are used only in class AccessB.
  4. Usage in constructor
    1. Call Encapsulate field on field y in class Ctor.
    2. Set field visibility to private, accessors visibility to public, select "Use Accessors Even When Field Is Accessible".
    3. Perform refactoring.
    • EXPECTED RESULT: Warning about usage in constructor is displayed.
  5. Nothing to encapsulate
    1. Call Encapsulate field in class EmptyClass.
    • EXPECTED RESULT: Dialog stating that EmptyClass has no fields is shown.
  6. Existing methods
    1. Call Encapsulate field on field a in class ExMethod.
    2. Keep defaults name, set field visibility modifier to protected and accessors visibility to public.
    3. Perform refactoring.
    • EXPECTED RESULT: A dialog with "No Patterns Found" shows up. The modifier are not changed, since they already exists.

Test suite: Miscellaneous

Purpose: To verify if this part of refactoring functionality corresponds to design and works right.

Setup: Project Default_TS_74_Refactoring.zip is needed in this test suite.

  1. Undo/Redo
    1. Perform some previous testcase (Rename, Change Method Parameters...) and invoke Undo action.
    2. Verify if changes were reverted to the initial state.
    3. Invoke Redo action.
    4. Verify if changes were same like after refactoring.
    • EXPECTED RESULT: Undo/Redo action works as expected.
  2. Same name in two projects
    1. Create a new General | Java Application project called JavaApplication1; with a main class Main in the package abc.
    2. Create a another new General | Java Application project called JavaApplication2; with a main class Main in the package abc.
    3. Create a new class Alfa in the package abc for JavaApplication1 project.
    4. Create a new class Beta in the package abc for JavaApplication2 project.
    5. Invoke Refactor | Rename action from the popup menu for the abc.Beta in the JavaApplication2 project.
    6. Fill a new class name Alfa in the Rename dialog and confirm this dialog.
    • EXPECTED RESULT: Class Beta from JavaApplication2 project should be renamed to Alfa.
  3. Preview window
    1. Open preview for refactoring (any of the earlier described testcases).
    2. Try function of the buttons in the left part.
    3. Click on some item in the tree.
    4. Double click on some item in the tree.
    • EXPECTED RESULT: The buttons in the right has following functions
      O Refresh refactoring data - brings back refactoring dialog, the values in the should in the state as they were when button Preview was pressed
      O Expand/Collapse all Node - expands/collapses the tree of refactoring preview
      O Show logical view - changes refactoring tree to show hierarchical package structure.
      O Show physical view - the tree shows only project and files where the changes will be performed.
      O Previous Occurrence, Next Occurrence - jumps to previous/next node in the refactoring tree.
      O Click on item opens and or set the preview to show related change (if available).
      O Double click shows related position in the main editor.
  4. Preview window - shortcut
    1. Open preview for refactoring (any of the earlier described testcases).
    2. Try shortcuts Ctrl-comma, Ctrl-period.
    • EXPECTED RESULT: The caret jump on next/previous item in result as when clicking on arrow button in left panel.
  5. Customize refactoring
    1. Open preview for any rename refactoring.
    2. Uncheck several refactoring elements in the refactoring tree.
    3. Perform refactoring.
    • EXPECTED RESULT: The unselected changes are not performed - not shown in preview and not performed in the code itself.
  6. Concurrent modification
    1. Call Rename refactoring on class.org.netbeans.tests.examples.packa.Bean.
    2. Enter new name and press button Preview.
    3. While preview is opened change significantly class Bean (e.g. add several new lines).
    • EXPECTED RESULT: The preview shows gray label Rename ..... NEEDS REFRESH and the Do Refactoring button is disabled.
  7. Find usages window
    1. Close 'Usages' window.
    2. Go to main menu 'Window | Output | Find Usages Results'.
    • EXPECTED RESULT: The empty window 'Usages' is opened in output area.
  8. Refactoring preview window
    1. Close 'Refactoring' window.
    2. Go to main menu 'Window | Output | Refactoring Preview'.
    • EXPECTED RESULT: The empty window 'Refactoring' is opened in output area.
  9. Refactoring preview window - panels
    1. Perform several find usages in a row.
    2. Right click on tab in 'Usages' window.
    3. Try 'Close Tab', 'Close All', 'Close Others Tabs' actions.
    • EXPECTED RESULT: The required tabs are closed.

Test suite: JDK 1.5+ Refactoring

Purpose: This test suite tests overall refactoring on JDK 1.5 and later sources.

Setup: Project Default15_TS_60_Refactoring.zip is needed in this test suite.

  1. Refactoring 1.5 - Find Usages
    1. Open package abc.
    2. Find usages of class abc.A.
    • EXPECTED RESULT: "Usages of A [17 occurrences]"
      should be displayed in the first line of Usages window.
      22 occurrences are found if 'Search in Comments' is checked.
  2. Refactoring 1.5 - Find Usages - Context
    1. Open annotation abc.def.DAnnotType in the editor and select X of En in default value of member coord in source text.
    2. Invoke the context menu and choose Find Usages.
    • EXPECTED RESULT: "Usages of X [4 occurrences]"
      should be displayed in the first line of Usages window.
      4 occurrences are found if 'Search in Comments' is checked.
  3. Refactoring 1.5 - Rename Class
    1. Open class abc.A in the editor.
    2. Find node corresponding to class abc.A in the Projects view.
    3. Invoke the context menu and choose Refactor | Rename....
    4. Change name to TestClassName and press Preview button.
    • EXPECTED RESULT: Rename A to TestClassName [22 occurrences]
      should be displayed in Refactoring window.
      27 occurrences are updated if 'Apply Rename on Comments' is checked. Project should be compilable.
  4. Refactoring 1.5 - Rename Generics
    1. Open class abc.A in the editor.
    2. Put cursor over T in the class declaration.
    3. Invoke the context menu and choose Refactor | Rename....
    4. Change name to X.
    • EXPECTED RESULT: Rename T to X [10 occurrences]
      should be displayed in Refactoring window.
      10 occurrences are updated if 'Apply Rename on Comments' is checked. Project should be compilable.
  5. Refactoring 1.5 - Rename Enumeration
    1. Open enumeration abc.En in the editor.
    2. Find node corresponding to enumeration abc.En in the Projects view.
    3. Invoke the context menu and choose Refactor | Rename....
    4. Change name to TestEnumeration.
    • EXPECTED RESULT: Rename En to TestEnumeration [22 occurrences]
      should be displayed in Refactoring window.
      25 occurrences are updated if 'Apply Rename on Comments' is checked. Project should be compilable.
  6. Refactoring 1.5 - Rename Enumeration Constant
    1. Open enumeration abc.En in the editor.
    2. Put caret over X constant in editor.
    3. Invoke the context menu and choose Refactor | Rename....
    4. Change name to W and press Preview button.
    • EXPECTED RESULT: Rename X to W [5 occurrences]
      should be displayed in Refactoring window.
      5 occurrences are updated if 'Apply Rename on Comments' is checked. Project should be compilable.
  7. Refactoring 1.5 - Rename Field
    1. Open class abc.A in the editor.
    2. Put caret over field list in the editor.
    3. Invoke the context menu and choose Refactor | Rename....
    4. Change name to testFieldName.
    • EXPECTED RESULT: Rename list to testFieldName [5 occurrences]
      should be displayed in Refactoring window.
      5 occurrences are updated if 'Apply Rename on Comments' is checked. Project should be compilable.
  8. Refactoring 1.5 - Rename Annotation Type
    1. Open annotation abc.def.DAnnotType in the editor and select DAnnotType in source text.
    2. Invoke the context menu and choose Refactor | Rename....
    3. Change name to AnnotType and press Preview.
    • EXPECTED RESULT: Rename DAnnotType to AnnotType [13 occurrences]
      should be displayed in Refactoring window.
      17 occurrences are updated if 'Apply Rename on Comments' is checked. Project should be compilable.
  9. Refactoring 1.5 - Rename Annotation Type Member
    1. Open annotation abc.def.DAnnotType in the editor and select coord member in source text.
    2. Invoke the context menu and choose Refactor | Rename....
    3. Change name to dcoord and press Preview button
    • EXPECTED RESULT: Rename DAnnotType to AnnotType [2 occurrences]
      should be displayed in Refactoring window.
      2 occurrences are updated if 'Apply Rename on Comments' is checked. Project should be compilable.
  10. Refactoring 1.5 - Move Class I
    1. Open class abc.A in the editor.
    2. Find node correspoding to class abc.A in the Projects view.
    3. Invoke the context menu and choose Refactor | Move Class....
    4. Set destination package to abc.def.
    • EXPECTED RESULT: Move class A to abc.def package [14 occurrences]
      should be displayed in Refactoring window. Project should be compilable.
  11. Refactoring 1.5 - Move Class II
    1. Open enumeration abc.En in the editor.
    2. Find node corresponding to enumeration abc.En in the Projects view.
    3. Invoke the context menu and choose Refactor | Move Class....
    4. Set destination package to abc.def.
    • EXPECTED RESULT: Move class En to abc.def package [8 occurrences]
      should be displayed in Refactoring window. Project should be compilable.
  12. Refactoring 1.5 - Encapsulate Fields
    1. Open class abc.A in the editor.
    2. Put caret over field list.
    3. Invoke the context menu and choose Refactor | Encapsulate Fields....
    4. Leave the default values in the dialog untouched and press Preview (encapsulate only list , Fields' Visibility private , Accessors' Visibility public , Use Accessors Even When Field Is Visible true and Generate Property Change Support false.
    5. There should be displayed warning:
      "The accessibility of field list is private but it is referenced from constructor of class B.",
      continue with Preview button again.
    • EXPECTED RESULT: Encapsulate fields in class abc.A [5 occurrences]
      should be displayed in Refactoring window. Project shouldn't be compilable.
      All occurrences of list in abc.A and abc.B should be replaced, the generated methods should have generics types.
  13. Refactoring 1.5 - Change Signature
    1. Open class abc.A in the editor.
    2. Put caret over field methodA(T, String, boolean, String...) on line 74.
    3. Invoke the context menu and choose Refactor | Change Method Parameters....
    4. Make some changes.
    • EXPECTED RESULT: Verify that the result is correct.
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