use of org.apache.struts.config.ModuleConfig in project sonarqube by SonarSource.
the class TestRequestUtils method testSelectApplication1b.
// Map to the second module -- direct
public void testSelectApplication1b() {
String[] prefixes = { "/1", "/2" };
context.setAttribute(Globals.MODULE_PREFIXES_KEY, prefixes);
request.setPathElements("/myapp", "/2/noform.do", null, null);
ModuleUtils.getInstance().selectModule(request, context);
ModuleConfig moduleConfig = (ModuleConfig) request.getAttribute(Globals.MODULE_KEY);
assertNotNull("Selected a module", moduleConfig);
assertEquals("Selected correct module", "/2", moduleConfig.getPrefix());
// FIXME - check module resources?
}
use of org.apache.struts.config.ModuleConfig in project sonarqube by SonarSource.
the class TestRequestUtils method testSelectApplication2a.
// Map to the default module -- include
public void testSelectApplication2a() {
request.setPathElements("/myapp", "/2/noform.do", null, null);
request.setAttribute(RequestProcessor.INCLUDE_SERVLET_PATH, "/noform.do");
ModuleUtils.getInstance().selectModule(request, context);
ModuleConfig moduleConfig = (ModuleConfig) request.getAttribute(Globals.MODULE_KEY);
assertNotNull("Selected an application", moduleConfig);
assertEquals("Selected correct application", "", moduleConfig.getPrefix());
// FIXME - check application resources?
}
use of org.apache.struts.config.ModuleConfig in project sonarqube by SonarSource.
the class TestTagUtils method testModuleConfig_getModuleConfig_PageContext.
// ----public ModuleConfig getModuleConfig(PageContext pageContext)
public void testModuleConfig_getModuleConfig_PageContext() {
MockServletConfig mockServletConfig = new MockServletConfig();
ModuleConfig moduleConfig = new ModuleConfigImpl("");
MockServletContext mockServletContext = new MockServletContext();
MockHttpServletRequest mockHttpServletRequest = new MockHttpServletRequest();
MockHttpServletResponse mockHttpServletResponse = new MockHttpServletResponse();
mockServletConfig.setServletContext(mockServletContext);
MockPageContext mockPageContext = new MockPageContext(mockServletConfig, mockHttpServletRequest, mockHttpServletResponse);
ModuleConfig foundModuleConfig = null;
try {
foundModuleConfig = tagutils.getModuleConfig(mockPageContext);
fail("Expected ModuleConfig to not be found");
} catch (NullPointerException ignore) {
// expected result
}
mockHttpServletRequest.setAttribute(Globals.MODULE_KEY, moduleConfig);
mockPageContext.getServletContext().setAttribute(Globals.MODULE_KEY, mockPageContext);
foundModuleConfig = tagutils.getModuleConfig(mockPageContext);
assertNotNull(foundModuleConfig);
}
use of org.apache.struts.config.ModuleConfig in project sonarqube by SonarSource.
the class RequestUtils method actionIdURL.
/**
* <p>Returns the true path of the destination action if the specified forward
* is an action-aliased URL. This method version forms the URL based on
* the current request; selecting the current module if the forward does not
* explicitly contain a module path.</p>
*
* @param forward the forward config
* @param request the current request
* @param servlet the servlet handling the current request
* @return the context-relative URL of the action if the forward has an action identifier; otherwise <code>null</code>.
* @since Struts 1.3.6
*/
public static String actionIdURL(ForwardConfig forward, HttpServletRequest request, ActionServlet servlet) {
ModuleConfig moduleConfig = null;
if (forward.getModule() != null) {
String prefix = forward.getModule();
moduleConfig = ModuleUtils.getInstance().getModuleConfig(prefix, servlet.getServletContext());
} else {
moduleConfig = ModuleUtils.getInstance().getModuleConfig(request);
}
return actionIdURL(forward.getPath(), moduleConfig, servlet);
}
Aggregations