Search in sources :

Example 1 with MockActionContext

use of org.apache.struts.chain.contexts.MockActionContext in project sonarqube by SonarSource.

the class TestCopyFormToContext method setUp.

/*
     * @see TestCase#setUp()
     */
protected void setUp() throws Exception {
    context = new MockActionContext();
    ModuleConfigImpl moduleConfig = new ModuleConfigImpl("/");
    context.setModuleConfig(moduleConfig);
    FormBeanConfig fooFBC = new FormBeanConfig();
    fooFBC.setName("foo");
    fooFBC.setType("org.apache.struts.mock.MockFormBean");
    moduleConfig.addFormBeanConfig(fooFBC);
    FormBeanConfig barFBC = new FormBeanConfig();
    barFBC.setName("bar");
    // use a different type so we can verify lookups better
    barFBC.setType("org.apache.struts.action.DynaActionForm");
    FormPropertyConfig fpc = new FormPropertyConfig();
    fpc.setName("property");
    fpc.setType("java.lang.String");
    fpc.setInitial("test");
    barFBC.addFormPropertyConfig(fpc);
    moduleConfig.addFormBeanConfig(barFBC);
    ActionConfig testActionConfig = new ActionConfig();
    testActionConfig.setPath("/Test");
    testActionConfig.setName("foo");
    testActionConfig.setScope("request");
    moduleConfig.addActionConfig(testActionConfig);
    // otherwise, ActionConfigMatcher will be null and we'll get an NPE...
    moduleConfig.freeze();
}
Also used : FormPropertyConfig(org.apache.struts.config.FormPropertyConfig) ActionConfig(org.apache.struts.config.ActionConfig) FormBeanConfig(org.apache.struts.config.FormBeanConfig) MockActionContext(org.apache.struts.chain.contexts.MockActionContext) ModuleConfigImpl(org.apache.struts.config.impl.ModuleConfigImpl)

Example 2 with MockActionContext

use of org.apache.struts.chain.contexts.MockActionContext in project sonar-java by SonarSource.

the class TestCopyFormToContext method setUp.

/*
     * @see TestCase#setUp()
     */
protected void setUp() throws Exception {
    context = new MockActionContext();
    ModuleConfigImpl moduleConfig = new ModuleConfigImpl("/");
    context.setModuleConfig(moduleConfig);
    FormBeanConfig fooFBC = new FormBeanConfig();
    fooFBC.setName("foo");
    fooFBC.setType("org.apache.struts.mock.MockFormBean");
    moduleConfig.addFormBeanConfig(fooFBC);
    FormBeanConfig barFBC = new FormBeanConfig();
    barFBC.setName("bar");
    // use a different type so we can verify lookups better
    barFBC.setType("org.apache.struts.action.DynaActionForm");
    FormPropertyConfig fpc = new FormPropertyConfig();
    fpc.setName("property");
    fpc.setType("java.lang.String");
    fpc.setInitial("test");
    barFBC.addFormPropertyConfig(fpc);
    moduleConfig.addFormBeanConfig(barFBC);
    ActionConfig testActionConfig = new ActionConfig();
    testActionConfig.setPath("/Test");
    testActionConfig.setName("foo");
    testActionConfig.setScope("request");
    moduleConfig.addActionConfig(testActionConfig);
    // otherwise, ActionConfigMatcher will be null and we'll get an NPE...
    moduleConfig.freeze();
}
Also used : FormPropertyConfig(org.apache.struts.config.FormPropertyConfig) ActionConfig(org.apache.struts.config.ActionConfig) FormBeanConfig(org.apache.struts.config.FormBeanConfig) MockActionContext(org.apache.struts.chain.contexts.MockActionContext) ModuleConfigImpl(org.apache.struts.config.impl.ModuleConfigImpl)

Aggregations

MockActionContext (org.apache.struts.chain.contexts.MockActionContext)2 ActionConfig (org.apache.struts.config.ActionConfig)2 FormBeanConfig (org.apache.struts.config.FormBeanConfig)2 FormPropertyConfig (org.apache.struts.config.FormPropertyConfig)2 ModuleConfigImpl (org.apache.struts.config.impl.ModuleConfigImpl)2