Search in sources :

Example 6 with MockConfigurationProvider

use of com.opensymphony.xwork2.config.providers.MockConfigurationProvider in project struts by apache.

the class SimpleActionValidationTest 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());
}
Also used : StrutsXmlConfigurationProvider(org.apache.struts2.config.StrutsXmlConfigurationProvider) XmlConfigurationProvider(com.opensymphony.xwork2.config.providers.XmlConfigurationProvider) StrutsXmlConfigurationProvider(org.apache.struts2.config.StrutsXmlConfigurationProvider) MockConfigurationProvider(com.opensymphony.xwork2.config.providers.MockConfigurationProvider)

Example 7 with MockConfigurationProvider

use of com.opensymphony.xwork2.config.providers.MockConfigurationProvider in project struts by apache.

the class StringValidatorTest method setUp.

@Override
protected void setUp() throws Exception {
    super.setUp();
    loadConfigurationProviders(new MockConfigurationProvider());
    ActionConfig config = new ActionConfig.Builder("", "name", "").build();
    ActionInvocation invocation = EasyMock.createNiceMock(ActionInvocation.class);
    ActionProxy proxy = EasyMock.createNiceMock(ActionProxy.class);
    EasyMock.expect(invocation.getProxy()).andReturn(proxy).anyTimes();
    EasyMock.expect(invocation.getAction()).andReturn(null).anyTimes();
    EasyMock.expect(invocation.invoke()).andReturn(Action.SUCCESS).anyTimes();
    EasyMock.expect(proxy.getMethod()).andReturn("execute").anyTimes();
    EasyMock.expect(proxy.getConfig()).andReturn(config).anyTimes();
    EasyMock.replay(invocation);
    EasyMock.replay(proxy);
    ActionContext.getContext().withActionInvocation(invocation);
    tpf = container.getInstance(TextProviderFactory.class);
}
Also used : TextProviderFactory(com.opensymphony.xwork2.TextProviderFactory) ActionConfig(com.opensymphony.xwork2.config.entities.ActionConfig) ActionProxy(com.opensymphony.xwork2.ActionProxy) MockConfigurationProvider(com.opensymphony.xwork2.config.providers.MockConfigurationProvider) ActionInvocation(com.opensymphony.xwork2.ActionInvocation)

Example 8 with MockConfigurationProvider

use of com.opensymphony.xwork2.config.providers.MockConfigurationProvider in project struts by apache.

the class DoubleRangeFieldValidatorTest method setUp.

@Override
protected void setUp() throws Exception {
    super.setUp();
    XmlConfigurationProvider provider = new StrutsXmlConfigurationProvider("xwork-default.xml");
    container.inject(provider);
    loadConfigurationProviders(provider, new MockConfigurationProvider());
    val = new DoubleRangeFieldValidator();
    val.setValueStack(ActionContext.getContext().getValueStack());
    ActionContext.getContext().setParameters(HttpParameters.create().build());
    tpf = container.getInstance(TextProviderFactory.class);
}
Also used : TextProviderFactory(com.opensymphony.xwork2.TextProviderFactory) StrutsXmlConfigurationProvider(org.apache.struts2.config.StrutsXmlConfigurationProvider) XmlConfigurationProvider(com.opensymphony.xwork2.config.providers.XmlConfigurationProvider) StrutsXmlConfigurationProvider(org.apache.struts2.config.StrutsXmlConfigurationProvider) MockConfigurationProvider(com.opensymphony.xwork2.config.providers.MockConfigurationProvider) DoubleRangeFieldValidator(com.opensymphony.xwork2.validator.validators.DoubleRangeFieldValidator)

Example 9 with MockConfigurationProvider

use of com.opensymphony.xwork2.config.providers.MockConfigurationProvider in project struts by apache.

the class ConfigurationTest method testMultipleConfigProviders.

public void testMultipleConfigProviders() {
    configurationManager.addContainerProvider(new MockConfigurationProvider());
    try {
        configurationManager.reload();
    } catch (ConfigurationException e) {
        e.printStackTrace();
        fail();
    }
    RuntimeConfiguration configuration = configurationManager.getConfiguration().getRuntimeConfiguration();
    // check that it has configuration from xml
    assertNotNull(configuration.getActionConfig("/foo/bar", "Bar"));
    // check that it has configuration from MockConfigurationProvider
    assertNotNull(configuration.getActionConfig("", MockConfigurationProvider.FOO_ACTION_NAME));
}
Also used : MockConfigurationProvider(com.opensymphony.xwork2.config.providers.MockConfigurationProvider)

Example 10 with MockConfigurationProvider

use of com.opensymphony.xwork2.config.providers.MockConfigurationProvider in project struts by apache.

the class LocaleAwareTest method setUp.

@Override
protected void setUp() throws Exception {
    super.setUp();
    XmlConfigurationProvider configurationProvider = new StrutsXmlConfigurationProvider("xwork-test-beans.xml");
    container.inject(configurationProvider);
    loadConfigurationProviders(configurationProvider, new MockConfigurationProvider());
    ValueStack stack = container.getInstance(ValueStackFactory.class).createValueStack();
    stack.getActionContext().withContainer(container);
    ActionContext.of(stack.getContext()).bind();
}
Also used : StrutsXmlConfigurationProvider(org.apache.struts2.config.StrutsXmlConfigurationProvider) XmlConfigurationProvider(com.opensymphony.xwork2.config.providers.XmlConfigurationProvider) StrutsXmlConfigurationProvider(org.apache.struts2.config.StrutsXmlConfigurationProvider) MockConfigurationProvider(com.opensymphony.xwork2.config.providers.MockConfigurationProvider) ValueStack(com.opensymphony.xwork2.util.ValueStack) ValueStackFactory(com.opensymphony.xwork2.util.ValueStackFactory)

Aggregations

MockConfigurationProvider (com.opensymphony.xwork2.config.providers.MockConfigurationProvider)13 XmlConfigurationProvider (com.opensymphony.xwork2.config.providers.XmlConfigurationProvider)11 StrutsXmlConfigurationProvider (org.apache.struts2.config.StrutsXmlConfigurationProvider)11 ActionConfig (com.opensymphony.xwork2.config.entities.ActionConfig)5 ActionProxy (com.opensymphony.xwork2.ActionProxy)3 TextProviderFactory (com.opensymphony.xwork2.TextProviderFactory)2 HashMap (java.util.HashMap)2 LinkedHashMap (java.util.LinkedHashMap)2 ActionInvocation (com.opensymphony.xwork2.ActionInvocation)1 ObjectFactory (com.opensymphony.xwork2.ObjectFactory)1 SimpleAction (com.opensymphony.xwork2.SimpleAction)1 ValueStack (com.opensymphony.xwork2.util.ValueStack)1 ValueStackFactory (com.opensymphony.xwork2.util.ValueStackFactory)1 DoubleRangeFieldValidator (com.opensymphony.xwork2.validator.validators.DoubleRangeFieldValidator)1