JavaxRequestContextHolderWebContextProvider.java

1
package fr.sii.ogham.spring.v2.template.thymeleaf;
2
3
import javax.servlet.ServletContext;
4
import javax.servlet.http.HttpServletRequest;
5
import javax.servlet.http.HttpServletResponse;
6
7
import org.springframework.web.context.ServletContextAware;
8
import org.springframework.web.context.request.RequestContextHolder;
9
import org.springframework.web.context.request.ServletRequestAttributes;
10
11
import fr.sii.ogham.core.template.context.Context;
12
import fr.sii.ogham.spring.template.thymeleaf.WebContextProvider;
13
import fr.sii.ogham.spring.util.compat.HttpServletRequestWrapper;
14
import fr.sii.ogham.spring.util.compat.HttpServletResponseWrapper;
15
import fr.sii.ogham.spring.util.compat.JavaxHttpServletRequestWrapper;
16
import fr.sii.ogham.spring.util.compat.JavaxHttpServletResponseWrapper;
17
import fr.sii.ogham.spring.util.compat.JavaxServletContextWrapper;
18
import fr.sii.ogham.spring.util.compat.ServletContextWrapper;
19
20
/**
21
 * Implementation that retrieves the current {@link HttpServletRequest} and
22
 * {@link HttpServletResponse} using {@link RequestContextHolder}.
23
 *
24
 * @author Aurélien Baudet
25
 *
26
 */
27
public class JavaxRequestContextHolderWebContextProvider implements WebContextProvider, ServletContextAware {
28
	private ServletContext servletContext;
29
30
	@Override
31
	public HttpServletRequestWrapper getRequest(Context context) {
32 1 1. getRequest : replaced return value with null for fr/sii/ogham/spring/v2/template/thymeleaf/JavaxRequestContextHolderWebContextProvider::getRequest → RUN_ERROR
		return new JavaxHttpServletRequestWrapper(((ServletRequestAttributes) RequestContextHolder.currentRequestAttributes()).getRequest());
33
	}
34
35
	@Override
36
	public HttpServletResponseWrapper getResponse(Context context) {
37 1 1. getResponse : replaced return value with null for fr/sii/ogham/spring/v2/template/thymeleaf/JavaxRequestContextHolderWebContextProvider::getResponse → RUN_ERROR
		return new JavaxHttpServletResponseWrapper(((ServletRequestAttributes) RequestContextHolder.currentRequestAttributes()).getResponse());
38
	}
39
40
	@Override
41
	public ServletContextWrapper getServletContext(Context context) {
42 1 1. getServletContext : replaced return value with null for fr/sii/ogham/spring/v2/template/thymeleaf/JavaxRequestContextHolderWebContextProvider::getServletContext → RUN_ERROR
		return new JavaxServletContextWrapper(servletContext);
43
	}
44
45
	@Override
46
	public void setServletContext(ServletContext servletContext) {
47
		this.servletContext = servletContext;
48
	}
49
50
}

Mutations

32

1.1
Location : getRequest
Killed by :
replaced return value with null for fr/sii/ogham/spring/v2/template/thymeleaf/JavaxRequestContextHolderWebContextProvider::getRequest → RUN_ERROR

37

1.1
Location : getResponse
Killed by :
replaced return value with null for fr/sii/ogham/spring/v2/template/thymeleaf/JavaxRequestContextHolderWebContextProvider::getResponse → RUN_ERROR

42

1.1
Location : getServletContext
Killed by :
replaced return value with null for fr/sii/ogham/spring/v2/template/thymeleaf/JavaxRequestContextHolderWebContextProvider::getServletContext → RUN_ERROR

Active mutators

Tests examined


Report generated by PIT 1.13.1