use of org.apache.struts.config.impl.ModuleConfigImpl in project sonarqube 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();
}
use of org.apache.struts.config.impl.ModuleConfigImpl in project sonarqube by SonarSource.
the class TagTestBase method setUp.
/**
* Helper method that creates/configures a basic configuration of Mock
* Objects.
*
*
* PageContext ServletConfig ServletContext HttpServletRequest HttpSession
* HttpServletResponse
*
* "/myapp", "/foo", null, null,
*/
public void setUp() {
// -- default Module
this.moduleConfig = new ModuleConfigImpl("");
this.moduleConfig.addForwardConfig(new ForwardConfig("foo", "/bar.jsp", false));
this.moduleConfig.addForwardConfig(new ForwardConfig("relative1", "relative.jsp", false));
this.moduleConfig.addForwardConfig(new ForwardConfig("relative2", "relative.jsp", false));
this.moduleConfig.addForwardConfig(new ForwardConfig("external", "http://struts.apache.org/", false));
// -- module "/2"
this.moduleConfig2 = new ModuleConfigImpl("/2");
this.moduleConfig2.addForwardConfig(new ForwardConfig("foo", "/baz.jsp", false));
this.moduleConfig2.addForwardConfig(new ForwardConfig("relative1", "relative.jsp", false));
this.moduleConfig2.addForwardConfig(new ForwardConfig("relative2", "relative.jsp", false));
this.moduleConfig2.addForwardConfig(new ForwardConfig("external", "http://struts.apache.org/", false));
// -- module "/3"
this.moduleConfig3 = new ModuleConfigImpl("/3");
// -- configure the ServletContext
this.servletContext = new MockServletContext();
this.servletContext.setAttribute(Globals.MODULE_KEY, moduleConfig);
this.servletContext.setAttribute(Globals.MODULE_KEY + "/2", moduleConfig2);
this.servletContext.setAttribute(Globals.MODULE_KEY + "/3", moduleConfig3);
// -- configure the ServletConfig
this.servletConfig = new MockServletConfig();
this.servletConfig.setServletContext(servletContext);
// -- configure the request
this.request = new MockHttpServletRequest(new MockHttpSession());
pageContext = new MockPageContext(servletConfig, request, new MockHttpServletResponse());
}
use of org.apache.struts.config.impl.ModuleConfigImpl 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);
}
Aggregations