use of org.apache.struts.mock.MockActionServlet in project sonarqube by SonarSource.
the class TestAuthorizeAction method setUp.
/* setUp method for test case */
protected void setUp() throws Exception {
this.request = new MockHttpServletRequest();
this.principal = new MockPrincipal("Mr. Macri", new String[] { "administrator" });
this.request.setUserPrincipal(principal);
MockServletConfig servletConfig = new MockServletConfig();
MockServletContext servletContext = new MockServletContext();
MockActionServlet servlet = new MockActionServlet(servletContext, servletConfig);
servlet.initInternal();
this.saContext = new ServletActionContext(servletContext, request, new MockHttpServletResponse());
this.saContext.setActionServlet(servlet);
this.command = new AuthorizeAction();
}
use of org.apache.struts.mock.MockActionServlet in project sonarqube by SonarSource.
the class TestPerformForward method setUp.
/* setUp method for test case */
protected void setUp() throws Exception {
this.request = new MockHttpServletRequest();
this.principal = new MockPrincipal("Mr. Macri", new String[] { "administrator" });
this.request.setUserPrincipal(principal);
MockServletConfig servletConfig = new MockServletConfig();
MockServletContext servletContext = new MockServletContext();
MockActionServlet servlet = new MockActionServlet(servletContext, servletConfig);
servlet.initInternal();
this.saContext = new ServletActionContext(servletContext, request, new MockHttpServletResponse());
this.saContext.setActionServlet(servlet);
this.command = new PerformForward();
}
use of org.apache.struts.mock.MockActionServlet in project sonarqube by SonarSource.
the class TestSetOriginalURI method testSetOriginalURI.
public void testSetOriginalURI() throws Exception {
MockHttpServletRequest request = new MockHttpServletRequest("foo/", "bar.do", null, null);
MockServletConfig servletConfig = new MockServletConfig();
MockServletContext servletContext = new MockServletContext();
MockActionServlet servlet = new MockActionServlet(servletContext, servletConfig);
servlet.initInternal();
ServletActionContext saContext = new ServletActionContext(servletContext, request, new MockHttpServletResponse());
saContext.setActionServlet(servlet);
boolean result = command.execute(saContext);
assertTrue(!result);
String uri = (String) request.getAttribute(Globals.ORIGINAL_URI_KEY);
assertTrue("Original uri not correct: " + uri, "bar.do".equals(uri));
request.setPathElements("foo/", "bar2.do", null, null);
uri = (String) request.getAttribute(Globals.ORIGINAL_URI_KEY);
assertTrue("Original uri not correct: " + uri, "bar.do".equals(uri));
}
Aggregations