use of org.apache.sling.models.testmodels.classes.SetOSGiModel in project sling by apache.
the class OSGiInjectionTest method testSetOSGiModelField.
@Test
public void testSetOSGiModelField() throws Exception {
ServiceReference ref1 = mock(ServiceReference.class);
ServiceInterface service1 = mock(ServiceInterface.class);
when(bundleContext.getService(ref1)).thenReturn(service1);
ServiceReference ref2 = mock(ServiceReference.class);
ServiceInterface service2 = mock(ServiceInterface.class);
when(bundleContext.getService(ref2)).thenReturn(service2);
when(bundleContext.getServiceReferences(ServiceInterface.class.getName(), null)).thenReturn(new ServiceReference[] { ref1, ref2 });
Resource res = mock(Resource.class);
SetOSGiModel model = factory.getAdapter(res, SetOSGiModel.class);
assertNull(model);
verify(bundleContext).registerService(eq(Runnable.class.getName()), eq(factory), any(Dictionary.class));
verify(bundleContext).addBundleListener(any(BundleListener.class));
verify(bundleContext).registerService(eq(Object.class.getName()), any(Object.class), any(Dictionary.class));
verify(bundleContext).getBundles();
verify(bundleContext).getBundle();
verifyNoMoreInteractions(res, bundleContext);
}
Aggregations