Example usage for org.springframework.mock.web MockBodyContent MockBodyContent

List of usage examples for org.springframework.mock.web MockBodyContent MockBodyContent

Introduction

In this page you can find the example usage for org.springframework.mock.web MockBodyContent MockBodyContent.

Prototype

public MockBodyContent(String content, Writer targetWriter) 

Source Link

Document

Create a MockBodyContent for the given response.

Usage

From source file:com.gantzgulch.taglibs.html.BodyTagRunner.java

public void execute(String bodyContentValue) throws JspException {
    this.bodyContentValue = bodyContentValue;
    this.mockBodyContent = new MockBodyContent(this.bodyContentValue, new StringWriter());

    while (state != endState) {
        state = state.execute();/*  www .j a va2  s.  co  m*/
    }
}

From source file:org.openmrs.web.taglib.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");
}

From source file:org.openmrs.web.taglib.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");
}

From source file:org.openmrs.web.taglib.OpenmrsMessageTagTest.java

/**
 * @see OpenmrsMessageTag#doEndTag()//from w  ww .  j av  a 2 s . c o  m
 */
@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);
}

From source file:org.openmrs.web.taglib.OpenmrsMessageTagTest.java

/**
 * @see OpenmrsMessageTag#doEndTag()//from www.j a  v  a  2s  .co m
 */
@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);
}

From source file:org.openmrs.web.taglib.OpenmrsMessageTagTest.java

/**
 * @see OpenmrsMessageTag#doEndTag()/*from   w  w w  .j  av a 2 s . c  om*/
 */
@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);
}