当前位置: 首页>>代码示例>>Java>>正文


Java SlingBindings.put方法代码示例

本文整理汇总了Java中org.apache.sling.api.scripting.SlingBindings.put方法的典型用法代码示例。如果您正苦于以下问题:Java SlingBindings.put方法的具体用法?Java SlingBindings.put怎么用?Java SlingBindings.put使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.apache.sling.api.scripting.SlingBindings的用法示例。


在下文中一共展示了SlingBindings.put方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: prepareRequestResponsePair

import org.apache.sling.api.scripting.SlingBindings; //导入方法依赖的package包/类
private Pair<MockSlingHttpServletRequest, MockSlingHttpServletResponse> prepareRequestResponsePair(String resourcePath,
                                                                                                   long lastModifiedDate,
                                                                                                   String selectorString,
                                                                                                   String requestExtension,
                                                                                                   String suffixExtension) {
    final MockSlingHttpServletRequest request =
            new MockSlingHttpServletRequest(CONTEXT.resourceResolver(), CONTEXT.bundleContext());
    final MockSlingHttpServletResponse response = new MockSlingHttpServletResponse();
    Resource resource = resourceResolver.getResource(resourcePath);
    request.setResource(resource);
    MockRequestPathInfo requestPathInfo = (MockRequestPathInfo) request.getRequestPathInfo();
    requestPathInfo.setSuffix("/" + lastModifiedDate + "." + suffixExtension);
    requestPathInfo.setSelectorString(selectorString);
    requestPathInfo.setExtension(requestExtension);
    requestPathInfo.setResourcePath(resourcePath);
    request.setContextPath(CONTEXT_PATH);
    SlingBindings bindings = new SlingBindings();
    bindings.put(SlingBindings.REQUEST, request);
    bindings.put(SlingBindings.RESPONSE, response);
    bindings.put(SlingBindings.SLING, CONTEXT.slingScriptHelper());
    bindings.put(SlingBindings.RESOLVER, resourceResolver);
    request.setAttribute(SlingBindings.class.getName(), bindings);
    return new RequestResponsePair(request, response);
}
 
开发者ID:Adobe-Marketing-Cloud,项目名称:aem-core-wcm-components,代码行数:25,代码来源:AdaptiveImageServletTest.java

示例2: getContainerUnderTest

import org.apache.sling.api.scripting.SlingBindings; //导入方法依赖的package包/类
private Container getContainerUnderTest(String resourcePath) {
    Resource resource = CONTEXT.resourceResolver().getResource(resourcePath);
    if (resource == null) {
        throw new IllegalStateException("Does the test resource " + resourcePath + " exist?");
    }
    SlingBindings bindings = new SlingBindings();
    MockSlingHttpServletRequest request = new MockSlingHttpServletRequest(CONTEXT.resourceResolver(), CONTEXT.bundleContext());
    MockSlingHttpServletResponse response = new MockSlingHttpServletResponse();
    request.setContextPath(CONTEXT_PATH);
    request.setResource(resource);
    bindings.put(SlingBindings.RESOURCE, resource);
    bindings.put(WCMBindings.PROPERTIES, resource.getValueMap());
    bindings.put(SlingBindings.REQUEST, request);
    bindings.put(SlingBindings.RESPONSE, response);
    Page page = CONTEXT.currentPage(CONTAINING_PAGE);
    bindings.put(WCMBindings.CURRENT_PAGE, page);
    request.setRequestDispatcherFactory(requestDispatcherFactory);
    request.setAttribute(SlingBindings.class.getName(), bindings);
    return request.adaptTo(Container.class);
}
 
开发者ID:Adobe-Marketing-Cloud,项目名称:aem-core-wcm-components,代码行数:21,代码来源:ContainerImplTest.java

示例3: getBreadcrumbUnderTest

import org.apache.sling.api.scripting.SlingBindings; //导入方法依赖的package包/类
private Breadcrumb getBreadcrumbUnderTest(String resourcePath, Style style) {
    Resource resource = CONTEXT.resourceResolver().getResource(resourcePath);
    if (resource == null) {
        throw new IllegalStateException("Did you forget to define test resource " + resourcePath + "?");
    }
    MockSlingHttpServletRequest request = new MockSlingHttpServletRequest(CONTEXT.resourceResolver(), CONTEXT.bundleContext());
    request.setResource(resource);
    request.setContextPath("");
    SlingBindings bindings = new SlingBindings();
    bindings.put(SlingBindings.RESOURCE, resource);
    bindings.put(WCMBindings.PROPERTIES, resource.getValueMap());
    bindings.put(WCMBindings.CURRENT_PAGE, CONTEXT.pageManager().getPage(CURRENT_PAGE));
    if (style == null) {
        style = mock(Style.class);
        when(style.get(any(), any(Object.class))).thenAnswer(
                invocation -> invocation.getArguments()[1]
        );
    }
    bindings.put(WCMBindings.CURRENT_STYLE, style);
    request.setAttribute(SlingBindings.class.getName(), bindings);
    return request.adaptTo(Breadcrumb.class);
}
 
开发者ID:Adobe-Marketing-Cloud,项目名称:aem-core-wcm-components,代码行数:23,代码来源:BreadcrumbImplTest.java

示例4: getListUnderTest

import org.apache.sling.api.scripting.SlingBindings; //导入方法依赖的package包/类
private List getListUnderTest(String resourcePath) {
    Resource resource = CONTEXT.resourceResolver().getResource(resourcePath);
    if (resource == null) {
        throw new IllegalStateException("Did you forget to defines test resource " + resourcePath + "?");
    }
    MockSlingHttpServletRequest request = new MockSlingHttpServletRequest(CONTEXT.resourceResolver(), CONTEXT.bundleContext());
    request.setResource(resource);
    SlingBindings bindings = new SlingBindings();
    bindings.put(SlingBindings.RESOURCE, resource);
    bindings.put(SlingBindings.REQUEST, request);
    bindings.put(WCMBindings.PROPERTIES, resource.getValueMap());
    Style style = mock(Style.class);
    when(style.get(any(), any(Object.class))).thenAnswer(
            invocation -> invocation.getArguments()[1]
    );
    bindings.put(WCMBindings.CURRENT_STYLE, style);
    bindings.put(WCMBindings.CURRENT_PAGE, CONTEXT.pageManager().getPage(CURRENT_PAGE));
    request.setAttribute(SlingBindings.class.getName(), bindings);
    return request.adaptTo(List.class);
}
 
开发者ID:Adobe-Marketing-Cloud,项目名称:aem-core-wcm-components,代码行数:21,代码来源:ListImplTest.java

示例5: getSocialMediaHelperUnderTest

import org.apache.sling.api.scripting.SlingBindings; //导入方法依赖的package包/类
private SocialMediaHelper getSocialMediaHelperUnderTest(String pagePath) {
    Resource currentResource = CONTEXT.resourceResolver().getResource(pagePath);
    Page currentPage = currentResource.adaptTo(Page.class);
    MockSlingHttpServletRequest request = new MockSlingHttpServletRequest(CONTEXT.resourceResolver(), CONTEXT.bundleContext());
    MockSlingHttpServletResponse response = new MockSlingHttpServletResponse();
    request.setContextPath(CONTEXT_PATH);
    request.setResource(currentResource);
    MockRequestPathInfo requestPathInfo = (MockRequestPathInfo) request.getRequestPathInfo();
    requestPathInfo.setExtension(EXTENSION);
    requestPathInfo.setResourcePath(currentResource.getPath());
    SlingBindings slingBindings = new SlingBindings();
    slingBindings.put(WCMBindings.CURRENT_PAGE, currentPage);
    slingBindings.put(SlingBindings.RESOLVER, CONTEXT.resourceResolver());
    slingBindings.put(SlingBindings.RESPONSE, response);
    request.setAttribute(SlingBindings.class.getName(), slingBindings);
    return request.adaptTo(SocialMediaHelper.class);
}
 
开发者ID:Adobe-Marketing-Cloud,项目名称:aem-core-wcm-components,代码行数:18,代码来源:SocialMediaHelperImplTest.java

示例6: getTitleUnderTest

import org.apache.sling.api.scripting.SlingBindings; //导入方法依赖的package包/类
private Title getTitleUnderTest(String resourcePath, Style style) {
    Resource resource = CONTEXT.resourceResolver().getResource(resourcePath);
    if (resource == null) {
        throw new IllegalStateException("Did you forget to define test resource " + resourcePath + "?");
    }
    MockSlingHttpServletRequest request = new MockSlingHttpServletRequest(CONTEXT.resourceResolver(), CONTEXT.bundleContext());
    SlingBindings bindings = new SlingBindings();
    bindings.put(SlingBindings.RESOURCE, resource);
    bindings.put(SlingBindings.REQUEST, request);
    bindings.put(WCMBindings.PROPERTIES, resource.getValueMap());
    bindings.put(WCMBindings.CURRENT_PAGE, CONTEXT.pageManager().getPage(TEST_PAGE));
    if (style == null) {
        style = mock(Style.class);
    }
    bindings.put(WCMBindings.CURRENT_STYLE, style);
    request.setResource(resource);
    request.setAttribute(SlingBindings.class.getName(), bindings);
    return request.adaptTo(Title.class);
}
 
开发者ID:Adobe-Marketing-Cloud,项目名称:aem-core-wcm-components,代码行数:20,代码来源:TitleImplTest.java

示例7: getListUnderTest

import org.apache.sling.api.scripting.SlingBindings; //导入方法依赖的package包/类
private List getListUnderTest(String resourcePath) {
    Resource resource = CONTEXT.resourceResolver().getResource(resourcePath);
    if (resource == null) {
        throw new IllegalStateException("Did you forget to defines test resource " + resourcePath + "?");
    }
    MockSlingHttpServletRequest request = new MockSlingHttpServletRequest(CONTEXT.resourceResolver(), CONTEXT.bundleContext());
    request.setResource(resource);
    request.setContextPath(CONTEXT_PATH);
    SlingBindings bindings = new SlingBindings();
    bindings.put(SlingBindings.RESOURCE, resource);
    bindings.put(SlingBindings.REQUEST, request);
    bindings.put(WCMBindings.PROPERTIES, resource.getValueMap());
    Style style = mock(Style.class);
    when(style.get(any(), any(Object.class))).thenAnswer(
            invocation -> invocation.getArguments()[1]
    );
    bindings.put(WCMBindings.CURRENT_STYLE, style);
    bindings.put(WCMBindings.CURRENT_PAGE, CONTEXT.pageManager().getPage(CURRENT_PAGE));
    request.setAttribute(SlingBindings.class.getName(), bindings);
    return request.adaptTo(List.class);
}
 
开发者ID:Adobe-Marketing-Cloud,项目名称:aem-core-wcm-components,代码行数:22,代码来源:ListImplTest.java

示例8: getTextUnderTest

import org.apache.sling.api.scripting.SlingBindings; //导入方法依赖的package包/类
private Text getTextUnderTest(String resourcePath) {
    Resource resource = CONTEXT.resourceResolver().getResource(resourcePath);
    MockSlingHttpServletRequest request = new MockSlingHttpServletRequest(CONTEXT.resourceResolver(), CONTEXT.bundleContext());
    request.setResource(resource);
    SlingBindings bindings = new SlingBindings();
    bindings.put(SlingBindings.RESOURCE, resource);
    bindings.put(WCMBindings.PROPERTIES, resource.getValueMap());
    request.setAttribute(SlingBindings.class.getName(), bindings);
    return request.adaptTo(Text.class);
}
 
开发者ID:Adobe-Marketing-Cloud,项目名称:aem-core-wcm-components,代码行数:11,代码来源:TextImplTest.java

示例9: getButtonUnderTest

import org.apache.sling.api.scripting.SlingBindings; //导入方法依赖的package包/类
private Button getButtonUnderTest(String resourcePath) {
    Resource resource = CONTEXT.resourceResolver().getResource(resourcePath);
    MockSlingHttpServletRequest request = new MockSlingHttpServletRequest(CONTEXT.resourceResolver(), CONTEXT.bundleContext());
    request.setResource(resource);
    SlingBindings bindings = new SlingBindings();
    bindings.put(SlingBindings.RESOURCE, resource);
    request.setAttribute(SlingBindings.class.getName(), bindings);
    return request.adaptTo(Button.class);
}
 
开发者ID:Adobe-Marketing-Cloud,项目名称:aem-core-wcm-components,代码行数:10,代码来源:ButtonImplTest.java

示例10: prepareHiddenFieldForTest

import org.apache.sling.api.scripting.SlingBindings; //导入方法依赖的package包/类
private Field prepareHiddenFieldForTest(String resourcePath) {
    MockSlingHttpServletRequest request = new MockSlingHttpServletRequest(CONTEXT.resourceResolver(), CONTEXT.bundleContext());
    Resource resource = CONTEXT.resourceResolver().getResource(resourcePath);
    request.setResource(resource);
    Page currentPage = CONTEXT.pageManager().getPage(CONTAINING_PAGE);
    SlingBindings slingBindings = new SlingBindings();
    slingBindings.put(WCMBindings.CURRENT_PAGE, currentPage);
    slingBindings.put(SlingBindings.RESOURCE, resource);
    slingBindings.put(WCMBindings.PROPERTIES, resource.getValueMap());
    request.setAttribute(SlingBindings.class.getName(), slingBindings);
    return request.adaptTo(Field.class);
}
 
开发者ID:Adobe-Marketing-Cloud,项目名称:aem-core-wcm-components,代码行数:13,代码来源:HiddenImplTest.java

示例11: getImageUnderTest

import org.apache.sling.api.scripting.SlingBindings; //导入方法依赖的package包/类
protected <T> T getImageUnderTest(String resourcePath, Class<T> imageClass) {
    Resource resource = CONTEXT.resourceResolver().getResource(resourcePath);
    if (resource == null) {
        throw new IllegalStateException("Does the test resource " + resourcePath + " exist?");
    }
    ContentPolicyMapping mapping = resource.adaptTo(ContentPolicyMapping.class);
    ContentPolicy contentPolicy = null;
    if (mapping != null) {
        contentPolicy = mapping.getPolicy();
    }
    SlingBindings slingBindings = new SlingBindings();
    Style style = null;
    if (contentPolicy != null) {
        when(contentPolicyManager.getPolicy(resource)).thenReturn(contentPolicy);
        style = new MockContentPolicyStyle(contentPolicy);
    }
    if (style == null) {
        style = mock(Style.class);
        when(style.get(anyString(), (Object) Matchers.anyObject())).thenAnswer(
                invocationOnMock -> invocationOnMock.getArguments()[1]
        );
    }
    slingBindings.put(SlingBindings.RESOURCE, resource);
    final MockSlingHttpServletRequest request =
            new MockSlingHttpServletRequest(CONTEXT.resourceResolver(), CONTEXT.bundleContext());
    request.setContextPath(CONTEXT_PATH);
    request.setResource(resource);
    Page page = CONTEXT.pageManager().getPage(PAGE);
    slingBindings.put(WCMBindings.CURRENT_PAGE, page);
    slingBindings.put(WCMBindings.WCM_MODE, new SightlyWCMMode(request));
    slingBindings.put(WCMBindings.PAGE_MANAGER, CONTEXT.pageManager());
    slingBindings.put(WCMBindings.CURRENT_STYLE, style);
    slingBindings.put(WCMBindings.PROPERTIES, resource.adaptTo(ValueMap.class));
    request.setAttribute(SlingBindings.class.getName(), slingBindings);
    return request.adaptTo(imageClass);
}
 
开发者ID:Adobe-Marketing-Cloud,项目名称:aem-core-wcm-components,代码行数:37,代码来源:ImageImplTest.java

示例12: getTextUnderTest

import org.apache.sling.api.scripting.SlingBindings; //导入方法依赖的package包/类
protected <T> T getTextUnderTest(Class<T> model, String resourcePath) {
    Resource resource = CONTEXT.resourceResolver().getResource(resourcePath);
    if (resource == null) {
        throw new IllegalStateException("Did you forget to define test resource " + resourcePath + "?");
    }
    MockSlingHttpServletRequest request = new MockSlingHttpServletRequest(CONTEXT.resourceResolver(), CONTEXT.bundleContext());
    SlingBindings bindings = new SlingBindings();
    bindings.put(SlingBindings.RESOURCE, resource);
    bindings.put(SlingBindings.REQUEST, request);
    bindings.put(WCMBindings.PROPERTIES, resource.getValueMap());
    request.setResource(resource);
    request.setAttribute(SlingBindings.class.getName(), bindings);
    return request.adaptTo(model);
}
 
开发者ID:Adobe-Marketing-Cloud,项目名称:aem-core-wcm-components,代码行数:15,代码来源:TextImplTest.java

示例13: getLanguageNavigationUnderTest

import org.apache.sling.api.scripting.SlingBindings; //导入方法依赖的package包/类
private LanguageNavigation getLanguageNavigationUnderTest(String resourcePath) {
    Resource resource = AEM_CONTEXT.resourceResolver().getResource(resourcePath);
    if (resource == null) {
        throw new IllegalStateException("Does the test resource " + resourcePath + " exist?");
    }
    ContentPolicyMapping mapping = resource.adaptTo(ContentPolicyMapping.class);
    ContentPolicy contentPolicy = null;
    if (mapping != null) {
        contentPolicy = mapping.getPolicy();
    }
    final MockSlingHttpServletRequest request =
            new MockSlingHttpServletRequest(AEM_CONTEXT.resourceResolver(), AEM_CONTEXT.bundleContext());
    request.setContextPath(CONTEXT_PATH);
    request.setResource(resource);
    Page currentPage = AEM_CONTEXT.pageManager().getContainingPage(resource);
    SlingBindings slingBindings = new SlingBindings();
    Style currentStyle;
    if (contentPolicy != null) {
        ContentPolicyManager policyManager = mock(ContentPolicyManager.class);
        when(policyManager.getPolicy(resource)).thenReturn(contentPolicy);
        currentStyle = new MockContentPolicyStyle(contentPolicy);
    } else {
        currentStyle = mock(Style.class);
        when(currentStyle.get(anyString(), (Object) Matchers.anyObject())).thenAnswer(
                invocation -> invocation.getArguments()[1]
        );
    }
    slingBindings.put(SlingBindings.RESOURCE, resource);
    slingBindings.put(WCMBindings.CURRENT_PAGE, currentPage);
    slingBindings.put(WCMBindings.PROPERTIES, resource.getValueMap());
    slingBindings.put(WCMBindings.CURRENT_STYLE, currentStyle);
    request.setAttribute(SlingBindings.class.getName(), slingBindings);
    return request.adaptTo(LanguageNavigation.class);
}
 
开发者ID:Adobe-Marketing-Cloud,项目名称:aem-core-wcm-components,代码行数:35,代码来源:LanguageNavigationImplTest.java

示例14: setUp

import org.apache.sling.api.scripting.SlingBindings; //导入方法依赖的package包/类
@Before
public void setUp() {
    slingBindings = (SlingBindings) context.request().getAttribute(SlingBindings.class.getName());
    slingBindings.put(WCMBindings.CURRENT_STYLE, slingBindings = (SlingBindings) context.request().getAttribute(SlingBindings.class
            .getName()));
    slingBindings.put(WCMBindings.CURRENT_PAGE, context.currentPage("/content/en/search/page"));
}
 
开发者ID:Adobe-Marketing-Cloud,项目名称:aem-core-wcm-components,代码行数:8,代码来源:SearchImplTest.java

示例15: getNavigationUnderTest

import org.apache.sling.api.scripting.SlingBindings; //导入方法依赖的package包/类
private Navigation getNavigationUnderTest(String resourcePath) {
    Resource resource = AEM_CONTEXT.resourceResolver().getResource(resourcePath);
    if (resource == null) {
        throw new IllegalStateException("Does the test resource " + resourcePath + " exist?");
    }
    ContentPolicyMapping mapping = resource.adaptTo(ContentPolicyMapping.class);
    ContentPolicy contentPolicy = null;
    if (mapping != null) {
        contentPolicy = mapping.getPolicy();
    }
    final MockSlingHttpServletRequest request =
            new MockSlingHttpServletRequest(AEM_CONTEXT.resourceResolver(), AEM_CONTEXT.bundleContext());
    request.setContextPath(CONTEXT_PATH);
    request.setResource(resource);
    Page currentPage = AEM_CONTEXT.pageManager().getContainingPage(resource);
    SlingBindings slingBindings = new SlingBindings();
    Style currentStyle;
    if (contentPolicy != null) {
        when(POLICY_MANAGER.getPolicy(resource)).thenReturn(contentPolicy);
        currentStyle = new MockContentPolicyStyle(contentPolicy);
    } else {
        currentStyle = mock(Style.class);
        when(currentStyle.get(anyString(), (Object) Matchers.anyObject())).thenAnswer(
                invocation -> invocation.getArguments()[1]
        );
    }
    slingBindings.put(SlingBindings.RESOURCE, resource);
    slingBindings.put(WCMBindings.CURRENT_PAGE, currentPage);
    slingBindings.put(WCMBindings.PROPERTIES, resource.getValueMap());
    slingBindings.put(WCMBindings.CURRENT_STYLE, currentStyle);
    request.setAttribute(SlingBindings.class.getName(), slingBindings);
    return request.adaptTo(Navigation.class);
}
 
开发者ID:Adobe-Marketing-Cloud,项目名称:aem-core-wcm-components,代码行数:34,代码来源:NavigationImplTest.java


注:本文中的org.apache.sling.api.scripting.SlingBindings.put方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。