Search in sources :

Example 16 with FormPropertyConfig

use of org.apache.struts.config.FormPropertyConfig in project sonarqube by SonarSource.

the class TestDynaActionFormClass method testConfigAdd.

// -------------------------------------------------- Verify FormBeanConfig
// Check for ability to add a property before and after freezing
public void testConfigAdd() {
    FormPropertyConfig prop = null;
    // Before freezing
    prop = beanConfig.findFormPropertyConfig("fooProperty");
    assertNull("fooProperty not found", prop);
    beanConfig.addFormPropertyConfig(new FormPropertyConfig("fooProperty", "java.lang.String", ""));
    prop = beanConfig.findFormPropertyConfig("fooProperty");
    assertNotNull("fooProperty found", prop);
    // after freezing
    beanConfig.freeze();
    prop = beanConfig.findFormPropertyConfig("barProperty");
    assertNull("barProperty not found", prop);
    try {
        beanConfig.addFormPropertyConfig(new FormPropertyConfig("barProperty", "java.lang.String", ""));
        fail("barProperty add not prevented");
    } catch (IllegalStateException e) {
        // Expected result
        ;
    }
}
Also used : FormPropertyConfig(org.apache.struts.config.FormPropertyConfig)

Example 17 with FormPropertyConfig

use of org.apache.struts.config.FormPropertyConfig in project sonarqube by SonarSource.

the class TestDynaActionFormClass method testConfigProperties.

// Check the configured FormPropertyConfig element properties
public void testConfigProperties() {
    for (int i = 0; i < dynaProperties.length; i++) {
        FormPropertyConfig dynaProperty = beanConfig.findFormPropertyConfig(dynaProperties[i].getName());
        assertNotNull("Found dynaProperty " + dynaProperties[i].getName(), dynaProperty);
        assertEquals("dynaProperty name for " + dynaProperties[i].getName(), dynaProperties[i].getName(), dynaProperty.getName());
        assertEquals("dynaProperty type for " + dynaProperties[i].getName(), dynaProperties[i].getType(), dynaProperty.getType());
        assertEquals("dynaProperty initial for " + dynaProperties[i].getName(), dynaProperties[i].getInitial(), dynaProperty.getInitial());
    }
}
Also used : FormPropertyConfig(org.apache.struts.config.FormPropertyConfig)

Example 18 with FormPropertyConfig

use of org.apache.struts.config.FormPropertyConfig in project sonar-java by SonarSource.

the class TestDynaActionFormClass method testConfigRemove.

// Check for ability to remove a property before and after freezing
public void testConfigRemove() {
    FormPropertyConfig prop = null;
    // Before freezing
    prop = beanConfig.findFormPropertyConfig("booleanProperty");
    assertNotNull("booleanProperty found", prop);
    beanConfig.removeFormPropertyConfig(prop);
    prop = beanConfig.findFormPropertyConfig("booleanProperty");
    assertNull("booleanProperty not deleted", prop);
    // after freezing
    beanConfig.freeze();
    prop = beanConfig.findFormPropertyConfig("booleanSecond");
    assertNotNull("booleanSecond found", prop);
    try {
        beanConfig.removeFormPropertyConfig(prop);
        fail("booleanSecond remove not prevented");
    } catch (IllegalStateException e) {
        // Expected result
        ;
    }
}
Also used : FormPropertyConfig(org.apache.struts.config.FormPropertyConfig)

Example 19 with FormPropertyConfig

use of org.apache.struts.config.FormPropertyConfig in project sonar-java by SonarSource.

the class TestDynaActionFormClass method testConfigAdd.

// -------------------------------------------------- Verify FormBeanConfig
// Check for ability to add a property before and after freezing
public void testConfigAdd() {
    FormPropertyConfig prop = null;
    // Before freezing
    prop = beanConfig.findFormPropertyConfig("fooProperty");
    assertNull("fooProperty not found", prop);
    beanConfig.addFormPropertyConfig(new FormPropertyConfig("fooProperty", "java.lang.String", ""));
    prop = beanConfig.findFormPropertyConfig("fooProperty");
    assertNotNull("fooProperty found", prop);
    // after freezing
    beanConfig.freeze();
    prop = beanConfig.findFormPropertyConfig("barProperty");
    assertNull("barProperty not found", prop);
    try {
        beanConfig.addFormPropertyConfig(new FormPropertyConfig("barProperty", "java.lang.String", ""));
        fail("barProperty add not prevented");
    } catch (IllegalStateException e) {
        // Expected result
        ;
    }
}
Also used : FormPropertyConfig(org.apache.struts.config.FormPropertyConfig)

Example 20 with FormPropertyConfig

use of org.apache.struts.config.FormPropertyConfig 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

FormPropertyConfig (org.apache.struts.config.FormPropertyConfig)24 FormBeanConfig (org.apache.struts.config.FormBeanConfig)10 ModuleConfigFactory (org.apache.struts.config.ModuleConfigFactory)6 ActionFormBean (org.apache.struts.action.ActionFormBean)4 ActionForward (org.apache.struts.action.ActionForward)4 ActionMapping (org.apache.struts.action.ActionMapping)4 ForwardConfig (org.apache.struts.config.ForwardConfig)4 IOException (java.io.IOException)2 MalformedURLException (java.net.MalformedURLException)2 MissingResourceException (java.util.MissingResourceException)2 StringTokenizer (java.util.StringTokenizer)2 ServletException (javax.servlet.ServletException)2 UnavailableException (javax.servlet.UnavailableException)2 DynaProperty (org.apache.commons.beanutils.DynaProperty)2 MockActionContext (org.apache.struts.chain.contexts.MockActionContext)2 ActionConfig (org.apache.struts.config.ActionConfig)2 ExceptionConfig (org.apache.struts.config.ExceptionConfig)2 ModuleConfigImpl (org.apache.struts.config.impl.ModuleConfigImpl)2 SAXException (org.xml.sax.SAXException)2