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
;
}
}
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());
}
}
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
;
}
}
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
;
}
}
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();
}
Aggregations