Examples of SlingBindings


Examples of org.apache.sling.api.scripting.SlingBindings

        assertNotNull(context.slingScriptHelper());
    }

    @Test
    public void testSlingBindings() {
        SlingBindings bindings = (SlingBindings) context.request().getAttribute(SlingBindings.class.getName());
        assertNotNull(bindings);
        assertSame(context.request(), bindings.get(SlingBindings.REQUEST));
        assertSame(context.response(), bindings.get(SlingBindings.RESPONSE));
        assertSame(context.slingScriptHelper(), bindings.get(SlingBindings.SLING));
    }
View Full Code Here

Examples of org.apache.sling.api.scripting.SlingBindings

        return bindings.get(name);
    }

    public Object getValue(Object adaptable, String name, Type type, AnnotatedElement element,
            DisposalCallbackRegistry callbackRegistry) {
        SlingBindings bindings = getBindings(adaptable);
        if (bindings == null) {
            return null;
        }
        if (type instanceof Class<?>) {
            return getValue(bindings, name, (Class<?>) type);
View Full Code Here

Examples of org.apache.sling.api.scripting.SlingBindings

    @Mock
    private Resource resource;

    @Before
    public void setUp() {
        SlingBindings bindings = new SlingBindings();
        bindings.put(SlingBindings.SLING, this.scriptHelper);
        when(this.request.getResourceResolver()).thenReturn(this.resourceResolver);
        when(this.request.getResource()).thenReturn(this.resource);
        when(this.request.getAttribute(SlingBindings.class.getName())).thenReturn(bindings);
        when(this.scriptHelper.getResponse()).thenReturn(this.response);
    }
View Full Code Here

Examples of org.apache.sling.api.scripting.SlingBindings

    }

    private SlingScriptHelper getScriptHelper(Object adaptable) {
        if (adaptable instanceof ServletRequest) {
            ServletRequest request = (ServletRequest) adaptable;
            SlingBindings bindings = (SlingBindings) request.getAttribute(SlingBindings.class.getName());
            if (bindings != null) {
                return bindings.getSling();
            } else {
                return null;
            }
        } else {
            return null;
View Full Code Here

Examples of org.apache.sling.api.scripting.SlingBindings

        return null;
    }

    private SlingScriptHelper getSlingScriptHelper(final SlingHttpServletRequest request) {
        SlingBindings bindings = (SlingBindings) request.getAttribute(SlingBindings.class.getName());
        if (bindings != null) {
            return bindings.getSling();
        }
        return null;
    }
View Full Code Here

Examples of org.apache.sling.api.scripting.SlingBindings

    @Before
    public void setup() {
        when(componentCtx.getBundleContext()).thenReturn(bundleContext);
        when(componentCtx.getProperties()).thenReturn(new Hashtable<String, Object>());

        bindings = new SlingBindings();

        factory = new ModelAdapterFactory();
        factory.activate(componentCtx);
        factory.bindInjector(bindingsInjector, new ServicePropertiesMap(1, 1));
        factory.bindInjector(attributesInjector, new ServicePropertiesMap(2, 2));
View Full Code Here

Examples of org.apache.sling.api.scripting.SlingBindings

    public final MockSlingHttpServletRequest request() {
        if (this.request == null) {
            this.request = new MockSlingHttpServletRequest(this.resourceResolver(), this.bundleContext());

            // initialize sling bindings
            SlingBindings bindings = new SlingBindings();
            bindings.put(SlingBindings.REQUEST, this.request);
            bindings.put(SlingBindings.RESPONSE, response());
            bindings.put(SlingBindings.SLING, slingScriptHelper());
            this.request.setAttribute(SlingBindings.class.getName(), bindings);
        }
        return this.request;
    }
View Full Code Here

Examples of org.apache.sling.api.scripting.SlingBindings

    @Before
    public void setup() {
        when(componentCtx.getBundleContext()).thenReturn(bundleContext);
        when(componentCtx.getProperties()).thenReturn(new Hashtable<String, Object>());

        SlingBindings bindings = new SlingBindings();
        bindings.setSling(sling);
        when(request.getAttribute(SlingBindings.class.getName())).thenReturn(bindings);

        factory = new ModelAdapterFactory();
        factory.activate(componentCtx);
        factory.bindInjector(new BindingsInjector(), new ServicePropertiesMap(1, 1));
View Full Code Here

Examples of org.apache.sling.api.scripting.SlingBindings

        factory.bindInjectAnnotationProcessorFactory(requestAttributeInjector,
                Collections.<String, Object> singletonMap(Constants.SERVICE_ID, 4L));
        factory.bindInjectAnnotationProcessorFactory(osgiInjector,
                Collections.<String, Object> singletonMap(Constants.SERVICE_ID, 5L));

        SlingBindings bindings = new SlingBindings();
        bindings.setLog(log);
        Mockito.when(request.getAttribute(SlingBindings.class.getName())).thenReturn(bindings);

    }
View Full Code Here

Examples of org.apache.sling.api.scripting.SlingBindings

        assertEquals(log, model.getService());
    }

    @Test
    public void testScriptVariableField() throws InvalidSyntaxException {
        SlingBindings bindings = new SlingBindings();
        SlingScriptHelper helper = mock(SlingScriptHelper.class);
        bindings.setSling(helper);
        when(request.getAttribute(SlingBindings.class.getName())).thenReturn(bindings);

        InjectorSpecificAnnotationModel model = factory.getAdapter(request, InjectorSpecificAnnotationModel.class);
        assertNotNull("Could not instanciate model", model);
        assertEquals(helper, model.getHelper());
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.