use of net.sourceforge.stripes.mock.MockHttpServletRequest in project jspwiki by apache.
the class TestEngine method saveText.
/**
* Convenience method that saves a wiki page by constructing a fake
* WikiContext and HttpServletRequest. We always want to do this using a
* WikiContext whose subject contains Role.ADMIN.
* Note: the WikiPage author will have the default value of "Guest".
* @param pageName
* @param content
* @throws WikiException
*/
public void saveText(String pageName, String content) throws WikiException {
// Build new request and associate our admin session
MockHttpServletRequest request = newHttpRequest();
WikiSession wikiSession = SessionMonitor.getInstance(this).find(request.getSession());
this.getAuthenticationManager().login(wikiSession, request, Users.ADMIN, Users.ADMIN_PASS);
// Create page and wiki context
WikiPage page = new WikiPage(this, pageName);
WikiContext context = new WikiContext(this, request, page);
saveText(context, content);
}
use of net.sourceforge.stripes.mock.MockHttpServletRequest in project jspwiki by apache.
the class TestEngine method saveTextAsJanne.
public void saveTextAsJanne(String pageName, String content) throws WikiException {
// Build new request and associate our Janne session
MockHttpServletRequest request = newHttpRequest();
WikiSession wikiSession = SessionMonitor.getInstance(this).find(request.getSession());
this.getAuthenticationManager().login(wikiSession, request, Users.JANNE, Users.JANNE_PASS);
// Create page and wiki context
WikiPage page = new WikiPage(this, pageName);
page.setAuthor(Users.JANNE);
WikiContext context = new WikiContext(this, request, page);
saveText(context, content);
}
use of net.sourceforge.stripes.mock.MockHttpServletRequest in project jspwiki by apache.
the class TestEngine method newHttpRequest.
/**
* Creates a correctly-instantiated mock HttpServletRequest with an associated
* HttpSession and path.
* @param path the path relative to the wiki context, for example "/Wiki.jsp"
* @return the new request
*/
public MockHttpServletRequest newHttpRequest(String path) {
MockHttpServletRequest request = new MockHttpServletRequest("/JSPWiki", path);
request.setSession(new MockHttpSession(this.getServletContext()));
request.addLocale(new Locale(""));
return request;
}
Aggregations