use of org.apache.sling.models.impl.injectors.OSGiServiceInjector in project sling by apache.
the class InjectorSpecificAnnotationTest method setup.
@Before
public void setup() {
when(componentCtx.getBundleContext()).thenReturn(bundleContext);
when(componentCtx.getProperties()).thenReturn(new Hashtable<String, Object>());
factory = new ModelAdapterFactory();
factory.activate(componentCtx);
osgiInjector = new OSGiServiceInjector();
osgiInjector.activate(componentCtx);
BindingsInjector bindingsInjector = new BindingsInjector();
ValueMapInjector valueMapInjector = new ValueMapInjector();
ChildResourceInjector childResourceInjector = new ChildResourceInjector();
RequestAttributeInjector requestAttributeInjector = new RequestAttributeInjector();
factory.bindInjector(bindingsInjector, Collections.<String, Object>singletonMap(Constants.SERVICE_ID, 1L));
factory.bindInjector(valueMapInjector, Collections.<String, Object>singletonMap(Constants.SERVICE_ID, 2L));
factory.bindInjector(childResourceInjector, Collections.<String, Object>singletonMap(Constants.SERVICE_ID, 3L));
factory.bindInjector(requestAttributeInjector, Collections.<String, Object>singletonMap(Constants.SERVICE_ID, 4L));
factory.bindInjector(osgiInjector, Collections.<String, Object>singletonMap(Constants.SERVICE_ID, 5L));
factory.bindStaticInjectAnnotationProcessorFactory(bindingsInjector, Collections.<String, Object>singletonMap(Constants.SERVICE_ID, 1L));
factory.bindInjectAnnotationProcessorFactory(valueMapInjector, Collections.<String, Object>singletonMap(Constants.SERVICE_ID, 2L));
factory.bindInjectAnnotationProcessorFactory2(childResourceInjector, Collections.<String, Object>singletonMap(Constants.SERVICE_ID, 3L));
factory.bindStaticInjectAnnotationProcessorFactory(requestAttributeInjector, Collections.<String, Object>singletonMap(Constants.SERVICE_ID, 4L));
factory.bindStaticInjectAnnotationProcessorFactory(osgiInjector, Collections.<String, Object>singletonMap(Constants.SERVICE_ID, 5L));
factory.bindViaProvider(new BeanPropertyViaProvider(), null);
SlingBindings bindings = new SlingBindings();
bindings.setLog(log);
Mockito.when(request.getAttribute(SlingBindings.class.getName())).thenReturn(bindings);
factory.adapterImplementations.addClassesAsAdapterAndImplementation(InjectorSpecificAnnotationModel.class, org.apache.sling.models.testmodels.classes.constructorinjection.InjectorSpecificAnnotationModel.class);
}
use of org.apache.sling.models.impl.injectors.OSGiServiceInjector in project sling by apache.
the class OSGiInjectionTest method setup.
@Before
public void setup() {
when(componentCtx.getBundleContext()).thenReturn(bundleContext);
when(componentCtx.getProperties()).thenReturn(new Hashtable<String, Object>());
factory = new ModelAdapterFactory();
factory.activate(componentCtx);
OSGiServiceInjector injectorFactory = new OSGiServiceInjector();
injectorFactory.activate(componentCtx);
factory.bindInjector(injectorFactory, new ServicePropertiesMap(1, 1));
bindings.setSling(helper);
factory.adapterImplementations.addClassesAsAdapterAndImplementation(SimpleOSGiModel.class, ListOSGiModel.class, RequestOSGiModel.class, ArrayOSGiModel.class, SetOSGiModel.class, OptionalListOSGiModel.class, org.apache.sling.models.testmodels.classes.constructorinjection.ListOSGiModel.class, org.apache.sling.models.testmodels.classes.constructorinjection.SimpleOSGiModel.class, CollectionOSGiModel.class, OptionalArrayOSGiModel.class);
}
Aggregations