use of org.apache.sling.models.testmodels.classes.SimpleOSGiModel in project sling by apache.
the class OSGiInjectionTest method testSimpleOSGiModelField.
@Test
public void testSimpleOSGiModelField() throws Exception {
ServiceReference ref = mock(ServiceReference.class);
ServiceInterface service = mock(ServiceInterface.class);
when(bundleContext.getServiceReferences(ServiceInterface.class.getName(), null)).thenReturn(new ServiceReference[] { ref });
when(bundleContext.getService(ref)).thenReturn(service);
Resource res = mock(Resource.class);
SimpleOSGiModel model = factory.getAdapter(res, SimpleOSGiModel.class);
assertNotNull(model);
assertNotNull(model.getService());
assertEquals(service, model.getService());
verifyNoMoreInteractions(res);
}
Aggregations