TS 71 Templates

(Difference between revisions)
(Test Specification for File Types and Project Templates)
(Test suite: New File Type Wizard)
Line 31: Line 31:
# {{testcase|Code Generation}}
# {{testcase|Code Generation}}
## Click Finish.
## Click Finish.
-
#* {{result|EXPECTED RESULT: The following files are created in the test package: ABCDataObject.java, ABCResolver.xml, ABCTemplate,abc, ABCVisualElement.java and layer.xml}}
+
#* {{result|EXPECTED RESULT: The following files are created in the test package: ABCDataObject.java, ABCResolver.xml, ABCTemplate.abc, ABCVisualElement.java and layer.xml}}
# {{testcase|Testing the behaviour of the new file type module}}
# {{testcase|Testing the behaviour of the new file type module}}
## Right click on the module and choose Run.
## Right click on the module and choose Run.

Revision as of 17:01, 13 November 2011

Test Specification for File Types and Project Templates

Author: Hermien Pellissier
Version: NetBeans 7.1
Last update: 23 October 2011
Introduction: Test cases for testing of file types and project templates support in the NetBeans platform.

Contents


Test suite: New File Type Wizard

Purpose: Verifying that the new File Type Wizard generates the correct code for registering a new file type in a platform application.
Setup: Create a new stand alone NetBeans module with code name base "test". This module will be used throughout the rest of the tests, and where applicable this will be referred to as Module A.

  1. Invalid MIME Type
    1. Select the "test" package in the newly created module.
    2. Choose File | New File... from the main IDE menu bar.
    3. Under categories select Module Development and under File Types select File Type.
    4. Click Next.
    5. Type an invalid MIME Type such as "abc".
    • EXPECTED RESULT: The next and finish buttons remain disabled and an error message is displayed.
  2. Valid MIME Type
    1. Change the MIME Type to the valid value "text/abc" (without the quotes).
    2. Choose the "by Filename Extension" option and enter "abc" for the extension.
    • EXPECTED RESULT: The next and finish buttons are enabled.
  3. Invalid Class Name Prefix
    1. Click next.
    2. On the "Name, Icon and Location" page, enter an invalid Class Name Prefix, e.g. a name starting with a digit.
    • EXPECTED RESULT: The next and finish buttons are disabled and an error message is displayed.
  4. Valid Class Name Prefix
    1. Enter a the following valid class name prefix: ABC.
    • EXPECTED RESULT: The finish button is enabled.
  5. Code Generation
    1. Click Finish.
    • EXPECTED RESULT: The following files are created in the test package: ABCDataObject.java, ABCResolver.xml, ABCTemplate.abc, ABCVisualElement.java and layer.xml
  6. Testing the behaviour of the new file type module
    1. Right click on the module and choose Run.
    2. In the platform application that starts up, choose File | New Project. Create a new Java Application.
    3. Select the new project in the Projects view.
    4. Go to File | New File... on the main menu bar.
    5. Under categories choose "Other" and under File Types choose "Empty ABC file".
    6. Click the Next button.
    7. Specify a file name and click Finish.
    • EXPECTED RESULT: A new file is created with some sample content.

Test suite: @TemplateRegistration for File Type

Purpose: Verifying that the new @TemplateRegistration works correctly (see also NewAndNoteworthyNB71#Templates). This new annotation can be used to register file types without having to specify them in the layer.xml file.
Setup: The module created in the previous test suite (Module A) will be reused here.

  1. Changing to use @TemplateRegistration
    1. From the module created previously, open ABCTemplate.abc, and modify the content to be "different sample content".
    2. Open the layer.xml file. Delete all of the contents of the <filesystem> tag and save the layer file.
    3. Select the test package, go to File | New File... and create a new Java Package Info file (from the Java category).
    4. Change the package file to look as follows:
      @org.netbeans.api.templates.TemplateRegistration(folder="Other", content="ABCTemplate.abc", displayName="Different empty ABC file")
      package test;
    5. Clean and build the module.
    6. In the Files view, find the generated layer file (build/cluster/modules/test.jar/META-INF/generated-layer.xml) and inspect it.
    • EXPECTED RESULT: A Templates folder as well as a folder called Editors should be present in the generated layer file.
  2. Testing the behaviour of the changed module
    1. Select the module in the Projects view and Run it.
    2. In the platform application that starts up, choose File | New Project. Create a new Java Application.
    3. Select the new project in the Projects view.
    4. Go to File | New File... on the main menu bar.
    5. Under categories choose "Other" and under File Types choose "Different empty ABC file" (note the change in name from the previous test suite!).
    6. Click the Next button.
    7. Specify a file name and click Finish.
    • EXPECTED RESULT: A new file is created with the content "different sample content".

Test suite: New Project Template Wizard

Purpose: Verifying that the new Project Template Wizard generates the correct code for registering a new project in a platform application.
Setup: A project template is created from an existing project. We will re-use the project created in the previous test suites (Module A) for this purpose. Module A should be open in the IDE at the start of this test suite. Create another standalone module (Module B) with code name base "template".

  1. Invalid Template Name
    1. Select the "template" package in the newly created module.
    2. Choose File | New File... from the main IDE menu bar.
    3. Under categories select Module Development and under File Types select Project Template.
    4. Click Next.
    5. Select Module A from the list of projects.
    6. Click Next.
    7. Type an invalid Template Name, such as a name starting with a digit.
    • EXPECTED RESULT: The next and finish buttons remain disabled and an error message is displayed.
  2. Valid Template Name
    1. Change the template name to the following valid value: ABCProject
    • EXPECTED RESULT: The error message is no longer displayed and the Finish button is enabled.
  3. Generating the Code
    1. Enter the following display name: ABC Project
    2. Choose the APISupport Category if not already selected by default.
    3. Click Finish.
    • EXPECTED RESULT: The following files are created: ABCProjectDescription.html, ABCProjectPanelVisual.java, ABCProjectProject.zip, ABCProjectWizardIterator.java, ABCProjectWizardPanel.java and layer.xml
  4. Testing the behaviour of the new project template module
    1. Right click on Module B and choose Run.
    2. In the platform application that starts up, choose File | New Project.
    3. Choose the Netbeans Modules category, and pick ABC Project from the Projects list.
    4. Click next.
    5. Specify a location for the new project and click Finish.
    • EXPECTED RESULT: A new project is created with the same structure as Module A.

Test suite: @TemplateRegistration for Project Template

Purpose: Verifying that the new @TemplateRegistration works correctly (see also NewAndNoteworthyNB71#Templates). This new annotation can be used to register project templates without having to specify them in the layer.xml file.
Setup: The module created in the previous test suite (Module B) will be reused here.

  1. Changing to use @TemplateRegistration
    1. Open the layer.xml file of Module B. Delete all of the contents of the <filesystem> tag and save the layer file.
    2. Open ABCProjectWizardIterator.java, and add the following annotation onto the class:
      @org.netbeans.api.templates.TemplateRegistration(folder="Project/Samples", content="ABCProjectProject.zip", displayName="ABC Project")
    3. Clean and build the module.
    4. In the Files view, find the generated layer file (build/cluster/modules/template.jar/META-INF/generated-layer.xml) and inspect it.
    • EXPECTED RESULT: A Templates folder should be present in the generated layer file.
  2. Testing the behaviour of the changed project template module
    1. Right click on Module B and choose Run.
    2. In the platform application that starts up, choose File | New Project.
    3. Choose the Samples category (note the change from before where it used to be in the NetBeans Modules category!), and pick ABC Project from the Projects list.
    4. Click next.
    5. Specify a location for the new project and click Finish.
    • EXPECTED RESULT: A new project is created with the same structure as Module A.
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