use of org.apache.struts.config.ActionConfig in project sonar-java by SonarSource.
the class AbstractPopulateActionForm method execute.
// ---------------------------------------------------------- Public Methods
/**
* <p>Populate the form bean (if any) for this request.</p>
*
* @param actionCtx The <code>Context</code> for the current request
* @return <code>false</code> so that processing continues
* @throws Exception On an unexpected error
*/
public boolean execute(ActionContext actionCtx) throws Exception {
// Is there a form bean for this request?
ActionForm actionForm = actionCtx.getActionForm();
if (actionForm == null) {
return (false);
}
// Reset the form bean property values
ActionConfig actionConfig = actionCtx.getActionConfig();
reset(actionCtx, actionConfig, actionForm);
populate(actionCtx, actionConfig, actionForm);
handleCancel(actionCtx, actionConfig, actionForm);
return (false);
}
use of org.apache.struts.config.ActionConfig in project sonar-java by SonarSource.
the class TestActionServlet method testProcessActionConfigClassOverriddenSubConfigClass.
/**
* Test the case where the subconfig has already specified its own config
* class. If the code still attempts to create a new instance, an error
* will be thrown.
*/
public void testProcessActionConfigClassOverriddenSubConfigClass() throws Exception {
moduleConfig.addActionConfig(baseAction);
ActionConfig customSub = new CustomActionConfigArg("/sub");
customSub.setExtends("/index");
moduleConfig.addActionConfig(customSub);
try {
actionServlet.processActionConfigClass(customSub, moduleConfig);
} catch (Exception e) {
fail("Exception should not be thrown");
}
}
use of org.apache.struts.config.ActionConfig in project sonar-java by SonarSource.
the class TestActionServlet method testProcessActionConfigClass.
/**
* Make sure processActionConfigClass() returns an instance of the correct
* class if the base config is using a custom class.
*/
public void testProcessActionConfigClass() throws Exception {
CustomActionConfig customBase = new CustomActionConfig("/base");
moduleConfig.addActionConfig(customBase);
ActionMapping customSub = new ActionMapping();
customSub.setPath("/sub");
customSub.setExtends("/base");
moduleConfig.addActionConfig(customSub);
ActionConfig result = actionServlet.processActionConfigClass(customSub, moduleConfig);
assertTrue("Incorrect class of action config", result instanceof CustomActionConfig);
assertEquals("Incorrect path", customSub.getPath(), result.getPath());
assertEquals("Incorrect extends", customSub.getExtends(), result.getExtends());
assertSame("Result was not registered in the module config", result, moduleConfig.findActionConfig("/sub"));
}
use of org.apache.struts.config.ActionConfig in project sonar-java by SonarSource.
the class TestActionServlet method notestProcessActionConfigClassError.
/**
* Make sure the code throws the correct exception when it can't create an
* instance of the base config's custom class.
*/
public void notestProcessActionConfigClassError() throws Exception {
ActionConfig customBase = new CustomActionConfigArg("/index");
moduleConfig.addActionConfig(customBase);
ActionConfig customSub = new ActionMapping();
customSub.setPath("/sub");
customSub.setExtends("/index");
moduleConfig.addActionConfig(customSub);
try {
actionServlet.processActionConfigClass(customSub, moduleConfig);
fail("Exception should be thrown");
} catch (UnavailableException e) {
// success
} catch (Exception e) {
fail("Unexpected exception thrown.");
}
}
use of org.apache.struts.config.ActionConfig in project sonar-java by SonarSource.
the class TestAuthorizeAction method testNotAuthorizedOneRole.
public void testNotAuthorizedOneRole() throws Exception {
ActionConfig config = new ActionConfig();
config.setPath("/testNotAuthorizedOneRole");
config.setRoles("roustabout");
this.saContext.setActionConfig(config);
try {
boolean result = command.execute(saContext);
} catch (UnauthorizedActionException ex) {
}
}
Aggregations