Package net.sourceforge.stripes.mock

Examples of net.sourceforge.stripes.mock.MockHttpServletRequest


    }
   
    public void testFindWikiActionNoParams()
    {
        Command a;
        MockHttpServletRequest request = m_engine.newHttpRequest( "" );
       
        // Passing an EDIT request with no explicit page params means the EDIT action
        a = resolver.findCommand( request, WikiContext.EDIT );
        assertEquals( PageCommand.EDIT, a );
        assertEquals( "EditContent.jsp", a.getContentTemplate() );
View Full Code Here


    {
        Command a;
        WikiPage page = m_engine.getPage( "SinglePage" );
       
        // Passing an EDIT request with page param yields a wrapped action
        MockHttpServletRequest request = m_engine.newHttpRequest( "/Edit.jsp?page=SinglePage" );
        request.getParameterMap().put( "page", new String[]{ "SinglePage" } );
        a = resolver.findCommand( request, WikiContext.EDIT );
        assertNotSame( PageCommand.EDIT, a );
        assertEquals( "EditContent.jsp", a.getContentTemplate() );
        assertEquals( "Edit.jsp", a.getJSP() );
        assertEquals( "%uEdit.jsp?page=%n", a.getURLPattern() );
        assertEquals( page, a.getTarget() );
       
        // Passing an EDIT request with page=FindPage yields FIND action, *not* edit
        request.setContextPath( "/Edit.jsp?page=FindPage" );
        request.getParameterMap().put( "page", new String[]{ "FindPage" } );
        a = resolver.findCommand( request, WikiContext.EDIT );
        assertEquals( WikiCommand.FIND, a );
        assertEquals( "FindContent.jsp", a.getContentTemplate() );
        assertEquals( "Search.jsp", a.getJSP() );
        assertEquals( "%uSearch.jsp", a.getURLPattern() );
        assertNull( a.getTarget() );
       
        // Passing an EDIT request with group="Foo" yields wrapped VIEW_GROUP
        request = m_engine.newHttpRequest( "/Group.jsp?group=Foo" );
        request.getParameterMap().put( "group", new String[]{ "Foo" } );
        a = resolver.findCommand( request, WikiContext.EDIT );
        assertNotSame( GroupCommand.VIEW_GROUP, a );
        assertEquals( "GroupContent.jsp", a.getContentTemplate() );
        assertEquals( "Group.jsp", a.getJSP() );
        assertEquals( "%uGroup.jsp?group=%n", a.getURLPattern() );
View Full Code Here

        assertEquals( new GroupPrincipal( "Foo" ), a.getTarget() );
    }
   
    public void testFindWikiActionWithPath()
    {
        MockHttpServletRequest request;
        Command a;
       
        // Passing an EDIT request with View JSP yields EDIT of the Front page
        request = m_engine.newHttpRequest( "/Wiki.jsp" );
        a = resolver.findCommand( request, WikiContext.EDIT );
View Full Code Here

     * @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() ) );
        return request;
    }
View Full Code Here

     */
    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
View Full Code Here

    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
View Full Code Here

    }

    public void testSimpleSearch3() throws Exception {
        String txt = "It was the dawn of the third age of mankind, ten years after the Earth-Minbari War.";
        MockHttpServletRequest request = m_engine.newHttpRequest();
        request.getParameterMap().put( "page", new String[]{ "TestPage" } );
       
        WikiContext ctx = m_engine.createContext( request, WikiContext.EDIT );
       
        m_engine.saveText( ctx, txt );
View Full Code Here

     * @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;
    }
View Full Code Here

     */
    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
View Full Code Here

    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
View Full Code Here

TOP

Related Classes of net.sourceforge.stripes.mock.MockHttpServletRequest

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.