Java Code Examples for org.apache.sling.api.scripting.SlingBindings#setLog()

The following examples show how to use org.apache.sling.api.scripting.SlingBindings#setLog() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: RequestInjectionTest.java    From sling-org-apache-sling-models-impl with Apache License 2.0 5 votes vote down vote up
@Before
public void setup() {
    SlingBindings bindings = new SlingBindings();
    bindings.setSling(sling);
    bindings.setLog(LoggerFactory.getLogger("test"));
    when(request.getAttribute(SlingBindings.class.getName())).thenReturn(bindings);

    factory = AdapterFactoryTest.createModelAdapterFactory();
    factory.bindInjector(new BindingsInjector(), new ServicePropertiesMap(1, 1));
    factory.adapterImplementations.addClassesAsAdapterAndImplementation(BindingsModel.class, org.apache.sling.models.testmodels.classes.constructorinjection.BindingsModel.class);
}
 
Example 2
Source File: InjectorSpecificAnnotationTest.java    From sling-org-apache-sling-models-impl with Apache License 2.0 5 votes vote down vote up
@Before
public void setup() {
    factory = AdapterFactoryTest.createModelAdapterFactory();

    osgiInjector = new OSGiServiceInjector();
    osgiInjector.activate(bundleContext);

    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.injectAnnotationProcessorFactories = Collections.<InjectAnnotationProcessorFactory>singletonList(valueMapInjector);
    factory.injectAnnotationProcessorFactories2 = Collections.<InjectAnnotationProcessorFactory2>singletonList(childResourceInjector);
    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);
}