Example usage for org.springframework.web.util ContentCachingResponseWrapper ContentCachingResponseWrapper

List of usage examples for org.springframework.web.util ContentCachingResponseWrapper ContentCachingResponseWrapper

Introduction

In this page you can find the example usage for org.springframework.web.util ContentCachingResponseWrapper ContentCachingResponseWrapper.

Prototype

public ContentCachingResponseWrapper(HttpServletResponse response) 

Source Link

Document

Create a new ContentCachingResponseWrapper for the given servlet response.

Usage

From source file:org.dspace.app.rest.utils.MultipartFileSenderTest.java

/**
 * This method will be run before every test as per @Before. It will
 * initialize resources required for the tests.
 * <p>//from  w ww .j  av  a  2 s .  com
 * Other methods can be annotated with @Before here or in subclasses
 * but no execution order is guaranteed
 */
@Before
public void init() throws AuthorizeException {
    try {
        String content = "0123456789";

        this.is = IOUtils.toInputStream(content, CharEncoding.UTF_8);
        this.fileName = "Test-Item.txt";
        this.mimeType = "text/plain";
        this.lastModified = new Date().getTime();
        this.length = content.getBytes().length;
        this.checksum = "testsum";

        this.request = mock(HttpServletRequest.class);
        this.response = new MockHttpServletResponse();

        //Using wrappers so we can save the content of the bodies and use them for tests
        this.requestWrapper = new ContentCachingRequestWrapper(request);
        this.responseWrapper = new ContentCachingResponseWrapper(response);
    } catch (IOException ex) {
        log.error("IO Error in init", ex);
        fail("SQL Error in init: " + ex.getMessage());
    }
}