Package org.apache.tiles

Examples of org.apache.tiles.AttributeContext


    @Test(expected = NoSuchPreparerException.class)
    public void testPrepareException() {
        Request request = createMock(Request.class);
        Map<String, Object> requestScope = createMock(Map.class);
        Deque<AttributeContext> deque = createMock(Deque.class);
        AttributeContext attributeContext = createMock(AttributeContext.class);

        expect(preparerFactory.getPreparer("preparer", request)).andReturn(null);

        replay(applicationContext, attributeEvaluatorFactory,
                definitionsFactory, preparerFactory, rendererFactory, request,
View Full Code Here


    @Test
    public void testRenderStringRequest() throws IOException {
        Request request = createMock(Request.class);
        Map<String, Object> requestScope = createMock(Map.class);
        Deque<AttributeContext> deque = createMock(Deque.class);
        AttributeContext attributeContext = createMock(AttributeContext.class);
        ViewPreparer preparer = createMock(ViewPreparer.class);
        Renderer renderer = createMock(Renderer.class);
        Definition definition = createMock(Definition.class);
        AttributeEvaluator evaluator = createMock(AttributeEvaluator.class);

        Attribute templateAttribute = Attribute.createTemplateAttribute("/my/template.jsp");

        expect(definitionsFactory.getDefinition("definition", request)).andReturn(definition);
        expect(request.getContext("request")).andReturn(requestScope).times(3);
        expect(requestScope.get(ATTRIBUTE_CONTEXT_STACK)).andReturn(deque).times(3);
        expect(deque.isEmpty()).andReturn(false);
        expect(deque.peek()).andReturn(attributeContext);
        expect(attributeContext.getPreparer()).andReturn(null);
        expect(attributeContext.getTemplateAttribute()).andReturn(templateAttribute);
        expect(attributeContext.getLocalAttributeNames()).andReturn(null);
        expect(attributeContext.getCascadedAttributeNames()).andReturn(null);
        expect(definition.getTemplateAttribute()).andReturn(templateAttribute);
        expect(rendererFactory.getRenderer("template")).andReturn(renderer);
        deque.push(isA(BasicAttributeContext.class));
        expect(attributeEvaluatorFactory.getAttributeEvaluator(templateAttribute)).andReturn(evaluator);
        expect(evaluator.evaluate(templateAttribute, request)).andReturn("/my/template.jsp");
View Full Code Here

    @Test
    public void testPushContext() {
        Request request = createMock(Request.class);
        Map<String, Object> requestScope = createMock(Map.class);
        Deque<AttributeContext> deque = createMock(Deque.class);
        AttributeContext attributeContext = createMock(AttributeContext.class);

        expect(request.getContext("request")).andReturn(requestScope);
        expect(requestScope.get(ATTRIBUTE_CONTEXT_STACK)).andReturn(deque);
        deque.push(attributeContext);
View Full Code Here

    @Test
    public void testPopContext() {
        Request request = createMock(Request.class);
        Map<String, Object> requestScope = createMock(Map.class);
        Deque<AttributeContext> deque = createMock(Deque.class);
        AttributeContext attributeContext = createMock(AttributeContext.class);

        expect(request.getContext("request")).andReturn(requestScope);
        expect(requestScope.get(ATTRIBUTE_CONTEXT_STACK)).andReturn(deque);
        expect(deque.pop()).andReturn(attributeContext);
View Full Code Here

    @Test
    public void testGetContext() {
        Request request = createMock(Request.class);
        Map<String, Object> requestScope = createMock(Map.class);
        Deque<AttributeContext> deque = createMock(Deque.class);
        AttributeContext attributeContext = createMock(AttributeContext.class);

        expect(request.getContext("request")).andReturn(requestScope);
        expect(requestScope.get(ATTRIBUTE_CONTEXT_STACK)).andReturn(deque);
        expect(deque.isEmpty()).andReturn(false);
        expect(deque.peek()).andReturn(attributeContext);
View Full Code Here

    @Test
    public void testRenderRequestDefinition() throws IOException {
        Request request = createMock(Request.class);
        Map<String, Object> requestScope = createMock(Map.class);
        Deque<AttributeContext> deque = createMock(Deque.class);
        AttributeContext attributeContext = createMock(AttributeContext.class);
        ViewPreparer preparer = createMock(ViewPreparer.class);
        Renderer renderer = createMock(Renderer.class);
        Definition definition = createMock(Definition.class);
        AttributeEvaluator evaluator = createMock(AttributeEvaluator.class);

        Attribute templateAttribute = Attribute.createTemplateAttribute("/my/template.jsp");

        expect(request.getContext("request")).andReturn(requestScope).times(3);
        expect(requestScope.get(ATTRIBUTE_CONTEXT_STACK)).andReturn(deque).times(3);
        expect(deque.isEmpty()).andReturn(false);
        expect(deque.peek()).andReturn(attributeContext);
        expect(attributeContext.getPreparer()).andReturn(null);
        expect(attributeContext.getTemplateAttribute()).andReturn(templateAttribute);
        expect(attributeContext.getLocalAttributeNames()).andReturn(null);
        expect(attributeContext.getCascadedAttributeNames()).andReturn(null);
        expect(definition.getTemplateAttribute()).andReturn(templateAttribute);
        expect(rendererFactory.getRenderer("template")).andReturn(renderer);
        deque.push(isA(BasicAttributeContext.class));
        expect(attributeEvaluatorFactory.getAttributeEvaluator(templateAttribute)).andReturn(evaluator);
        expect(evaluator.evaluate(templateAttribute, request)).andReturn("/my/template.jsp");
View Full Code Here

    @Test(expected = CannotRenderException.class)
    public void testRenderRequestDefinitionException() throws IOException {
        Request request = createMock(Request.class);
        Map<String, Object> requestScope = createMock(Map.class);
        Deque<AttributeContext> deque = createMock(Deque.class);
        AttributeContext attributeContext = createMock(AttributeContext.class);
        ViewPreparer preparer = createMock(ViewPreparer.class);
        Renderer renderer = createMock(Renderer.class);
        Definition definition = createMock(Definition.class);
        AttributeEvaluator evaluator = createMock(AttributeEvaluator.class);

        Attribute templateAttribute = Attribute.createTemplateAttribute("/my/template.jsp");

        expect(request.getContext("request")).andReturn(requestScope).times(3);
        expect(requestScope.get(ATTRIBUTE_CONTEXT_STACK)).andReturn(deque).times(3);
        expect(deque.isEmpty()).andReturn(false);
        expect(deque.peek()).andReturn(attributeContext);
        expect(attributeContext.getPreparer()).andReturn(null);
        expect(attributeContext.getTemplateAttribute()).andReturn(templateAttribute);
        expect(attributeContext.getLocalAttributeNames()).andReturn(null);
        expect(attributeContext.getCascadedAttributeNames()).andReturn(null);
        expect(definition.getTemplateAttribute()).andReturn(templateAttribute);
        expect(rendererFactory.getRenderer("template")).andReturn(renderer);
        deque.push(isA(BasicAttributeContext.class));
        expect(attributeEvaluatorFactory.getAttributeEvaluator(templateAttribute)).andReturn(evaluator);
        expect(evaluator.evaluate(templateAttribute, request)).andReturn("/mytemplate.jsp");
View Full Code Here

    @Test
    public void testRenderRequestAttributeContext() throws IOException {
        Request request = createMock(Request.class);
        Map<String, Object> requestScope = createMock(Map.class);
        Deque<AttributeContext> deque = createMock(Deque.class);
        AttributeContext attributeContext = createMock(AttributeContext.class);
        ViewPreparer preparer = createMock(ViewPreparer.class);
        Attribute templateAttribute = createMock(Attribute.class);
        Renderer renderer = createMock(Renderer.class);
        AttributeEvaluator evaluator = createMock(AttributeEvaluator.class);

        expect(attributeContext.getPreparer()).andReturn(null);
        expect(attributeContext.getTemplateAttribute()).andReturn(templateAttribute);
        expect(templateAttribute.getRenderer()).andReturn("renderer");
        expect(rendererFactory.getRenderer("renderer")).andReturn(renderer);
        expect(attributeEvaluatorFactory.getAttributeEvaluator(templateAttribute)).andReturn(evaluator);
        expect(evaluator.evaluate(templateAttribute, request)).andReturn("/mytemplate.jsp");
        expect(templateAttribute.isPermitted(request)).andReturn(true);
View Full Code Here

    @Test(expected = CannotRenderException.class)
    public void testRenderRequestAttributeContextException() throws IOException {
        Request request = createMock(Request.class);
        Map<String, Object> requestScope = createMock(Map.class);
        Deque<AttributeContext> deque = createMock(Deque.class);
        AttributeContext attributeContext = createMock(AttributeContext.class);
        Attribute templateAttribute = createMock(Attribute.class);
        Renderer renderer = createMock(Renderer.class);
        AttributeEvaluator evaluator = createMock(AttributeEvaluator.class);

        expect(attributeContext.getPreparer()).andReturn("preparer").times(2);
        expect(preparerFactory.getPreparer("preparer", request)).andReturn(null);
        expect(attributeContext.getTemplateAttribute()).andReturn(templateAttribute);
        expect(templateAttribute.getRenderer()).andReturn("renderer");
        expect(rendererFactory.getRenderer("renderer")).andReturn(renderer);
        expect(attributeEvaluatorFactory.getAttributeEvaluator(templateAttribute)).andReturn(evaluator);
        expect(evaluator.evaluate(templateAttribute, request)).andReturn("/mytemplate.jsp");
        expect(templateAttribute.isPermitted(request)).andReturn(true);
View Full Code Here

   * @param request the Servlet request
   * @param response the Servlet response
   */
  protected void addRuntimeAttributes(BasicTilesContainer container, Map<String, Attribute> resultMap,
      HttpServletRequest request, HttpServletResponse response) {
    AttributeContext attributeContext = container.getAttributeContext(new Object[] { request, response });
    Set<String> attributeNames = new HashSet<String>();
    if (attributeContext.getLocalAttributeNames() != null) {
      attributeNames.addAll(attributeContext.getLocalAttributeNames());
    }
    if (attributeContext.getCascadedAttributeNames() != null) {
      attributeNames.addAll(attributeContext.getCascadedAttributeNames());
    }
    for (String name : attributeNames) {
      Attribute attr = attributeContext.getAttribute(name);
      resultMap.put(name, attr);
    }
  }
View Full Code Here

TOP

Related Classes of org.apache.tiles.AttributeContext

Copyright © 2018 www.massapicom. 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.