use of org.apache.struts.mock.MockHttpServletResponse 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