예제 #1
0
 @Override
 public void setDependencies(BundleContext bundleContext, ServiceReference serviceReference) {
   eventDispatcher =
       (EventDispatcher) ServiceHelper.getGlobalInstance(EventDispatcher.class, this);
   eventDispatcher.eventHandlerAdded(
       bundleContext.getServiceReference(INeutronFirewallAware.class.getName()), this);
 }
예제 #2
0
  @Test
  public void testSetDependencies() throws Exception {
    NeutronL3Adapter neutronL3Adapter = mock(NeutronL3Adapter.class);
    EventDispatcher eventDispatcher = mock(EventDispatcher.class);

    PowerMockito.mockStatic(ServiceHelper.class);
    PowerMockito.when(ServiceHelper.getGlobalInstance(NeutronL3Adapter.class, routerHandler))
        .thenReturn(neutronL3Adapter);
    PowerMockito.when(ServiceHelper.getGlobalInstance(EventDispatcher.class, routerHandler))
        .thenReturn(eventDispatcher);

    routerHandler.setDependencies(mock(BundleContext.class), mock(ServiceReference.class));

    assertEquals(
        "Error, did not return the correct object", getField("neutronL3Adapter"), neutronL3Adapter);
    assertEquals(
        "Error, did not return the correct object", routerHandler.eventDispatcher, eventDispatcher);
  }