Package org.springframework.mock.web

Examples of org.springframework.mock.web.MockBodyContent


    StringBuilder body = new StringBuilder();
    body.append("<a href=\"http://myDomain.com\">Link</a>");
    body.append("\n");
    body.append("<div>Content</div>");
   
    extraHtmlTag.setBodyContent(new MockBodyContent(body.toString(), mockPageContext.getOut()));
    extraHtmlTag.setUid("M");
    extraHtmlTag.setCssClass("class1");
    extraHtmlTag.setCssStyle("float:left");
    extraHtmlTag.setContainer("div");
  }
View Full Code Here


    StringBuilder body = new StringBuilder();
    body.append("<a href=\"http://myDomain.com\">Link</a>");
    body.append("\n");
    body.append("<div>Content</div>");
   
    extraHtmlTag.setBodyContent(new MockBodyContent(body.toString(), mockPageContext.getOut()));
    extraHtmlTag.setUid("M");
    extraHtmlTag.setCssClass("class1");
    extraHtmlTag.setCssStyle("float:left");
  }
View Full Code Here

    @Test
    public void testMessageBody() throws Exception {
        this.setUp(null);

        MockBodyContent content = new MockBodyContent("This is the body content 01.", (Writer)null);
        this.tag.setBodyContent(content);

        assertEquals("The message is not correct.", "This is the body content 01.", this.tag.getMessage());
    }
View Full Code Here

    @Test
    public void testMessageStringBodyIgnored() throws Exception {
        this.setUp(null);

        MockBodyContent content = new MockBodyContent("This is more body content 02.", (Writer)null);
        this.tag.setBodyContent(content);
        this.tag.setMessage("This is another message 02.");

        assertEquals("The message is not correct.", "This is another message 02.", this.tag.getMessage());
    }
View Full Code Here

    @Test
    public void testMessageBody() throws Exception {
        this.setUp(null);

        MockBodyContent content = new MockBodyContent("This is the body content 01.", (Writer)null);
        this.tag.setBodyContent(content);

        assertEquals("The message is not correct.", "This is the body content 01.", this.tag.getMessage());
    }
View Full Code Here

    @Test
    public void testMessageStringBodyIgnored() throws Exception {
        this.setUp(null);

        MockBodyContent content = new MockBodyContent("This is more body content 02.", (Writer)null);
        this.tag.setBodyContent(content);
        this.tag.setMessage("This is another message 02.");

        assertEquals("The message is not correct.", "This is another message 02.", this.tag.getMessage());
    }
View Full Code Here

  }


  public void testWithExplicitNonWhitespaceBodyContent() throws Exception {
    String mockContent = "This is some explicit body content";
    this.tag.setBodyContent(new MockBodyContent(mockContent, getWriter()));

    // construct an errors instance of the tag
    TestBean target = new TestBean();
    target.setName("Rob Harrop");
    Errors errors = new BeanPropertyBindingResult(target, COMMAND_NAME);
View Full Code Here

    assertEquals(Tag.EVAL_PAGE, result);
    assertEquals(mockContent, getOutput());
  }

  public void testWithExplicitWhitespaceBodyContent() throws Exception {
    this.tag.setBodyContent(new MockBodyContent("\t\n   ", getWriter()));

    // construct an errors instance of the tag
    TestBean target = new TestBean();
    target.setName("Rob Harrop");
    Errors errors = new BeanPropertyBindingResult(target, COMMAND_NAME);
View Full Code Here

    assertContainsAttribute(output, "id", "name.errors");
    assertBlockTagContains(output, "Default Message");
  }

  public void testWithExplicitEmptyWhitespaceBodyContent() throws Exception {
    this.tag.setBodyContent(new MockBodyContent("", getWriter()));

    // construct an errors instance of the tag
    TestBean target = new TestBean();
    target.setName("Rob Harrop");
    Errors errors = new BeanPropertyBindingResult(target, COMMAND_NAME);
View Full Code Here

    exposeBindingResult(errors);
    int result = this.tag.doStartTag();
    assertEquals(BodyTag.EVAL_BODY_BUFFERED, result);
    assertNotNull(getPageContext().getAttribute(ErrorsTag.MESSAGES_ATTRIBUTE));
    String bodyContent = "Foo";
    this.tag.setBodyContent(new MockBodyContent(bodyContent, getWriter()));
    this.tag.doEndTag();
    this.tag.doFinally();
    assertEquals(bodyContent, getOutput());
    assertNull(getPageContext().getAttribute(ErrorsTag.MESSAGES_ATTRIBUTE));
  }
View Full Code Here

TOP

Related Classes of org.springframework.mock.web.MockBodyContent

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.