Java Code Examples for org.springframework.mock.web.MockHttpServletResponse#setContentType()

The following examples show how to use org.springframework.mock.web.MockHttpServletResponse#setContentType() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: LoggingFilterTest.java    From servlet-logging-filter with Apache License 2.0 5 votes vote down vote up
@BeforeEach
public void setUp() {

	httpServletRequest = new MockHttpServletRequest("GET", "http://localhost:8080/test");
	httpServletRequest.addHeader("Accept", "application/json");
	httpServletRequest.addParameter("param1", "1000");
	httpServletRequest.setContent("Test request body".getBytes());
	httpServletRequest.setContentType(MediaType.TEXT_PLAIN_VALUE);

	httpServletResponse = new MockHttpServletResponse();
	httpServletResponse.setContentType(MediaType.TEXT_PLAIN_VALUE);

	filterChain = new MockFilterChain(new HttpRequestHandlerServlet(), new TestFilter());
}
 
Example 2
Source File: HttpFilterBenchmarks.java    From spring-cloud-sleuth with Apache License 2.0 5 votes vote down vote up
@Benchmark
@Measurement(iterations = 5, time = 1)
@Fork(3)
public void filterWithoutSleuth(BenchmarkContext context)
		throws IOException, ServletException {
	MockHttpServletRequest request = builder().buildRequest(new MockServletContext());
	MockHttpServletResponse response = new MockHttpServletResponse();
	response.setContentType(MediaType.APPLICATION_JSON_VALUE);

	context.dummyFilter.doFilter(request, response, new MockFilterChain());
}
 
Example 3
Source File: HttpFilterBenchmarks.java    From spring-cloud-sleuth with Apache License 2.0 5 votes vote down vote up
@Benchmark
@Measurement(iterations = 5, time = 1)
@Fork(3)
public void filterWithSleuth(BenchmarkContext context)
		throws ServletException, IOException {
	MockHttpServletRequest request = builder().buildRequest(new MockServletContext());
	MockHttpServletResponse response = new MockHttpServletResponse();
	response.setContentType(MediaType.APPLICATION_JSON_VALUE);

	context.tracingFilter.doFilter(request, response, new MockFilterChain());
}
 
Example 4
Source File: ResponseHeaderIT.java    From glowroot with Apache License 2.0 5 votes vote down vote up
@Override
public void executeApp() throws Exception {
    MockHttpServletResponse response = new PatchedMockHttpServletResponse();
    response.setContentLength(1);
    response.setContentType("text/plain");
    response.setCharacterEncoding("UTF-8");
    response.setLocale(Locale.ENGLISH);
}