WebExpressionContextProvider.java

1
package fr.sii.ogham.spring.v2.template.thymeleaf;
2
3
import java.util.Map;
4
5
import javax.servlet.ServletContext;
6
import javax.servlet.http.HttpServletRequest;
7
import javax.servlet.http.HttpServletResponse;
8
9
import org.springframework.context.ApplicationContext;
10
import org.thymeleaf.IEngineConfiguration;
11
import org.thymeleaf.ITemplateEngine;
12
import org.thymeleaf.context.IContext;
13
import org.thymeleaf.context.WebExpressionContext;
14
import org.thymeleaf.spring5.view.ThymeleafView;
15
16
import fr.sii.ogham.core.template.context.Context;
17
import fr.sii.ogham.spring.template.thymeleaf.ThymeleafWebContextProvider;
18
19
/**
20
 * Generate an instance of {@link WebExpressionContext} for Thymeleaf v3.
21
 * 
22
 * This is used to mimic the behavior of {@link ThymeleafView} in order to give
23
 * access to {@link HttpServletRequest}, {@link HttpServletResponse} and
24
 * {@link ServletContext} from templates.
25
 * 
26
 * @author Aurélien Baudet
27
 *
28
 */
29
public class WebExpressionContextProvider implements ThymeleafWebContextProvider {
30
	private final ITemplateEngine viewTemplateEngine;
31
32
	public WebExpressionContextProvider(ITemplateEngine viewTemplateEngine) {
33
		super();
34
		this.viewTemplateEngine = viewTemplateEngine;
35
	}
36
37
	@Override
38
	public IContext getWebContext(Context context, IContext base, HttpServletRequest request, HttpServletResponse response, ServletContext servletContext, ApplicationContext applicationContext,
39
			Map<String, Object> springModel) {
40
		final IEngineConfiguration configuration = viewTemplateEngine.getConfiguration();
41 1 1. getWebContext : replaced return value with null for fr/sii/ogham/spring/v2/template/thymeleaf/WebExpressionContextProvider::getWebContext → TIMED_OUT
		return new WebExpressionContext(configuration, request, response, servletContext, base.getLocale(), springModel);
42
	}
43
44
}

Mutations

41

1.1
Location : getWebContext
Killed by : none
replaced return value with null for fr/sii/ogham/spring/v2/template/thymeleaf/WebExpressionContextProvider::getWebContext → TIMED_OUT

Active mutators

Tests examined


Report generated by PIT OGHAM