Java 类org.springframework.mock.web.MockBodyContent 实例源码

项目:openmrs-module-legacyui    文件:OpenmrsMessageTagTest.java   
@Test
@Verifies(value = "a single argument works", method = "doEndTag()")
public void doEndTag_singleArgument() throws Exception {
    openmrsMessageTag.setArguments("singleArgument");
    openmrsMessageTag.setCode(TEST_CODE_ONE_ARG);
    openmrsMessageTag.setBodyContent(new MockBodyContent("doesn't matter", new MockHttpServletResponse()));

    checkDoEndTagEvaluation("this is a test with arg1: singleArgument");
}
项目:openmrs-module-legacyui    文件:OpenmrsMessageTagTest.java   
@Test
@Verifies(value = "an array of arguments with more than one element works", method = "doEndTag()")
public void doEndTag_doubleArgument() throws Exception {
    openmrsMessageTag.setArguments("firstArgument,secondArgument");
    openmrsMessageTag.setCode(TEST_CODE_TWO_ARGS);
    openmrsMessageTag.setBodyContent(new MockBodyContent("doesn't matter", new MockHttpServletResponse()));

    checkDoEndTagEvaluation("this is a test with arg1: firstArgument, and arg2: secondArgument");
}
项目:openmrs-module-legacyui    文件:OpenmrsMessageTagTest.java   
/**
 * @see OpenmrsMessageTag#doEndTag()
 */
@Test
@Verifies(value = "use body content as fallback if no message resolved", method = "doEndTag()")
public void doEndTag_shouldUseBodyContentAsFallbackIfNoMessageResolved() throws Exception {
    String expectedOutput = "test body content";
    openmrsMessageTag.setBodyContent(new MockBodyContent(expectedOutput, new MockHttpServletResponse()));
    openmrsMessageTag.setCode("test.wrong.code");

    checkDoEndTagEvaluation(expectedOutput);
}
项目:openmrs-module-legacyui    文件:OpenmrsMessageTagTest.java   
/**
 * @see OpenmrsMessageTag#doEndTag()
 */
@Test
@Verifies(value = "use body content in prior to text attribute as fallback if no message resolved", method = "doEndTag()")
public void doEndTag_shouldUseBodyContentInPriorToTextAttributeAsFallbackIfNoMessageResolved() throws Exception {
    String expectedOutput = "test body content";
    openmrsMessageTag.setBodyContent(new MockBodyContent(expectedOutput, new MockHttpServletResponse()));
    openmrsMessageTag.setText("test content");
    openmrsMessageTag.setCode("test.wrong.code");

    checkDoEndTagEvaluation(expectedOutput);
}
项目:openmrs-module-legacyui    文件:OpenmrsMessageTagTest.java   
/**
 * @see OpenmrsMessageTag#doEndTag()
 */
@Test
@Verifies(value = "ignore fallbacks if tag locale differs from context locale", method = "doEndTag()")
public void doEndTag_shouldIgnoreFallbacksIfTagLocaleDiffersFromContextLocale() throws Exception {
    String expectedOutput = "test.wrong.code";
    openmrsMessageTag.setBodyContent(new MockBodyContent(expectedOutput, new MockHttpServletResponse()));
    openmrsMessageTag.setText("test content");
    openmrsMessageTag.setCode(expectedOutput);
    openmrsMessageTag.setLocale("uk");

    checkDoEndTagEvaluation(expectedOutput);
}
项目:log4j2    文件:LoggingMessageTagSupportTest.java   
@Test
public void testMessageBody() throws Exception {
    this.setUp(null);

    final 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());
}
项目:log4j2    文件:LoggingMessageTagSupportTest.java   
@Test
public void testMessageStringBodyIgnored() throws Exception {
    this.setUp(null);

    final 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());
}
项目:logging-log4j2    文件:LoggingMessageTagSupportTest.java   
@Test
public void testMessageBody() throws Exception {
    this.setUp(null);

    final 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());
}
项目:logging-log4j2    文件:LoggingMessageTagSupportTest.java   
@Test
public void testMessageStringBodyIgnored() throws Exception {
    this.setUp(null);

    final 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());
}