Monday, 17 December 2012

OSGi Assertions and Utilities library 1.1.0 released

Hello,

I've released a new version 1.1.0 of OSGi Assertions and Utilities library for integration tests. 

Changes:
  • Asynchronously change Bundle state (install, start, stop, update, uninstall) with and without delays
  •     @Test
        public void test_Start_Bundle_Async() {
            // bundle stopped
            assertBundleState(Bundle.RESOLVED | Bundle.INSTALLED,
                              "org.knowhowlab.osgi.testing.it.test.bundle", 
                              1L, TimeUnit.MILLISECONDS);
            // start bundle in 2 sec
            startBundleAsync(getBundleContext(),  
                             "org.knowhowlab.osgi.testing.it.test.bundle", 
                             2, TimeUnit.SECONDS);
            // bundle is still stopped
            assertBundleState(Bundle.RESOLVED | Bundle.INSTALLED,
                              "org.knowhowlab.osgi.testing.it.test.bundle", 
                              1L, TimeUnit.MILLISECONDS);
            // bundle is active after 5 sec
            assertBundleState(Bundle.ACTIVE,
                              "org.knowhowlab.osgi.testing.it.test.bundle", 
                              5, TimeUnit.SECONDS);
        }
    
  • Asynchronously change Service state (register, update, unregister) with and without delays
  •     @Test
        public void test_RegisterService_Async() {
            // service unregistered
            assertServiceUnavailable(TestService.class);
            // register service in 2 sec
            registerServiceAsync(getBundleContext(), TestService.class, 
                                 new TestService(), null, 2, TimeUnit.SECONDS);
            // service still unregistered
            assertServiceUnavailable(TestService.class);
            // service registered
            assertServiceAvailable(TestService.class, 5, TimeUnit.SECONDS);
        }
    
  • Handle BundleEvents
  •     @Test
        public void test_Bundle_Event() {
            // start bundle in 2 sec
            startBundleAsync(getBundleContext(), 
                             "org.knowhowlab.osgi.testing.it.test.bundle", 
                             2, TimeUnit.SECONDS);
            // expect bundle event within 5 sec
            assertBundleEvent(BundleEvent.STARTED,
                              "org.knowhowlab.osgi.testing.it.test.bundle", 
                              5, TimeUnit.SECONDS);
        }
    
  • Handle ServiceEvents
  •     @Test
        public void test_Service_Event() {
            // register service in 2 sec
            registerServiceAsync(getBundleContext(), TestService.class, 
                                 new TestService(), null, 2, TimeUnit.SECONDS);
            // service registered within 5 sec
            assertServiceEvent(ServiceEvent.REGISTERED, TestService.class, 
                               5, TimeUnit.SECONDS);
        }
    
  • Handle FrameworkEvents
  •     @Test
        public void test_Framework_Event() {
            // change start level
            Executors.newSingleThreadScheduledExecutor()
                       .schedule(new Runnable() {
                                 public void run() {
                                      StartLevel startLevel = 
                                      ServiceUtils.getService(getBundleContext(),
                                                              StartLevel.class);
                                      startLevel.setStartLevel(10);
                                                   }
                                                }, 2, TimeUnit.SECONDS);
    
            // start level changed within 5 sec
            assertFrameworkEvent(FrameworkEvent.STARTLEVEL_CHANGED, 
                                 0, 5, TimeUnit.SECONDS);
        }
    

References:

  1. Sources: GitHub
  2. Mailing List: knowhowlab-osgi-testing


Thank you for your attention. Your feedback is welcome as usual.
Best Regards.

No comments:

Post a Comment