Package org.apache.aries.blueprint.sample

Examples of org.apache.aries.blueprint.sample.DefaultRunnable


    public void testDefaultReference() throws Exception {
      BlueprintContainer blueprintContainer = Helper.getBlueprintContainerForBundle(context(), "org.apache.aries.blueprint.sample");
      assertNotNull(blueprintContainer);

      Runnable refRunnable = (Runnable) blueprintContainer.getComponentInstance("refWithDefault");
      DefaultRunnable defaultRunnable = (DefaultRunnable) blueprintContainer.getComponentInstance("defaultRunnable");
      refRunnable.run();
     
      assertEquals("The default runnable was not called", 1, defaultRunnable.getCount());
     
      Runnable mockService = Skeleton.newMock(Runnable.class);
     
      ServiceRegistration reg = bundleContext.registerService(Runnable.class.getName(), mockService, null);
     
      refRunnable.run();
     
      assertEquals("The default runnable was called when a service was bound", 1, defaultRunnable.getCount());
     
      Skeleton.getSkeleton(mockService).assertCalled(new MethodCall(Runnable.class, "run"));
     
      reg.unregister();
     
      refRunnable.run();
     
      assertEquals("The default runnable was not called", 2, defaultRunnable.getCount());
    }
View Full Code Here


    public void testDefaultReference() throws Exception {
      BlueprintContainer blueprintContainer = Helper.getBlueprintContainerForBundle(context(), "org.apache.aries.blueprint.sample");
      assertNotNull(blueprintContainer);

      Runnable refRunnable = (Runnable) blueprintContainer.getComponentInstance("refWithDefault");
      DefaultRunnable defaultRunnable = (DefaultRunnable) blueprintContainer.getComponentInstance("defaultRunnable");
      refRunnable.run();
      waitForAsynchronousHandling();
      Thread.sleep(2000);
     
      assertEquals("The default runnable was not called", 1, defaultRunnable.getCount());
     
      Runnable mockService = Skeleton.newMock(Runnable.class);
     
      ServiceRegistration reg = bundleContext.registerService(Runnable.class.getName(), mockService, null);
      waitForAsynchronousHandling();
      Thread.sleep(2000);

      refRunnable.run();
     
      assertEquals("The default runnable was called when a service was bound", 1, defaultRunnable.getCount());
     
      Skeleton.getSkeleton(mockService).assertCalled(new MethodCall(Runnable.class, "run"));
     
      reg.unregister();
      waitForAsynchronousHandling();
      Thread.sleep(2000);

      refRunnable.run();
     
      assertEquals("The default runnable was not called", 2, defaultRunnable.getCount());
    }
View Full Code Here

TOP

Related Classes of org.apache.aries.blueprint.sample.DefaultRunnable

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.