use of org.apache.struts.config.ActionConfig in project sonarqube by SonarSource.
the class ExecuteCommand method getCommand.
/**
* <p>Find the <code>ActionConfig</code> in the current context and, if it
* is properly configured, lookup the appropriate <code>commons-chain</code>
* command.</p>
*
* @param context A valid ActionContext
* @return a <code>Command</code> to execute, or null if none is specified
* or if the specified command cannot be found.
*/
protected Command getCommand(ActionContext context) {
ActionConfig actionConfig = context.getActionConfig();
String commandName = actionConfig.getCommand();
if (commandName == null) {
return null;
}
String catalogName = actionConfig.getCatalog();
return getCommand(commandName, catalogName);
}
use of org.apache.struts.config.ActionConfig in project sonarqube by SonarSource.
the class TestActionServlet method testProcessActionConfigClassSubConfigCustomClass.
/**
* Make sure processActionConfigClass() returns the same class instance if
* the base config isn't using a custom class.
*/
public void testProcessActionConfigClassSubConfigCustomClass() throws Exception {
moduleConfig.addActionConfig(baseAction);
ActionConfig customSub = new ActionMapping();
customSub.setPath("/sub");
customSub.setExtends("/index");
moduleConfig.addActionConfig(customSub);
ActionConfig result = actionServlet.processActionConfigClass(customSub, moduleConfig);
assertSame("The instance returned should be the param given it.", customSub, result);
}
use of org.apache.struts.config.ActionConfig in project sonarqube 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 sonarqube by SonarSource.
the class TestActionServlet method testProcessActionConfigClassNoExtends.
/**
* Make sure processActionConfigClass() returns what it was given if the
* action passed to it doesn't extend anything.
*/
public void testProcessActionConfigClassNoExtends() throws Exception {
moduleConfig.addActionConfig(baseAction);
ActionConfig result = null;
try {
result = actionServlet.processActionConfigClass(baseAction, moduleConfig);
} catch (UnavailableException e) {
fail("An exception should not be thrown here");
}
assertSame("Result should be the same as the input.", baseAction, result);
}
use of org.apache.struts.config.ActionConfig in project sonarqube 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.");
}
}
Aggregations