use of com.mockobjects.servlet.MockServletContext in project struts by apache.
the class ServletActionContextTest method setUp.
public void setUp() {
Map<String, Object> extraContext = new HashMap<>();
request = new MockHttpServletRequest();
response = new MockHttpServletResponse();
servletContext = new MockServletContext();
extraContext.put(HTTP_REQUEST, request);
extraContext.put(HTTP_RESPONSE, response);
extraContext.put(SERVLET_CONTEXT, servletContext);
actionContext = ActionContext.of(extraContext).bind();
}
use of com.mockobjects.servlet.MockServletContext in project commons-configuration by apache.
the class TestServletContextConfiguration method getConfiguration.
@Override
protected AbstractConfiguration getConfiguration() {
final Properties parameters = new Properties();
parameters.setProperty("key1", "value1");
parameters.setProperty("key2", "value2");
parameters.setProperty("list", "value1, value2");
parameters.setProperty("listesc", "value1\\,value2");
// create a servlet context
final ServletContext context = new MockServletContext() {
@Override
public String getInitParameter(final String key) {
return parameters.getProperty(key);
}
@Override
public Enumeration<?> getInitParameterNames() {
return parameters.keys();
}
};
// create a servlet config
final MockServletConfig config = new MockServletConfig();
config.setServletContext(context);
// create a servlet
final Servlet servlet = new HttpServlet() {
/**
* Serial version UID.
*/
private static final long serialVersionUID = 1L;
@Override
public ServletConfig getServletConfig() {
return config;
}
};
final ServletContextConfiguration resultConfig = new ServletContextConfiguration(servlet);
resultConfig.setListDelimiterHandler(new DefaultListDelimiterHandler(','));
return resultConfig;
}
Aggregations