TS 74 JavaProject

Java Project

Author:Jiri Prox jiri.prox@oracle.com
Version:7.4
Last update:2013/07/22
Introduction:This test specification covers features related to java project, project view and java libraries

Contents

Test suite: COS - UI

Purpose: This suite is focused on menu item availability.
Setup: Create new J2SE project, make sure that Compile On Save is enabled (Compile tab of project properties). Run the project!!!

  1. Compile singe file, package
    1. Open context menu on file in project view
    2. Open context menu on package in project view
    3. Disable CoS and perform previous steps again.
    • EXPECTED RESULT: Item 'Compile file' / 'Compile package' are disabled if CoS is enabled. After disabling CoS the IDE behaves as previous version - ant is used do compile class or whole
  2. Compile project
    1. Open context menu on project
    2. Open Run main menu
    3. Press Build
    • EXPECTED RESULT: The dialog warning about the fact that clean&build must be performed instead of build is shown.
  3. Compile project with errors
    1. Make a syntax error in the code
    2. Run the project
    • EXPECTED RESULT: The dialog informing about uncompilable code is shown. The user have possibility to cancel run or to continue. There is checkbox to disable this dialog next time
  4. Disable/Enable CoS
    1. Open project properties
    2. Switch to Compile tab
    3. Disable CoS
    4. Close properties
    5. Enable CoS again
    • EXPECTED RESULT: Clean is performed when setting is changed

Test suite: COS - Compiling, Building,Running

Purpose: This suite describes compiling a building project
Setup: Locate the directory, where are stored compiled classes. The location should be {userdir}/var/cache/index/{index_version}/sX/classes, where X is a decimal number
Comments: The test cases should be performed in a row since they depends on result of previous case.

  1. Change and save
    1. Open class from the project
    2. Clean it
    3. Make sure CoS is enabled
    4. Make some modification and save
    • EXPECTED RESULT: The related .class file is updated, but only in userdir, Need to Compile batch should appear. Compile actions are enabled
  2. Compile
    1. Compile the modified file (F9)
    • EXPECTED RESULT: The file is compiled by ant. Need to compile badge disappears. Compile action is still enabled
  3. Build
    1. Build project
    • EXPECTED RESULT: Build is performed by ant
  4. Run
    1. Run project
    • EXPECTED RESULT: The classes from userdir are copied to build/classes folder, the application is launched with build/classes folder on it's classpath. Compile actions are disabled, need to compile badges are not visible
  5. Modify source
    1. Modify any file
    2. Save it
    • EXPECTED RESULT: The .class files is updated in build/classes folder, need to compile badge is not shown
  6. Run project
    1. Run project
    • EXPECTED RESULT: The project is launched w/o any compilation of copying classes
  7. Build project
    1. Build project
    • EXPECTED RESULT: The dialog asking of performing Clean&Build is shown. Cancel the action
  8. Clean
    1. Cleans project
    • EXPECTED RESULT: The content of build/classes is erased. The compile action is enabled again, Need to compile badges appears for all source files

Test suite: COS - Dependent projects

Setup: Have a project A and B,A is depending on B

  1. Running A
    1. Enable CoS for project A
    2. Run project A
    • EXPECTED RESULT: The CoS is applied on both projects -> classes are copied from userdir if necessary, application has build/classes dirs on its classpath. The behavior is not dependent on project B
  2. Building A
    1. Make sure CoS is enabled for A
    2. Clean&Build project A
    • EXPECTED RESULT: The A is cleaned and build, if there was classes fro inner javac in buidl/classes of project B, the project is cleaned as well. Otherwise B is only build by ant.
  3. Running B
    1. Run project B
    • EXPECTED RESULT: Running depends on CoS setting of project B. No setting of A is taking in account

Test suite: COS - Errors in code

  1. Error in code
    1. Create new project
    2. Make syntax error (e.g undefined variable) in main method)
    3. Run the project
    4. In the dialog select Run Anyway
    • EXPECTED RESULT: The project is started. When part of code, where is the error, is executed the runtime exception 'Uncompilable code' is thrown
  2. Disable dialog
    1. Run project B
    2. Check 'Always run w/o asking'
    3. Press Run Anyway
    • EXPECTED RESULT: The dialog is never opened when running project with errors

Test suite: J2SE project

  1. Creating project
    1. Create new J2se project from menu (File -> New Project)
    • EXPECTED RESULT: Project is created, main class is generated. Project is compilable and all features (goto type, code completion) works fine.
  2. Adding libraries
    1. Open project properties and select node Libraries
    2. In tab "Compile" press add Library and select some class library
    • EXPECTED RESULT: Library classes are added to project classpath (check by code completion and building project). If library has assigned sources Go To Declaration works for library classes. If the library contains javadoc Javadoc Index Search work as well. (Code completion javadoc depends on sources - it generated directly from comments)
  3. Adding libraries - another way
    1. Open project properties and select node Libraries
    2. In tab "Compile" use add Jar/Folder and and Project
    • EXPECTED RESULT: Classes from jar/folder and from project's output jar are added as in previous case
  4. Adding libraries - building
    1. Build project with added several types of libraries
    • EXPECTED RESULT: Required jars are moved to dist/lib (it have to be JavaApplication not Java Library project and whole folder should not be added in Libraries tab)
  5. Removing libraries
    1. Remove libraries added in previous cases, one by one
    2. Verify project class path after each remove
    • EXPECTED RESULT: The classes from removed libraries are not in classpath any more. It can be verified in code completion and by broken build is library class is used somewhere in the project
  6. Adding source root
    1. Open project properties and select node Sources
    2. Press Add folder in Source packages folder and select some folder with java files (it must not be owned by another project)
    3. Remove the source folder again
    • EXPECTED RESULT:When root is added the java files (and other files) are visible in the project view, the java files are added to classpath (can be verified by code completion). After remove, the java files are not in classpath anymore

Test suite: Sample java project

  1. Sample project
    1. Create all java sample project
    • EXPECTED RESULT:All projects can be created and compiled w/o any problems
     

Test suite: Project view

  1. List
    1. Open anagram game project
    2. Right click in the Project view (to the blank space) and from context menu select View Java Packages as: List
    3. Try some refactoring - rename package, move classes among packages
    • EXPECTED RESULT: Packages are displayed as list - e.g. there is single item for each non-empty package. In this case: com.toy.anagrams.lib and com.toy.anagrams.ui. Refactoring work as expected
  2. Tree
    1. Open anagram game project
    2. Right click in the Project view (to the blank space) and from context menu select View Java Packages as: Tree
    3. Try some refactoring - rename package, move classes among packages
    • EXPECTED RESULT: Packages are displayed as tree - e.g. it is a copy of the directory tree. Refactoring work as expected
  3. Reduced Tree
    1. Open anagram game project
    2. Right click in the Project view (to the blank space) and from context menu select View Java Packages as: Reduced Tree
    3. Try some refactoring - rename package, move classes among packages
    • EXPECTED RESULT: Packages are displayed as combination of previous case. There is one node com.toy.anagrams containing two nodes lib and ui

Test suite: Turning project to shared libraries

Purpose: This suite tests transformation of project to project with sharable libraries

Setup: Prepare several java libraries and jars

  1. Copy Library
    1. Create new project w/o sharable libraries
    2. Add library to its classpath
    3. Open project properties, select Libraries, click on Browse
    4. On 1st page confirm default value
    5. On second page select 'Copy library JAR Files to New Libraries Folder'
    6. Confirm
    • EXPECTED RESULT: The project is successfully transformed, the jars are copied to new location
  2. Keep Library
    1. Create new project w/o sharable libraries
    2. Add library to its classpath
    3. Open project properties, select Libraries, click on Browse
    4. On 1st page confirm default value
    5. On second page select each of values 'Use Relative Path to JAR File' and 'Use Absolute Path to JAR File'
    6. Confirm
    • EXPECTED RESULT: The project is successfully transformed, the jars are not copied to new location, check config file in shared libraries folder that the paths are resolved correctly
  3. Copy JAR
    1. Create new project w/o sharable libraries
    2. Add jar to its classpath
    3. Open project properties, select Libraries, click on Browse
    4. On 1st page confirm default value
    5. On second page select 'Copy JAR/Folder to New Libraries Folder'
    6. Confirm
    • EXPECTED RESULT: The project is successfully transformed, the jars are copied to new location
  4. Keep jars
    1. Create new project w/o sharable libraries
    2. Add jars to its classpath
    3. Open project properties, select Libraries, click on Browse
    4. On 1st page confirm default value
    5. On second page select each of values 'Use Relative Path to JAR/Folder' and 'Use Absolute Path to JAR/Folder'
    6. Confirm
    • EXPECTED RESULT: The project is successfully transformed, the jars are not copied to new location, check config file in shared libraries folder that the paths are resolved correctly

Test suite: Background Scanning

  1. Initial scanning
    1. Start IDE with fresh userdir
    2. Create new java project
    • EXPECTED RESULT: Initial scan is launched when project is created. Local java features - like semantic highlighting, navigator, code folding and local navigation should work. There is not enough information for other features - like cross file navigation, go to type, refactoring, code completion - so this features should display warning that the results may be incomplete or they should be blocked until the scan is finished
  2. Transaction
    1. Open Netbeans module - for example JavaEditor
    2. Try java navigation features - like ctrl click, code completion and go to type
    • EXPECTED RESULT: The scan is started when the module is opened. it starts scanning modules wich the JavaEditor depends on - first is the low level modules, e..g. the modules which does not depend on anything. Local java features should work immediately. Non local features behavior depends on the state of the scan. Each time the module is scanned the repository is updated. For example Go to type should return 'Lookup' once the related module is scanned, while the scan continues. There should be always the warning that the scan is not finished.
  3. Restart IDE
    1. Open some project
    2. Wait until scan is finished
    3. Turn of IDE
    4. Make some changes in opened project
    5. Start IDE again
    • EXPECTED RESULT: When IDE is restarted, the 'update' check is launched. If there is some change the scan is started. It works as described in previous test cases, but this time the metadata are already present - as they were just before closing IDE - so the non local features should work. The changes are taken in account once the related source root is scanned

Test suite: FreeForm project

  1. Creating freeform project
    1. Unzip attached archive
    2. File -> New Project, select Java Free form project
    3. On next page enter the path to the extracted archive in the Location textfield, the others textfields should be filled automatically
    4. On next page the 3 ant targets should be prefilled in appropriate textfields (compile, clean, test), keep the defaults
    5. On next page add 'source' subfolder to Source Package Folders and 'test' subfolder as Test Package Folder, continue on next page
    6. Add CoreLib.jar from libs subfolder to source classpath, and JUnit from the same folder to the classpath for tests
    7. Press Finish
    • EXPECTED RESULT: Project is created, there are no compilations error, project can be build
     

Test suite: Support for annotation processors in the editor

Purpose: There is a new feature on the libraries allowing to add annotation processors to your project (besides putting them directly into the classpath) For this purpose there will be used "lombok" project
Setup: download "lombok.jar" [1] and put into "Processor" (Project Properties | Libraries) and "Compile" tabs. Make sure all check boxes for annotation processing are checked - Project Properties | Build | Compiling | Enable Annotation Processing and Enable Annotations Processing in Editor.

  1. Property options
    1. Select project root of desired java application project and invoke "Properties" popup menu from within "Projects" view.
    2. Choose "Libraries" category. There should be "Processor" tab between "Compile" and "Run" tabs.
    3. Now switch to "Build | Compiling" category.
    • EXPECTED RESULT: There should be "Enable Annotation Processing" and "Enable Annotation Processing in Editor" checkboxes, "Annotation Processors" list with "Add" and "Remove". "Annotation Options" list with "Add" and "Remove" button.
  2. Annotation processor and Code completion
    1. Create new java file.
    2. Enter new property: "private final int i;"
    3. Add annotation "@Data" before "class".
    4. Add annotation "@Getter" before "private ..." class field.
    5. There should be error reported. Add all necessary imports.
    6. Create new method "private void method() { | };" Put the cursor to the position of "|" character in the method. Invoke Code Completion}
    7. Create new java file.
    8. Enter new property: "private final int i;"
    9. Add annotation "@Data" before "class".
    10. Add annotation "@Getter" before "private ..." class field.
    11. There should be error reported. Add all necessary imports.
    • EXPECTED RESULT: After resolving all imports, then "Navigator" window there should be getter for "i", constructor with "i" field initialization. Experiment with other annotations, make sure project is compilable.


     }}

Test suite: Java Platform

Purpose: This test suite tests adding and configuring new java platforms

  1. Java Platform with sources and local javadoc
    1. Open Java Platforms
    2. Click on Add Platform
    3. Specify the path to the JDK and click on Next
    4. Check platform name, and sources location (specify the sources if the zip is not found automatically). Change the javadoc path to javadoc zip (can be downloaded from java.oracle.com)
    5. Check Go to Type and Show javadoc on some class from JDK
    6. Try code completion to show javadoc and complete some JDK class name (e.g. System)
    7. Try code completion to complete some method call (e.g. System.exi)
    • EXPECTED RESULT:The javadoc is loaded from local archive. The go to type open the specified source file. Code completion shows correct javadoc and provides correct argument names (not arg0, arg1). The origin of javadoc can be verified by clicking on 'Browse javadoc' icon in code completion popup, it will open the browser and input related URL.
  2. Java Platform with sources and remote javadoc
    1. Reconfigure the java platform from the previous test case - set the javadoc to be loaded from remote URL (e.g. http://download.oracle.com/javase/7/docs/api/ for jdk 7)
    2. Repeat test from previous test case
    • EXPECTED RESULT:Go to type works the same. Javadoc (in Show javadoc action or code completion) is loaded from URL, which may take some time.

Argument names are obtained from sources, not from remote javadoc (due to performance)

  1. Java platform without sources
    1. Customize java platform created in first test case - delete the sources
    2. Check Go To Type functionality
    3. Check argument names in code completion (e.g. type System.exi and call code completion)
    • EXPECTED RESULT:Go to type open decompiled file - there are method heads but not bodies (only as bytecode in comments). Names of arguments are generic (it the javadoc is remote)
  2. Java Platform without sources - Attach Sources
    1. Open java.lang.String
    2. Click on Attach Sources in upper right editor corner
    3. Specify the path to sources for rt.jar
    4. Check the platform configuration and others features as in first test case
    • EXPECTED RESULT:The specified javadoc is added to platform configuration. From now on, the java platform works as in first test case (or second, if javadoc is remote)
  3. Java Platform without javadoc
    1. Create new java platform, with local sources but without javadoc (or use the platform from previous test case and delete javadoc)
    2. Test javadoc in code completion
    • EXPECTED RESULT:The javadoc is parsed from the JDK sources, so I cannot be opened in external browser. The Browse javadoc button is disabled in code completion
  4. Java Platfrom - attach javadoc
    1. Use platform from previous test case, delete source archive.
    2. Call code completion for some JDK class
    3. In javadoc popup click on Attach javadoc and select local javadoc archive (or specify remote URL)
    • EXPECTED RESULT:The configuration is updated - the javadoc is added to platform
  5. Using java platform
    1. Open some project
    2. In project properties select Libraries
    3. Select one of the java platforms
    • EXPECTED RESULT:The project is compiled and run on specified platform. Note the Source/Binary level when originally the project uses 1.7 and 1.6 platform is selected - there is warning in such case.
  6. Delete java platform
    1. Go to Java Platform
    2. Delete some of the platform
    • EXPECTED RESULT:Platform is deleted. If there is project using this platform, it is rendered red in project view and the missing platform must be resolved. Default platform cannot be deleted.

Test suite: Profiles

Purpose: This test suite describes support for profiles introduced in jdk 1.8
Comments: This test suite requires jdk 1.8

  1. Switching profiles
    1. Create new j2se project
    2. In project properties 'Sources' tab, try changing to each profile
    3. Compile and build project
    • EXPECTED RESULT:There is Profile combo box in Sources tab, values are Full JRE, Compact1, Compact2 and Compact3. After a project is builded, the profile value is correctly propagated to MANIFEST files
  2. Support in code
    1. In the editor type following code: java.util.Map map;
      java.sql.Date date;
      java.lang.instrument.ClassDefinition cd;
      javax.swing.JButton button;
    2. Try switching profiles
    • EXPECTED RESULT:The second line is correct only if profiles is set to compact2 or higher, the third line is valid only for compat3 or higher, the last line is correct only for FullJRE
  3. Code completion
    1. Try using code completion for various profiles
    • EXPECTED RESULT:The code completion will provide only classes which may be used in given profile. List is here [2]
  4. Inspection
    1. Use code from second test case
    2. Select some profile
    3. Run Inspect on current file
    4. From the Configuration combobox select 'JDK8 profiles Conformance' and run inspection
    • EXPECTED RESULT:The inspection will find all occurrences of classes which may not be used in current profile

Test suite: Keep JavaFx on Classpah

Comments: This test suite requires two java platforms, jdk1.7 nad jdk1.8

  1. JDK1.7
    1. Create new J2SE project on platform jdk1.7
    2. Open Project properties and in the Deployment tab, select Keep JavaFX RT artifacts on classpath
    3. Clean and build project
    • EXPECTED RESULT:In the manifest there are added javaFx artifacts : Class-Path: lib/jfxrt.jar lib/javaws.jar lib/deploy.jar lib/plugin.jar
  2. JDK1.8
    1. Switch project from previous test case to jdk1.8 platform
    2. Clean and build
    • EXPECTED RESULT:In the manifest there are added javaFx artifacts : Class-Path: lib/javaws.jar lib/deploy.jar lib/plugin.jar
  3. No support
    1. Open project properties for the project from previous test case
    2. Unselect Keep JavaFX RT artifacts on classpath
    3. Clean and build
    • EXPECTED RESULT:In property Class-Path: in manifest is empty (while the javafx classes can be used in the code without any error)

Test suite: Native Packaging

Comments: This test suite requires correctly installed Inno Setup and WiX

  1. Enable
    1. Create new j2se project
    2. In project properties, deployment tab, select Enable Native Packaging Action in Project Menu
    3. Close project properties
    4. Right click on the project
    • EXPECTED RESULT:There is new item in context menu Package As containing following items: All Artifacts, All Installers, Image Only, EXE installer, MSI installer
  2. Packaging
    1. Try each item from the Package as menu
    • EXPECTED RESULT:Selected artifact is created in the dist/bundles directory
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