use of org.apache.struts.config.FormBeanConfig in project sonarqube by SonarSource.
the class TestActionServlet method notestProcessFormBeanConfigClassError.
/**
* Make sure the code throws the correct exception when it can't create an
* instance of the base config's custom class.
*/
public void notestProcessFormBeanConfigClassError() throws Exception {
CustomFormBeanConfigArg customBase = new CustomFormBeanConfigArg("customBase");
moduleConfig.addFormBeanConfig(customBase);
FormBeanConfig customSub = new FormBeanConfig();
customSub.setName("customSub");
customSub.setExtends("customBase");
moduleConfig.addFormBeanConfig(customSub);
try {
actionServlet.processFormBeanConfigClass(customSub, moduleConfig);
fail("Exception should be thrown");
} catch (UnavailableException e) {
// success
} catch (Exception e) {
fail("Unexpected exception thrown.");
}
}
use of org.apache.struts.config.FormBeanConfig in project sonarqube by SonarSource.
the class TestActionServlet method testInitModuleFormBeansNullFormType.
/**
* Test that initModuleFormBeans throws an exception when a form with a
* null type is present.
*/
public void testInitModuleFormBeansNullFormType() throws ServletException {
FormBeanConfig formBean = new FormBeanConfig();
formBean.setName("noTypeForm");
moduleConfig.addFormBeanConfig(formBean);
try {
actionServlet.initModuleFormBeans(moduleConfig);
fail("An exception should've been thrown here.");
} catch (UnavailableException e) {
// success
} catch (Exception e) {
fail("Unrecognized exception thrown: " + e);
}
}
use of org.apache.struts.config.FormBeanConfig in project sonarqube by SonarSource.
the class TestActionServlet method testProcessFormBeanConfigClassOverriddenSubFormClass.
/**
* Test the case where the subform has already specified its own form bean
* config class. If the code still attempts to create a new instance, an
* error will be thrown.
*/
public void testProcessFormBeanConfigClassOverriddenSubFormClass() throws Exception {
CustomFormBeanConfigArg customBase = new CustomFormBeanConfigArg("customBase");
moduleConfig.addFormBeanConfig(customBase);
FormBeanConfig customSub = new CustomFormBeanConfigArg("customSub");
customSub.setExtends("customBase");
moduleConfig.addFormBeanConfig(customSub);
try {
actionServlet.processFormBeanConfigClass(customSub, moduleConfig);
} catch (Exception e) {
fail("Exception should not be thrown");
}
}
use of org.apache.struts.config.FormBeanConfig in project sonarqube by SonarSource.
the class TestActionServlet method testProcessFormBeanConfigClassNoExtends.
/**
* Make sure processFormBeanConfigClass() returns what it was given if the
* form passed to it doesn't extend anything.
*/
public void testProcessFormBeanConfigClassNoExtends() throws Exception {
moduleConfig.addFormBeanConfig(baseFormBean);
FormBeanConfig result = null;
try {
result = actionServlet.processFormBeanConfigClass(baseFormBean, moduleConfig);
} catch (UnavailableException e) {
fail("An exception should not be thrown when there's nothing to do");
}
assertSame("Result should be the same as the input.", baseFormBean, result);
}
use of org.apache.struts.config.FormBeanConfig in project sonarqube by SonarSource.
the class TestActionServlet method testProcessFormBeanConfigClass.
/**
* Make sure processFormBeanConfigClass() returns an instance of the
* correct class if the base config is using a custom class.
*/
public void testProcessFormBeanConfigClass() throws Exception {
CustomFormBeanConfig customBase = new CustomFormBeanConfig();
customBase.setName("customBase");
moduleConfig.addFormBeanConfig(customBase);
FormBeanConfig customSub = new FormBeanConfig();
customSub.setName("customSub");
customSub.setExtends("customBase");
customSub.setType("org.apache.struts.action.DynaActionForm");
moduleConfig.addFormBeanConfig(customSub);
FormBeanConfig result = actionServlet.processFormBeanConfigClass(customSub, moduleConfig);
assertTrue("Incorrect class of form bean config", result instanceof CustomFormBeanConfig);
assertEquals("Incorrect name", customSub.getName(), result.getName());
assertEquals("Incorrect type", customSub.getType(), result.getType());
assertEquals("Incorrect extends", customSub.getExtends(), result.getExtends());
assertEquals("Incorrect 'restricted' value", customSub.isRestricted(), result.isRestricted());
assertSame("Result was not registered in the module config", result, moduleConfig.findFormBeanConfig("customSub"));
}
Aggregations