You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@jspwiki.apache.org by aj...@apache.org on 2008/08/13 08:01:29 UTC

svn commit: r685452 - in /incubator/jspwiki/branches/JSPWIKI_2_9_STRIPES_BRANCH: doc/ src/com/ecyrd/jspwiki/ src/com/ecyrd/jspwiki/action/ tests/com/ecyrd/jspwiki/ tests/com/ecyrd/jspwiki/action/

Author: ajaquith
Date: Tue Aug 12 23:01:27 2008
New Revision: 685452

URL: http://svn.apache.org/viewvc?rev=685452&view=rev
Log:
Fixed failing unit tests. Now at parity with trunk except for 5 TOC tests and the stress test.

Removed:
    incubator/jspwiki/branches/JSPWIKI_2_9_STRIPES_BRANCH/src/com/ecyrd/jspwiki/action/AbstractUserProfileActionBean.java
Modified:
    incubator/jspwiki/branches/JSPWIKI_2_9_STRIPES_BRANCH/doc/README - Stripes Migration
    incubator/jspwiki/branches/JSPWIKI_2_9_STRIPES_BRANCH/src/com/ecyrd/jspwiki/WikiContext.java
    incubator/jspwiki/branches/JSPWIKI_2_9_STRIPES_BRANCH/src/com/ecyrd/jspwiki/action/LoginActionBean.java
    incubator/jspwiki/branches/JSPWIKI_2_9_STRIPES_BRANCH/src/com/ecyrd/jspwiki/action/UserProfileActionBean.java
    incubator/jspwiki/branches/JSPWIKI_2_9_STRIPES_BRANCH/tests/com/ecyrd/jspwiki/TestEngine.java
    incubator/jspwiki/branches/JSPWIKI_2_9_STRIPES_BRANCH/tests/com/ecyrd/jspwiki/action/GroupActionBeanTest.java
    incubator/jspwiki/branches/JSPWIKI_2_9_STRIPES_BRANCH/tests/com/ecyrd/jspwiki/action/HandlerInfoTest.java
    incubator/jspwiki/branches/JSPWIKI_2_9_STRIPES_BRANCH/tests/com/ecyrd/jspwiki/action/UserPreferencesActionBeanTest.java
    incubator/jspwiki/branches/JSPWIKI_2_9_STRIPES_BRANCH/tests/com/ecyrd/jspwiki/action/UserProfileActionBeanTest.java
    incubator/jspwiki/branches/JSPWIKI_2_9_STRIPES_BRANCH/tests/com/ecyrd/jspwiki/action/ViewActionBeanTest.java
    incubator/jspwiki/branches/JSPWIKI_2_9_STRIPES_BRANCH/tests/com/ecyrd/jspwiki/action/WikiActionBeanFactoryTest.java

Modified: incubator/jspwiki/branches/JSPWIKI_2_9_STRIPES_BRANCH/doc/README - Stripes Migration
URL: http://svn.apache.org/viewvc/incubator/jspwiki/branches/JSPWIKI_2_9_STRIPES_BRANCH/doc/README%20-%20Stripes%20Migration?rev=685452&r1=685451&r2=685452&view=diff
==============================================================================
--- incubator/jspwiki/branches/JSPWIKI_2_9_STRIPES_BRANCH/doc/README - Stripes Migration (original)
+++ incubator/jspwiki/branches/JSPWIKI_2_9_STRIPES_BRANCH/doc/README - Stripes Migration Tue Aug 12 23:01:27 2008
@@ -359,10 +359,17 @@
 -----------
 WikiTagBase changes slightly to support Stripes. Instead of extending import javax.servlet.jsp.tagext.TagSupport, it now extends StripesTagSupport. However, StripesTagSupport does not supply the methods setId/GetId. So, we've had to implement these. Also, the method TagSupport.findAncestorWithClass which is used by TabTag needs to be replaced by StripesTagSupport.getParentTag (without need for classcast).
 
+=========================================================================================
 
 TESTING NOTES
 =============
 
+JSP Migration
+-------------
+Form tags:
+- JavaScript onSubmit() code should be scrubbed?
+
+
 Eclipse Tools Notes
 -------------------
 TestEngine: Because of its use of Stripes mock objects, TestEngine needs to be able to find the various implementations provided in JSPWiki. Therefore, it is extremely sensitive to changes in the build path. In particular, the mock servlet filter used by TestEngine hard-wires in the relative location build for finding ActionBeans. This is the directory (relative to the project root) that the Ant build scripts use for placing generated Java class files. The Eclipse project configuration must configure itself the same way. To run unit tests in Eclipse, the build directory absolutely must place generated class files in this directory, rather than the Eclipse default of classes. If unit tests do not run in Eclipse for some reason, this is the likeliest culprit.

Modified: incubator/jspwiki/branches/JSPWIKI_2_9_STRIPES_BRANCH/src/com/ecyrd/jspwiki/WikiContext.java
URL: http://svn.apache.org/viewvc/incubator/jspwiki/branches/JSPWIKI_2_9_STRIPES_BRANCH/src/com/ecyrd/jspwiki/WikiContext.java?rev=685452&r1=685451&r2=685452&view=diff
==============================================================================
--- incubator/jspwiki/branches/JSPWIKI_2_9_STRIPES_BRANCH/src/com/ecyrd/jspwiki/WikiContext.java (original)
+++ incubator/jspwiki/branches/JSPWIKI_2_9_STRIPES_BRANCH/src/com/ecyrd/jspwiki/WikiContext.java Tue Aug 12 23:01:27 2008
@@ -132,7 +132,7 @@
     public static final String    VIEW_GROUP = HandlerInfo.getHandlerInfo( GroupActionBean.class, "view" ).getRequestContext();
 
     /** User is editing preferences */
-    public static final String    PREFS    = HandlerInfo.getHandlerInfo( UserPreferencesActionBean.class, "editFavorites" ).getRequestContext();
+    public static final String    PREFS    = HandlerInfo.getHandlerInfo( UserPreferencesActionBean.class, "createAssertedName" ).getRequestContext();
 
     /** User is renaming a page. */
     public static final String    RENAME   = HandlerInfo.getHandlerInfo( RenameActionBean.class, "rename" ).getRequestContext();

Modified: incubator/jspwiki/branches/JSPWIKI_2_9_STRIPES_BRANCH/src/com/ecyrd/jspwiki/action/LoginActionBean.java
URL: http://svn.apache.org/viewvc/incubator/jspwiki/branches/JSPWIKI_2_9_STRIPES_BRANCH/src/com/ecyrd/jspwiki/action/LoginActionBean.java?rev=685452&r1=685451&r2=685452&view=diff
==============================================================================
--- incubator/jspwiki/branches/JSPWIKI_2_9_STRIPES_BRANCH/src/com/ecyrd/jspwiki/action/LoginActionBean.java (original)
+++ incubator/jspwiki/branches/JSPWIKI_2_9_STRIPES_BRANCH/src/com/ecyrd/jspwiki/action/LoginActionBean.java Tue Aug 12 23:01:27 2008
@@ -7,24 +7,51 @@
 
 import net.sourceforge.stripes.action.*;
 import net.sourceforge.stripes.util.UrlBuilder;
-import net.sourceforge.stripes.validation.LocalizableError;
 import net.sourceforge.stripes.validation.SimpleError;
 import net.sourceforge.stripes.validation.ValidationErrors;
 
 import org.apache.log4j.Logger;
 
-import com.ecyrd.jspwiki.WikiEngine;
 import com.ecyrd.jspwiki.WikiSession;
 import com.ecyrd.jspwiki.auth.WikiSecurityException;
 import com.ecyrd.jspwiki.auth.login.CookieAssertionLoginModule;
 import com.ecyrd.jspwiki.auth.login.CookieAuthenticationLoginModule;
 import com.ecyrd.jspwiki.auth.permissions.WikiPermission;
-import com.ecyrd.jspwiki.workflow.DecisionRequiredException;
 
 @UrlBinding( "/Login.jsp" )
-public class LoginActionBean extends AbstractUserProfileActionBean
+public class LoginActionBean extends AbstractActionBean
 {
-    private String m_redirect = null;
+    private static final Logger log = Logger.getLogger( LoginActionBean.class );
+
+    /**
+     * Sets cookies and redirects the user to a wiki page after a successful
+     * profile creation or login.
+     * 
+     * @param bean the WikiActionBean currently executing
+     * @param pageName the page to redirect to after login or profile creation
+     * @param rememberMe whether to set the "remember me?" cookie
+     */
+    private Resolution saveCookiesAndRedirect( String pageName, boolean rememberMe )
+    {
+        // Set user cookie
+        Principal principal = getWikiSession().getUserPrincipal();
+        CookieAssertionLoginModule.setUserCookie( getContext().getResponse(), principal.getName() );
+
+        // Set "remember me?" cookie
+        if( rememberMe )
+        {
+            CookieAuthenticationLoginModule.setLoginCookie( getEngine(), getContext().getResponse(), principal.getName() );
+        }
+
+        Resolution r = null;
+        if( pageName != null )
+        {
+            UrlBuilder builder = new UrlBuilder( getContext().getLocale(), ViewActionBean.class, false );
+            builder.addParameter( "page", pageName );
+            r = new RedirectResolution( builder.toString() );
+        }
+        return r;
+    }
 
     private String m_username = null;
 
@@ -32,36 +59,21 @@
 
     private String m_password;
 
-    private static final Logger log = Logger.getLogger( LoginActionBean.class );
-
-    public String getJ_userName()
-    {
-        return m_username;
-    }
+    private String m_redirect;
 
     public String getJ_password()
     {
         return m_password;
     }
 
-    public void setJ_username( String username )
-    {
-        m_username = username;
-    }
-
-    public void setJ_password( String password )
-    {
-        m_password = password;
-    }
-
-    public void setJ_remember( boolean remember )
+    public boolean getJ_remember()
     {
-        m_remember = remember;
+        return m_remember;
     }
 
-    public boolean getJ_remember()
+    public String getJ_userName()
     {
-        return m_remember;
+        return m_username;
     }
 
     public String getRedirect()
@@ -97,7 +109,7 @@
             {
                 // Set cookies as needed and redirect
                 log.info( "Successfully authenticated user " + m_username + " (custom auth)" );
-                r = redirectToOriginalPage();
+                r = saveCookiesAndRedirect( m_redirect, m_remember );
             }
             else
             {
@@ -130,85 +142,25 @@
         return null;
     }
 
-    public void setRedirect( String redirect )
+    public void setJ_password( String password )
     {
-        m_redirect = redirect;
-        setVariable( "redirect", redirect );
+        m_password = password;
     }
 
-    /**
-     * Attempts to save the user profile, after all other validation routines
-     * have executed. If the save executes without error, this method will
-     * return <code>null</code>. Otherwise, any error conditions will return
-     * a non-null Resolution. For example, if an approval is required to save
-     * the profile, a RedirectResolution redirecting the user to the
-     * <code>ApprovalRequiredForUserProfiles</code> will be returned. Other
-     * validation errors will cause redirection back to the profile tab.
-     * 
-     * @return
-     */
-    @HandlesEvent( "saveProfile" )
-    @HandlerPermission( permissionClass = WikiPermission.class, target = "${engine.applicationName}", actions = WikiPermission.EDIT_PROFILE_ACTION )
-    public Resolution save()
+    public void setJ_remember( boolean remember )
     {
-        WikiActionBeanContext context = getContext();
-        Resolution r = null;
-        try
-        {
-            // Save the profile
-            WikiEngine engine = getEngine();
-            engine.getUserManager().setUserProfile( getWikiSession(), m_profile );
-            CookieAssertionLoginModule.setUserCookie( context.getResponse(), m_profile.getFullname() );
-        }
-
-        // Not so fast my friend! Approvals are required...
-        catch( DecisionRequiredException e )
-        {
-            UrlBuilder builder = new UrlBuilder( this.getContext().getLocale(), ViewActionBean.class, false );
-            builder.addParameter( "page", "ApprovalRequiredForUserProfiles" );
-            r = new RedirectResolution( builder.toString() );
-        }
-
-        // Any other errors are either UI or config problems, so let the user
-        // know about them
-        catch( Exception e )
-        {
-            ValidationErrors errors = context.getValidationErrors();
-            errors.addGlobalError( new LocalizableError( "saveError", e.getMessage() ) );
-            UrlBuilder builder = new UrlBuilder( this.getContext().getLocale(), LoginActionBean.class, false );
-            builder.addParameter( "tab", "profile" );
-            r = new RedirectResolution( builder.toString() );
-        }
-
-        // Set cookies as needed and redirect
-        r = redirectToOriginalPage();
-
-        return r;
+        m_remember = remember;
     }
 
-    /**
-     * Executes after a successful profile creation or login
-     */
-    private Resolution redirectToOriginalPage()
+    public void setJ_username( String username )
     {
-        // Set user cookie
-        Principal principal = getWikiSession().getUserPrincipal();
-        CookieAssertionLoginModule.setUserCookie( getContext().getResponse(), principal.getName() );
-
-        // Set "remember me?" cookie
-        if( m_remember )
-        {
-            CookieAuthenticationLoginModule.setLoginCookie( getEngine(), getContext().getResponse(), principal.getName() );
-        }
+        m_username = username;
+    }
 
-        Resolution r = null;
-        if( m_redirect != null )
-        {
-            UrlBuilder builder = new UrlBuilder( this.getContext().getLocale(), ViewActionBean.class, false );
-            builder.addParameter( "page", m_redirect );
-            r = new RedirectResolution( builder.toString() );
-        }
-        return r;
+    public void setRedirect( String redirect )
+    {
+        m_redirect = redirect;
+        setVariable( "redirect", redirect );
     }
 
     /**
@@ -229,7 +181,7 @@
         if( getWikiSession().isAuthenticated() )
         {
             // Set cookies as needed and redirect
-            r = redirectToOriginalPage();
+            r = saveCookiesAndRedirect( m_redirect, m_remember );
             if( r == null )
             {
                 r = new RedirectResolution( ViewActionBean.class );
@@ -242,7 +194,7 @@
             // Have we already been submitted? If yes, then we can assume that
             // we have been logged in before.
             //
-            
+
             HttpSession session = getContext().getRequest().getSession();
             Object seen = session.getAttribute( "_redirect" );
             if( seen != null )
@@ -252,9 +204,8 @@
                 getContext().getValidationErrors().addGlobalError( new SimpleError( message ) );
                 return new RedirectResolution( MessageActionBean.class ).flash( this );
             }
-            session.setAttribute( "_redirect", "I love Outi" ); // Just any
-                                                                // marker will
-                                                                // do
+            session.setAttribute( "_redirect", "I love Outi" ); // Any marker
+            // will do
 
             // If using container auth, the container will have automatically
             // attempted to log in the user before Login.jsp was loaded.
@@ -268,4 +219,5 @@
 
         return r;
     }
+
 }

Modified: incubator/jspwiki/branches/JSPWIKI_2_9_STRIPES_BRANCH/src/com/ecyrd/jspwiki/action/UserProfileActionBean.java
URL: http://svn.apache.org/viewvc/incubator/jspwiki/branches/JSPWIKI_2_9_STRIPES_BRANCH/src/com/ecyrd/jspwiki/action/UserProfileActionBean.java?rev=685452&r1=685451&r2=685452&view=diff
==============================================================================
--- incubator/jspwiki/branches/JSPWIKI_2_9_STRIPES_BRANCH/src/com/ecyrd/jspwiki/action/UserProfileActionBean.java (original)
+++ incubator/jspwiki/branches/JSPWIKI_2_9_STRIPES_BRANCH/src/com/ecyrd/jspwiki/action/UserProfileActionBean.java Tue Aug 12 23:01:27 2008
@@ -1,65 +1,248 @@
 package com.ecyrd.jspwiki.action;
 
+import java.security.Principal;
+
 import net.sourceforge.stripes.action.*;
+import net.sourceforge.stripes.controller.LifecycleStage;
 import net.sourceforge.stripes.util.UrlBuilder;
-import net.sourceforge.stripes.validation.LocalizableError;
-import net.sourceforge.stripes.validation.ValidationErrors;
+import net.sourceforge.stripes.validation.*;
+
+import org.apache.log4j.Logger;
 
 import com.ecyrd.jspwiki.WikiEngine;
+import com.ecyrd.jspwiki.WikiSession;
+import com.ecyrd.jspwiki.auth.AuthenticationManager;
+import com.ecyrd.jspwiki.auth.NoSuchPrincipalException;
+import com.ecyrd.jspwiki.auth.UserManager;
 import com.ecyrd.jspwiki.auth.login.CookieAssertionLoginModule;
 import com.ecyrd.jspwiki.auth.permissions.WikiPermission;
+import com.ecyrd.jspwiki.auth.user.UserDatabase;
+import com.ecyrd.jspwiki.auth.user.UserProfile;
 import com.ecyrd.jspwiki.workflow.DecisionRequiredException;
 
 /**
  * @author Andrew Jaquith
  */
 @UrlBinding( "/UserProfile.jsp" )
-public class UserProfileActionBean extends AbstractUserProfileActionBean
+public class UserProfileActionBean extends AbstractActionBean
 {
+    Logger log = Logger.getLogger( UserProfileActionBean.class );
+
+    private String m_redirect = null;
+
+    protected UserProfile m_profile = null;
+
+    protected String m_passwordAgain = null;
+
+    public String getPasswordAgain()
+    {
+        return m_passwordAgain;
+    }
+
+    public UserProfile getProfile()
+    {
+        return m_profile;
+    }
+
+    public String getRedirect()
+    {
+        return m_redirect;
+    }
+
+    /**
+     * Pre-action that loads the UserProfile before user-supplied parameters are
+     * bound to the ActionBean.
+     * 
+     * @return <code>null</code>, always
+     */
+    @Before( stages = LifecycleStage.BindingAndValidation )
+    public Resolution initUserProfile()
+    {
+        // Retrieve the user profile
+        WikiEngine engine = getEngine();
+        WikiSession session = getWikiSession();
+        UserManager manager = engine.getUserManager();
+        m_profile = manager.getUserProfile( session );
+
+        // Null out the password, so that we don't re-encrypt it by accident
+        m_profile.setPassword( null );
+        return null;
+    }
 
     /**
-     * Attempts to save the user profile, after all other validation routines have executed.
-     * If the save executes without error, this method will return <code>null</code>.
-     * Otherwise, any error conditions will return a non-null Resolution.
-     * For example, if an approval is required to save the profile, a RedirectResolution
-     * redirecting the user to the <code>ApprovalRequiredForUserProfiles</code>
-     * will be returned. Other validation errors will cause redirection back to the profile tab.
+     * Attempts to save the user profile, after all other validation routines
+     * have executed. If the save executes without error, this method will
+     * return a Resolution to the source page that executed the method. Error
+     * conditions will also return a Resolution. For example, if an approval is
+     * required to save the profile, a RedirectResolution redirecting the user
+     * to the <code>ApprovalRequiredForUserProfiles</code> will be returned.
+     * Other validation errors will cause redirection back to the profile tab.
+     * 
      * @return
      */
-    @HandlesEvent( "saveProfile" )
+    @HandlesEvent( "save" )
     @HandlerPermission( permissionClass = WikiPermission.class, target = "${engine.applicationName}", actions = WikiPermission.EDIT_PROFILE_ACTION )
     public Resolution save()
     {
         WikiActionBeanContext context = getContext();
+        ValidationErrors errors = context.getValidationErrors();
         Resolution r = null;
         try
         {
             // Save the profile
             WikiEngine engine = getEngine();
-            engine.getUserManager().setUserProfile( getWikiSession(), m_profile);
-            CookieAssertionLoginModule.setUserCookie(context.getResponse(), m_profile.getFullname());
+            engine.getUserManager().setUserProfile( getWikiSession(), m_profile );
+            CookieAssertionLoginModule.setUserCookie( context.getResponse(), m_profile.getFullname() );
         }
-        
-        // Not so fast my friend! Approvals are required...
+
+        // Not so fast, Swifty Lazar! What if someone must approve the profile?
         catch( DecisionRequiredException e )
         {
             UrlBuilder builder = new UrlBuilder( this.getContext().getLocale(), ViewActionBean.class, false );
             builder.addParameter( "page", "ApprovalRequiredForUserProfiles" );
             r = new RedirectResolution( builder.toString() );
         }
-        
-        // Any other errors are either UI or config problems, so let the user know about them
-        catch (Exception e)
+
+        // Any other errors are either UI or config problems, so let the user
+        // know about them
+        catch( Exception e )
         {
-            ValidationErrors errors = context.getValidationErrors();
             errors.addGlobalError( new LocalizableError( "saveError", e.getMessage() ) );
-            UrlBuilder builder = new UrlBuilder( this.getContext().getLocale(), UserProfileActionBean.class, false );
-            builder.addParameter( "tab", "profile" );
-            r = new RedirectResolution( builder.toString() );
         }
-        
-        // The save executed correctly and without errors, so return nothing
-        return r;
+
+        // If no errors, send user to front page (or redirected page)
+        if( errors.size() == 0 )
+        {
+            // Set user cookie
+            Principal principal = getWikiSession().getUserPrincipal();
+            CookieAssertionLoginModule.setUserCookie( getContext().getResponse(), principal.getName() );
+            UrlBuilder builder = new UrlBuilder( getContext().getLocale(), ViewActionBean.class, false );
+            if( m_redirect != null )
+            {
+                builder.addParameter( "page", m_redirect );
+            }
+            return new RedirectResolution( builder.toString() );
+        }
+
+        // Otherwise, return user to source page
+        UrlBuilder builder = new UrlBuilder( this.getContext().getLocale(), context.getSourcePage(), false );
+        builder.addParameter( "tab", "profile" );
+        return new RedirectResolution( builder.toString() );
+    }
+
+    public void setPasswordAgain( String password )
+    {
+        m_passwordAgain = password;
+    }
+
+    @ValidateNestedProperties( { @Validate( field = "loginName", maxlength = 100, required = true, on = "save" ),
+                                @Validate( field = "fullname", maxlength = 100, required = true, on = "save" ),
+                                @Validate( field = "password", minlength = 8, maxlength = 100 ),
+                                @Validate( field = "email", converter = EmailTypeConverter.class ) } )
+    public void setProfile( UserProfile profile )
+    {
+        m_profile = profile;
+    }
+
+    public void setRedirect( String redirect )
+    {
+        m_redirect = redirect;
+        setVariable( "redirect", redirect );
+    }
+
+    /**
+     * After all fields validate correctly, this method verifies that the user
+     * has the correct permissions to save the UserProfile, and checks that the
+     * supplied full name or login name don't collide with those used by
+     * somebody else.
+     * 
+     * @param errors the current validation errors for this ActionBean
+     */
+    @ValidationMethod( on = "save", when = ValidationState.NO_ERRORS )
+    public void validateNoCollision( ValidationErrors errors )
+    {
+        WikiEngine engine = getEngine();
+        WikiSession session = getWikiSession();
+        UserManager manager = getEngine().getUserManager();
+        UserDatabase database = manager.getUserDatabase();
+
+        // Locate the old user profile
+        UserProfile oldProfile = manager.getUserProfile( session );
+
+        // If container authenticated, override the login name and password
+        // The login name should always be the one provided by the container
+        AuthenticationManager authMgr = engine.getAuthenticationManager();
+        if( authMgr.isContainerAuthenticated() )
+        {
+            m_profile.setLoginName( oldProfile.getLoginName() );
+            m_profile.setPassword( null );
+        }
+
+        // User profiles that may already have fullname or loginname
+        UserProfile otherProfile;
+        try
+        {
+            otherProfile = database.findByLoginName( m_profile.getLoginName() );
+            if( otherProfile != null && !otherProfile.equals( oldProfile ) )
+            {
+                errors.add( "profile.loginName", new LocalizableError( "nameCollision" ) );
+            }
+        }
+        catch( NoSuchPrincipalException e )
+        {
+        }
+        try
+        {
+            otherProfile = database.findByFullName( m_profile.getFullname() );
+            if( otherProfile != null && !otherProfile.equals( oldProfile ) )
+            {
+                errors.add( "profile.fullname", new LocalizableError( "nameCollision" ) );
+            }
+        }
+        catch( NoSuchPrincipalException e )
+        {
+        }
+    }
+
+    /**
+     * After all fields validate correctly, this method validates that the user
+     * account is not spam.
+     * 
+     * @param errors the current validation errors for this ActionBean
+     */
+    @ValidationMethod( on = "save", when = ValidationState.NO_ERRORS )
+    public void validateNotSpam( ValidationErrors errors )
+    {
+        log.info( "Skipped validateNotSpam method because it has not been coded yet..." );
+    }
+
+    /**
+     * If the user profile is new, this method verifies that the user has
+     * supplied matching passwords.
+     * 
+     * @param errors the current validation errors for this ActionBean
+     */
+    @ValidationMethod( on = "save", when = ValidationState.ALWAYS )
+    public void validatePasswords( ValidationErrors errors )
+    {
+        // All new profiles must have a supplied password
+        if( m_profile.isNew() )
+        {
+            if( m_profile.getPassword() == null )
+            {
+                errors.add( "profile.password", new ScopedLocalizableError( "validation.required", "valueNotPresent" ) );
+            }
+        }
+
+        // If a password was supplied, the same value must also have been passed
+        // to passwordAgain
+        if( m_profile.getPassword() != null )
+        {
+            if( !m_profile.getPassword().equals( m_passwordAgain ) )
+            {
+                errors.add( "profile.password", new ScopedLocalizableError( "validation.required", "noPasswordMatch" ) );
+            }
+        }
     }
 
     /**

Modified: incubator/jspwiki/branches/JSPWIKI_2_9_STRIPES_BRANCH/tests/com/ecyrd/jspwiki/TestEngine.java
URL: http://svn.apache.org/viewvc/incubator/jspwiki/branches/JSPWIKI_2_9_STRIPES_BRANCH/tests/com/ecyrd/jspwiki/TestEngine.java?rev=685452&r1=685451&r2=685452&view=diff
==============================================================================
--- incubator/jspwiki/branches/JSPWIKI_2_9_STRIPES_BRANCH/tests/com/ecyrd/jspwiki/TestEngine.java (original)
+++ incubator/jspwiki/branches/JSPWIKI_2_9_STRIPES_BRANCH/tests/com/ecyrd/jspwiki/TestEngine.java Tue Aug 12 23:01:27 2008
@@ -1,14 +1,10 @@
 
 package com.ecyrd.jspwiki;
+import java.io.*;
 import java.util.HashMap;
 import java.util.Map;
 import java.util.Properties;
-import java.io.*;
 
-import javax.servlet.Servlet;
-import javax.servlet.ServletConfig;
-import javax.servlet.ServletException;
-import javax.servlet.http.HttpServlet;
 import javax.servlet.http.HttpServletRequest;
 
 import net.sourceforge.stripes.controller.DispatcherServlet;
@@ -26,7 +22,10 @@
 import com.ecyrd.jspwiki.auth.SessionMonitor;
 import com.ecyrd.jspwiki.auth.Users;
 import com.ecyrd.jspwiki.auth.WikiSecurityException;
-import com.ecyrd.jspwiki.providers.*;
+import com.ecyrd.jspwiki.providers.AbstractFileProvider;
+import com.ecyrd.jspwiki.providers.BasicAttachmentProvider;
+import com.ecyrd.jspwiki.providers.FileSystemProvider;
+import com.ecyrd.jspwiki.providers.ProviderException;
 import com.ecyrd.jspwiki.ui.WikiServletFilter;
 
 /**
@@ -359,6 +358,7 @@
     private static Properties cleanTestProps( Properties props )
     {
         props.put( AuthenticationManager.PROP_LOGIN_THROTTLING, "false" );
+        props.put( WikiEngine.PROP_URLCONSTRUCTOR, "com.ecyrd.jspwiki.url.DefaultURLConstructor" );
         return props;
     }
 
@@ -373,9 +373,33 @@
      */
     public MockRoundtrip guestTrip( Class<? extends WikiActionBean> beanClass )
     {
-        MockServletContext servletContext = initStripesServletContext();
+        MockServletContext servletContext = (MockServletContext)getServletContext();
+        if ( servletContext.getFilters().size() == 0 )
+        {
+            initStripesServletContext();
+        }
         return new MockRoundtrip( servletContext, beanClass );
     }
+    
+    /**
+     * Creates a guest "round trip" object that initializes itself with the TestEngine's mock servlet context,
+     * plus a new mock request, mock response and URL.
+     * This method is the preferred way to instantiate request and response objects, which can be
+     * obtained by calling {@link net.sourceforge.stripes.mock.MockRoundtrip#getRequest()} and
+     * {@link net.sourceforge.stripes.mock.MockRoundtrip#getResponse()}.
+     * @param url the URL to start with
+     * @return the mock rountrip
+     */
+    public MockRoundtrip guestTrip( String url )
+    {
+        MockServletContext servletContext = (MockServletContext)getServletContext();
+        if ( servletContext.getFilters().size() == 0 )
+        {
+            initStripesServletContext();
+        }
+        return new MockRoundtrip( servletContext, url );
+    }
+    
 
     /**
      * Creates a "round trip" object initialized with a supplied set of credentials. The WikiSession
@@ -389,7 +413,11 @@
      */
     public MockRoundtrip authenticatedTrip( String user, String password, Class<? extends WikiActionBean> beanClass ) throws WikiSecurityException
     {
-        MockServletContext servletContext = initStripesServletContext();
+        MockServletContext servletContext = (MockServletContext)getServletContext();
+        if ( servletContext.getFilters().size() == 0 )
+        {
+            initStripesServletContext();
+        }
         MockRoundtrip trip = new MockRoundtrip( servletContext, beanClass );
         WikiSession session = WikiSession.getWikiSession( this, trip.getRequest() );
         this.getAuthenticationManager().login( session, Users.ADMIN, Users.ADMIN_PASS );
@@ -397,58 +425,25 @@
     }
     
     /**
-     * Returns the TestEngine's MockServletContext, but with the Stripes filters and servlets added
-     * @return the initialized mock context
+     * Initializes the TestEngine's MockServletContext, with the Stripes filters and servlets added
      */
-    private MockServletContext initStripesServletContext()
+    private void initStripesServletContext()
     {
+        // Configure the filter and servlet
         MockServletContext servletContext = (MockServletContext)getServletContext();
+        servletContext.addFilter( WikiServletFilter.class, "WikiServletFilter", new HashMap<String,String>() );
+        servletContext.setServlet(DispatcherServlet.class, "StripesDispatcher", null);
         
-        // Add mock StripesFilter and WikiServletfilter and to servlet config
+        // Add extension classes
         Map<String,String> filterParams = new HashMap<String,String>();
         filterParams.put("ActionResolver.Packages", "com.ecyrd.jspwiki.action");
         filterParams.put("Extension.Packages", "com.ecyrd.jspwiki.action");
+        
+        // Add the exception handler class
         filterParams.put( "ExceptionHandler.Class", "com.ecyrd.jspwiki.action.WikiExceptionHandler" );
-        servletContext.addFilter(StripesFilter.class, "StripesFilter", filterParams);
-        servletContext.addFilter( WikiServletFilter.class, "WikiServletFilter", new HashMap<String,String>() );
-        servletContext.setServlet(DispatcherServlet.class, "StripesDispatcher", null);
         
-        return servletContext;
+        // Return the configured servlet context
+        servletContext.addFilter(StripesFilter.class, "StripesFilter", filterParams);
     }
     
-    /**
-     * Static single instance of the mock servlet.
-     */
-    private static final Servlet MOCK_SERVLET = new MockServlet();
-
-    /**
-     * Captive servlet class that does absolutely nothing. Used by
-     * MockRoundtrip.
-     */
-    protected static class MockServlet extends HttpServlet
-    {
-        private static final long serialVersionUID = 1L;
-        
-        private ServletConfig m_config;
-        
-        public MockServlet()
-        {
-        }
-
-        public ServletConfig getServletConfig()
-        {
-            return m_config;
-        }
-
-        public String getServletInfo()
-        {
-            return "Mock servlet";
-        }
-
-        public void init( ServletConfig config ) throws ServletException
-        {
-            m_config = config;
-        }
-    }
-
 }

Modified: incubator/jspwiki/branches/JSPWIKI_2_9_STRIPES_BRANCH/tests/com/ecyrd/jspwiki/action/GroupActionBeanTest.java
URL: http://svn.apache.org/viewvc/incubator/jspwiki/branches/JSPWIKI_2_9_STRIPES_BRANCH/tests/com/ecyrd/jspwiki/action/GroupActionBeanTest.java?rev=685452&r1=685451&r2=685452&view=diff
==============================================================================
--- incubator/jspwiki/branches/JSPWIKI_2_9_STRIPES_BRANCH/tests/com/ecyrd/jspwiki/action/GroupActionBeanTest.java (original)
+++ incubator/jspwiki/branches/JSPWIKI_2_9_STRIPES_BRANCH/tests/com/ecyrd/jspwiki/action/GroupActionBeanTest.java Tue Aug 12 23:01:27 2008
@@ -1,18 +1,12 @@
 package com.ecyrd.jspwiki.action;
 
-import java.lang.reflect.Method;
-import java.security.Permission;
 import java.util.Properties;
 
 import junit.framework.Test;
 import junit.framework.TestCase;
 import junit.framework.TestSuite;
-import net.sourceforge.stripes.mock.MockRoundtrip;
-import net.sourceforge.stripes.mock.MockServletContext;
-import net.sourceforge.stripes.util.UrlBuilder;
 
 import com.ecyrd.jspwiki.TestEngine;
-import com.ecyrd.jspwiki.auth.permissions.GroupPermission;
 
 public class GroupActionBeanTest extends TestCase
 {
@@ -32,30 +26,6 @@
             throw new RuntimeException( "Could not set up TestEngine: " + e.getMessage() );
         }
     }
-    
-    public void testURLBuild() throws Exception
-    {
-        UrlBuilder builder = new UrlBuilder( null, GroupActionBean.class, false );
-        builder.addParameter( "group", m_engine.getGroupManager().getGroup( "Admin" ).getName() );
-        builder.addParameter( "foo", "bar" );
-        String url = builder.toString();
-        assertEquals( "/Group.jsp?group=Admin&foo=bar", url );
-    }
-    
-    public void testURLParse() throws Exception
-    {
-        MockServletContext ctx = (MockServletContext) m_engine.getServletContext();
-        MockRoundtrip trip;
-        GroupActionBean bean;
-
-        // Set up a new GroupActionBean with group Admin and event
-        // "view"
-        trip = new MockRoundtrip( ctx, "/Group.jsp/group=Admin&foo=bar" );
-        trip.getRequest().setMethod( "GET" );
-        trip.execute( "view" );
-        bean = trip.getActionBean( GroupActionBean.class );
-        assertNotNull( bean );
-    }
 
     public static Test suite()
     {

Modified: incubator/jspwiki/branches/JSPWIKI_2_9_STRIPES_BRANCH/tests/com/ecyrd/jspwiki/action/HandlerInfoTest.java
URL: http://svn.apache.org/viewvc/incubator/jspwiki/branches/JSPWIKI_2_9_STRIPES_BRANCH/tests/com/ecyrd/jspwiki/action/HandlerInfoTest.java?rev=685452&r1=685451&r2=685452&view=diff
==============================================================================
--- incubator/jspwiki/branches/JSPWIKI_2_9_STRIPES_BRANCH/tests/com/ecyrd/jspwiki/action/HandlerInfoTest.java (original)
+++ incubator/jspwiki/branches/JSPWIKI_2_9_STRIPES_BRANCH/tests/com/ecyrd/jspwiki/action/HandlerInfoTest.java Tue Aug 12 23:01:27 2008
@@ -95,7 +95,7 @@
 
         // Set up a new GroupActionBean with the real group Admin and event
         // "view"
-        trip = new MockRoundtrip( ctx, "/Group.jsp" );
+        trip = m_engine.guestTrip( "/Group.jsp" );
         trip.getRequest().setMethod( "GET" );
         trip.addParameter( "group", "Admin" );
         trip.execute( "view" );
@@ -115,7 +115,7 @@
 
         // Set up a new GroupActionBean with the real group Admin and event
         // "save"
-        trip = new MockRoundtrip( ctx, "/Group.jsp" );
+        trip = m_engine.guestTrip( "/Group.jsp" );
         trip.addParameter( "group", "Admin" );
         trip.execute( "save" );
         bean = trip.getActionBean( GroupActionBean.class );
@@ -133,7 +133,7 @@
 
         // Set up a new GroupActionBean with the real group Admin and event
         // "delete"
-        trip = new MockRoundtrip( ctx, "/Group.jsp" );
+        trip = m_engine.guestTrip( "/Group.jsp" );
         trip.addParameter( "group", "Admin" );
         trip.execute( "delete" );
         bean = trip.getActionBean( GroupActionBean.class );
@@ -152,7 +152,6 @@
 
     public void testNotEvaluatedPermissionAnnotation() throws Exception
     {
-        MockServletContext ctx = (MockServletContext) m_engine.getServletContext();
         MockRoundtrip trip;
         GroupActionBean bean;
         Method method;
@@ -160,7 +159,7 @@
         Permission perm;
 
         // Set up a new GroupActionBean with the non-existent group Foo
-        trip = new MockRoundtrip( ctx, "/Group.jsp" );
+        trip = m_engine.guestTrip( "/Group.jsp" );
         trip.addParameter( "group", "Foo" );
         trip.execute( "view" );
         bean = trip.getActionBean( GroupActionBean.class );

Modified: incubator/jspwiki/branches/JSPWIKI_2_9_STRIPES_BRANCH/tests/com/ecyrd/jspwiki/action/UserPreferencesActionBeanTest.java
URL: http://svn.apache.org/viewvc/incubator/jspwiki/branches/JSPWIKI_2_9_STRIPES_BRANCH/tests/com/ecyrd/jspwiki/action/UserPreferencesActionBeanTest.java?rev=685452&r1=685451&r2=685452&view=diff
==============================================================================
--- incubator/jspwiki/branches/JSPWIKI_2_9_STRIPES_BRANCH/tests/com/ecyrd/jspwiki/action/UserPreferencesActionBeanTest.java (original)
+++ incubator/jspwiki/branches/JSPWIKI_2_9_STRIPES_BRANCH/tests/com/ecyrd/jspwiki/action/UserPreferencesActionBeanTest.java Tue Aug 12 23:01:27 2008
@@ -10,7 +10,6 @@
 import net.sourceforge.stripes.mock.MockHttpServletRequest;
 import net.sourceforge.stripes.mock.MockHttpServletResponse;
 import net.sourceforge.stripes.mock.MockRoundtrip;
-import net.sourceforge.stripes.mock.MockServletContext;
 
 import com.ecyrd.jspwiki.TestEngine;
 import com.ecyrd.jspwiki.WikiSession;
@@ -38,12 +37,11 @@
     
     public void testCreateAssertedName() throws Exception
     {
-        MockServletContext ctx = (MockServletContext)m_engine.getServletContext();
         MockRoundtrip trip;
         UserPreferencesActionBean bean;
         
         // Create session; set 'assertion' param; verify it got saved
-        trip = new MockRoundtrip(ctx, "/UserPreferences.jsp");
+        trip = m_engine.guestTrip( "/UserPreferences.jsp");
         trip.setParameter("assertedName", "MyAssertedIdentity");
         trip.setParameter("createAssertedName", "true");
         trip.execute();
@@ -61,12 +59,11 @@
     
     public void testCreateAssertedNameAfterLogin() throws Exception
     {
-        MockServletContext ctx = (MockServletContext)m_engine.getServletContext();
         MockRoundtrip trip;
         UserPreferencesActionBean bean;
         
         // Create session; login in as Janne
-        trip = new MockRoundtrip(ctx, "/UserPreferences.jsp");
+        trip = m_engine.guestTrip( "/UserPreferences.jsp");
         MockHttpServletRequest request = trip.getRequest();
         WikiSession wikiSession = WikiSession.getWikiSession(m_engine, request);
         boolean login = m_engine.getAuthenticationManager().login(wikiSession, Users.JANNE,Users.JANNE_PASS);
@@ -88,12 +85,11 @@
     
     public void testClearAssertedName() throws Exception
     {
-        MockServletContext ctx = (MockServletContext)m_engine.getServletContext();
         MockRoundtrip trip;
         UserPreferencesActionBean bean;
         
         // Create session; set 'assertion' param; verify it got saved
-        trip = new MockRoundtrip(ctx, "/UserPreferences.jsp");
+        trip = m_engine.guestTrip( "/UserPreferences.jsp");
         MockHttpServletRequest request = trip.getRequest();
         Cookie cookie = new Cookie(CookieAssertionLoginModule.PREFS_COOKIE_NAME, "MyAssertedIdentity");
         request.setCookies(new Cookie[]{cookie});

Modified: incubator/jspwiki/branches/JSPWIKI_2_9_STRIPES_BRANCH/tests/com/ecyrd/jspwiki/action/UserProfileActionBeanTest.java
URL: http://svn.apache.org/viewvc/incubator/jspwiki/branches/JSPWIKI_2_9_STRIPES_BRANCH/tests/com/ecyrd/jspwiki/action/UserProfileActionBeanTest.java?rev=685452&r1=685451&r2=685452&view=diff
==============================================================================
--- incubator/jspwiki/branches/JSPWIKI_2_9_STRIPES_BRANCH/tests/com/ecyrd/jspwiki/action/UserProfileActionBeanTest.java (original)
+++ incubator/jspwiki/branches/JSPWIKI_2_9_STRIPES_BRANCH/tests/com/ecyrd/jspwiki/action/UserProfileActionBeanTest.java Tue Aug 12 23:01:27 2008
@@ -19,368 +19,367 @@
 public class UserProfileActionBeanTest extends TestCase
 {
     TestEngine m_engine;
-    
+
     public void setUp()
     {
         // Start the WikiEngine, and stash reference
         Properties props = new Properties();
-        try 
+        try
         {
             props.load( TestEngine.findTestProperties() );
             m_engine = new TestEngine( props );
         }
-        catch (Exception e)
+        catch( Exception e )
         {
-            throw new RuntimeException("Could not set up TestEngine: " + e.getMessage());
+            throw new RuntimeException( "Could not set up TestEngine: " + e.getMessage() );
         }
     }
-    
-    public void testMissingParameters() throws Exception {
-        MockServletContext ctx = (MockServletContext)m_engine.getServletContext();
+
+    public void testMissingParameters() throws Exception
+    {
         MockRoundtrip trip;
         UserProfileActionBean bean;
         ValidationErrors errors;
-        
-        // Get the profile, but don't set any parameters; should fail with 4 errors
+
+        // Get the profile, but don't set any parameters; should fail with 3
+        // errors
         // profile.fullname
         // profile.loginName
         // profile.passwordAgain
-        trip = new MockRoundtrip(ctx, "/UserProfile.jsp");
-        trip.execute("save");
-        bean = trip.getActionBean(UserProfileActionBean.class);
+        trip = m_engine.guestTrip( UserProfileActionBean.class );
+        trip.execute( "save" );
+        bean = trip.getActionBean( UserProfileActionBean.class );
         // Check to make sure all our expected validation errors are here...
         errors = bean.getContext().getValidationErrors();
-        assertEquals( 3, errors.size());
+        assertEquals( 3, errors.size() );
         assertTrue( errors.containsKey( "profile.loginName" ) );
         assertTrue( errors.containsKey( "profile.fullname" ) );
         assertTrue( errors.containsKey( "profile.password" ) );
         // Validate that the bean values are set (or not!) as expected
-        assertEquals(null, bean.getProfile().getLoginName() );
-        assertEquals(null, bean.getProfile().getFullname() );
-        assertEquals(null, bean.getProfile().getPassword() );
-        assertEquals(null, bean.getPasswordAgain() );
-        assertEquals(null, bean.getProfile().getEmail() );
-        assertEquals(MockRoundtrip.DEFAULT_SOURCE_PAGE, trip.getDestination() );
-        
+        assertEquals( null, bean.getProfile().getLoginName() );
+        assertEquals( null, bean.getProfile().getFullname() );
+        assertEquals( null, bean.getProfile().getPassword() );
+        assertEquals( null, bean.getPasswordAgain() );
+        assertEquals( null, bean.getProfile().getEmail() );
+        assertEquals( MockRoundtrip.DEFAULT_SOURCE_PAGE, trip.getDestination() );
+
         // Submit just the e-mail param
-        trip = new MockRoundtrip(ctx, "/UserProfile.jsp");
-        trip.setParameter("profile.email", "fred@friendly.org");
-        trip.execute("save");
-        bean = trip.getActionBean(UserProfileActionBean.class);
+        trip = m_engine.guestTrip( "/UserProfile.jsp" );
+        trip.setParameter( "profile.email", "fred@friendly.org" );
+        trip.execute( "save" );
+        bean = trip.getActionBean( UserProfileActionBean.class );
         errors = bean.getContext().getValidationErrors();
         // Check to make sure all our expected validation errors are here...
         errors = bean.getContext().getValidationErrors();
-        assertEquals( 3, errors.size());
+        assertEquals( 3, errors.size() );
         assertTrue( errors.containsKey( "profile.loginName" ) );
         assertTrue( errors.containsKey( "profile.fullname" ) );
         assertTrue( errors.containsKey( "profile.password" ) );
         // Validate that the bean values are set (or not!) as expected
-        assertEquals(null, bean.getProfile().getLoginName() );
-        assertEquals(null, bean.getProfile().getFullname() );
-        assertEquals(null, bean.getProfile().getPassword() );
-        assertEquals(null, bean.getPasswordAgain() );
-        assertEquals("fred@friendly.org", bean.getProfile().getEmail() );
-        assertEquals(MockRoundtrip.DEFAULT_SOURCE_PAGE, trip.getDestination() );
-        
+        assertEquals( null, bean.getProfile().getLoginName() );
+        assertEquals( null, bean.getProfile().getFullname() );
+        assertEquals( null, bean.getProfile().getPassword() );
+        assertEquals( null, bean.getPasswordAgain() );
+        assertEquals( "fred@friendly.org", bean.getProfile().getEmail() );
+        assertEquals( MockRoundtrip.DEFAULT_SOURCE_PAGE, trip.getDestination() );
+
         // Submit just the full name param
-        trip = new MockRoundtrip(ctx, "/UserProfile.jsp");
-        trip.setParameter("profile.fullname", "Fred Friendly");
-        trip.execute("save");
-        bean = trip.getActionBean(UserProfileActionBean.class);
+        trip = m_engine.guestTrip( "/UserProfile.jsp" );
+        trip.setParameter( "profile.fullname", "Fred Friendly" );
+        trip.execute( "save" );
+        bean = trip.getActionBean( UserProfileActionBean.class );
         // Check to make sure all our expected validation errors are here...
         errors = bean.getContext().getValidationErrors();
-        assertEquals( 2, errors.size());
+        assertEquals( 2, errors.size() );
         assertTrue( errors.containsKey( "profile.loginName" ) );
         assertTrue( errors.containsKey( "profile.password" ) );
         // Validate that the bean values are set (or not!) as expected
-        assertEquals(null, bean.getProfile().getLoginName() );
-        assertEquals("Fred Friendly", bean.getProfile().getFullname() );
-        assertEquals(null, bean.getProfile().getPassword() );
-        assertEquals(null, bean.getPasswordAgain() );
-        assertEquals(null, bean.getProfile().getEmail() );
-        assertEquals(MockRoundtrip.DEFAULT_SOURCE_PAGE, trip.getDestination() );
-        
+        assertEquals( null, bean.getProfile().getLoginName() );
+        assertEquals( "Fred Friendly", bean.getProfile().getFullname() );
+        assertEquals( null, bean.getProfile().getPassword() );
+        assertEquals( null, bean.getPasswordAgain() );
+        assertEquals( null, bean.getProfile().getEmail() );
+        assertEquals( MockRoundtrip.DEFAULT_SOURCE_PAGE, trip.getDestination() );
+
         // Submit just the login name param
-        trip = new MockRoundtrip(ctx, "/UserProfile.jsp");
-        trip.setParameter("profile.loginName", "fred");
-        trip.execute("save");
-        bean = trip.getActionBean(UserProfileActionBean.class);
+        trip = m_engine.guestTrip( "/UserProfile.jsp" );
+        trip.setParameter( "profile.loginName", "fred" );
+        trip.execute( "save" );
+        bean = trip.getActionBean( UserProfileActionBean.class );
         // Check to make sure all our expected validation errors are here...
         errors = bean.getContext().getValidationErrors();
-        assertEquals( 2, errors.size());
+        assertEquals( 2, errors.size() );
         assertTrue( errors.containsKey( "profile.fullname" ) );
         assertTrue( errors.containsKey( "profile.password" ) );
         // Validate that the bean values are set (or not!) as expected
-        assertEquals("fred", bean.getProfile().getLoginName() );
-        assertEquals(null, bean.getProfile().getFullname() );
-        assertEquals(null, bean.getProfile().getPassword() );
-        assertEquals(null, bean.getPasswordAgain() );
-        assertEquals(null, bean.getProfile().getEmail() );
-        assertEquals(MockRoundtrip.DEFAULT_SOURCE_PAGE, trip.getDestination() );
-        
+        assertEquals( "fred", bean.getProfile().getLoginName() );
+        assertEquals( null, bean.getProfile().getFullname() );
+        assertEquals( null, bean.getProfile().getPassword() );
+        assertEquals( null, bean.getPasswordAgain() );
+        assertEquals( null, bean.getProfile().getEmail() );
+        assertEquals( MockRoundtrip.DEFAULT_SOURCE_PAGE, trip.getDestination() );
+
         // Submit just the first password field
-        trip = new MockRoundtrip(ctx, "/UserProfile.jsp");
-        trip.setParameter("profile.password", "myPassword");
-        trip.execute("save");
-        bean = trip.getActionBean(UserProfileActionBean.class);
+        trip = m_engine.guestTrip( "/UserProfile.jsp" );
+        trip.setParameter( "profile.password", "myPassword" );
+        trip.execute( "save" );
+        bean = trip.getActionBean( UserProfileActionBean.class );
         // Check to make sure all our expected validation errors are here...
         errors = bean.getContext().getValidationErrors();
-        assertEquals( 3, errors.size());
+        assertEquals( 3, errors.size() );
         assertTrue( errors.containsKey( "profile.loginName" ) );
         assertTrue( errors.containsKey( "profile.fullname" ) );
         assertTrue( errors.containsKey( "profile.password" ) );
         // Validate that the bean values are set (or not!) as expected
-        assertEquals(null, bean.getProfile().getLoginName() );
-        assertEquals(null, bean.getProfile().getFullname() );
-        assertEquals("myPassword", bean.getProfile().getPassword() );
-        assertEquals(null, bean.getPasswordAgain() );
-        assertEquals(null, bean.getProfile().getEmail() );
-        assertEquals(MockRoundtrip.DEFAULT_SOURCE_PAGE, trip.getDestination() );
-        
+        assertEquals( null, bean.getProfile().getLoginName() );
+        assertEquals( null, bean.getProfile().getFullname() );
+        assertEquals( "myPassword", bean.getProfile().getPassword() );
+        assertEquals( null, bean.getPasswordAgain() );
+        assertEquals( null, bean.getProfile().getEmail() );
+        assertEquals( MockRoundtrip.DEFAULT_SOURCE_PAGE, trip.getDestination() );
+
         // Submit just the second password field
-        trip = new MockRoundtrip(ctx, "/UserProfile.jsp");
-        trip.setParameter("passwordAgain", "myPassword");
-        trip.execute("save");
-        bean = trip.getActionBean(UserProfileActionBean.class);
+        trip = m_engine.guestTrip( "/UserProfile.jsp" );
+        trip.setParameter( "passwordAgain", "myPassword" );
+        trip.execute( "save" );
+        bean = trip.getActionBean( UserProfileActionBean.class );
         // Check to make sure all our expected validation errors are here...
         errors = bean.getContext().getValidationErrors();
-        assertEquals( 3, errors.size());
+        assertEquals( 3, errors.size() );
         assertTrue( errors.containsKey( "profile.loginName" ) );
         assertTrue( errors.containsKey( "profile.fullname" ) );
         assertTrue( errors.containsKey( "profile.password" ) );
         // Validate that the bean values are set (or not!) as expected
-        assertEquals(null, bean.getProfile().getLoginName() );
-        assertEquals(null, bean.getProfile().getFullname() );
-        assertEquals(null, bean.getProfile().getPassword() );
-        assertEquals("myPassword", bean.getPasswordAgain() );
-        assertEquals(null, bean.getProfile().getEmail() );
-        assertEquals(MockRoundtrip.DEFAULT_SOURCE_PAGE, trip.getDestination() );
+        assertEquals( null, bean.getProfile().getLoginName() );
+        assertEquals( null, bean.getProfile().getFullname() );
+        assertEquals( null, bean.getProfile().getPassword() );
+        assertEquals( "myPassword", bean.getPasswordAgain() );
+        assertEquals( null, bean.getProfile().getEmail() );
+        assertEquals( MockRoundtrip.DEFAULT_SOURCE_PAGE, trip.getDestination() );
     }
-    
-    public void testMismatchedPasswords() throws Exception {
-        MockServletContext ctx = (MockServletContext)m_engine.getServletContext();
+
+    public void testMismatchedPasswords() throws Exception
+    {
         MockRoundtrip trip;
         UserProfileActionBean bean;
         ValidationErrors errors;
-        
+
         // Set different passwords
-        trip = new MockRoundtrip(ctx, "/UserProfile.jsp");
-        trip.setParameter("profile.loginName", "fred");
-        trip.setParameter("profile.fullname", "Fred Friendly");
-        trip.setParameter("profile.email", "fred@friendly.org");
-        trip.setParameter("profile.password", "mypassword");
-        trip.setParameter("passwordAgain", "Mypassword");
-        trip.execute("save");
-        bean = trip.getActionBean(UserProfileActionBean.class);
+        trip = m_engine.guestTrip( "/UserProfile.jsp" );
+        trip.setParameter( "profile.loginName", "fred" );
+        trip.setParameter( "profile.fullname", "Fred Friendly" );
+        trip.setParameter( "profile.email", "fred@friendly.org" );
+        trip.setParameter( "profile.password", "mypassword" );
+        trip.setParameter( "passwordAgain", "Mypassword" );
+        trip.execute( "save" );
+        bean = trip.getActionBean( UserProfileActionBean.class );
         // Check to make sure all our expected validation errors are here...
         errors = bean.getContext().getValidationErrors();
-        assertEquals( 1, errors.size());
-        assertTrue( errors.containsKey( "profile.password") );
-        assertEquals(MockRoundtrip.DEFAULT_SOURCE_PAGE, trip.getDestination() );
+        assertEquals( 1, errors.size() );
+        assertTrue( errors.containsKey( "profile.password" ) );
+        assertEquals( MockRoundtrip.DEFAULT_SOURCE_PAGE, trip.getDestination() );
     }
-    
-    public void testIllegalEmail() throws Exception {
-        MockServletContext ctx = (MockServletContext)m_engine.getServletContext();
+
+    public void testIllegalEmail() throws Exception
+    {
         MockRoundtrip trip;
         UserProfileActionBean bean;
         ValidationErrors errors;
-        
+
         // Set an illegal e-mail address
-        trip = new MockRoundtrip(ctx, "/UserProfile.jsp");
-        trip.setParameter("profile.loginName", "fred");
-        trip.setParameter("profile.fullname", "Fred Friendly");
-        trip.setParameter("profile.email", "illegalEmail");
-        trip.setParameter("profile.password", "mypassword");
-        trip.setParameter("passwordAgain", "mypassword");
-        trip.execute("save");
-        bean = trip.getActionBean(UserProfileActionBean.class);
+        trip = m_engine.guestTrip( "/UserProfile.jsp" );
+        trip.setParameter( "profile.loginName", "fred" );
+        trip.setParameter( "profile.fullname", "Fred Friendly" );
+        trip.setParameter( "profile.email", "illegalEmail" );
+        trip.setParameter( "profile.password", "mypassword" );
+        trip.setParameter( "passwordAgain", "mypassword" );
+        trip.execute( "save" );
+        bean = trip.getActionBean( UserProfileActionBean.class );
         // Check to make sure all our expected validation errors are here...
         errors = bean.getContext().getValidationErrors();
-        assertEquals( 1, errors.size());
-        assertTrue( errors.containsKey( "profile.email") );
-        assertEquals(MockRoundtrip.DEFAULT_SOURCE_PAGE, trip.getDestination() );
+        assertEquals( 1, errors.size() );
+        assertTrue( errors.containsKey( "profile.email" ) );
+        assertEquals( MockRoundtrip.DEFAULT_SOURCE_PAGE, trip.getDestination() );
     }
-    
+
     public void testSaveProfile() throws Exception
     {
-        MockServletContext ctx = (MockServletContext)m_engine.getServletContext();
         MockRoundtrip trip;
         UserProfileActionBean bean;
         ValidationErrors errors;
-        
+
         // Generate user ID and validate it doesn't exist already
-        String suffix = String.valueOf(System.currentTimeMillis());
-        assertFalse( userExists("user" + suffix));
-        
+        String suffix = String.valueOf( System.currentTimeMillis() );
+        assertFalse( userExists( "user" + suffix ) );
+
         // Create new user
-        trip = new MockRoundtrip(ctx, "/UserProfile.jsp");
-        trip.setParameter("profile.loginName", "user"+suffix);
-        trip.setParameter("profile.fullname", "Fred Friendly"+suffix);
-        trip.setParameter("profile.email", "fred@friendly.org");
-        trip.setParameter("profile.password", "mypassword");
-        trip.setParameter("passwordAgain", "mypassword");
-        trip.execute("save");
-        bean = trip.getActionBean(UserProfileActionBean.class);
+        trip = m_engine.guestTrip( "/UserProfile.jsp" );
+        trip.setParameter( "profile.loginName", "user" + suffix );
+        trip.setParameter( "profile.fullname", "Fred Friendly" + suffix );
+        trip.setParameter( "profile.email", "fred@friendly.org" );
+        trip.setParameter( "profile.password", "mypassword" );
+        trip.setParameter( "passwordAgain", "mypassword" );
+        trip.execute( "save" );
+        bean = trip.getActionBean( UserProfileActionBean.class );
         errors = bean.getContext().getValidationErrors();
         // Check to make sure no validation errors here...
-        assertEquals( 0, errors.size());
-        assertEquals("/", trip.getDestination() );
-        
+        assertEquals( 0, errors.size() );
+        assertEquals( "/Wiki.jsp", trip.getDestination() );
+
         // Verify user was saved
-        assertTrue( userExists("user" + suffix));
-        
+        assertTrue( userExists( "user" + suffix ) );
+
         // Verify that wikiname and timestamps were set too
         UserDatabase db = m_engine.getUserManager().getUserDatabase();
-        UserProfile profile = db.findByLoginName("user"+suffix);
-        assertEquals("FredFriendly"+suffix, profile.getWikiName());
-        assertNotNull(profile.getCreated());
-        assertNotNull(profile.getLastModified());
-        
+        UserProfile profile = db.findByLoginName( "user" + suffix );
+        assertEquals( "FredFriendly" + suffix, profile.getWikiName() );
+        assertNotNull( profile.getCreated() );
+        assertNotNull( profile.getLastModified() );
+
         // Delete the user we just created
-        m_engine.getUserManager().getUserDatabase().deleteByLoginName("user"+suffix);
+        m_engine.getUserManager().getUserDatabase().deleteByLoginName( "user" + suffix );
     }
-    
+
     public void testSaveProfileWithCollisions() throws Exception
     {
-        MockServletContext ctx = (MockServletContext)m_engine.getServletContext();
         MockRoundtrip trip;
         UserProfileActionBean bean;
         ValidationErrors errors;
-        
+
         // Create user #1; save; verify it saved ok
-        String suffix1 = String.valueOf(System.currentTimeMillis());
-        trip = new MockRoundtrip(ctx, "/UserProfile.jsp");
-        trip.setParameter("profile.loginName", "user"+suffix1);
-        trip.setParameter("profile.fullname", "Fred Friendly"+suffix1);
-        trip.setParameter("profile.email", "fred1@friendly.org");
-        trip.setParameter("profile.password", "mypassword");
-        trip.setParameter("passwordAgain", "mypassword");
-        trip.execute("save");
-        bean = trip.getActionBean(UserProfileActionBean.class);
+        String suffix1 = String.valueOf( System.currentTimeMillis() );
+        trip = m_engine.guestTrip( "/UserProfile.jsp" );
+        trip.setParameter( "profile.loginName", "user" + suffix1 );
+        trip.setParameter( "profile.fullname", "Fred Friendly" + suffix1 );
+        trip.setParameter( "profile.email", "fred1@friendly.org" );
+        trip.setParameter( "profile.password", "mypassword" );
+        trip.setParameter( "passwordAgain", "mypassword" );
+        trip.execute( "save" );
+        bean = trip.getActionBean( UserProfileActionBean.class );
         // Check to make sure no validation errors here...
         errors = bean.getContext().getValidationErrors();
-        assertEquals( 0, errors.size());
-        assertEquals("/", trip.getDestination() );
-        assertTrue( userExists("user" + suffix1));
-        
-        // Create user #2, but same loginName as #1; save; verify it did NOT save
+        assertEquals( 0, errors.size() );
+        assertEquals( "/Wiki.jsp", trip.getDestination() );
+        assertTrue( userExists( "user" + suffix1 ) );
+
+        // Create user #2, but same loginName as #1; save; verify it did NOT
+        // save
         // (because loginnames collided), and redirected back to .Action
-        String suffix2 = String.valueOf(System.currentTimeMillis());
-        trip = new MockRoundtrip(ctx, "/UserProfile.jsp");
-        trip.setParameter("profile.loginName", "user"+suffix1);
-        trip.setParameter("profile.fullname", "Fred Friendly"+suffix2);
-        trip.setParameter("profile.email", "fred2@friendly.org");
-        trip.setParameter("profile.password", "mypassword");
-        trip.setParameter("passwordAgain", "mypassword");
-        trip.execute("save");
-        bean = trip.getActionBean(UserProfileActionBean.class);
+        String suffix2 = String.valueOf( System.currentTimeMillis() );
+        trip = m_engine.guestTrip( "/UserProfile.jsp" );
+        trip.setParameter( "profile.loginName", "user" + suffix1 );
+        trip.setParameter( "profile.fullname", "Fred Friendly" + suffix2 );
+        trip.setParameter( "profile.email", "fred2@friendly.org" );
+        trip.setParameter( "profile.password", "mypassword" );
+        trip.setParameter( "passwordAgain", "mypassword" );
+        trip.execute( "save" );
+        bean = trip.getActionBean( UserProfileActionBean.class );
         // Check to make sure all our expected validation errors are here...
         errors = bean.getContext().getValidationErrors();
-        assertEquals( 1, errors.size());
-        assertTrue( errors.containsKey( "profile.loginName") );
-        assertEquals(MockRoundtrip.DEFAULT_SOURCE_PAGE, trip.getDestination() );
-        assertFalse( userExists("user" + suffix2));
-        
+        assertEquals( 1, errors.size() );
+        assertTrue( errors.containsKey( "profile.loginName" ) );
+        assertEquals( MockRoundtrip.DEFAULT_SOURCE_PAGE, trip.getDestination() );
+        assertFalse( userExists( "user" + suffix2 ) );
+
         // Create user #2, but same fullname as #1; save; verify it did NOT save
         // (because fullnames collided), and redirected back to .Action
-        trip = new MockRoundtrip(ctx, "/UserProfile.jsp");
-        trip.setParameter("profile.loginName", "user"+suffix2);
-        trip.setParameter("profile.fullname", "Fred Friendly"+suffix1);
-        trip.setParameter("profile.email", "fred2@friendly.org");
-        trip.setParameter("profile.password", "mypassword");
-        trip.setParameter("passwordAgain", "mypassword");
-        trip.execute("save");
-        bean = trip.getActionBean(UserProfileActionBean.class);
+        trip = m_engine.guestTrip( "/UserProfile.jsp" );
+        trip.setParameter( "profile.loginName", "user" + suffix2 );
+        trip.setParameter( "profile.fullname", "Fred Friendly" + suffix1 );
+        trip.setParameter( "profile.email", "fred2@friendly.org" );
+        trip.setParameter( "profile.password", "mypassword" );
+        trip.setParameter( "passwordAgain", "mypassword" );
+        trip.execute( "save" );
+        bean = trip.getActionBean( UserProfileActionBean.class );
         // Check to make sure all our expected validation errors are here...
         errors = bean.getContext().getValidationErrors();
-        assertEquals( 1, errors.size());
-        assertTrue( errors.containsKey( "profile.fullname") );
-        assertEquals(MockRoundtrip.DEFAULT_SOURCE_PAGE, trip.getDestination() );
-        assertFalse( userExists("user" + suffix2));
-        
+        assertEquals( 1, errors.size() );
+        assertTrue( errors.containsKey( "profile.fullname" ) );
+        assertEquals( MockRoundtrip.DEFAULT_SOURCE_PAGE, trip.getDestination() );
+        assertFalse( userExists( "user" + suffix2 ) );
+
         // Delete the first user we just created
-        m_engine.getUserManager().getUserDatabase().deleteByLoginName("user"+suffix1);
+        m_engine.getUserManager().getUserDatabase().deleteByLoginName( "user" + suffix1 );
     }
-    
+
     public void testSaveProfileAgain() throws Exception
     {
-        MockServletContext ctx = (MockServletContext)m_engine.getServletContext();
         MockRoundtrip trip;
         UserProfileActionBean bean;
         ValidationErrors errors;
-        
+
         // Create user; save; verify it saved ok
-        String suffix = String.valueOf(System.currentTimeMillis());
-        trip = new MockRoundtrip(ctx, "/UserProfile.jsp");
-        trip.setParameter("profile.loginName", "user"+suffix);
-        trip.setParameter("profile.fullname", "Fred Friendly"+suffix);
-        trip.setParameter("profile.email", "fred1@friendly.org");
-        trip.setParameter("profile.password", "mypassword");
-        trip.setParameter("passwordAgain", "mypassword");
-        trip.execute("save");
-        bean = trip.getActionBean(UserProfileActionBean.class);
-        errors = bean.getContext().getValidationErrors();
-        assertEquals( 0, errors.size());
-        assertEquals("/", trip.getDestination() );
-        assertTrue( userExists("user" + suffix));
-        
+        String suffix = String.valueOf( System.currentTimeMillis() );
+        trip = m_engine.guestTrip( "/UserProfile.jsp" );
+        trip.setParameter( "profile.loginName", "user" + suffix );
+        trip.setParameter( "profile.fullname", "Fred Friendly" + suffix );
+        trip.setParameter( "profile.email", "fred1@friendly.org" );
+        trip.setParameter( "profile.password", "mypassword" );
+        trip.setParameter( "passwordAgain", "mypassword" );
+        trip.execute( "save" );
+        bean = trip.getActionBean( UserProfileActionBean.class );
+        errors = bean.getContext().getValidationErrors();
+        assertEquals( 0, errors.size() );
+        assertEquals( "/Wiki.jsp", trip.getDestination() );
+        assertTrue( userExists( "user" + suffix ) );
+
         // Create new session and login as new user...
-        trip = new MockRoundtrip(ctx, "/UserProfile.jsp");
+        trip = m_engine.guestTrip( "/UserProfile.jsp" );
         MockHttpServletRequest request = trip.getRequest();
-        WikiSession wikiSession = WikiSession.getWikiSession(m_engine, request);
-        boolean login = m_engine.getAuthenticationManager().login(wikiSession, "user"+suffix,"mypassword");
-        assertTrue("Could not log in.", login);
-        
+        WikiSession wikiSession = WikiSession.getWikiSession( m_engine, request );
+        boolean login = m_engine.getAuthenticationManager().login( wikiSession, "user" + suffix, "mypassword" );
+        assertTrue( "Could not log in.", login );
+
         // Make sure the saved profile is loaded when we access prefs page
-        trip.execute("save");
-        bean = trip.getActionBean(UserProfileActionBean.class);
-        assertEquals("user"+suffix, bean.getProfile().getLoginName());
-        assertEquals("Fred Friendly"+suffix, bean.getProfile().getFullname());
-        assertEquals("fred1@friendly.org", bean.getProfile().getEmail());
-        
+        trip.execute( "save" );
+        bean = trip.getActionBean( UserProfileActionBean.class );
+        assertEquals( "user" + suffix, bean.getProfile().getLoginName() );
+        assertEquals( "Fred Friendly" + suffix, bean.getProfile().getFullname() );
+        assertEquals( "fred1@friendly.org", bean.getProfile().getEmail() );
+
         // Now, create another session, and log in again....
-        trip = new MockRoundtrip(ctx, "/UserProfile.jsp");
+        trip = m_engine.guestTrip( "/UserProfile.jsp" );
         request = trip.getRequest();
-        wikiSession = WikiSession.getWikiSession(m_engine, request);
-        login = m_engine.getAuthenticationManager().login(wikiSession, "user"+suffix,"mypassword");
-        assertTrue("Could not lot in.", login);
-        
+        wikiSession = WikiSession.getWikiSession( m_engine, request );
+        login = m_engine.getAuthenticationManager().login( wikiSession, "user" + suffix, "mypassword" );
+        assertTrue( "Could not lot in.", login );
+
         // Pass new values for the mutable fields (except the password).
         // The e-mails, loginname and fullname should all change
-        trip.addParameter("profile.loginName", "wilma");
-        trip.addParameter("profile.fullname", "Wilma Flintstone");
-        trip.addParameter("profile.email", "wilma@flintstone.org");
-        trip.execute("save");
-        bean = trip.getActionBean(UserProfileActionBean.class);
-        assertEquals("wilma", bean.getProfile().getLoginName());
-        assertEquals("Wilma Flintstone", bean.getProfile().getFullname());
-        assertEquals("wilma@flintstone.org", bean.getProfile().getEmail());
-        assertNull(bean.getProfile().getPassword());
-        assertNull(bean.getPasswordAgain());
-        
+        trip.addParameter( "profile.loginName", "wilma" );
+        trip.addParameter( "profile.fullname", "Wilma Flintstone" );
+        trip.addParameter( "profile.email", "wilma@flintstone.org" );
+        trip.execute( "save" );
+        bean = trip.getActionBean( UserProfileActionBean.class );
+        assertEquals( "wilma", bean.getProfile().getLoginName() );
+        assertEquals( "Wilma Flintstone", bean.getProfile().getFullname() );
+        assertEquals( "wilma@flintstone.org", bean.getProfile().getEmail() );
+        assertNull( bean.getProfile().getPassword() );
+        assertNull( bean.getPasswordAgain() );
+
         // Delete the user we just created
-        m_engine.getUserManager().getUserDatabase().deleteByLoginName("wilma");
+        m_engine.getUserManager().getUserDatabase().deleteByLoginName( "wilma" );
     }
-    
+
     public static Test suite()
     {
         return new TestSuite( UserProfileActionBeanTest.class );
     }
-    
-    private boolean userExists(String name)
+
+    private boolean userExists( String name )
     {
         UserDatabase db = m_engine.getUserManager().getUserDatabase();
         boolean found = false;
-        try 
+        try
         {
-            db.find(name);
+            db.find( name );
             found = true;
         }
-        catch (NoSuchPrincipalException e)
+        catch( NoSuchPrincipalException e )
         {
             // Swallow
         }
         return found;
     }
-    
+
 }

Modified: incubator/jspwiki/branches/JSPWIKI_2_9_STRIPES_BRANCH/tests/com/ecyrd/jspwiki/action/ViewActionBeanTest.java
URL: http://svn.apache.org/viewvc/incubator/jspwiki/branches/JSPWIKI_2_9_STRIPES_BRANCH/tests/com/ecyrd/jspwiki/action/ViewActionBeanTest.java?rev=685452&r1=685451&r2=685452&view=diff
==============================================================================
--- incubator/jspwiki/branches/JSPWIKI_2_9_STRIPES_BRANCH/tests/com/ecyrd/jspwiki/action/ViewActionBeanTest.java (original)
+++ incubator/jspwiki/branches/JSPWIKI_2_9_STRIPES_BRANCH/tests/com/ecyrd/jspwiki/action/ViewActionBeanTest.java Tue Aug 12 23:01:27 2008
@@ -6,7 +6,6 @@
 import junit.framework.TestCase;
 import junit.framework.TestSuite;
 import net.sourceforge.stripes.mock.MockRoundtrip;
-import net.sourceforge.stripes.mock.MockServletContext;
 
 import com.ecyrd.jspwiki.TestEngine;
 import com.ecyrd.jspwiki.WikiPage;
@@ -37,8 +36,7 @@
         assertNotNull("Did not save page Test!", page);
         
         // Set the 'page' request parameter to 'Main'...
-        MockServletContext ctx = (MockServletContext)m_engine.getServletContext();
-        MockRoundtrip trip = new MockRoundtrip(ctx, "/Wiki.jsp");
+        MockRoundtrip trip = m_engine.guestTrip( "/Wiki.jsp");
         trip.setParameter("page", "Test");
         trip.execute("view");
 
@@ -57,8 +55,7 @@
         assertNotNull("Did not save page Main!", page);
         
         // Execute the request without specifying a page
-        MockServletContext ctx = (MockServletContext)m_engine.getServletContext();
-        MockRoundtrip trip = new MockRoundtrip(ctx, "/Wiki.jsp");
+        MockRoundtrip trip = m_engine.guestTrip( "/Wiki.jsp");
         trip.execute("view");
 
         // ...we should automatically see Main bound to the ActionBean (nice!)

Modified: incubator/jspwiki/branches/JSPWIKI_2_9_STRIPES_BRANCH/tests/com/ecyrd/jspwiki/action/WikiActionBeanFactoryTest.java
URL: http://svn.apache.org/viewvc/incubator/jspwiki/branches/JSPWIKI_2_9_STRIPES_BRANCH/tests/com/ecyrd/jspwiki/action/WikiActionBeanFactoryTest.java?rev=685452&r1=685451&r2=685452&view=diff
==============================================================================
--- incubator/jspwiki/branches/JSPWIKI_2_9_STRIPES_BRANCH/tests/com/ecyrd/jspwiki/action/WikiActionBeanFactoryTest.java (original)
+++ incubator/jspwiki/branches/JSPWIKI_2_9_STRIPES_BRANCH/tests/com/ecyrd/jspwiki/action/WikiActionBeanFactoryTest.java Tue Aug 12 23:01:27 2008
@@ -19,7 +19,7 @@
 
 public class WikiActionBeanFactoryTest extends TestCase
 {
-    TestEngine testEngine;
+    TestEngine m_engine;
     WikiActionBeanFactory resolver;
 
     protected void setUp() throws Exception
@@ -27,21 +27,21 @@
         Properties props = new Properties();
         props.load( TestEngine.findTestProperties() );
         props.put( WikiEngine.PROP_MATCHPLURALS, "yes" );
-        testEngine = new TestEngine( props );
-        resolver = testEngine.getWikiActionBeanFactory();
-        testEngine.saveText( "SinglePage", "This is a test." );
-        testEngine.saveText( "PluralPages", "This is a test." );
+        m_engine = new TestEngine( props );
+        resolver = m_engine.getWikiActionBeanFactory();
+        m_engine.saveText( "SinglePage", "This is a test." );
+        m_engine.saveText( "PluralPages", "This is a test." );
     }
     
     protected void tearDown() throws Exception
     {
-        testEngine.deletePage( "TestPage" );
+        m_engine.deletePage( "TestPage" );
     }
     
     public void testNewActionBean() throws WikiException
     {
         WikiActionBean bean;
-        MockRoundtrip trip = testEngine.guestTrip( ViewActionBean.class );
+        MockRoundtrip trip = m_engine.guestTrip( ViewActionBean.class );
         MockHttpServletRequest request = trip.getRequest();
         MockHttpServletResponse response = trip.getResponse();
         
@@ -81,20 +81,20 @@
     public void testNewActionBeanByJSP() throws WikiException
     {
         WikiActionBean bean;
-        MockRoundtrip trip = testEngine.guestTrip( ViewActionBean.class );
+        MockRoundtrip trip = m_engine.guestTrip( ViewActionBean.class );
         MockHttpServletRequest request = trip.getRequest();
         MockHttpServletResponse response = trip.getResponse();
         MockHttpSession session = (MockHttpSession)request.getSession();
 
         // Request for "UserPreference.jsp" should resolve to PREFS action
-        request = new MockHttpServletRequest( testEngine.getServletContext().getServletContextName(), "/UserPreferences.jsp");
+        request = new MockHttpServletRequest( m_engine.getServletContext().getServletContextName(), "/UserPreferences.jsp");
         request.setSession( session );
         bean = resolver.newActionBean( request, response, UserPreferencesActionBean.class );
         assertEquals( WikiContext.PREFS, bean.getRequestContext() );
         
         // We don't care about JSPs not mapped to actions, because the bean we get only depends on the class we pass
         // FIXME: this won't work because WikiActionBeanResolver doesn't keep a cache of URLBindings 
-        request = new MockHttpServletRequest( testEngine.getServletContext().getServletContextName(), "/NonExistent.jsp");
+        request = new MockHttpServletRequest( m_engine.getServletContext().getServletContextName(), "/NonExistent.jsp");
         request.setSession( session );
         bean = resolver.newActionBean( request, response, EditActionBean.class );
         assertEquals( WikiContext.EDIT, bean.getRequestContext() );
@@ -104,14 +104,14 @@
     public void testActionBeansWithParams() throws Exception
     {
         WikiActionBean bean;
-        WikiPage page = testEngine.getPage( "SinglePage" );
-        MockRoundtrip trip = testEngine.guestTrip( ViewActionBean.class );
+        WikiPage page = m_engine.getPage( "SinglePage" );
+        MockRoundtrip trip = m_engine.guestTrip( ViewActionBean.class );
         MockHttpServletRequest request = trip.getRequest();
         MockHttpServletResponse response = trip.getResponse();
         MockHttpSession session = (MockHttpSession)request.getSession();
         
         // Passing an EDIT request with page param yields an ActionBean with a non-null page property
-        request = new MockHttpServletRequest( testEngine.getServletContext().getServletContextName(), "/Edit.jsp");
+        request = new MockHttpServletRequest( m_engine.getServletContext().getServletContextName(), "/Edit.jsp");
         request.setSession( session );
         request.getParameterMap().put( "page", new String[]{"SinglePage"} );
         bean = resolver.newActionBean( request, response, EditActionBean.class );
@@ -120,14 +120,14 @@
         
         // Passing a VIEW request with page=FindPage yields an ordinary page name, not a special page or JSP
         // FIXME: this won't work because WikiActionBeanResolver doesn't keep a cache of URLBindings 
-        request = new MockHttpServletRequest( testEngine.getServletContext().getServletContextName(), "/Wiki.jsp");
+        request = new MockHttpServletRequest( m_engine.getServletContext().getServletContextName(), "/Wiki.jsp");
         request.setSession( session );
         request.getParameterMap().put( "page", new String[]{"FindPage"} );
         bean = resolver.newActionBean( request, response, ViewActionBean.class );
         assertEquals( WikiContext.VIEW, bean.getRequestContext() );
         
         // Passing a VIEW_GROUP request with group="Art" gets a ViewGroupActionBean
-        request = new MockHttpServletRequest( testEngine.getServletContext().getServletContextName(), "/Wiki.jsp");
+        request = new MockHttpServletRequest( m_engine.getServletContext().getServletContextName(), "/Wiki.jsp");
         request.setSession( session );
         request.getParameterMap().put( "group", new String[]{"Art"} );
         bean = resolver.newActionBean( request, response, GroupActionBean.class );