Step 6: Testing the Vendor Application

In this step the application will be tested using the OSGi console commands.

  1. Click in the Console view and type ss to display as short status report of the installed bundles.
  2. osgi> ss
    
    Framework is launched.
    
    id	State       Bundle
    0	ACTIVE      system.bundle_3.2.2.R32x_v20070118
    1	ACTIVE      org.eclipse.equinox.servlet.api_1.0.0.v20060601
    2	ACTIVE      org.eclipse.osgi.services_3.1.100.v20060601
    3	ACTIVE      org.eclipse.soda.sat.core_1.0.0.200702192231
    4	ACTIVE      org.eclipse.soda.sat.tutorial.customer_1.0.0
    5	ACTIVE      org.eclipse.soda.sat.tutorial.vendor.hotdog_1.0.0
    6	ACTIVE      org.eclipse.soda.sat.tutorial.vendor.popcorn_1.0.0
    7	ACTIVE      org.eclipse.soda.sat.tutorial.vendor.service_1.0.0
    
  3. The first thing to notice is that our application is running and that there is no expectation in terms of bundle installation order.
  4. Type bundle 5 to display the details of the org.eclipse.soda.sat.tutorial.vendor.hotdog bundle. You will see that it has registered a VendorService that has the OSGi framework has given a service.id of 22.
    osgi> bundle 5
    initial@reference:file:../../../../workspace/org.eclipse.soda.sat.tutorial.vendor.hotdog/ [5]
      Id=5, Status=ACTIVE
      Registered Services
        {org.eclipse.soda.sat.tutorial.vendor.service.VendorService}={bundle.version=1.0.0,
          service.registration.timestamp=1171816001659, service.id=22}
      No services in use.
      No exported packages
      Imported packages
        org.eclipse.soda.sat.core.framework; version="1.0.0"
        org.eclipse.soda.sat.tutorial.vendor.service; version="0.0.0"
      No fragment bundles
      Named class space
        org.eclipse.soda.sat.tutorial.vendor.hotdog; bundle-version="1.0.0"[provided]
      No required bundles
    
  5. Type bundle 6 to display the details of the org.eclipse.soda.sat.tutorial.vendor.popcorn bundle. You will see that it has registered a VendorService that has the OSGi framework has given a service.id of 23.
    osgi> bundle 6
    initial@reference:file:../../../../home/workspace/org.eclipse.soda.sat.tutorial.vendor.popcorn/ [6]
      Id=6, Status=ACTIVE
      Registered Services
        {org.eclipse.soda.sat.tutorial.vendor.service.VendorService}={bundle.version=1.0.0,
          service.registration.timestamp=1172374204942, service.id=23}
      No services in use.
      No exported packages
      Imported packages
        org.eclipse.soda.sat.core.framework; version="1.0.0"
        org.eclipse.soda.sat.core.util; version="1.0.0"
        org.eclipse.soda.sat.tutorial.vendor.service; version="0.0.0"
      No fragment bundles
      Named class space
        org.eclipse.soda.sat.tutorial.vendor.popcorn; bundle-version="1.0.0"[provided]
      No required bundles
    
  6. Type bundle 4 to display the details of the org.eclipse.soda.sat.tutorial.customer bundle. You will see that it has acquired a VendorService that the OSGi framework has given a service.id of 22.
    osgi> bundle 4
    initial@reference:file:../../../../home/workspace/org.eclipse.soda.sat.tutorial.customer/ [4]
      Id=4, Status=ACTIVE
      No registered services.
      Services in use:
        {org.eclipse.soda.sat.tutorial.vendor.service.VendorService}={bundle.version=1.0.0,
          service.registration.timestamp=1172374204942, service.id=22}
      No exported packages
      Imported packages
        org.eclipse.soda.sat.core.framework; version="1.0.0"
        org.eclipse.soda.sat.core.util; version="1.0.0"
        org.eclipse.soda.sat.tutorial.vendor.service; version="0.0.0"
      No fragment bundles
      Named class space
        org.eclipse.soda.sat.tutorial.customer; bundle-version="1.0.0"[provided]
      No required bundles
    
  7. Both the org.eclipse.soda.sat.tutorial.customer bundle's logging to the console and the fact that it has acquired a VendorService with a service.id of 22 indicates that it is using the org.eclipse.soda.sat.tutorial.vendor.hotdog bundle's implementation of the VendorService interface.
  8. What do you think would happen if we were to stop the org.eclipse.soda.sat.tutorial.vendor.hotdog bundle? Give it a try by typing stop 5.
    osgi> stop 5
    [INFO] 2007-02-24 22:47:13.251 - The Customer bundle has been deactivated
    [INFO] 2007-02-24 22:47:13.251 - The Customer bundle has been activated
    [INFO] 2007-02-24 22:47:13.251 - The Customer bought popcorn from Orville Redenbacher
    [INFO] 2007-02-24 22:47:13.251 - The Hotdog Vendor bundle has been deactivated
    
  9. What just happened? We can confirm this by typing bundle 4 to display the details of the org.eclipse.soda.sat.tutorial.customer bundle.
    osgi> bundle 4
    initial@reference:file:../../../../home/workspace/org.eclipse.soda.sat.tutorial.customer/ [4]
      Id=4, Status=ACTIVE
      No registered services.
      Services in use:
        {org.eclipse.soda.sat.tutorial.vendor.service.VendorService}={bundle.version=1.0.0,
          service.registration.timestamp=1172374642541, service.id=23}
      No exported packages
      Imported packages
        org.eclipse.soda.sat.core.framework; version="1.0.0"
        org.eclipse.soda.sat.core.util; version="1.0.0"
        org.eclipse.soda.sat.tutorial.vendor.service; version="0.0.0"
      No fragment bundles
      Named class space
        org.eclipse.soda.sat.tutorial.customer; bundle-version="1.0.0"[provided]
      No required bundles
    
  10. Sure enough, the org.eclipse.soda.sat.tutorial.customer bundle is now using an implementation of the VendorService with a service.id of 23, which you may recall from earlier, is the service.id given to the VendorService registered by the org.eclipse.soda.sat.tutorial.vendor.popcorn bundle.
  11. What do you think would happen if we were to stop the org.eclipse.soda.sat.tutorial.vendor.popcorn bundle? Give it a try by typing stop 6.
  12. osgi> stop 6
    [INFO] 2007-02-24 22:49:41.674 - The Customer bundle has been deactivated
    [INFO] 2007-02-24 22:49:41.674 - The Popcorn Vendor bundle has been deactivated
    
  13. What just happened? We can confirm this by typing bundle 4 to display the details of the org.eclipse.soda.sat.tutorial.customer bundle.
    osgi> bundle 4
    initial@reference:file:../../../../home/workspace/org.eclipse.soda.sat.tutorial.customer/ [4]
      Id=4, Status=ACTIVE
      No registered services.
      No services in use.
      No exported packages
      Imported packages
        org.eclipse.soda.sat.core.framework; version="1.0.0"
        org.eclipse.soda.sat.core.util; version="1.0.0"
        org.eclipse.soda.sat.tutorial.vendor.service; version="0.0.0"
      No fragment bundles
      Named class space
        org.eclipse.soda.sat.tutorial.customer; bundle-version="1.0.0"[provided]
      No required bundles
    
  14. Sure enough, the org.eclipse.soda.sat.tutorial.customer bundle is no longer using a VendorService.
  15. Starting the org.eclipse.soda.sat.tutorial.vendor.hotdog bundle and/or the org.eclipse.soda.sat.tutorial.vendor.popcorn bundle will cause the org.eclipse.soda.sat.tutorial.customer bundle to be activated once more.
  16. Let's start both bundles by typing start 5 6.
    osgi> start 5 6
    [INFO] 2007-02-24 22:51:29.149 - The Hotdog Vendor bundle has been activated
    [INFO] 2007-02-24 22:51:29.149 - The Customer bundle has been activated
    [INFO] 2007-02-24 22:51:29.149 - The Customer bought hotdog from Ball Park
    [INFO] 2007-02-24 22:51:29.149 - The Popcorn Vendor bundle has been activated
    
  17. Not surprisingly the org.eclipse.soda.sat.tutorial.customer bundle was activated once more since it was able to acquire the VendorService registered by the org.eclipse.soda.sat.tutorial.vendor.hotdog bundle.
  18. Having tested the application, let's type shutdown to shutdown the OSGi framework.
    osgi> shutdown
    [INFO] 2007-02-24 22:52:10.087 - The Popcorn Vendor bundle has been deactivated
    [INFO] 2007-02-24 22:52:10.087 - The Customer bundle has been deactivated
    [INFO] 2007-02-24 22:52:10.087 - The Hotdog Vendor bundle has been deactivated
    [INFO] 2007-02-24 22:52:10.087 - The Customer bundle has been stopped
    
  19. Now type ss to get a short status of the bundles.
          
    osgi> ss
    
    Framework is shutdown.
    
    id	State       Bundle
    0	RESOLVED    system.bundle_3.2.2.R32x_v20070118
    1	INSTALLED   org.eclipse.equinox.servlet.api_1.0.0.v20060601
    2	INSTALLED   org.eclipse.osgi.services_3.1.100.v20060601
    3	INSTALLED   org.eclipse.soda.sat.core_1.0.0.200702192231
    4	INSTALLED   org.eclipse.soda.sat.tutorial.customer_1.0.0
    5	INSTALLED   org.eclipse.soda.sat.tutorial.vendor.hotdog_1.0.0
    6	INSTALLED   org.eclipse.soda.sat.tutorial.vendor.popcorn_1.0.0
    7	INSTALLED   org.eclipse.soda.sat.tutorial.vendor.service_1.0.0
    
  20. As you can see the framework is now shutdown and all the bundles have reverted to the INSTALLED state.
  21. Since the bundles are persisted by the OSGi framework it is possible to launch the framework and have the application start once more. Launch the framework by typing launch, and then set the framework's start level to 6 by typing setfwsl 6.
    osgi> launch
    
    osgi> setfwsl 6
    Framework Active Start Level = 6
    
    osgi> [INFO] 2007-02-24 22:53:04.686 - The Customer bundle has been started
    [INFO] 2007-02-24 22:53:04.686 - The Hotdog Vendor bundle has been activated
    [INFO] 2007-02-24 22:53:04.696 - The Customer bundle has been activated
    [INFO] 2007-02-24 22:53:04.696 - The Customer bought hotdog from Ball Park
    [INFO] 2007-02-24 22:53:04.696 - The Popcorn Vendor bundle has been activated
    
  22. Finally, to terminate the application by typing close.
  23. osgi> close
    
    [INFO] 2007-02-24 22:53:31.575 - The Popcorn Vendor bundle has been deactivated
    [INFO] 2007-02-24 22:53:31.575 - The Customer bundle has been deactivated
    [INFO] 2007-02-24 22:53:31.575 - The Hotdog Vendor bundle has been deactivated
    [INFO] 2007-02-24 22:53:31.575 - The Customer bundle has been stopped