TS 73 Apisupport OSGI

Apisupport OSGI test Specification

Author: Tomas Musil and Hermien Pellissier
Version: 1.1
Last updated: 11 October 2012
Introduction: This test specification covers the most important features of OSGi functionality in Ant-based projects.

Contents


Test suite: Ant OSGi Bundle

Purpose: Test creation of an OSGi Bundle project archetype and appropriate file templates.
Setup: No special steps are required.

  1. Create OSGi Bundle
    1. In new project wizard (File > New Project...), choose the NetBeans Modules category and Module project type.
    2. On the Name and Location panel, choose Standalone Module.
    3. On the Basic Module Configuration panel, enter a valid code name base and check Generate OSGi Bundle.
    4. Click Finish.
    • EXPECTED RESULT: The new OSGi Bundle project is created with an OSGi specific icon. The project structure should look like an ordinary Ant-based Module project.
  2. OSGi Metadata
    1. Clean and build the newly created project.
    2. Navigate to Files view.
    3. In build folder browse to cluster/modules.
    4. Expand the JAR file and open it's manifest file (META-INF/MANIFEST.MF).
    • EXPECTED RESULT: The manifest should contain OSGi metadata (Bundle-Name, Bundle-Version etc).
  3. Project Customizer
    1. In the package that should already be in the project, create a new empty Java class.
    2. Right-click on the project and choose Properties from the context menu.
    3. Under the Sources category, change the source level.
    4. Under the Libraries category, on the Module Dependencies tab, click Add... and choose the Lookup API module.
    5. Under the Display category, change the Display Name property.
    6. Under the API Versioning category, change the Specification Version.
    7. Still under the API Versioning category, mark the single package in the project as public.
    8. Click OK.
    9. Clean and build the project.
    10. Open the manifest file from the JAR again (ensure that you are in fact seeing the new version!).
    • EXPECTED RESULT: All changes are reflected in manifest.mf, including new Export-Package and Require-Bundle lines, and Bundle.properties (for the display name).
  4. Bundle Activator
    1. Right-click on the project and choose New > Other....
    2. Choose the Module Development category and Installer / Activator file type.
    3. Click Next.
    4. Choose a package if not selected.
    5. Click Finish.
    6. Add the following code to the generated start() method: System.out.println("Bundles: " + c.getBundles().length);
    7. Clean and Build the project.
    8. Verify that activator is registered in the manifest.mf in the output jar.
    9. Run the project.
    • EXPECTED RESULT: The application is started. In the output window in the IDE, there should now be a line starting with "Bundles:". (Search for it - it won't be the last line).
  5. Compatibility with NetBeans Module System
    1. Create a new Action (right-click the project, choose New > Action).
    2. Accept the default values, noting the location in the menu system.
    3. Choose a display name and Finish the wizard.
    4. Check that there are new dependencies on a number of NetBeans modules.
    5. Build and Run the project.
    • EXPECTED RESULT: After the application starts, the action appears on the menu bar in the location noted earlier. This proves that an OSGi module can depend on NetBeans Modules.

Test suite: Module suite with OSGi Bundle

Purpose: Test creation of a suite containing an OSGi Bundle project as well as dependencies on standard NetBeans modules.
Setup: A GlassFish installation is required to test dependencies on external OSGi bundles.

  1. Module suite with added cluster
    1. Create new module suite
    2. Create new OSGi bundle in it.
    3. Create new module in it.
    4. Go to suite customizer
    5. Check only platform cluster
    6. Invoke Add cluster
    7. Browse for some folder with OSGi bundle(s). You can use e.g. modules in Glassfish installation.
    • EXPECTED RESULT: Cluster is successfully added, modules in it can be included/exluded
  2. Add dependency on OSGi Bundle
    1. Create in empty Module in suite some package and class
    2. In project customizer, add this package as public
    3. Invoke Add dependency in empty OSGi bundle in suite and add dependency on this empty module
    4. Use some class from OSGI bundle in module
    • EXPECTED RESULT: Code completion should work, suite can be compiled.
  3. Add dependency on Module
    1. Very similar to previous test case, try to add dependency on Module from suite in OSGi bundle in suite.
    • EXPECTED RESULT: Code completion should work, suite can be compiled.
  4. Add dependency for Module on Bundle from external cluster
    1. Add dependency on some bundle from externally added cluster and use it in code of Module
    • EXPECTED RESULT: Code completion should work, suite can be compiled.
  5. Add dependency for OSGi Bundle on Bundle from external cluster
    1. Add dependency on some bundle from externally added cluster and use it in code of OSGi Bundle
    • EXPECTED RESULT: Code completion should work, suite can be compiled.

Test suite: Felix Container Support (Experimental)

Purpose: Testing the support for running an application in the Felix container.
Setup: No special steps are required.

  1. Run in Felix
    1. Create new NetBeans platform app project
    2. Invoke from its popup OSGI > Run in Felix
    • EXPECTED RESULT: Platform instance is correctly started.
  2. Debug in Felix
    1. Create some new module to NetBeans platform app project
    2. Create some new OSGi bundle to NetBeans platform app project
    3. Create new bundle activator for OSGi bundle, type some code into start() method and put there breakpoint
    4. Create new module installer for module, type some code into restored() method and put there breakpoint
    5. Invoke from platform app project popup: OSGi > Debug in Felix
    • EXPECTED RESULT: Debugger should stop on both breakpoints.
  3. Profile in Felix
    1. Invoke from platform app project popup OSGi > Profile in Felix
    • EXPECTED RESULT: You are able to collect e.g. live results from profiler.

Test suite: Building (Experimental)

Purpose: Testing the support for building bundles and bundle repositories.
Setup: No special steps are required.

  1. Build Bundles
    1. Create a new NetBeans Platform Application project.
    2. From the platform application project's context menu, invoke OSGi > Build Bundles.
    • EXPECTED RESULT: OSGi bundle JAR files are created in the build/osgi folder. Check also that JAR files contain OSGi metadata in their MANIFEST.MF files.
  2. Build Bundle Repository
    1. Clean and build the project created in the previous test.
    2. From the platform application project's context menu, invoke OSGi > Build Bundle Repository.
    • EXPECTED RESULT: OSGi bundle JAR files are created in the build/osgi folder. Additionally, the repository.xml file is created in the same location, describing repository.
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