use of com.opensymphony.xwork2.config.providers.MockConfigurationProvider in project struts by apache.
the class ValidateAction method testNonexistentParametersGetLoggedInDevMode.
public void testNonexistentParametersGetLoggedInDevMode() throws Exception {
XmlConfigurationProvider provider = new StrutsXmlConfigurationProvider("xwork-test-beans.xml");
container.inject(provider);
loadConfigurationProviders(provider, new MockConfigurationProvider(Collections.singletonMap("struts.devMode", "true")));
Map<String, Object> params = new HashMap<>();
params.put("not_a_property", "There is no action property named like this");
HashMap<String, Object> extraContext = new HashMap<>();
extraContext.put(ActionContext.PARAMETERS, HttpParameters.create(params).build());
ActionConfig config = configuration.getRuntimeConfiguration().getActionConfig("", MockConfigurationProvider.PARAM_INTERCEPTOR_ACTION_NAME);
container.inject(config.getInterceptors().get(0).getInterceptor());
ActionProxy proxy = actionProxyFactory.createActionProxy("", MockConfigurationProvider.PARAM_INTERCEPTOR_ACTION_NAME, null, extraContext);
proxy.execute();
final String actionMessage = "" + ((SimpleAction) proxy.getAction()).getActionMessages().toArray()[0];
assertTrue(actionMessage.contains("Error setting expression 'not_a_property' with value 'There is no action property named like this'"));
}
use of com.opensymphony.xwork2.config.providers.MockConfigurationProvider in project struts by apache.
the class ValidateAction method testNonexistentParametersAreIgnoredInProductionMode.
public void testNonexistentParametersAreIgnoredInProductionMode() throws Exception {
XmlConfigurationProvider provider = new StrutsXmlConfigurationProvider("xwork-test-beans.xml");
container.inject(provider);
loadConfigurationProviders(provider, new MockConfigurationProvider(Collections.singletonMap("struts.devMode", "false")));
Map<String, Object> params = new HashMap<>();
params.put("not_a_property", "There is no action property named like this");
HashMap<String, Object> extraContext = new HashMap<>();
extraContext.put(ActionContext.PARAMETERS, HttpParameters.create(params).build());
ActionConfig config = configuration.getRuntimeConfiguration().getActionConfig("", MockConfigurationProvider.PARAM_INTERCEPTOR_ACTION_NAME);
container.inject(config.getInterceptors().get(0).getInterceptor());
ActionProxy proxy = actionProxyFactory.createActionProxy("", MockConfigurationProvider.PARAM_INTERCEPTOR_ACTION_NAME, null, extraContext);
proxy.execute();
assertTrue(((SimpleAction) proxy.getAction()).getActionMessages().isEmpty());
}
use of com.opensymphony.xwork2.config.providers.MockConfigurationProvider in project struts by apache.
the class AnnotationWorkflowInterceptorTest method setUp.
@Override
public void setUp() throws Exception {
super.setUp();
XmlConfigurationProvider provider = new StrutsXmlConfigurationProvider("xwork-default.xml");
container.inject(provider);
loadConfigurationProviders(provider, new MockConfigurationProvider());
}
use of com.opensymphony.xwork2.config.providers.MockConfigurationProvider in project struts by apache.
the class ChainingInterceptorWithConfigTest method setUp.
@Override
protected void setUp() throws Exception {
super.setUp();
XmlConfigurationProvider provider = new StrutsXmlConfigurationProvider("xwork-default.xml");
container.inject(provider);
this.objectFactory = container.getInstance(ObjectFactory.class);
loadConfigurationProviders(provider, new MockConfigurationProvider());
}
use of com.opensymphony.xwork2.config.providers.MockConfigurationProvider in project struts by apache.
the class LongRangeValidatorTest method setUp.
@Override
protected void setUp() throws Exception {
super.setUp();
XmlConfigurationProvider provider = new StrutsXmlConfigurationProvider("xwork-test-beans.xml");
container.inject(provider);
loadConfigurationProviders(provider, new MockConfigurationProvider());
}
Aggregations