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/03 14:28:11 UTC

svn commit: r682151 [1/4] - in /incubator/jspwiki/branches/JSPWIKI_2_9_STRIPES_BRANCH/tests/com/ecyrd/jspwiki: ./ action/ attachment/ auth/ auth/acl/ auth/authorize/ auth/login/ auth/user/ content/ diff/ parser/ plugin/ providers/ render/ rss/ search/ ...

Author: ajaquith
Date: Sun Aug  3 05:28:09 2008
New Revision: 682151

URL: http://svn.apache.org/viewvc?rev=682151&view=rev
Log:
Massive re-factoring to make Stripes less invasive.

Added:
    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   (with props)
    incubator/jspwiki/branches/JSPWIKI_2_9_STRIPES_BRANCH/tests/com/ecyrd/jspwiki/content/
    incubator/jspwiki/branches/JSPWIKI_2_9_STRIPES_BRANCH/tests/com/ecyrd/jspwiki/content/AllTests.java
    incubator/jspwiki/branches/JSPWIKI_2_9_STRIPES_BRANCH/tests/com/ecyrd/jspwiki/content/PageRenamerTest.java
    incubator/jspwiki/branches/JSPWIKI_2_9_STRIPES_BRANCH/tests/com/ecyrd/jspwiki/url/
    incubator/jspwiki/branches/JSPWIKI_2_9_STRIPES_BRANCH/tests/com/ecyrd/jspwiki/url/AllTests.java   (with props)
    incubator/jspwiki/branches/JSPWIKI_2_9_STRIPES_BRANCH/tests/com/ecyrd/jspwiki/url/DefaultURLConstructorTest.java   (with props)
    incubator/jspwiki/branches/JSPWIKI_2_9_STRIPES_BRANCH/tests/com/ecyrd/jspwiki/url/ShortURLConstructorTest.java   (with props)
    incubator/jspwiki/branches/JSPWIKI_2_9_STRIPES_BRANCH/tests/com/ecyrd/jspwiki/url/ShortViewURLConstructorTest.java   (with props)
    incubator/jspwiki/branches/JSPWIKI_2_9_STRIPES_BRANCH/tests/com/ecyrd/jspwiki/util/CryptoUtilTest.java
    incubator/jspwiki/branches/JSPWIKI_2_9_STRIPES_BRANCH/tests/com/ecyrd/jspwiki/util/SerializerTest.java
    incubator/jspwiki/branches/JSPWIKI_2_9_STRIPES_BRANCH/tests/com/ecyrd/jspwiki/util/TimedCounterListTest.java
    incubator/jspwiki/branches/JSPWIKI_2_9_STRIPES_BRANCH/tests/com/ecyrd/jspwiki/web/TestContainer.java   (with props)
Removed:
    incubator/jspwiki/branches/JSPWIKI_2_9_STRIPES_BRANCH/tests/com/ecyrd/jspwiki/PageRenamerTest.java
    incubator/jspwiki/branches/JSPWIKI_2_9_STRIPES_BRANCH/tests/com/ecyrd/jspwiki/TestHttpServletRequest.java
    incubator/jspwiki/branches/JSPWIKI_2_9_STRIPES_BRANCH/tests/com/ecyrd/jspwiki/TestHttpSession.java
    incubator/jspwiki/branches/JSPWIKI_2_9_STRIPES_BRANCH/tests/com/ecyrd/jspwiki/action/EventPermissionInfoTest.java
    incubator/jspwiki/branches/JSPWIKI_2_9_STRIPES_BRANCH/tests/com/ecyrd/jspwiki/parser/AndyTest.java
    incubator/jspwiki/branches/JSPWIKI_2_9_STRIPES_BRANCH/tests/com/ecyrd/jspwiki/web/CommonContainerTests.java
    incubator/jspwiki/branches/JSPWIKI_2_9_STRIPES_BRANCH/tests/com/ecyrd/jspwiki/web/CommonCustomTests.java
    incubator/jspwiki/branches/JSPWIKI_2_9_STRIPES_BRANCH/tests/com/ecyrd/jspwiki/web/CommonTests.java
    incubator/jspwiki/branches/JSPWIKI_2_9_STRIPES_BRANCH/tests/com/ecyrd/jspwiki/web/ContainerJDBCTest.java
    incubator/jspwiki/branches/JSPWIKI_2_9_STRIPES_BRANCH/tests/com/ecyrd/jspwiki/web/ContainerTest.java
    incubator/jspwiki/branches/JSPWIKI_2_9_STRIPES_BRANCH/tests/com/ecyrd/jspwiki/web/CustomAbsoluteTest.java
    incubator/jspwiki/branches/JSPWIKI_2_9_STRIPES_BRANCH/tests/com/ecyrd/jspwiki/web/CustomJDBCTest.java
    incubator/jspwiki/branches/JSPWIKI_2_9_STRIPES_BRANCH/tests/com/ecyrd/jspwiki/web/CustomTest.java
Modified:
    incubator/jspwiki/branches/JSPWIKI_2_9_STRIPES_BRANCH/tests/com/ecyrd/jspwiki/AllTests.java
    incubator/jspwiki/branches/JSPWIKI_2_9_STRIPES_BRANCH/tests/com/ecyrd/jspwiki/PageManagerTest.java
    incubator/jspwiki/branches/JSPWIKI_2_9_STRIPES_BRANCH/tests/com/ecyrd/jspwiki/TestAuthorizer.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/TestJDBCDataSource.java
    incubator/jspwiki/branches/JSPWIKI_2_9_STRIPES_BRANCH/tests/com/ecyrd/jspwiki/TestJNDIContext.java
    incubator/jspwiki/branches/JSPWIKI_2_9_STRIPES_BRANCH/tests/com/ecyrd/jspwiki/TextUtilTest.java
    incubator/jspwiki/branches/JSPWIKI_2_9_STRIPES_BRANCH/tests/com/ecyrd/jspwiki/VariableManagerTest.java
    incubator/jspwiki/branches/JSPWIKI_2_9_STRIPES_BRANCH/tests/com/ecyrd/jspwiki/WikiEngineTest.java
    incubator/jspwiki/branches/JSPWIKI_2_9_STRIPES_BRANCH/tests/com/ecyrd/jspwiki/WikiSessionTest.java
    incubator/jspwiki/branches/JSPWIKI_2_9_STRIPES_BRANCH/tests/com/ecyrd/jspwiki/action/AllTests.java
    incubator/jspwiki/branches/JSPWIKI_2_9_STRIPES_BRANCH/tests/com/ecyrd/jspwiki/action/RenameActionBeanTest.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
    incubator/jspwiki/branches/JSPWIKI_2_9_STRIPES_BRANCH/tests/com/ecyrd/jspwiki/attachment/AttachmentManagerTest.java
    incubator/jspwiki/branches/JSPWIKI_2_9_STRIPES_BRANCH/tests/com/ecyrd/jspwiki/auth/AllTests.java
    incubator/jspwiki/branches/JSPWIKI_2_9_STRIPES_BRANCH/tests/com/ecyrd/jspwiki/auth/AuthenticationManagerTest.java
    incubator/jspwiki/branches/JSPWIKI_2_9_STRIPES_BRANCH/tests/com/ecyrd/jspwiki/auth/AuthorizationManagerTest.java
    incubator/jspwiki/branches/JSPWIKI_2_9_STRIPES_BRANCH/tests/com/ecyrd/jspwiki/auth/GroupManagerTest.java
    incubator/jspwiki/branches/JSPWIKI_2_9_STRIPES_BRANCH/tests/com/ecyrd/jspwiki/auth/SecurityEventTrap.java
    incubator/jspwiki/branches/JSPWIKI_2_9_STRIPES_BRANCH/tests/com/ecyrd/jspwiki/auth/UserManagerTest.java
    incubator/jspwiki/branches/JSPWIKI_2_9_STRIPES_BRANCH/tests/com/ecyrd/jspwiki/auth/acl/AclEntryImplTest.java
    incubator/jspwiki/branches/JSPWIKI_2_9_STRIPES_BRANCH/tests/com/ecyrd/jspwiki/auth/acl/AclImplTest.java
    incubator/jspwiki/branches/JSPWIKI_2_9_STRIPES_BRANCH/tests/com/ecyrd/jspwiki/auth/authorize/JDBCGroupDatabaseTest.java
    incubator/jspwiki/branches/JSPWIKI_2_9_STRIPES_BRANCH/tests/com/ecyrd/jspwiki/auth/authorize/XMLGroupDatabaseTest.java
    incubator/jspwiki/branches/JSPWIKI_2_9_STRIPES_BRANCH/tests/com/ecyrd/jspwiki/auth/login/AnonymousLoginModuleTest.java
    incubator/jspwiki/branches/JSPWIKI_2_9_STRIPES_BRANCH/tests/com/ecyrd/jspwiki/auth/login/CookieAssertionLoginModuleTest.java
    incubator/jspwiki/branches/JSPWIKI_2_9_STRIPES_BRANCH/tests/com/ecyrd/jspwiki/auth/login/UserDatabaseLoginModuleTest.java
    incubator/jspwiki/branches/JSPWIKI_2_9_STRIPES_BRANCH/tests/com/ecyrd/jspwiki/auth/login/WebContainerLoginModuleTest.java
    incubator/jspwiki/branches/JSPWIKI_2_9_STRIPES_BRANCH/tests/com/ecyrd/jspwiki/auth/user/JDBCUserDatabaseTest.java
    incubator/jspwiki/branches/JSPWIKI_2_9_STRIPES_BRANCH/tests/com/ecyrd/jspwiki/auth/user/UserProfileTest.java
    incubator/jspwiki/branches/JSPWIKI_2_9_STRIPES_BRANCH/tests/com/ecyrd/jspwiki/auth/user/XMLUserDatabaseTest.java
    incubator/jspwiki/branches/JSPWIKI_2_9_STRIPES_BRANCH/tests/com/ecyrd/jspwiki/diff/ContextualDiffProviderTest.java
    incubator/jspwiki/branches/JSPWIKI_2_9_STRIPES_BRANCH/tests/com/ecyrd/jspwiki/parser/CreoleToJSPWikiTranslatorTest.java
    incubator/jspwiki/branches/JSPWIKI_2_9_STRIPES_BRANCH/tests/com/ecyrd/jspwiki/parser/JSPWikiMarkupParserTest.java
    incubator/jspwiki/branches/JSPWIKI_2_9_STRIPES_BRANCH/tests/com/ecyrd/jspwiki/plugin/CounterPluginTest.java
    incubator/jspwiki/branches/JSPWIKI_2_9_STRIPES_BRANCH/tests/com/ecyrd/jspwiki/plugin/GroupsTest.java
    incubator/jspwiki/branches/JSPWIKI_2_9_STRIPES_BRANCH/tests/com/ecyrd/jspwiki/plugin/PluginManagerTest.java
    incubator/jspwiki/branches/JSPWIKI_2_9_STRIPES_BRANCH/tests/com/ecyrd/jspwiki/plugin/ReferringPagesPluginTest.java
    incubator/jspwiki/branches/JSPWIKI_2_9_STRIPES_BRANCH/tests/com/ecyrd/jspwiki/plugin/TableOfContentsTest.java
    incubator/jspwiki/branches/JSPWIKI_2_9_STRIPES_BRANCH/tests/com/ecyrd/jspwiki/plugin/UndefinedPagesPluginTest.java
    incubator/jspwiki/branches/JSPWIKI_2_9_STRIPES_BRANCH/tests/com/ecyrd/jspwiki/providers/BasicAttachmentProviderTest.java
    incubator/jspwiki/branches/JSPWIKI_2_9_STRIPES_BRANCH/tests/com/ecyrd/jspwiki/providers/CounterProvider.java
    incubator/jspwiki/branches/JSPWIKI_2_9_STRIPES_BRANCH/tests/com/ecyrd/jspwiki/providers/FileSystemProviderTest.java
    incubator/jspwiki/branches/JSPWIKI_2_9_STRIPES_BRANCH/tests/com/ecyrd/jspwiki/providers/RCSFileProviderTest.java
    incubator/jspwiki/branches/JSPWIKI_2_9_STRIPES_BRANCH/tests/com/ecyrd/jspwiki/providers/VersioningFileProviderTest.java
    incubator/jspwiki/branches/JSPWIKI_2_9_STRIPES_BRANCH/tests/com/ecyrd/jspwiki/providers/VerySimpleProvider.java
    incubator/jspwiki/branches/JSPWIKI_2_9_STRIPES_BRANCH/tests/com/ecyrd/jspwiki/render/CreoleRendererTest.java
    incubator/jspwiki/branches/JSPWIKI_2_9_STRIPES_BRANCH/tests/com/ecyrd/jspwiki/render/RenderingManagerTest.java
    incubator/jspwiki/branches/JSPWIKI_2_9_STRIPES_BRANCH/tests/com/ecyrd/jspwiki/render/WysiwygEditingRendererTest.java
    incubator/jspwiki/branches/JSPWIKI_2_9_STRIPES_BRANCH/tests/com/ecyrd/jspwiki/rss/AllTests.java
    incubator/jspwiki/branches/JSPWIKI_2_9_STRIPES_BRANCH/tests/com/ecyrd/jspwiki/rss/RSSGeneratorTest.java
    incubator/jspwiki/branches/JSPWIKI_2_9_STRIPES_BRANCH/tests/com/ecyrd/jspwiki/search/SearchManagerTest.java
    incubator/jspwiki/branches/JSPWIKI_2_9_STRIPES_BRANCH/tests/com/ecyrd/jspwiki/ui/InputValidatorTest.java
    incubator/jspwiki/branches/JSPWIKI_2_9_STRIPES_BRANCH/tests/com/ecyrd/jspwiki/util/AllTests.java
    incubator/jspwiki/branches/JSPWIKI_2_9_STRIPES_BRANCH/tests/com/ecyrd/jspwiki/util/MailUtilTest.java
    incubator/jspwiki/branches/JSPWIKI_2_9_STRIPES_BRANCH/tests/com/ecyrd/jspwiki/web/AllTests.java
    incubator/jspwiki/branches/JSPWIKI_2_9_STRIPES_BRANCH/tests/com/ecyrd/jspwiki/workflow/ApprovalWorkflowTest.java
    incubator/jspwiki/branches/JSPWIKI_2_9_STRIPES_BRANCH/tests/com/ecyrd/jspwiki/workflow/DecisionQueueTest.java
    incubator/jspwiki/branches/JSPWIKI_2_9_STRIPES_BRANCH/tests/com/ecyrd/jspwiki/workflow/OutcomeTest.java
    incubator/jspwiki/branches/JSPWIKI_2_9_STRIPES_BRANCH/tests/com/ecyrd/jspwiki/workflow/TaskTest.java
    incubator/jspwiki/branches/JSPWIKI_2_9_STRIPES_BRANCH/tests/com/ecyrd/jspwiki/xmlrpc/RPCHandlerTest.java

Modified: incubator/jspwiki/branches/JSPWIKI_2_9_STRIPES_BRANCH/tests/com/ecyrd/jspwiki/AllTests.java
URL: http://svn.apache.org/viewvc/incubator/jspwiki/branches/JSPWIKI_2_9_STRIPES_BRANCH/tests/com/ecyrd/jspwiki/AllTests.java?rev=682151&r1=682150&r2=682151&view=diff
==============================================================================
--- incubator/jspwiki/branches/JSPWIKI_2_9_STRIPES_BRANCH/tests/com/ecyrd/jspwiki/AllTests.java (original)
+++ incubator/jspwiki/branches/JSPWIKI_2_9_STRIPES_BRANCH/tests/com/ecyrd/jspwiki/AllTests.java Sun Aug  3 05:28:09 2008
@@ -1,12 +1,15 @@
 
 package com.ecyrd.jspwiki;
 
-import java.util.Properties;
-import org.apache.log4j.PropertyConfigurator;
 import java.io.IOException;
 import java.io.InputStream;
+import java.util.Properties;
 
-import junit.framework.*;
+import junit.framework.Test;
+import junit.framework.TestCase;
+import junit.framework.TestSuite;
+
+import org.apache.log4j.PropertyConfigurator;
 
 public class AllTests extends TestCase
 {
@@ -43,7 +46,6 @@
 
         suite.addTest( FileUtilTest.suite() );
         suite.addTest( PageManagerTest.suite() );
-        suite.addTest( PageRenamerTest.suite() );
         suite.addTest( PropertyReaderTest.suite() );
         suite.addTest( ReferenceManagerTest.suite() );
         suite.addTest( ReleaseTest.suite() );
@@ -54,6 +56,7 @@
         suite.addTest( WikiSessionTest.suite() );
         suite.addTest( WikiEngineTest.suite() );
         suite.addTest( com.ecyrd.jspwiki.action.AllTests.suite() );
+        suite.addTest( com.ecyrd.jspwiki.content.AllTests.suite() );
         suite.addTest( com.ecyrd.jspwiki.attachment.AllTests.suite() );
         suite.addTest( com.ecyrd.jspwiki.auth.AllTests.suite() );
         suite.addTest( com.ecyrd.jspwiki.dav.AllTests.suite() );
@@ -67,6 +70,7 @@
         suite.addTest( com.ecyrd.jspwiki.rss.AllTests.suite() );
         suite.addTest( com.ecyrd.jspwiki.search.AllTests.suite() );
         suite.addTest( com.ecyrd.jspwiki.ui.AllTests.suite() );
+        suite.addTest( com.ecyrd.jspwiki.url.AllTests.suite() );
         suite.addTest( com.ecyrd.jspwiki.util.AllTests.suite() );
         // These are not runnable without a running tomcat
         //suite.addTest( com.ecyrd.jspwiki.web.AllTests.suite() );

Modified: incubator/jspwiki/branches/JSPWIKI_2_9_STRIPES_BRANCH/tests/com/ecyrd/jspwiki/PageManagerTest.java
URL: http://svn.apache.org/viewvc/incubator/jspwiki/branches/JSPWIKI_2_9_STRIPES_BRANCH/tests/com/ecyrd/jspwiki/PageManagerTest.java?rev=682151&r1=682150&r2=682151&view=diff
==============================================================================
--- incubator/jspwiki/branches/JSPWIKI_2_9_STRIPES_BRANCH/tests/com/ecyrd/jspwiki/PageManagerTest.java (original)
+++ incubator/jspwiki/branches/JSPWIKI_2_9_STRIPES_BRANCH/tests/com/ecyrd/jspwiki/PageManagerTest.java Sun Aug  3 05:28:09 2008
@@ -1,12 +1,16 @@
 
 package com.ecyrd.jspwiki;
 
-import junit.framework.*;
-import java.util.*;
+import java.util.Properties;
 
-import org.apache.log4j.*;
+import junit.framework.Test;
+import junit.framework.TestCase;
+import junit.framework.TestSuite;
 
-import com.ecyrd.jspwiki.providers.*;
+import org.apache.log4j.PropertyConfigurator;
+
+import com.ecyrd.jspwiki.PageManager;
+import com.ecyrd.jspwiki.providers.CachingProvider;
 
 public class PageManagerTest extends TestCase
 {

Modified: incubator/jspwiki/branches/JSPWIKI_2_9_STRIPES_BRANCH/tests/com/ecyrd/jspwiki/TestAuthorizer.java
URL: http://svn.apache.org/viewvc/incubator/jspwiki/branches/JSPWIKI_2_9_STRIPES_BRANCH/tests/com/ecyrd/jspwiki/TestAuthorizer.java?rev=682151&r1=682150&r2=682151&view=diff
==============================================================================
--- incubator/jspwiki/branches/JSPWIKI_2_9_STRIPES_BRANCH/tests/com/ecyrd/jspwiki/TestAuthorizer.java (original)
+++ incubator/jspwiki/branches/JSPWIKI_2_9_STRIPES_BRANCH/tests/com/ecyrd/jspwiki/TestAuthorizer.java Sun Aug  3 05:28:09 2008
@@ -1,6 +1,22 @@
 /*
- * (C) Janne Jalkanen 2005
- * 
+    JSPWiki - a JSP-based WikiWiki clone.
+
+    Licensed to the Apache Software Foundation (ASF) under one
+    or more contributor license agreements.  See the NOTICE file
+    distributed with this work for additional information
+    regarding copyright ownership.  The ASF licenses this file
+    to you under the Apache License, Version 2.0 (the
+    "License"); you may not use this file except in compliance
+    with the License.  You may obtain a copy of the License at
+
+       http://www.apache.org/licenses/LICENSE-2.0
+
+    Unless required by applicable law or agreed to in writing,
+    software distributed under the License is distributed on an
+    "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+    KIND, either express or implied.  See the License for the
+    specific language governing permissions and limitations
+    under the License.    
  */
 package com.ecyrd.jspwiki;
 
@@ -50,7 +66,7 @@
      */
     public Principal[] getRoles()
     {
-        return (Principal[])m_roles.clone();
+        return m_roles;
     }
     
     /**

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=682151&r1=682150&r2=682151&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 Sun Aug  3 05:28:09 2008
@@ -5,21 +5,24 @@
 import java.util.Properties;
 import java.io.*;
 
+import javax.servlet.*;
+import javax.servlet.http.HttpServlet;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+import javax.servlet.http.HttpSession;
+
 import net.sourceforge.stripes.controller.DispatcherServlet;
 import net.sourceforge.stripes.controller.StripesFilter;
-import net.sourceforge.stripes.mock.MockHttpServletRequest;
-import net.sourceforge.stripes.mock.MockRoundtrip;
-import net.sourceforge.stripes.mock.MockServletContext;
+import net.sourceforge.stripes.mock.*;
 
 import org.apache.log4j.Logger;
 
-import com.ecyrd.jspwiki.action.ViewActionBean;
 import com.ecyrd.jspwiki.action.WikiActionBean;
-import com.ecyrd.jspwiki.action.WikiActionBeanContext;
 import com.ecyrd.jspwiki.attachment.Attachment;
 import com.ecyrd.jspwiki.auth.Users;
 import com.ecyrd.jspwiki.auth.WikiSecurityException;
 import com.ecyrd.jspwiki.providers.*;
+import com.ecyrd.jspwiki.ui.WikiServletFilter;
 
 /**
  *  <p>Simple test engine that always assumes pages are found. The version of TestEngine that is part of JSPWiki 3.0
@@ -38,17 +41,20 @@
 {
     static Logger log = Logger.getLogger( TestEngine.class );
 
+    private HttpSession m_adminSession;
+    private HttpSession m_janneSession;
+    private WikiSession m_adminWikiSession;
+    private WikiSession m_janneWikiSession;
+    private WikiSession m_guestWikiSession;
+
     /**
      * Creates WikiSession with the privileges of the administrative user.
      * For testing purposes, obviously.
      * @return the wiki session
      */
-    public WikiSession adminSession() throws WikiSecurityException
+    public WikiSession adminSession()
     {
-        MockHttpServletRequest request = guestTrip( ViewActionBean.class ).getRequest();
-        WikiSession session = WikiSession.getWikiSession( this, request );
-        this.getAuthenticationManager().login( session, Users.ADMIN, Users.ADMIN_PASS );
-        return session;
+        return m_adminWikiSession;
     }
 
     /**
@@ -58,41 +64,7 @@
      */
     public WikiSession guestSession()
     {
-        MockHttpServletRequest request = guestTrip( ViewActionBean.class ).getRequest();
-        return WikiSession.getWikiSession( this, request );
-    }
-   
-    /**
-     * Creates a "round trip" object initialized with a supplied set of credentials. The WikiSession
-     * associated with the created MockRoundtrip object will have privileges appropriate for
-     * the credentials supplied.
-     * @param user the login name
-     * @param password the password
-     * @param beanClass the Stripes action bean to start with
-     * @return the initialized round trip
-     * @throws WikiSecurityException
-     */
-    public MockRoundtrip authenticatedTrip( String user, String password, Class<? extends WikiActionBean> beanClass ) throws WikiSecurityException
-    {
-        MockRoundtrip trip = new MockRoundtrip( getServletContext(), beanClass );
-        MockHttpServletRequest request = trip.getRequest();
-        WikiSession session = WikiSession.getWikiSession( this, request);
-        this.getAuthenticationManager().login( session, Users.ADMIN, Users.ADMIN_PASS );
-        return trip;
-    }
-    
-    /**
-     * Creates a guest "round trip" object that initializes itself with the TestEngine's mock servlet context,
-     * plus a new mock request, mock response and action bean of type {@link com.ecyrd.jspwiki.action.ViewActionBean}.
-     * 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 beanClass the Stripes action bean to start with
-     * @return the mock rountrip
-     */
-    public MockRoundtrip guestTrip( Class<? extends WikiActionBean> beanClass )
-    {
-        return new MockRoundtrip( getServletContext(), beanClass );
+        return m_guestWikiSession;
     }
 
     /**
@@ -100,70 +72,73 @@
      * For testing purposes, obviously.
      * @return the wiki session
      */
-    public WikiSession janneSession() throws WikiSecurityException
+    public WikiSession janneSession()
     {
-        MockHttpServletRequest request = guestTrip( ViewActionBean.class ).getRequest();
-        request = guestTrip( ViewActionBean.class ).getRequest();
-        WikiSession session = WikiSession.getWikiSession( this, request );
-        this.getAuthenticationManager().login( session, Users.JANNE, Users.JANNE_PASS );
-        return session;
+        return m_janneWikiSession;
     }
 
     public TestEngine( Properties props )
         throws WikiException
     {
-        super( newServletContext( "test" ) , "test", props );
+        super( new MockServletContext( "test" ), "test", props );
         
         // Stash the WikiEngine in the servlet context
-        MockServletContext servletContext = this.getServletContext();
+        MockServletContext servletContext = (MockServletContext)this.getServletContext();
         servletContext.setAttribute("com.ecyrd.jspwiki.WikiEngine", this);
-    
-        // Add our preferred Stripes startup parameters
-        Map<String, String> filterParams = new HashMap<String, String>();
-        filterParams.put("Configuration.Class", "com.ecyrd.jspwiki.ui.WikiRuntimeConfiguration");
-        filterParams.put("ActionResolver.UrlFilters", "build/");
-        filterParams.put("ActionResolver.PackageFilters", "com.ecyrd.jspwiki");
-        filterParams.put("ActionBeanContext.Class", "com.ecyrd.jspwiki.action.WikiActionBeanContext");
-        filterParams.put("Interceptor.Classes", "com.ecyrd.jspwiki.ui.WikiInterceptor,net.sourceforge.stripes.controller.BeforeAfterMethodInterceptor");
-        filterParams.put("ExceptionHandler.Class", "net.sourceforge.stripes.exception.DefaultExceptionHandler");
         
-        // Add a captive Stripes Filter and Stripes Dispatcher to the servlet context
+        // Add mock StripesFilter and WikiServletfilter and to servlet config
+        Map<String,String> filterParams = new HashMap<String,String>();
+        filterParams.put("ActionResolver.Packages", "com.ecyrd.jspwiki.action");
+        filterParams.put("Extension.Packages", "com.ecyrd.jspwiki.action");
+        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);
-    }
 
+        // Set up long-running admin session
+        HttpServletRequest request = newHttpRequest();
+        m_adminWikiSession = WikiSession.getWikiSession( this, request );
+        this.getAuthenticationManager().login( m_adminWikiSession,
+                Users.ADMIN,
+                Users.ADMIN_PASS );
+        m_adminSession = request.getSession();
+
+        // Set up a test Janne session
+        request = newHttpRequest();
+        m_janneWikiSession = WikiSession.getWikiSession( this, request );
+        this.getAuthenticationManager().login( m_janneWikiSession,
+                Users.JANNE,
+                Users.JANNE_PASS );
+        m_janneSession = request.getSession();
+
+        // Set up guest session
+        request = newHttpRequest();
+        m_guestWikiSession = WikiSession.getWikiSession( this, request );
+    }
+    
     /**
-     * Creates a mock servlet context used to initialize the test WikiEngine.
-     * @return the initialized servlet context
+     * Creates a correctly-instantiated mock HttpServletRequest with an associated
+     * HttpSession.
+     * @return the new request
      */
-    private static MockServletContext newServletContext( String name )
+    public MockHttpServletRequest newHttpRequest()
     {
-        MockServletContext servletContext = new MockServletContext( name );
-        return servletContext;
+        return newHttpRequest( "/Wiki.jsp" );
     }
-    
-    public static void emptyPageDir()
-    {
-        Properties properties = new Properties();
-
-        try
-        {
-            properties.load( findTestProperties() );
 
-            String pagedir = properties.getProperty( AbstractFileProvider.PROP_PAGEDIR );
-            if( pagedir != null )
-            {
-                File f = new File( pagedir );
-
-                if( f.exists() && f.isDirectory() )
-                {
-                    deleteAll( f );
-                }
-            }
-        }
-        catch( IOException e ) {} // Fine
+    /**
+     * 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() ) );
+        return request;
     }
-
+    
     public static void emptyWorkDir()
     {
         Properties properties = new Properties();
@@ -336,14 +311,12 @@
         throws WikiException
     {
         // Build new request and associate our admin session
-        MockRoundtrip trip = guestTrip( ViewActionBean.class );
-        MockHttpServletRequest request = trip.getRequest();
-        WikiSession session = WikiSession.getWikiSession( this, request );
-        this.getAuthenticationManager().login( session, Users.ADMIN, Users.ADMIN_PASS );
+        MockHttpServletRequest request = new MockHttpServletRequest( "/JSPWiki", "/Wiki.jsp" );
+        request.setSession( m_adminSession );
 
         // Create page and wiki context
         WikiPage page = new WikiPage( this, pageName );
-        WikiContext context = this.getWikiActionBeanFactory().newViewActionBean( trip.getRequest(), trip.getResponse(), page );
+        WikiContext context = getWikiActionBeanFactory().newViewActionBean( request, (HttpServletResponse)null, page );
         saveText( context, content );
     }
 
@@ -351,87 +324,93 @@
         throws WikiException
     {
         // Build new request and associate our Janne session
-        MockRoundtrip trip = guestTrip( ViewActionBean.class );
-        MockHttpServletRequest request = trip.getRequest();
-        WikiSession session = WikiSession.getWikiSession( this, request );
-        this.getAuthenticationManager().login( session, Users.JANNE, Users.JANNE_PASS );
+        MockHttpServletRequest request = new MockHttpServletRequest( "/JSPWiki", "/Wiki.jsp" );
+        request.setSession( m_janneSession );
 
         // Create page and wiki context
         WikiPage page = new WikiPage( this, pageName );
-        WikiContext context = this.getWikiActionBeanFactory().newViewActionBean( trip.getRequest(), trip.getResponse(), page );
+        WikiContext context = getWikiActionBeanFactory().newViewActionBean( request, (HttpServletResponse)null, page );
         saveText( context, content );
     }
 
-    /**
-     *  Returns the converted HTML of the page using a different
-     *  context than the default context.
-     *
-     *  @param  context A WikiContext in which you wish to render this page in.
-     *  @param  page WikiPage reference.
-     *  @return HTML-rendered version of the page.
-     */
-    @Override
-    public String getHTML( WikiContext context, WikiPage page )
+    public static void trace()
     {
-        // If needed, inject a mock request/response into the ActionBeanContext
-        WikiActionBeanContext wac = context.getContext();
-        if ( wac.getRequest() == null || wac.getResponse() == null )
+        try
         {
-            MockRoundtrip trip = guestTrip( context.getClass() );
-            wac.setRequest( trip.getRequest() );
-            wac.setResponse( trip.getResponse() );
+            throw new Exception("Foo");
+        }
+        catch( Exception e )
+        {
+            e.printStackTrace();
         }
-        return super.getHTML( context, page );
     }
-
+    
     /**
-     *  Returns the converted HTML of the page.
-     *
-     *  @param page WikiName of the page to convert.
-     *  @return HTML-rendered version of the page.
+     * Creates a guest "round trip" object that initializes itself with the TestEngine's mock servlet context,
+     * plus a new mock request, mock response and action bean of type {@link com.ecyrd.jspwiki.action.ViewActionBean}.
+     * 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 beanClass the Stripes action bean to start with
+     * @return the mock rountrip
      */
-    @Override
-    public String getHTML( String page )
+    public MockRoundtrip guestTrip( Class<? extends WikiActionBean> beanClass )
     {
-        return getHTML( page, WikiPageProvider.LATEST_VERSION );
+        return new MockRoundtrip( (MockServletContext)getServletContext(), beanClass );
     }
 
     /**
-     *  Returns the converted HTML of the page's specific version.
-     *  The version must be a positive integer, otherwise the current
-     *  version is returned.
-     *
-     *  @param pagename WikiName of the page to convert.
-     *  @param version Version number to fetch
-     *  @return HTML-rendered page text.
+     * Creates a "round trip" object initialized with a supplied set of credentials. The WikiSession
+     * associated with the created MockRoundtrip object will have privileges appropriate for
+     * the credentials supplied.
+     * @param user the login name
+     * @param password the password
+     * @param beanClass the Stripes action bean to start with
+     * @return the initialized round trip
+     * @throws WikiSecurityException
      */
-    @Override
-    public String getHTML( String pagename, int version )
+    public MockRoundtrip authenticatedTrip( String user, String password, Class<? extends WikiActionBean> beanClass ) throws WikiSecurityException
     {
-        WikiPage page = getPage( pagename, version );
-
-        WikiContext context = getWikiActionBeanFactory().newViewActionBean( page );
-
-        String res = getHTML( context, page );
-
-        return res;
+        MockRoundtrip trip = new MockRoundtrip( (MockServletContext)getServletContext(), beanClass );
+        MockHttpServletRequest request = trip.getRequest();
+        WikiSession session = WikiSession.getWikiSession( this, request);
+        this.getAuthenticationManager().login( session, Users.ADMIN, Users.ADMIN_PASS );
+        return trip;
     }
     
-    @Override
-    public MockServletContext getServletContext()
-    {
-        return (MockServletContext)super.getServletContext();
-    }
+    /**
+     * Static single instance of the mock servlet.
+     */
+    private static final Servlet MOCK_SERVLET = new MockServlet();
 
-    public static void trace()
+    /**
+     * Captive servlet class that does absolutely nothing. Used by
+     * MockRoundtrip.
+     */
+    protected static class MockServlet extends HttpServlet
     {
-        try
+        private static final long serialVersionUID = 1L;
+        
+        private ServletConfig m_config;
+        
+        public MockServlet()
         {
-            throw new Exception("Foo");
         }
-        catch( Exception e )
+
+        public ServletConfig getServletConfig()
         {
-            e.printStackTrace();
+            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/TestJDBCDataSource.java
URL: http://svn.apache.org/viewvc/incubator/jspwiki/branches/JSPWIKI_2_9_STRIPES_BRANCH/tests/com/ecyrd/jspwiki/TestJDBCDataSource.java?rev=682151&r1=682150&r2=682151&view=diff
==============================================================================
--- incubator/jspwiki/branches/JSPWIKI_2_9_STRIPES_BRANCH/tests/com/ecyrd/jspwiki/TestJDBCDataSource.java (original)
+++ incubator/jspwiki/branches/JSPWIKI_2_9_STRIPES_BRANCH/tests/com/ecyrd/jspwiki/TestJDBCDataSource.java Sun Aug  3 05:28:09 2008
@@ -126,8 +126,8 @@
     /**
      * Initialization method that reads a File, and attempts to locate and load
      * the JDBC driver from properties specified therein.
-     * @throws SQLException
      * @param file the file containing the JDBC properties
+     * @throws SQLException
      */
     protected void initializeJDBC( File file ) throws Exception
     {
@@ -150,8 +150,8 @@
 
         // Load the driver using the sytem class loader
         final ClassLoader parent = ClassLoader.getSystemClassLoader();
-        URLClassLoader loader = (URLClassLoader)AccessController.doPrivileged( new PrivilegedAction() {
-            public Object run() {
+        URLClassLoader loader = AccessController.doPrivileged( new PrivilegedAction<URLClassLoader>() {
+            public URLClassLoader run() {
                 return new URLClassLoader( new URL[] { driverURL }, parent );
             }
         });

Modified: incubator/jspwiki/branches/JSPWIKI_2_9_STRIPES_BRANCH/tests/com/ecyrd/jspwiki/TestJNDIContext.java
URL: http://svn.apache.org/viewvc/incubator/jspwiki/branches/JSPWIKI_2_9_STRIPES_BRANCH/tests/com/ecyrd/jspwiki/TestJNDIContext.java?rev=682151&r1=682150&r2=682151&view=diff
==============================================================================
--- incubator/jspwiki/branches/JSPWIKI_2_9_STRIPES_BRANCH/tests/com/ecyrd/jspwiki/TestJNDIContext.java (original)
+++ incubator/jspwiki/branches/JSPWIKI_2_9_STRIPES_BRANCH/tests/com/ecyrd/jspwiki/TestJNDIContext.java Sun Aug  3 05:28:09 2008
@@ -4,11 +4,7 @@
 import java.util.Hashtable;
 import java.util.Map;
 
-import javax.naming.Context;
-import javax.naming.Name;
-import javax.naming.NameParser;
-import javax.naming.NamingEnumeration;
-import javax.naming.NamingException;
+import javax.naming.*;
 import javax.naming.spi.InitialContextFactory;
 
 /**
@@ -37,7 +33,7 @@
 public class TestJNDIContext implements Context
 {
 
-    private final Map      m_bindings  = new HashMap();
+    private final Map<String, Object> m_bindings  = new HashMap<String, Object>();
 
     private static boolean initialized = false;
 
@@ -171,6 +167,7 @@
      * No-op; always returns <code>null</code>.
      * @see javax.naming.Context#getEnvironment()
      */
+    @SuppressWarnings("unchecked")
     public Hashtable getEnvironment() throws NamingException
     {
         // TODO Auto-generated method stub
@@ -208,7 +205,7 @@
      * No-op; always returns <code>null</code>.
      * @see javax.naming.Context#list(javax.naming.Name)
      */
-    public NamingEnumeration list( Name name ) throws NamingException
+    public NamingEnumeration<NameClassPair> list( Name name ) throws NamingException
     {
         return null;
     }
@@ -217,7 +214,7 @@
      * No-op; always returns <code>null</code>.
      * @see javax.naming.Context#list(java.lang.String)
      */
-    public NamingEnumeration list( String name ) throws NamingException
+    public NamingEnumeration<NameClassPair> list( String name ) throws NamingException
     {
         return null;
     }
@@ -226,7 +223,7 @@
      * No-op; always returns <code>null</code>.
      * @see javax.naming.Context#listBindings(javax.naming.Name)
      */
-    public NamingEnumeration listBindings( Name name ) throws NamingException
+    public NamingEnumeration<Binding> listBindings( Name name ) throws NamingException
     {
         return null;
     }
@@ -235,7 +232,7 @@
      * No-op; always returns <code>null</code>.
      * @see javax.naming.Context#listBindings(java.lang.String)
      */
-    public NamingEnumeration listBindings( String name ) throws NamingException
+    public NamingEnumeration<Binding> listBindings( String name ) throws NamingException
     {
         return null;
     }

Modified: incubator/jspwiki/branches/JSPWIKI_2_9_STRIPES_BRANCH/tests/com/ecyrd/jspwiki/TextUtilTest.java
URL: http://svn.apache.org/viewvc/incubator/jspwiki/branches/JSPWIKI_2_9_STRIPES_BRANCH/tests/com/ecyrd/jspwiki/TextUtilTest.java?rev=682151&r1=682150&r2=682151&view=diff
==============================================================================
--- incubator/jspwiki/branches/JSPWIKI_2_9_STRIPES_BRANCH/tests/com/ecyrd/jspwiki/TextUtilTest.java (original)
+++ incubator/jspwiki/branches/JSPWIKI_2_9_STRIPES_BRANCH/tests/com/ecyrd/jspwiki/TextUtilTest.java Sun Aug  3 05:28:09 2008
@@ -144,6 +144,41 @@
 
         assertEquals( "afafaf", TextUtil.replaceString( text, "b", "f" ) ); 
     }
+    
+    public void testReplaceStringCaseUnsensitive1()
+    {
+        String text = "aABcAa";
+
+        assertEquals( "ddBcdd", TextUtil.replaceStringCaseUnsensitive( text, "aa", "dd" ) ); 
+    }
+
+    public void testReplaceStringCaseUnsensitive2()
+    {
+        String text = "Abcde";
+
+        assertEquals( "fbcde", TextUtil.replaceStringCaseUnsensitive( text, "a", "f" ) ); 
+    }
+
+    public void testReplaceStringCaseUnsensitive3()
+    {
+        String text = "aBAbab";
+
+        assertEquals( "afAfaf", TextUtil.replaceStringCaseUnsensitive( text, "b", "f" ) ); 
+    }
+    
+    public void testReplaceStringCaseUnsensitive4()
+    {
+        String text = "AaBAcAAfaa";
+
+        assertEquals( "ddBAcddfdd", TextUtil.replaceStringCaseUnsensitive( text, "aa", "dd" ) ); 
+    }
+
+    public void testReplaceStringCaseUnsensitive5()
+    {
+        String text = "aAaBaCAAafaa";
+
+        assertEquals( "dBaCdfaa", TextUtil.replaceStringCaseUnsensitive( text, "aaa", "d" ) );     
+    }
 
     // Pure UNIX.
     public void testNormalizePostdata1()

Modified: incubator/jspwiki/branches/JSPWIKI_2_9_STRIPES_BRANCH/tests/com/ecyrd/jspwiki/VariableManagerTest.java
URL: http://svn.apache.org/viewvc/incubator/jspwiki/branches/JSPWIKI_2_9_STRIPES_BRANCH/tests/com/ecyrd/jspwiki/VariableManagerTest.java?rev=682151&r1=682150&r2=682151&view=diff
==============================================================================
--- incubator/jspwiki/branches/JSPWIKI_2_9_STRIPES_BRANCH/tests/com/ecyrd/jspwiki/VariableManagerTest.java (original)
+++ incubator/jspwiki/branches/JSPWIKI_2_9_STRIPES_BRANCH/tests/com/ecyrd/jspwiki/VariableManagerTest.java Sun Aug  3 05:28:09 2008
@@ -29,7 +29,7 @@
 
             m_variableManager = new VariableManager( props );
             TestEngine testEngine = new TestEngine( props );
-            m_context = testEngine.getWikiActionBeanFactory().newViewActionBean( new WikiPage( testEngine, PAGE_NAME ) );
+            m_context = testEngine.getWikiActionBeanFactory().newViewActionBean( null, null, new WikiPage( testEngine, PAGE_NAME ) );
 
         }
         catch( IOException e ) {}

Modified: incubator/jspwiki/branches/JSPWIKI_2_9_STRIPES_BRANCH/tests/com/ecyrd/jspwiki/WikiEngineTest.java
URL: http://svn.apache.org/viewvc/incubator/jspwiki/branches/JSPWIKI_2_9_STRIPES_BRANCH/tests/com/ecyrd/jspwiki/WikiEngineTest.java?rev=682151&r1=682150&r2=682151&view=diff
==============================================================================
--- incubator/jspwiki/branches/JSPWIKI_2_9_STRIPES_BRANCH/tests/com/ecyrd/jspwiki/WikiEngineTest.java (original)
+++ incubator/jspwiki/branches/JSPWIKI_2_9_STRIPES_BRANCH/tests/com/ecyrd/jspwiki/WikiEngineTest.java Sun Aug  3 05:28:09 2008
@@ -889,7 +889,7 @@
         Collection pages = m_engine.getReferenceManager().findReferrers( "RenameBugTestPage" );
         assertEquals( "has one", "OldNameTestPage", pages.iterator().next() );
         
-        WikiContext ctx = m_engine.getWikiActionBeanFactory().newViewActionBean( m_engine.getPage("OldNameTestPage") );
+        WikiContext ctx = m_engine.getWikiActionBeanFactory().newViewActionBean( null, null, m_engine.getPage("OldNameTestPage") );
         
         m_engine.renamePage( ctx, "OldNameTestPage", "NewNameTestPage", true );
             
@@ -907,7 +907,7 @@
     {
         WikiPage p = new WikiPage( m_engine, NAME1 );
     
-        WikiContext context = m_engine.getWikiActionBeanFactory().newViewActionBean( p );
+        WikiContext context = m_engine.getWikiActionBeanFactory().newViewActionBean( null, null, p );
 
         context.getPage().setAttribute( WikiPage.CHANGENOTE, "Test change" );
         
@@ -927,5 +927,61 @@
     
         assertEquals( null, p3.getAttribute(WikiPage.CHANGENOTE) );
     }
+    
+    public void testCreatePage() throws Exception 
+    {
+        String text = "Foobar.\r\n";
+        String name = "mrmyxpltz";
+        
+        assertEquals( "page should not exist right now",
+                      false,
+                      m_engine.pageExists( name ) );
+
+        m_engine.saveText( name, text );
+
+        assertEquals( "page does not exist",
+                      true,
+                      m_engine.pageExists( name ) );
+    }
+    
+    public void testCreateEmptyPage() throws Exception 
+    {
+        String text = "";
+        String name = "mrmxyzptlk";
+        
+        assertEquals( "page should not exist right now",
+                      false,
+                      m_engine.pageExists( name ) );
+
+        m_engine.saveText( name, text );
+
+        assertEquals( "page should not exist right now neither",
+                      false,
+                      m_engine.pageExists( name ) );
+    }
+    
+    public void testSaveExistingPageWithEmptyContent() throws Exception 
+    {
+        String text = "Foobar.\r\n";
+        String name = NAME1;
+        
+        m_engine.saveText( name, text );
+
+        assertEquals( "page does not exist",
+                      true,
+                      m_engine.pageExists( name ) );
+        
+        // saveText uses normalizePostData to assure it conforms to certain rules
+        assertEquals( "wrong content",
+                      TextUtil.normalizePostData( text ),
+                      m_engine.getText( name ) );
+        
+        m_engine.saveText( name, "" );
+        
+        assertEquals( "wrong content",
+                      TextUtil.normalizePostData( "" ), 
+                      m_engine.getText( name ) );
+        
+    }
 
 }

Modified: incubator/jspwiki/branches/JSPWIKI_2_9_STRIPES_BRANCH/tests/com/ecyrd/jspwiki/WikiSessionTest.java
URL: http://svn.apache.org/viewvc/incubator/jspwiki/branches/JSPWIKI_2_9_STRIPES_BRANCH/tests/com/ecyrd/jspwiki/WikiSessionTest.java?rev=682151&r1=682150&r2=682151&view=diff
==============================================================================
--- incubator/jspwiki/branches/JSPWIKI_2_9_STRIPES_BRANCH/tests/com/ecyrd/jspwiki/WikiSessionTest.java (original)
+++ incubator/jspwiki/branches/JSPWIKI_2_9_STRIPES_BRANCH/tests/com/ecyrd/jspwiki/WikiSessionTest.java Sun Aug  3 05:28:09 2008
@@ -1,28 +1,30 @@
 package com.ecyrd.jspwiki;
 
+import java.io.IOException;
 import java.security.Principal;
 import java.util.HashSet;
 import java.util.Properties;
 import java.util.Set;
 
+import javax.servlet.*;
 import javax.servlet.http.Cookie;
+import javax.servlet.http.HttpServletRequest;
 
 import junit.framework.Test;
 import junit.framework.TestCase;
 import junit.framework.TestSuite;
-import net.sourceforge.stripes.action.UrlBinding;
-import net.sourceforge.stripes.mock.MockHttpServletRequest;
-import net.sourceforge.stripes.mock.MockHttpSession;
-import net.sourceforge.stripes.mock.MockRoundtrip;
+
+import net.sourceforge.stripes.mock.*;
 
 import org.apache.commons.lang.ArrayUtils;
 
-import com.ecyrd.jspwiki.action.ViewActionBean;
 import com.ecyrd.jspwiki.auth.AuthenticationManager;
 import com.ecyrd.jspwiki.auth.Users;
 import com.ecyrd.jspwiki.auth.WikiPrincipal;
 import com.ecyrd.jspwiki.auth.authorize.Role;
 import com.ecyrd.jspwiki.auth.login.CookieAssertionLoginModule;
+import com.ecyrd.jspwiki.auth.login.CookieAuthenticationLoginModule;
+import com.ecyrd.jspwiki.ui.WikiServletFilter;
 
 public class WikiSessionTest extends TestCase
 {
@@ -103,66 +105,107 @@
         assertFalse( WikiSession.isIPV4Address( "..." ) );
     }
     
-    public void testIsContainerStatusChanged()
+    public void testIPAddress() throws ServletException, IOException
     {
-        MockRoundtrip trip;
-        MockHttpSession session;
         MockHttpServletRequest request;
         WikiSession wikiSession;
-        String servletContext;
         
-        // A naked HTTP request without userPrincipal/remoteUser shouldn't count as changed
-        trip = m_engine.guestTrip( ViewActionBean.class );
-        request = trip.getRequest();
-        session = (MockHttpSession)request.getSession();
-        servletContext = "/" + m_engine.getServletContext().getServletContextName();
+        // A naked HTTP request without userPrincipal/remoteUser should be anonymous
+        request = m_engine.newHttpRequest();
         request.setUserPrincipal( null );
+        runSecurityFilter(m_engine, request);
         wikiSession = WikiSession.getWikiSession( m_engine, request );
-        assertFalse( wikiSession.isContainerStatusChanged( request ) );
-        
-        // Changing the UserPrincipal value should trigger a change...
-        request = new MockHttpServletRequest(servletContext, ViewActionBean.class.getAnnotation(UrlBinding.class).value());
-        request.setSession(session);
-        request.setUserPrincipal( new WikiPrincipal( "Fred Flintstone") );
-        assertTrue( wikiSession.isContainerStatusChanged( request ) );
+        assertTrue( wikiSession.isAnonymous());
+    }
+    
+    public void testUserPrincipal() throws ServletException, IOException
+    {
+        MockHttpServletRequest request;
+        WikiSession wikiSession;
         
-        // ...but if the next request has the same UserPrincipal, it shouldn't.
-        request = new MockHttpServletRequest(servletContext, ViewActionBean.class.getAnnotation(UrlBinding.class).value());
-        request.setSession(session);
-        request = m_engine.guestTrip( ViewActionBean.class ).getRequest();
+        // Changing the UserPrincipal value should cause the user to be authenticated...
+        request = m_engine.newHttpRequest();
         request.setUserPrincipal( new WikiPrincipal( "Fred Flintstone") );
-        assertFalse( wikiSession.isContainerStatusChanged( request ) );
+        runSecurityFilter(m_engine, request);
+        wikiSession = WikiSession.getWikiSession( m_engine, request );
+        assertTrue( wikiSession.isAuthenticated());
+        assertEquals( "Fred Flintstone", wikiSession.getUserPrincipal().getName() );
+    }
         
-        // If we twiddle the remoteUser field, it should trigger a change again...
-        request = new MockHttpServletRequest(servletContext, ViewActionBean.class.getAnnotation(UrlBinding.class).value());
-        request.setSession(session);
-        request.setUserPrincipal( new WikiPrincipal( "Fred") );
-        assertTrue( wikiSession.isContainerStatusChanged( request ) );
-        
-        // ...but not if we follow up with a similar request again.
-        request = new MockHttpServletRequest(servletContext, ViewActionBean.class.getAnnotation(UrlBinding.class).value());
-        request.setSession(session);
-        request.setUserPrincipal( new WikiPrincipal( "Fred") );
-        assertFalse( wikiSession.isContainerStatusChanged( request ) );
-        
-        // And finally, if we null the UserPrincipal again, 
-        // it should not trigger a change.
-        request = new MockHttpServletRequest(servletContext, ViewActionBean.class.getAnnotation(UrlBinding.class).value());
-        request.setSession(session);
-        request.setUserPrincipal( null );
-        assertFalse( wikiSession.isContainerStatusChanged( request ) );
+    public void testAssertionCookie() throws ServletException, IOException
+    {
+        MockHttpServletRequest request;
+        WikiSession wikiSession;
         
-        // Adding the magic "assertion cookie" should trigger a change in status.
-        request = new MockHttpServletRequest(servletContext, ViewActionBean.class.getAnnotation(UrlBinding.class).value());
-        request.setSession(session);
+        // Adding the magic "assertion cookie" should  set asserted status.
+        request = m_engine.newHttpRequest();
         request.setUserPrincipal( null );
         String cookieName = CookieAssertionLoginModule.PREFS_COOKIE_NAME;
-        request.setCookies( new Cookie[] { new Cookie( cookieName, "FredFlintstone" ) });
-        assertTrue( wikiSession.isContainerStatusChanged( request ) );
+        request.setCookies( new Cookie[] { new Cookie( cookieName, "FredFlintstone" ) } );
+        runSecurityFilter(m_engine, request);
+        wikiSession = WikiSession.getWikiSession( m_engine, request );
+        assertTrue( wikiSession.isAsserted());
+        assertEquals( "FredFlintstone", wikiSession.getUserPrincipal().getName() );
     }
 
-    public void testGetStatus()
+    public void testAuthenticationCookieDefaults() throws ServletException, IOException
     {
+        MockHttpServletRequest request;
+        WikiSession wikiSession;
+        
+        // Set the authentication cookie first
+        MockHttpServletResponse response = new MockHttpServletResponse();
+        CookieAuthenticationLoginModule.setLoginCookie( m_engine, response, "Fred Flintstone" );
+        Cookie[] cookies = response.getCookies();
+        assertEquals(1, cookies.length);
+        String uid = cookies[0].getValue();
+        
+        // Adding the magic "authentication cookie" should NOT count as authenticated in the default case
+        // (because cookie authentication is OFF).
+        request = m_engine.newHttpRequest();
+        request.setUserPrincipal( null );
+        request.setCookies( new Cookie[] { new Cookie( "JSPWikiUID", uid ) } );
+        runSecurityFilter(m_engine, request);
+        wikiSession = WikiSession.getWikiSession( m_engine, request );
+        assertTrue( wikiSession.isAnonymous());
+        assertFalse( wikiSession.isAuthenticated());
+        assertEquals( "127.0.0.1", wikiSession.getUserPrincipal().getName() );
+        
+        // Clear the authentication cookie
+        response = new MockHttpServletResponse();
+        CookieAuthenticationLoginModule.clearLoginCookie( m_engine, request, response );
+    }
+    
+    public void testAuthenticationCookieWhenOn() throws WikiException, ServletException, IOException
+    {
+        Properties props = new Properties();
+        props.load( TestEngine.findTestProperties() );
+        props.setProperty( AuthenticationManager.PROP_ALLOW_COOKIE_AUTH, "true");
+        m_engine = new TestEngine( props );
+        
+        MockHttpServletRequest request;
+        WikiSession wikiSession;
+        
+        // Set the authentication cookie first
+        MockHttpServletResponse response = new MockHttpServletResponse();
+        CookieAuthenticationLoginModule.setLoginCookie( m_engine, response, "Fred Flintstone" );
+        Cookie[] cookies = response.getCookies();
+        assertEquals(1, cookies.length);
+        String uid = cookies[0].getValue();
+        
+        // Adding the magic "authentication cookie" should count as authenticated
+        request = m_engine.newHttpRequest();
+        request.setUserPrincipal( null );
+        request.setCookies( new Cookie[] { new Cookie( "JSPWikiUID", uid ) } );
+        runSecurityFilter(m_engine, request);
+        wikiSession = WikiSession.getWikiSession( m_engine, request );
+        assertFalse( wikiSession.isAnonymous());
+        assertTrue( wikiSession.isAuthenticated());
+        assertEquals( "Fred Flintstone", wikiSession.getUserPrincipal().getName() );
+        
+        // Clear the authentication cookie
+        response = new MockHttpServletResponse();
+        CookieAuthenticationLoginModule.clearLoginCookie( m_engine, request, response );
     }
     
     /**
@@ -174,18 +217,13 @@
     public static WikiSession anonymousSession( TestEngine engine ) throws Exception
     {
         // Build anon session
-        MockHttpServletRequest request = engine.guestTrip( ViewActionBean.class ).getRequest();
+        MockHttpServletRequest request = engine.newHttpRequest();
         
         // Log in
-        boolean loggedIn = engine.getAuthenticationManager().login( request );
-        if ( !loggedIn )
-        {
-            throw new IllegalStateException( "Couldn't set up anonymous user." );
-        }
-        
-        WikiSession session = WikiSession.getWikiSession( engine, request );
+        runSecurityFilter( engine, request );
         
         // Make sure the user is actually anonymous
+        WikiSession session = WikiSession.getWikiSession( engine, request );
         if ( !session.isAnonymous() )
         {
             throw new IllegalStateException( "Session is not anonymous." );
@@ -201,13 +239,13 @@
     public static WikiSession assertedSession( TestEngine engine, String name, Principal[] roles ) throws Exception
     {
         // We can use cookies right?
-        if ( !AuthenticationManager.allowsCookieAssertions() )
+        if ( !engine.getAuthenticationManager().allowsCookieAssertions() )
         {
             throw new IllegalStateException( "Couldn't set up asserted user: login config doesn't allow cookies." );
         }
         
         // Build anon session
-        MockHttpServletRequest request = engine.guestTrip( ViewActionBean.class ).getRequest();
+        MockHttpServletRequest request = engine.newHttpRequest();
         Set<String> r = new HashSet<String>();
         for ( int i = 0; i < roles.length; i++ )
         {
@@ -220,19 +258,10 @@
         request.setCookies( new Cookie[] { cookie } );
         
         // Log in
-        boolean loggedIn = engine.getAuthenticationManager().login( request );
-        if ( !loggedIn )
-        {
-            throw new IllegalStateException( "Couldn't log in asserted user." );
-        }
-        
-        WikiSession session = WikiSession.getWikiSession( engine, request );
+        runSecurityFilter(engine, request);
         
         // Make sure the user is actually asserted
-        if ( !session.hasPrincipal( Role.ASSERTED ) )
-        {
-            throw new IllegalStateException( "Didn't find Role.ASSERTED in session." );
-        }
+        WikiSession session = WikiSession.getWikiSession( engine, request );
         return session;
     }
     
@@ -244,18 +273,13 @@
     public static WikiSession authenticatedSession( TestEngine engine, String id, String password ) throws Exception
     {
         // Build anon session
-        MockHttpServletRequest request = engine.guestTrip( ViewActionBean.class ).getRequest();
+        MockHttpServletRequest request = engine.newHttpRequest();
         
         // Log in as anon
-        boolean loggedIn = engine.getAuthenticationManager().login( request );
-        if ( !loggedIn )
-        {
-            throw new IllegalStateException( "Couldn't log in anonymous user." );
-        }
-        
-        WikiSession session = WikiSession.getWikiSession( engine, request );
+        runSecurityFilter(engine, request);
         
         // Log in the user with credentials
+        WikiSession session = WikiSession.getWikiSession( engine, request );
         engine.getAuthenticationManager().login( session, id, password );
         
         // Make sure the user is actually authenticated
@@ -269,7 +293,7 @@
     public static WikiSession containerAuthenticatedSession( TestEngine engine, String id, Principal[] roles ) throws Exception
     {
         // Build container session
-        MockHttpServletRequest request = engine.guestTrip( ViewActionBean.class ).getRequest();
+        MockHttpServletRequest request = engine.newHttpRequest();
         Set<String> r = new HashSet<String>();
         for ( int i = 0; i < roles.length; i++ )
         {
@@ -278,26 +302,71 @@
         request.setRoles( r );
         request.setUserPrincipal( new WikiPrincipal( id ) );
         
-        // Log in as anon
-        boolean loggedIn = engine.getAuthenticationManager().login( request );
-        if ( !loggedIn )
-        {
-            throw new IllegalStateException( "Couldn't log in anonymous user." );
-        }
-        
-        WikiSession session = WikiSession.getWikiSession( engine, request );
-        
-        // Log in the user with credentials
-        engine.getAuthenticationManager().login( request );
+        // Log in
+        runSecurityFilter(engine,request);
         
         // Make sure the user is actually authenticated
+        WikiSession session = WikiSession.getWikiSession( engine, request );
         if ( !session.isAuthenticated() )
         {
             throw new IllegalStateException( "Could not log in authenticated user '" + id + "'" );
         }
         return session;
     }
+    
+    /**
+     * "Scaffolding" method that runs the session security filter on a mock request. We do this by creating a
+     * complete mock servlet context and filter chain, and running the request through it. 
+     * @param engine the wiki engine
+     * @param request the mock request to pass itnto the 
+     * @throws ServletException
+     * @throws IOException
+     */
+    private static void runSecurityFilter(WikiEngine engine, HttpServletRequest request) throws ServletException, IOException
+    {
+        // Create a mock servlet context and stash the wiki engine in it
+        ServletContext servletCtx = new MockServletContext( "JSPWiki" );
+        servletCtx.setAttribute( "com.ecyrd.jspwiki.WikiEngine", engine );
+        
+        // Create a mock filter configuration and add the servlet context we just created
+        MockFilterConfig filterConfig = new MockFilterConfig();
+        filterConfig.setFilterName( "WikiServletFilter" );
+        filterConfig.setServletContext( servletCtx );
+        
+        // Create the security filter and run the request  through it
+        Filter filter = new WikiServletFilter();
+        MockFilterChain chain = new MockFilterChain();
+        chain.addFilter( filter );
+        Servlet servlet = new MockServlet();
+        chain.setServlet( servlet );
+        filter.init(filterConfig);
+        filter.doFilter(request, null, chain );
+    }
+
+    private static class MockServlet implements Servlet
+    {
+        private ServletConfig m_config;
+        
+        public void destroy() { }
+
+        public ServletConfig getServletConfig()
+        {
+            return m_config;
+        }
+
+        public String getServletInfo()
+        {
+            return "Mock servlet";
+        }
 
+        public void init( ServletConfig config ) throws ServletException
+        {
+            m_config = config;
+        }
+
+        public void service( ServletRequest request, ServletResponse response ) throws ServletException, IOException { }
+    }
+    
     public static Test suite() 
     {
         return new TestSuite( WikiSessionTest.class );

Modified: incubator/jspwiki/branches/JSPWIKI_2_9_STRIPES_BRANCH/tests/com/ecyrd/jspwiki/action/AllTests.java
URL: http://svn.apache.org/viewvc/incubator/jspwiki/branches/JSPWIKI_2_9_STRIPES_BRANCH/tests/com/ecyrd/jspwiki/action/AllTests.java?rev=682151&r1=682150&r2=682151&view=diff
==============================================================================
--- incubator/jspwiki/branches/JSPWIKI_2_9_STRIPES_BRANCH/tests/com/ecyrd/jspwiki/action/AllTests.java (original)
+++ incubator/jspwiki/branches/JSPWIKI_2_9_STRIPES_BRANCH/tests/com/ecyrd/jspwiki/action/AllTests.java Sun Aug  3 05:28:09 2008
@@ -14,7 +14,8 @@
     {
         TestSuite suite = new TestSuite("ActionBean tests");
 
-        suite.addTest( EventPermissionInfoTest.suite() );
+        suite.addTest( GroupActionBeanTest.suite() );
+        suite.addTest( HandlerInfoTest.suite() );
         suite.addTest( RenameActionBeanTest.suite() );
         suite.addTest( UserPreferencesActionBeanTest.suite() );
         suite.addTest( UserProfileActionBeanTest.suite() );

Added: 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=682151&view=auto
==============================================================================
--- incubator/jspwiki/branches/JSPWIKI_2_9_STRIPES_BRANCH/tests/com/ecyrd/jspwiki/action/GroupActionBeanTest.java (added)
+++ incubator/jspwiki/branches/JSPWIKI_2_9_STRIPES_BRANCH/tests/com/ecyrd/jspwiki/action/GroupActionBeanTest.java Sun Aug  3 05:28:09 2008
@@ -0,0 +1,64 @@
+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
+{
+    TestEngine m_engine;
+
+    public void setUp()
+    {
+        // Start the WikiEngine, and stash reference
+        Properties props = new Properties();
+        try
+        {
+            props.load( TestEngine.findTestProperties() );
+            m_engine = new TestEngine( props );
+        }
+        catch( Exception e )
+        {
+            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()
+    {
+        return new TestSuite( GroupActionBeanTest.class );
+    }
+}

Added: 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=682151&view=auto
==============================================================================
--- incubator/jspwiki/branches/JSPWIKI_2_9_STRIPES_BRANCH/tests/com/ecyrd/jspwiki/action/HandlerInfoTest.java (added)
+++ incubator/jspwiki/branches/JSPWIKI_2_9_STRIPES_BRANCH/tests/com/ecyrd/jspwiki/action/HandlerInfoTest.java Sun Aug  3 05:28:09 2008
@@ -0,0 +1,183 @@
+package com.ecyrd.jspwiki.action;
+
+import java.lang.reflect.Method;
+import java.security.Permission;
+import java.util.Map;
+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 com.ecyrd.jspwiki.TestEngine;
+import com.ecyrd.jspwiki.auth.permissions.GroupPermission;
+import com.ecyrd.jspwiki.auth.permissions.WikiPermission;
+
+public class HandlerInfoTest extends TestCase
+{
+    TestEngine m_engine;
+
+    public void setUp()
+    {
+        // Start the WikiEngine, and stash reference
+        Properties props = new Properties();
+        try
+        {
+            props.load( TestEngine.findTestProperties() );
+            m_engine = new TestEngine( props );
+        }
+        catch( Exception e )
+        {
+            throw new RuntimeException( "Could not set up TestEngine: " + e.getMessage() );
+        }
+    }
+
+    public void testGetRequestContext() throws Exception
+    {
+        assertEquals( "createGroup", HandlerInfo.getHandlerInfo( GroupActionBean.class, "create" ).getRequestContext() );
+        assertEquals( "deleteGroup", HandlerInfo.getHandlerInfo( GroupActionBean.class, "delete" ).getRequestContext() );
+        assertEquals( "editGroup", HandlerInfo.getHandlerInfo( GroupActionBean.class, "save" ).getRequestContext() );
+        assertEquals( "group", HandlerInfo.getHandlerInfo( GroupActionBean.class, "view" ).getRequestContext() );
+    }
+
+    public void testPermissionAnnotations() throws Exception
+    {
+        Map<Method, HandlerInfo> map = HandlerInfo.getHandlerInfoCollection( GroupActionBean.class );
+        assertEquals( 4, map.size() );
+
+        Method method = GroupActionBean.class.getMethod( "view", new Class[0] );
+        assertTrue( map.containsKey( method ) );
+        HandlerInfo handlerInfo = map.get( method );
+        assertEquals( GroupPermission.class, handlerInfo.getPermissionClass() );
+        assertEquals( "${group.name}", handlerInfo.getPermissionTarget() );
+        assertNotNull( handlerInfo.getPermissionTargetExpression() );
+        assertEquals( "view", handlerInfo.getPermissionActions() );
+        assertNull( handlerInfo.getActionsExpression() );
+
+        method = GroupActionBean.class.getMethod( "save", new Class[0] );
+        assertTrue( map.containsKey( method ) );
+        handlerInfo = map.get( method );
+        assertEquals( GroupPermission.class, handlerInfo.getPermissionClass() );
+        assertEquals( "${group.name}", handlerInfo.getPermissionTarget() );
+        assertNotNull( handlerInfo.getPermissionTargetExpression() );
+        assertEquals( "edit", handlerInfo.getPermissionActions() );
+        assertNull( handlerInfo.getActionsExpression() );
+
+        method = GroupActionBean.class.getMethod( "delete", new Class[0] );
+        assertTrue( map.containsKey( method ) );
+        handlerInfo = map.get( method );
+        assertEquals( GroupPermission.class, handlerInfo.getPermissionClass() );
+        assertEquals( "${group.name}", handlerInfo.getPermissionTarget() );
+        assertNotNull( handlerInfo.getPermissionTargetExpression() );
+        assertEquals( "delete", handlerInfo.getPermissionActions() );
+        assertNull( handlerInfo.getActionsExpression() );
+
+        method = GroupActionBean.class.getMethod( "create", new Class[0] );
+        assertTrue( map.containsKey( method ) );
+        handlerInfo = map.get( method );
+        assertEquals( WikiPermission.class, handlerInfo.getPermissionClass() );
+        assertEquals( WikiPermission.CREATE_GROUPS_ACTION, handlerInfo.getPermissionTarget() );
+        assertNull( handlerInfo.getPermissionTargetExpression() );
+        assertNull( handlerInfo.getPermissionActions() );
+        assertNull( handlerInfo.getActionsExpression() );
+    }
+
+    public void testEvaluatedPermissionAnnotation() throws Exception
+    {
+        MockServletContext ctx = (MockServletContext) m_engine.getServletContext();
+        MockRoundtrip trip;
+        GroupActionBean bean;
+        Method method;
+        HandlerInfo handlerInfo;
+        Permission perm;
+
+        // Set up a new GroupActionBean with the real group Admin and event
+        // "view"
+        trip = new MockRoundtrip( ctx, "/Group.jsp" );
+        trip.getRequest().setMethod( "GET" );
+        trip.addParameter( "group", "Admin" );
+        trip.execute( "view" );
+        bean = trip.getActionBean( GroupActionBean.class );
+        assertNotNull( bean );
+
+        // The view handler should return a "view" GroupPermission
+        method = GroupActionBean.class.getMethod( "view", new Class[0] );
+        Map<Method,HandlerInfo> handlerInfos = HandlerInfo.getHandlerInfoCollection( GroupActionBean.class );
+        handlerInfo = handlerInfos.get( method );
+        assertNotNull( handlerInfo );
+        perm = handlerInfo.getPermission( bean );
+        assertNotNull( perm );
+        assertEquals( GroupPermission.class, perm.getClass() );
+        assertEquals( "Admin", perm.getName() );
+        assertEquals( "view", perm.getActions() );
+
+        // Set up a new GroupActionBean with the real group Admin and event
+        // "save"
+        trip = new MockRoundtrip( ctx, "/Group.jsp" );
+        trip.addParameter( "group", "Admin" );
+        trip.execute( "save" );
+        bean = trip.getActionBean( GroupActionBean.class );
+        assertNotNull( bean );
+
+        // The view handler should return a "edit" GroupPermission
+        method = GroupActionBean.class.getMethod( "save", new Class[0] );
+        handlerInfo = handlerInfos.get( method );
+        assertNotNull( handlerInfo );
+        perm = handlerInfo.getPermission( bean );
+        assertNotNull( perm );
+        assertEquals( GroupPermission.class, perm.getClass() );
+        assertEquals( "Admin", perm.getName() );
+        assertEquals( "edit", perm.getActions() );
+
+        // Set up a new GroupActionBean with the real group Admin and event
+        // "delete"
+        trip = new MockRoundtrip( ctx, "/Group.jsp" );
+        trip.addParameter( "group", "Admin" );
+        trip.execute( "delete" );
+        bean = trip.getActionBean( GroupActionBean.class );
+        assertNotNull( bean );
+
+        // The view handler should return a "view" GroupPermission
+        method = GroupActionBean.class.getMethod( "delete", new Class[0] );
+        handlerInfo = handlerInfos.get( method );
+        assertNotNull( handlerInfo );
+        perm = handlerInfo.getPermission( bean );
+        assertNotNull( perm );
+        assertEquals( GroupPermission.class, perm.getClass() );
+        assertEquals( "Admin", perm.getName() );
+        assertEquals( "delete", perm.getActions() );
+    }
+
+    public void testNotEvaluatedPermissionAnnotation() throws Exception
+    {
+        MockServletContext ctx = (MockServletContext) m_engine.getServletContext();
+        MockRoundtrip trip;
+        GroupActionBean bean;
+        Method method;
+        HandlerInfo handlerInfo;
+        Permission perm;
+
+        // Set up a new GroupActionBean with the non-existent group Foo
+        trip = new MockRoundtrip( ctx, "/Group.jsp" );
+        trip.addParameter( "group", "Foo" );
+        trip.execute( "view" );
+        bean = trip.getActionBean( GroupActionBean.class );
+        assertNotNull( bean );
+
+        // The view handler should NOT return a "view" GroupPermission (because
+        // EL can't evaluate)
+        method = GroupActionBean.class.getMethod( "view", new Class[0] );
+        Map<Method,HandlerInfo> handlerInfos = HandlerInfo.getHandlerInfoCollection( GroupActionBean.class );
+        handlerInfo = handlerInfos.get( method );
+        assertNotNull( handlerInfo );
+        perm = handlerInfo.getPermission( bean );
+        assertNull( perm );
+    }
+
+    public static Test suite()
+    {
+        return new TestSuite( HandlerInfoTest.class );
+    }
+}

Propchange: incubator/jspwiki/branches/JSPWIKI_2_9_STRIPES_BRANCH/tests/com/ecyrd/jspwiki/action/HandlerInfoTest.java
------------------------------------------------------------------------------
    svn:executable = *

Modified: incubator/jspwiki/branches/JSPWIKI_2_9_STRIPES_BRANCH/tests/com/ecyrd/jspwiki/action/RenameActionBeanTest.java
URL: http://svn.apache.org/viewvc/incubator/jspwiki/branches/JSPWIKI_2_9_STRIPES_BRANCH/tests/com/ecyrd/jspwiki/action/RenameActionBeanTest.java?rev=682151&r1=682150&r2=682151&view=diff
==============================================================================
--- incubator/jspwiki/branches/JSPWIKI_2_9_STRIPES_BRANCH/tests/com/ecyrd/jspwiki/action/RenameActionBeanTest.java (original)
+++ incubator/jspwiki/branches/JSPWIKI_2_9_STRIPES_BRANCH/tests/com/ecyrd/jspwiki/action/RenameActionBeanTest.java Sun Aug  3 05:28:09 2008
@@ -22,7 +22,6 @@
         Properties props = new Properties();
         try 
         {
-            TestEngine.emptyPageDir();
             TestEngine.emptyWorkDir();
             props.load( TestEngine.findTestProperties() );
             m_engine = new TestEngine( props );
@@ -108,7 +107,7 @@
         trip.execute("rename");
         errors = trip.getValidationErrors();
         assertEquals( 0, errors.size() );
-        assertEquals( "/Wiki.action?page=TestRenamed", trip.getDestination() );
+        assertEquals( "/Wiki.jsp?page=TestRenamed", trip.getDestination() );
         assertFalse( m_engine.pageExists( "Test" ) );
         assertTrue( m_engine.pageExists( "TestRenamed" ) );
     
@@ -138,7 +137,7 @@
         trip.execute("rename");
         errors = trip.getValidationErrors();
         assertEquals( 0, errors.size() );
-        assertEquals( "/Wiki.action?page=TestRenamed", trip.getDestination() );
+        assertEquals( "/Wiki.jsp?page=TestRenamed", trip.getDestination() );
         assertFalse( m_engine.pageExists( "Test" ) );
         assertTrue( m_engine.pageExists( "TestRenamed" ) );
         referringText = m_engine.getPureText( m_engine.getPage("ReferstoTest") );
@@ -161,7 +160,7 @@
         trip.execute("rename");
          errors = trip.getValidationErrors();
         assertEquals( 0, errors.size() );
-        assertEquals( "/Wiki.action?page=TestRenamed", trip.getDestination() );
+        assertEquals( "/Wiki.jsp?page=TestRenamed", trip.getDestination() );
         assertFalse( m_engine.pageExists( "Test" ) );
         assertTrue( m_engine.pageExists( "TestRenamed" ) );
         referringText = m_engine.getPureText( m_engine.getPage("ReferstoTest") );
@@ -184,7 +183,7 @@
         trip.execute("rename");
         errors = trip.getValidationErrors();
         assertEquals( 0, errors.size() );
-        assertEquals( "/Wiki.action?page=TestRenamed", trip.getDestination() );
+        assertEquals( "/Wiki.jsp?page=TestRenamed", trip.getDestination() );
         assertFalse( m_engine.pageExists( "Test" ) );
         assertTrue( m_engine.pageExists( "TestRenamed" ) );
         referringText = m_engine.getPureText( m_engine.getPage("ReferstoTest") );

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=682151&r1=682150&r2=682151&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 Sun Aug  3 05:28:09 2008
@@ -38,12 +38,12 @@
     
     public void testCreateAssertedName() throws Exception
     {
-        MockServletContext ctx = m_engine.getServletContext();
+        MockServletContext ctx = (MockServletContext)m_engine.getServletContext();
         MockRoundtrip trip;
         UserPreferencesActionBean bean;
         
         // Create session; set 'assertion' param; verify it got saved
-        trip = new MockRoundtrip(ctx, "/UserPreferences.action");
+        trip = new MockRoundtrip(ctx, "/UserPreferences.jsp");
         trip.setParameter("assertedName", "MyAssertedIdentity");
         trip.setParameter("createAssertedName", "true");
         trip.execute();
@@ -61,12 +61,12 @@
     
     public void testCreateAssertedNameAfterLogin() throws Exception
     {
-        MockServletContext ctx = m_engine.getServletContext();
+        MockServletContext ctx = (MockServletContext)m_engine.getServletContext();
         MockRoundtrip trip;
         UserPreferencesActionBean bean;
         
         // Create session; login in as Janne
-        trip = new MockRoundtrip(ctx, "/UserPreferences.action");
+        trip = new MockRoundtrip(ctx, "/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 +88,12 @@
     
     public void testClearAssertedName() throws Exception
     {
-        MockServletContext ctx = m_engine.getServletContext();
+        MockServletContext ctx = (MockServletContext)m_engine.getServletContext();
         MockRoundtrip trip;
         UserPreferencesActionBean bean;
         
         // Create session; set 'assertion' param; verify it got saved
-        trip = new MockRoundtrip(ctx, "/UserPreferences.action");
+        trip = new MockRoundtrip(ctx, "/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=682151&r1=682150&r2=682151&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 Sun Aug  3 05:28:09 2008
@@ -36,7 +36,7 @@
     }
     
     public void testMissingParameters() throws Exception {
-        MockServletContext ctx = m_engine.getServletContext();
+        MockServletContext ctx = (MockServletContext)m_engine.getServletContext();
         MockRoundtrip trip;
         UserProfileActionBean bean;
         ValidationErrors errors;
@@ -45,7 +45,7 @@
         // profile.fullname
         // profile.loginName
         // profile.passwordAgain
-        trip = new MockRoundtrip(ctx, "/UserProfile.action");
+        trip = new MockRoundtrip(ctx, "/UserProfile.jsp");
         trip.execute("save");
         bean = trip.getActionBean(UserProfileActionBean.class);
         // Check to make sure all our expected validation errors are here...
@@ -63,7 +63,7 @@
         assertEquals(MockRoundtrip.DEFAULT_SOURCE_PAGE, trip.getDestination() );
         
         // Submit just the e-mail param
-        trip = new MockRoundtrip(ctx, "/UserProfile.action");
+        trip = new MockRoundtrip(ctx, "/UserProfile.jsp");
         trip.setParameter("profile.email", "fred@friendly.org");
         trip.execute("save");
         bean = trip.getActionBean(UserProfileActionBean.class);
@@ -83,7 +83,7 @@
         assertEquals(MockRoundtrip.DEFAULT_SOURCE_PAGE, trip.getDestination() );
         
         // Submit just the full name param
-        trip = new MockRoundtrip(ctx, "/UserProfile.action");
+        trip = new MockRoundtrip(ctx, "/UserProfile.jsp");
         trip.setParameter("profile.fullname", "Fred Friendly");
         trip.execute("save");
         bean = trip.getActionBean(UserProfileActionBean.class);
@@ -101,7 +101,7 @@
         assertEquals(MockRoundtrip.DEFAULT_SOURCE_PAGE, trip.getDestination() );
         
         // Submit just the login name param
-        trip = new MockRoundtrip(ctx, "/UserProfile.action");
+        trip = new MockRoundtrip(ctx, "/UserProfile.jsp");
         trip.setParameter("profile.loginName", "fred");
         trip.execute("save");
         bean = trip.getActionBean(UserProfileActionBean.class);
@@ -119,7 +119,7 @@
         assertEquals(MockRoundtrip.DEFAULT_SOURCE_PAGE, trip.getDestination() );
         
         // Submit just the first password field
-        trip = new MockRoundtrip(ctx, "/UserProfile.action");
+        trip = new MockRoundtrip(ctx, "/UserProfile.jsp");
         trip.setParameter("profile.password", "myPassword");
         trip.execute("save");
         bean = trip.getActionBean(UserProfileActionBean.class);
@@ -138,7 +138,7 @@
         assertEquals(MockRoundtrip.DEFAULT_SOURCE_PAGE, trip.getDestination() );
         
         // Submit just the second password field
-        trip = new MockRoundtrip(ctx, "/UserProfile.action");
+        trip = new MockRoundtrip(ctx, "/UserProfile.jsp");
         trip.setParameter("passwordAgain", "myPassword");
         trip.execute("save");
         bean = trip.getActionBean(UserProfileActionBean.class);
@@ -158,13 +158,13 @@
     }
     
     public void testMismatchedPasswords() throws Exception {
-        MockServletContext ctx = m_engine.getServletContext();
+        MockServletContext ctx = (MockServletContext)m_engine.getServletContext();
         MockRoundtrip trip;
         UserProfileActionBean bean;
         ValidationErrors errors;
         
         // Set different passwords
-        trip = new MockRoundtrip(ctx, "/UserProfile.action");
+        trip = new MockRoundtrip(ctx, "/UserProfile.jsp");
         trip.setParameter("profile.loginName", "fred");
         trip.setParameter("profile.fullname", "Fred Friendly");
         trip.setParameter("profile.email", "fred@friendly.org");
@@ -180,13 +180,13 @@
     }
     
     public void testIllegalEmail() throws Exception {
-        MockServletContext ctx = m_engine.getServletContext();
+        MockServletContext ctx = (MockServletContext)m_engine.getServletContext();
         MockRoundtrip trip;
         UserProfileActionBean bean;
         ValidationErrors errors;
         
         // Set an illegal e-mail address
-        trip = new MockRoundtrip(ctx, "/UserProfile.action");
+        trip = new MockRoundtrip(ctx, "/UserProfile.jsp");
         trip.setParameter("profile.loginName", "fred");
         trip.setParameter("profile.fullname", "Fred Friendly");
         trip.setParameter("profile.email", "illegalEmail");
@@ -203,7 +203,7 @@
     
     public void testSaveProfile() throws Exception
     {
-        MockServletContext ctx = m_engine.getServletContext();
+        MockServletContext ctx = (MockServletContext)m_engine.getServletContext();
         MockRoundtrip trip;
         UserProfileActionBean bean;
         ValidationErrors errors;
@@ -213,7 +213,7 @@
         assertFalse( userExists("user" + suffix));
         
         // Create new user
-        trip = new MockRoundtrip(ctx, "/UserProfile.action");
+        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");
@@ -242,14 +242,14 @@
     
     public void testSaveProfileWithCollisions() throws Exception
     {
-        MockServletContext ctx = m_engine.getServletContext();
+        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.action");
+        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");
@@ -266,7 +266,7 @@
         // 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.action");
+        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");
@@ -283,7 +283,7 @@
         
         // 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.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");
@@ -304,14 +304,14 @@
     
     public void testSaveProfileAgain() throws Exception
     {
-        MockServletContext ctx = m_engine.getServletContext();
+        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.action");
+        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");
@@ -325,7 +325,7 @@
         assertTrue( userExists("user" + suffix));
         
         // Create new session and login as new user...
-        trip = new MockRoundtrip(ctx, "/UserProfile.action");
+        trip = new MockRoundtrip(ctx, "/UserProfile.jsp");
         MockHttpServletRequest request = trip.getRequest();
         WikiSession wikiSession = WikiSession.getWikiSession(m_engine, request);
         boolean login = m_engine.getAuthenticationManager().login(wikiSession, "user"+suffix,"mypassword");
@@ -339,7 +339,7 @@
         assertEquals("fred1@friendly.org", bean.getProfile().getEmail());
         
         // Now, create another session, and log in again....
-        trip = new MockRoundtrip(ctx, "/UserProfile.action");
+        trip = new MockRoundtrip(ctx, "/UserProfile.jsp");
         request = trip.getRequest();
         wikiSession = WikiSession.getWikiSession(m_engine, request);
         login = m_engine.getAuthenticationManager().login(wikiSession, "user"+suffix,"mypassword");

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=682151&r1=682150&r2=682151&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 Sun Aug  3 05:28:09 2008
@@ -37,8 +37,8 @@
         assertNotNull("Did not save page Test!", page);
         
         // Set the 'page' request parameter to 'Main'...
-        MockServletContext ctx = m_engine.getServletContext();
-        MockRoundtrip trip = new MockRoundtrip(ctx, "/Wiki.action");
+        MockServletContext ctx = (MockServletContext)m_engine.getServletContext();
+        MockRoundtrip trip = new MockRoundtrip(ctx, "/Wiki.jsp");
         trip.setParameter("page", "Test");
         trip.execute("view");
 
@@ -47,7 +47,7 @@
         assertEquals( page, bean.getPage() );
         
         // ...and the destination should be Wiki.jsp (aka /View.action)
-        assertEquals("/Wiki.action", trip.getDestination() );
+        assertEquals("/Wiki.jsp", trip.getDestination() );
     }
     
     public void testActionBeanNoParameter() throws Exception {
@@ -57,8 +57,8 @@
         assertNotNull("Did not save page Main!", page);
         
         // Execute the request without specifying a page
-        MockServletContext ctx = m_engine.getServletContext();
-        MockRoundtrip trip = new MockRoundtrip(ctx, "/Wiki.action");
+        MockServletContext ctx = (MockServletContext)m_engine.getServletContext();
+        MockRoundtrip trip = new MockRoundtrip(ctx, "/Wiki.jsp");
         trip.execute("view");
 
         // ...we should automatically see Main bound to the ActionBean (nice!)
@@ -67,7 +67,7 @@
         assertEquals( page, bean.getPage() );
         
         // ...and the destination should be Wiki.jsp (aka /View.action)
-        assertEquals("/Wiki.action", trip.getDestination() );
+        assertEquals("/Wiki.jsp", trip.getDestination() );
     }
     
     public static Test suite()