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 2009/04/26 01:47:12 UTC

svn commit: r768626 - in /incubator/jspwiki/trunk: ./ src/java/org/apache/wiki/ src/java/org/apache/wiki/action/ src/java/org/apache/wiki/attachment/ src/java/org/apache/wiki/auth/acl/ src/java/org/apache/wiki/content/ src/java/org/apache/wiki/parser/ ...

Author: ajaquith
Date: Sat Apr 25 23:47:11 2009
New Revision: 768626

URL: http://svn.apache.org/viewvc?rev=768626&view=rev
Log:
Many unit test fixes, including many to JSPWikiMarkupParser. Over 90% of tests pass now. WikiPath is now truly immutable. DefaultURLConstructor omits the space name from pages if in the main space, and colons are no longer URLencoded. Fixed bug in ContentManager that was preventing page ACLs from being changed correctly if a user's name changed.

Modified:
    incubator/jspwiki/trunk/ChangeLog
    incubator/jspwiki/trunk/src/java/org/apache/wiki/JCRWikiPage.java
    incubator/jspwiki/trunk/src/java/org/apache/wiki/ReferenceManager.java
    incubator/jspwiki/trunk/src/java/org/apache/wiki/Release.java
    incubator/jspwiki/trunk/src/java/org/apache/wiki/action/DeleteActionBean.java
    incubator/jspwiki/trunk/src/java/org/apache/wiki/action/RenameActionBean.java
    incubator/jspwiki/trunk/src/java/org/apache/wiki/action/UploadActionBean.java
    incubator/jspwiki/trunk/src/java/org/apache/wiki/attachment/AttachmentManager.java
    incubator/jspwiki/trunk/src/java/org/apache/wiki/auth/acl/DefaultAclManager.java
    incubator/jspwiki/trunk/src/java/org/apache/wiki/content/ContentManager.java
    incubator/jspwiki/trunk/src/java/org/apache/wiki/content/WikiPath.java
    incubator/jspwiki/trunk/src/java/org/apache/wiki/parser/JSPWikiMarkupParser.java
    incubator/jspwiki/trunk/src/java/org/apache/wiki/url/DefaultURLConstructor.java
    incubator/jspwiki/trunk/tests/java/org/apache/wiki/ReferenceManagerTest.java
    incubator/jspwiki/trunk/tests/java/org/apache/wiki/auth/UserManagerTest.java
    incubator/jspwiki/trunk/tests/java/org/apache/wiki/content/EnglishPluralsPageNameResolverTest.java
    incubator/jspwiki/trunk/tests/java/org/apache/wiki/parser/JSPWikiMarkupParserTest.java
    incubator/jspwiki/trunk/tests/java/org/apache/wiki/ui/migrator/JspParserTest.java
    incubator/jspwiki/trunk/tests/java/org/apache/wiki/ui/stripes/HandlerInfoTest.java

Modified: incubator/jspwiki/trunk/ChangeLog
URL: http://svn.apache.org/viewvc/incubator/jspwiki/trunk/ChangeLog?rev=768626&r1=768625&r2=768626&view=diff
==============================================================================
--- incubator/jspwiki/trunk/ChangeLog (original)
+++ incubator/jspwiki/trunk/ChangeLog Sat Apr 25 23:47:11 2009
@@ -1,3 +1,12 @@
+2009-04-25  Andrew Jaquith <ajaquith AT apache DOT org>
+
+        * 3.0.0-svn-105
+        
+        * Many unit test fixes, including many to JSPWikiMarkupParser. About 90% of tests pass now.
+        WikiPath is now truly immutable. DefaultURLConstructor omits the space name from pages if
+        in the main space, and colons are no longer URLencoded. Fixed bug in ContentManager that
+        was preventing page ACLs from being changed correctly if a user's name changed.
+        
 2009-04-23  Harry Metske <me...@apache.org>
 
         * 3.0.0-svn-104

Modified: incubator/jspwiki/trunk/src/java/org/apache/wiki/JCRWikiPage.java
URL: http://svn.apache.org/viewvc/incubator/jspwiki/trunk/src/java/org/apache/wiki/JCRWikiPage.java?rev=768626&r1=768625&r2=768626&view=diff
==============================================================================
--- incubator/jspwiki/trunk/src/java/org/apache/wiki/JCRWikiPage.java (original)
+++ incubator/jspwiki/trunk/src/java/org/apache/wiki/JCRWikiPage.java Sat Apr 25 23:47:11 2009
@@ -126,7 +126,7 @@
             }
             else
             {
-                throw new IllegalStateException( "The value returned by " + key + " was not a Serializalble, as expected.");
+                throw new IllegalStateException( "The value returned by " + key + " was not a Serializable, as expected.");
             }
         }
         catch( ItemNotFoundException e ) {}
@@ -159,14 +159,16 @@
         return property.getString();
     }
 
-    /* (non-Javadoc)
-     * @see org.apache.wiki.WikiPage#setAttribute(java.lang.String, java.lang.Object)
+    /**
+     * {@inheritDoc}
      */
-    public void setAttribute( String key, String attribute )
+    public void setAttribute( String key, Serializable attribute )
     {
         try
         {
-            getJCRNode().setProperty( key, attribute );
+            // FIXME: Using the string value can't possibly be
+            // the right thing to do here.
+            getJCRNode().setProperty( key, attribute.toString() );
         }
         catch(RepositoryException e) {} // FIXME: Should log
     }
@@ -562,13 +564,6 @@
         }
     }
 
- 
-    public void setAttribute( String key, Serializable attribute )
-    {
-        // TODO Auto-generated method stub
-        
-    }
-
     public WikiPage getParent() throws PageNotFoundException, ProviderException
     {
         return m_engine.getContentManager().getPage( m_name.getParent() );

Modified: incubator/jspwiki/trunk/src/java/org/apache/wiki/ReferenceManager.java
URL: http://svn.apache.org/viewvc/incubator/jspwiki/trunk/src/java/org/apache/wiki/ReferenceManager.java?rev=768626&r1=768625&r2=768626&view=diff
==============================================================================
--- incubator/jspwiki/trunk/src/java/org/apache/wiki/ReferenceManager.java (original)
+++ incubator/jspwiki/trunk/src/java/org/apache/wiki/ReferenceManager.java Sat Apr 25 23:47:11 2009
@@ -363,7 +363,7 @@
     }
     
     /**
-     *  Updates the referred pages of a new or edited WikiPage. If a refersTo
+     *  Updates list of pages a new or edited WikiPage refers to. If a refersTo
      *  entry for this page already exists, it is removed and a new one is built
      *  from scratch. Also calls updateReferredBy() for each referenced page.
      *  <P>

Modified: incubator/jspwiki/trunk/src/java/org/apache/wiki/Release.java
URL: http://svn.apache.org/viewvc/incubator/jspwiki/trunk/src/java/org/apache/wiki/Release.java?rev=768626&r1=768625&r2=768626&view=diff
==============================================================================
--- incubator/jspwiki/trunk/src/java/org/apache/wiki/Release.java (original)
+++ incubator/jspwiki/trunk/src/java/org/apache/wiki/Release.java Sat Apr 25 23:47:11 2009
@@ -77,7 +77,7 @@
      *  <p>
      *  If the build identifier is empty, it is not added.
      */
-    public static final String     BUILD         = "104";
+    public static final String     BUILD         = "105";
     
     /**
      *  This is the generic version string you should use

Modified: incubator/jspwiki/trunk/src/java/org/apache/wiki/action/DeleteActionBean.java
URL: http://svn.apache.org/viewvc/incubator/jspwiki/trunk/src/java/org/apache/wiki/action/DeleteActionBean.java?rev=768626&r1=768625&r2=768626&view=diff
==============================================================================
--- incubator/jspwiki/trunk/src/java/org/apache/wiki/action/DeleteActionBean.java (original)
+++ incubator/jspwiki/trunk/src/java/org/apache/wiki/action/DeleteActionBean.java Sat Apr 25 23:47:11 2009
@@ -60,7 +60,7 @@
      * @throws ProviderException if the delete failed for any reason
      */
     @HandlesEvent( "delete" )
-    @HandlerPermission( permissionClass = PagePermission.class, target = "${page.qualifiedName}", actions = PagePermission.DELETE_ACTION )
+    @HandlerPermission( permissionClass = PagePermission.class, target = "${page.path}", actions = PagePermission.DELETE_ACTION )
     @WikiRequestContext( "del" )
     public Resolution delete() throws PageNotFoundException, ProviderException
     {

Modified: incubator/jspwiki/trunk/src/java/org/apache/wiki/action/RenameActionBean.java
URL: http://svn.apache.org/viewvc/incubator/jspwiki/trunk/src/java/org/apache/wiki/action/RenameActionBean.java?rev=768626&r1=768625&r2=768626&view=diff
==============================================================================
--- incubator/jspwiki/trunk/src/java/org/apache/wiki/action/RenameActionBean.java (original)
+++ incubator/jspwiki/trunk/src/java/org/apache/wiki/action/RenameActionBean.java Sat Apr 25 23:47:11 2009
@@ -111,7 +111,7 @@
      * @throws WikiException if the page cannot be renamed
      */
     @HandlesEvent( "rename" )
-    @HandlerPermission( permissionClass = PagePermission.class, target = "${page.qualifiedName}", actions = PagePermission.RENAME_ACTION )
+    @HandlerPermission( permissionClass = PagePermission.class, target = "${page.path}", actions = PagePermission.RENAME_ACTION )
     @WikiRequestContext( "rename" )
     public Resolution rename() throws WikiException
     {

Modified: incubator/jspwiki/trunk/src/java/org/apache/wiki/action/UploadActionBean.java
URL: http://svn.apache.org/viewvc/incubator/jspwiki/trunk/src/java/org/apache/wiki/action/UploadActionBean.java?rev=768626&r1=768625&r2=768626&view=diff
==============================================================================
--- incubator/jspwiki/trunk/src/java/org/apache/wiki/action/UploadActionBean.java (original)
+++ incubator/jspwiki/trunk/src/java/org/apache/wiki/action/UploadActionBean.java Sat Apr 25 23:47:11 2009
@@ -103,7 +103,7 @@
      * @return Resolution
      */
     @HandlesEvent( "upload" )
-    @HandlerPermission( permissionClass = PagePermission.class, target = "${page.qualifiedName}", actions = PagePermission.UPLOAD_ACTION )
+    @HandlerPermission( permissionClass = PagePermission.class, target = "${page.path}", actions = PagePermission.UPLOAD_ACTION )
     @WikiRequestContext( "upload" )
     public Resolution upload() throws Exception
     {

Modified: incubator/jspwiki/trunk/src/java/org/apache/wiki/attachment/AttachmentManager.java
URL: http://svn.apache.org/viewvc/incubator/jspwiki/trunk/src/java/org/apache/wiki/attachment/AttachmentManager.java?rev=768626&r1=768625&r2=768626&view=diff
==============================================================================
--- incubator/jspwiki/trunk/src/java/org/apache/wiki/attachment/AttachmentManager.java (original)
+++ incubator/jspwiki/trunk/src/java/org/apache/wiki/attachment/AttachmentManager.java Sat Apr 25 23:47:11 2009
@@ -210,9 +210,13 @@
         if( att == null )
         {
             att = m_engine.getContentManager().getPage( name, version );
+            if ( att != null && att.isAttachment() )
+            {
+                return att;
+            }
         }
 
-        return att;
+        return null;
     }
 
     /**

Modified: incubator/jspwiki/trunk/src/java/org/apache/wiki/auth/acl/DefaultAclManager.java
URL: http://svn.apache.org/viewvc/incubator/jspwiki/trunk/src/java/org/apache/wiki/auth/acl/DefaultAclManager.java?rev=768626&r1=768625&r2=768626&view=diff
==============================================================================
--- incubator/jspwiki/trunk/src/java/org/apache/wiki/auth/acl/DefaultAclManager.java (original)
+++ incubator/jspwiki/trunk/src/java/org/apache/wiki/auth/acl/DefaultAclManager.java Sat Apr 25 23:47:11 2009
@@ -215,7 +215,7 @@
             }
             catch ( ProviderException e )
             {
-                throw new WikiSecurityException( "Could not set Acl. Reason: ProviderExcpetion " + e.getMessage(), e );
+                throw new WikiSecurityException( "Could not set Acl. Reason: ProviderException " + e.getMessage(), e );
             }
         }
     }

Modified: incubator/jspwiki/trunk/src/java/org/apache/wiki/content/ContentManager.java
URL: http://svn.apache.org/viewvc/incubator/jspwiki/trunk/src/java/org/apache/wiki/content/ContentManager.java?rev=768626&r1=768625&r2=768626&view=diff
==============================================================================
--- incubator/jspwiki/trunk/src/java/org/apache/wiki/content/ContentManager.java (original)
+++ incubator/jspwiki/trunk/src/java/org/apache/wiki/content/ContentManager.java Sat Apr 25 23:47:11 2009
@@ -1320,13 +1320,13 @@
                 for ( Iterator<WikiPage> it = pages.iterator(); it.hasNext(); )
                 {
                     WikiPage page = (WikiPage)it.next();
-                    boolean aclChanged = changeAcl( page, oldPrincipals, newPrincipal );
-                    if ( aclChanged )
+                    Acl acl = changeAcl( page, oldPrincipals, newPrincipal );
+                    if ( acl != null )
                     {
                         // If the Acl needed changing, change it now
                         try
                         {
-                            m_engine.getAclManager().setPermissions( page, page.getAcl() );
+                            m_engine.getAclManager().setPermissions( page, acl );
                         }
                         catch ( WikiSecurityException e )
                         {
@@ -1348,18 +1348,19 @@
 
     /**
      *  For a single wiki page, replaces all Acl entries matching a supplied array of Principals 
-     *  with a new Principal.
+     *  with a new Principal. If the Acl is changed, the changed Acl is returned. Otherwise,
+     *  (the Acl did not change), null is returned.
      * 
      *  @param page the wiki page whose Acl is to be modified
      *  @param oldPrincipals an array of Principals to replace; all AclEntry objects whose
      *   {@link AclEntry#getPrincipal()} method returns one of these Principals will be replaced
      *  @param newPrincipal the Principal that should receive the old Principals' permissions
-     *  @return <code>true</code> if the Acl was actually changed; <code>false</code> otherwise
+     *  @return a non-<code>null</code> Acl if the Acl was actually changed; <code>null</code> otherwise
      */
-    protected boolean changeAcl( WikiPage page, Principal[] oldPrincipals, Principal newPrincipal )
+    protected Acl changeAcl( WikiPage page, Principal[] oldPrincipals, Principal newPrincipal )
     {
         Acl acl = page.getAcl();
-        boolean pageChanged = false;
+        boolean aclChanged = false;
         if ( acl != null )
         {
             Enumeration<AclEntry> entries = acl.entries();
@@ -1379,7 +1380,7 @@
                         Permission permission = (Permission)permissions.nextElement();
                         newEntry.addPermission(permission);
                     }
-                    pageChanged = true;
+                    aclChanged = true;
                     entriesToRemove.add( entry );
                     entriesToAdd.add( newEntry );
                 }
@@ -1395,7 +1396,7 @@
                 acl.addEntry( entry );
             }
         }
-        return pageChanged;
+        return aclChanged ? acl : null;
     }
 
     /*

Modified: incubator/jspwiki/trunk/src/java/org/apache/wiki/content/WikiPath.java
URL: http://svn.apache.org/viewvc/incubator/jspwiki/trunk/src/java/org/apache/wiki/content/WikiPath.java?rev=768626&r1=768625&r2=768626&view=diff
==============================================================================
--- incubator/jspwiki/trunk/src/java/org/apache/wiki/content/WikiPath.java (original)
+++ incubator/jspwiki/trunk/src/java/org/apache/wiki/content/WikiPath.java Sat Apr 25 23:47:11 2009
@@ -32,15 +32,12 @@
  *  
  *  @since 3.0
  */
-public class WikiPath implements Serializable, Comparable<WikiPath>
+public final class WikiPath implements Serializable, Comparable<WikiPath>
 {
     private static final long serialVersionUID = 1L;
-    private String m_space;
-    private String m_path;
-    private String m_stringRepresentation = null;
-    
-    private WikiPath()
-    {}
+    private final String m_space;
+    private final String m_path;
+    private final String m_stringRepresentation;
     
     /**
      *  Create a WikiName from a space and a path.
@@ -52,6 +49,7 @@
     {
         m_space = (space != null) ? space : ContentManager.DEFAULT_SPACE;
         m_path  = path;
+        m_stringRepresentation = m_space+":"+m_path;
     }
     
     /**
@@ -69,22 +67,15 @@
     {
         if( path == null ) throw new IllegalArgumentException("null path given to WikiName.valueOf().");
         
-        WikiPath name = new WikiPath();
         int colon = path.indexOf(':');
         
         if( colon != -1 )
         {
             // This is a FQN
-            name.m_space = path.substring( 0, colon );
-            name.m_path  = path.substring( colon+1 );
-            
-            return name;
+            return new WikiPath( path.substring( 0, colon ), path.substring( colon+1 ) );
         }
 
-        name.m_space = ContentManager.DEFAULT_SPACE;
-        name.m_path = path;
-        
-        return name;
+        return new WikiPath ( ContentManager.DEFAULT_SPACE, path );
     }
     
     /**
@@ -149,13 +140,6 @@
      */
     public String toString()
     {
-        //
-        //  The String representation is cached for maximum speed
-        //  and object creation overhead.
-        //
-        if( m_stringRepresentation == null )
-            m_stringRepresentation = m_space+":"+m_path;
-        
         return m_stringRepresentation;
     }
 
@@ -168,7 +152,7 @@
      */
     public int hashCode()
     {
-        return toString().hashCode();
+        return m_stringRepresentation.hashCode();
     }
     
     /**

Modified: incubator/jspwiki/trunk/src/java/org/apache/wiki/parser/JSPWikiMarkupParser.java
URL: http://svn.apache.org/viewvc/incubator/jspwiki/trunk/src/java/org/apache/wiki/parser/JSPWikiMarkupParser.java?rev=768626&r1=768625&r2=768626&view=diff
==============================================================================
--- incubator/jspwiki/trunk/src/java/org/apache/wiki/parser/JSPWikiMarkupParser.java (original)
+++ incubator/jspwiki/trunk/src/java/org/apache/wiki/parser/JSPWikiMarkupParser.java Sat Apr 25 23:47:11 2009
@@ -35,12 +35,16 @@
 
 import org.apache.commons.lang.StringEscapeUtils;
 import org.apache.commons.lang.StringUtils;
-import org.apache.wiki.*;
+import org.apache.wiki.InternalWikiException;
+import org.apache.wiki.VariableManager;
+import org.apache.wiki.WikiContext;
+import org.apache.wiki.WikiEngine;
 import org.apache.wiki.api.PluginException;
 import org.apache.wiki.api.WikiPage;
 import org.apache.wiki.attachment.AttachmentManager;
 import org.apache.wiki.auth.WikiSecurityException;
 import org.apache.wiki.auth.acl.Acl;
+import org.apache.wiki.content.ContentManager;
 import org.apache.wiki.content.PageNotFoundException;
 import org.apache.wiki.content.WikiPath;
 import org.apache.wiki.i18n.InternationalizationManager;
@@ -439,7 +443,15 @@
         {
             if( page == null || page.length() == 0 ) return null;
 
-            return m_engine.getFinalPageName( WikiPath.valueOf( page ) ).toString();
+            WikiPath path = WikiPath.valueOf( page );
+            WikiPath finalPath = m_engine.getFinalPageName( path );
+            path = finalPath != null ? finalPath : path;
+            if ( m_engine.pageExists( path.toString() ) )
+            {
+                String pageLink = ContentManager.DEFAULT_SPACE.equals( path.getSpace() ) ? path.getPath() : path.toString();
+                return pageLink;
+            }
+            return null;
         }
         catch( Exception e )
         {
@@ -1673,8 +1685,7 @@
         try
         {
             att = mgr.getAttachmentInfo( m_context, linktext );
-            
-            return att.getName();
+            return att == null ? null : att.getName();
         }
         catch( PageNotFoundException e )
         {}

Modified: incubator/jspwiki/trunk/src/java/org/apache/wiki/url/DefaultURLConstructor.java
URL: http://svn.apache.org/viewvc/incubator/jspwiki/trunk/src/java/org/apache/wiki/url/DefaultURLConstructor.java?rev=768626&r1=768625&r2=768626&view=diff
==============================================================================
--- incubator/jspwiki/trunk/src/java/org/apache/wiki/url/DefaultURLConstructor.java (original)
+++ incubator/jspwiki/trunk/src/java/org/apache/wiki/url/DefaultURLConstructor.java Sat Apr 25 23:47:11 2009
@@ -32,6 +32,7 @@
 import org.apache.commons.lang.StringUtils;
 import org.apache.wiki.WikiContext;
 import org.apache.wiki.WikiEngine;
+import org.apache.wiki.content.ContentManager;
 import org.apache.wiki.util.TextUtil;
 
 
@@ -156,12 +157,29 @@
      *  encoding.  See http://issues.apache.org/bugzilla/show_bug.cgi?id=39278
      *  for more info.
      *  
-     *  We also convert any %2F's back to slashes to make nicer-looking URLs.
+     *  We also convert any %2F's back to slashes to make nicer-looking URLs,
+     *  and the first %3A into a colon (:) because it denotes the space.
      */
     private final String encodeURI( String uri )
     {
+        int colon = uri.indexOf( ':' );
+        
         uri = m_engine.encodeName(uri);
         
+        // Add back the colon for the space name if not the default space
+        if ( colon != -1 )
+        {
+            String space = uri.substring( 0, colon );
+            if ( ContentManager.DEFAULT_SPACE.equals( space ) )
+            {
+                uri = uri.substring( colon + 3, uri.length() );
+            }
+            else
+            {
+                uri = space + ":" + uri.substring( colon + 3, uri.length() );
+            }
+        }
+        
         uri = StringUtils.replace( uri, "+", "%20" );
         uri = StringUtils.replace( uri, "%2F", "/" );
         

Modified: incubator/jspwiki/trunk/tests/java/org/apache/wiki/ReferenceManagerTest.java
URL: http://svn.apache.org/viewvc/incubator/jspwiki/trunk/tests/java/org/apache/wiki/ReferenceManagerTest.java?rev=768626&r1=768625&r2=768626&view=diff
==============================================================================
--- incubator/jspwiki/trunk/tests/java/org/apache/wiki/ReferenceManagerTest.java (original)
+++ incubator/jspwiki/trunk/tests/java/org/apache/wiki/ReferenceManagerTest.java Sat Apr 25 23:47:11 2009
@@ -122,7 +122,7 @@
     {
         Collection<WikiPath> c = findReferrers("Foobar2");
         
-        assertTrue( c.size() == 1 && c.contains("Foobar") );
+        assertTrue( c.size() == 1 && c.contains( WikiPath.valueOf( "Foobar") ) );
 
         engine.deletePage( "Foobar" );
         
@@ -269,7 +269,7 @@
         assertEquals( "Foobars referrers count", 2, c.size() );
 
         assertTrue( "Foobars referrers", 
-                    c.contains("TestPage") && c.contains("Foobar"));
+                    c.contains( WikiPath.valueOf( "TestPage" ) ) && c.contains( WikiPath.valueOf( "Foobar" ) ) );
     }
 
     public void testCircularRefs()

Modified: incubator/jspwiki/trunk/tests/java/org/apache/wiki/auth/UserManagerTest.java
URL: http://svn.apache.org/viewvc/incubator/jspwiki/trunk/tests/java/org/apache/wiki/auth/UserManagerTest.java?rev=768626&r1=768625&r2=768626&view=diff
==============================================================================
--- incubator/jspwiki/trunk/tests/java/org/apache/wiki/auth/UserManagerTest.java (original)
+++ incubator/jspwiki/trunk/tests/java/org/apache/wiki/auth/UserManagerTest.java Sat Apr 25 23:47:11 2009
@@ -31,6 +31,7 @@
 import org.apache.wiki.WikiSession;
 import org.apache.wiki.WikiSessionTest;
 import org.apache.wiki.api.WikiPage;
+import org.apache.wiki.auth.acl.Acl;
 import org.apache.wiki.auth.authorize.Group;
 import org.apache.wiki.auth.authorize.GroupManager;
 import org.apache.wiki.auth.permissions.PermissionFactory;
@@ -109,7 +110,6 @@
       ContentManager contentManager = m_engine.getContentManager();
       AuthorizationManager authManager = m_engine.getAuthorizationManager();
       int oldGroupCount = groupManager.getRoles().length;
-      int oldPageCount = contentManager.getTotalPageCount( null );
       
       // Setup Step 1: create a new user with random name
       WikiSession session = m_engine.guestSession();
@@ -145,6 +145,7 @@
       assertTrue  ( groupManager.isUserInRole( session, group.getPrincipal() ) );
       
       // Setup Step 3: create a new page with our test user in the ACL
+      int oldPageCount = contentManager.getTotalPageCount( null );
       String pageName = "TestPage" + now;
       m_engine.saveText( pageName, "Test text. [{ALLOW view " + oldName + ", " + oldLogin + ", Alice}] More text." );
       
@@ -185,16 +186,18 @@
       // Test 3: our page should not contain the old wiki name OR login name
       // in the ACL any more (the full name is always used)
       p = m_engine.getPage( pageName );
-      assertNull   ( p.getAcl().getEntry( new WikiPrincipal( oldLogin ) ) );
-      assertNull   ( p.getAcl().getEntry( new WikiPrincipal( oldName  ) ) );
-      assertNull   ( p.getAcl().getEntry( new WikiPrincipal( newLogin ) ) );
-      assertNotNull( p.getAcl().getEntry( new WikiPrincipal( newName  ) ) );
+      Acl acl = p.getAcl();
+      assertNotNull ( acl );
+      assertNull   ( acl.getEntry( new WikiPrincipal( oldLogin ) ) );
+      assertNull   ( acl.getEntry( new WikiPrincipal( oldName  ) ) );
+      assertNull   ( acl.getEntry( new WikiPrincipal( newLogin ) ) );
+      assertNotNull( acl.getEntry( new WikiPrincipal( newName  ) ) );
       assertTrue( "Test User view page", authManager.checkPermission( session, PermissionFactory.getPagePermission( p, "view" ) ) );
       assertFalse( "Bob !view page", authManager.checkPermission( bobSession, PermissionFactory.getPagePermission( p, "view" ) ) );
       
       // Test 4: our page text should have been re-written
-      // (The new full name should be in the ACL, but the login name should have been removed)
-      String expectedText = "[{ALLOW view Alice," + newName + "}]\nTest text.  More text.\r\n";
+      // (with the ACL text surgically removed)
+      String expectedText = "Test text.  More text.\r\n";
       String actualText = m_engine.getText( pageName );
       assertEquals( expectedText, actualText );
       
@@ -252,8 +255,8 @@
       assertFalse( "Bob !view page", authManager.checkPermission( bobSession, PermissionFactory.getPagePermission( p, "view" ) ) );
       
       // Test 8: our page text should have been re-written
-      // (The new full name should be in the ACL, but the login name should have been removed)
-      expectedText = "[{ALLOW view Alice," + oldName + "}]\nMore test text.  More text.\r\n";
+      // (with the ACL text surgically removed)
+      expectedText = "More test text.  More text.\r\n";
       actualText = m_engine.getText( pageName );
       assertEquals( expectedText, actualText );
       

Modified: incubator/jspwiki/trunk/tests/java/org/apache/wiki/content/EnglishPluralsPageNameResolverTest.java
URL: http://svn.apache.org/viewvc/incubator/jspwiki/trunk/tests/java/org/apache/wiki/content/EnglishPluralsPageNameResolverTest.java?rev=768626&r1=768625&r2=768626&view=diff
==============================================================================
--- incubator/jspwiki/trunk/tests/java/org/apache/wiki/content/EnglishPluralsPageNameResolverTest.java (original)
+++ incubator/jspwiki/trunk/tests/java/org/apache/wiki/content/EnglishPluralsPageNameResolverTest.java Sat Apr 25 23:47:11 2009
@@ -69,7 +69,7 @@
         assertEquals( "Main:PluralPages", page.toString() );
         
         page = resolver.resolve( WikiPath.valueOf("NonExistentPage") );
-        assertEquals( "Main:NonExistentPage", page.toString() );
+        assertEquals( null, page );
     }
 
     public static Test suite()

Modified: incubator/jspwiki/trunk/tests/java/org/apache/wiki/parser/JSPWikiMarkupParserTest.java
URL: http://svn.apache.org/viewvc/incubator/jspwiki/trunk/tests/java/org/apache/wiki/parser/JSPWikiMarkupParserTest.java?rev=768626&r1=768625&r2=768626&view=diff
==============================================================================
--- incubator/jspwiki/trunk/tests/java/org/apache/wiki/parser/JSPWikiMarkupParserTest.java (original)
+++ incubator/jspwiki/trunk/tests/java/org/apache/wiki/parser/JSPWikiMarkupParserTest.java Sat Apr 25 23:47:11 2009
@@ -95,7 +95,10 @@
 
     private String translate( String src ) throws Exception
     {
-        return translate( testEngine.createPage( WikiPath.valueOf( PAGE_NAME ) ), src );
+        WikiPath path = WikiPath.valueOf( PAGE_NAME );
+        boolean exists = testEngine.pageExists( path.toString() );
+        WikiPage page = exists ? testEngine.getPage( path.toString() ) : testEngine.createPage( path );
+        return translate( page, src );
     }
 
     private String translate( WikiEngine e, String src ) throws Exception
@@ -232,6 +235,7 @@
 
     public void testHyperlinksCCNonExistant() throws Exception
     {
+        testEngine.deletePage( "HyperLink" );
         String src = "This should be a HyperLink.";
 
         assertEquals( "This should be a <a class=\"createpage\" href=\"/Edit.jsp?page=HyperLink\" title=\"Create &quot;HyperLink&quot;\">HyperLink</a>.",

Modified: incubator/jspwiki/trunk/tests/java/org/apache/wiki/ui/migrator/JspParserTest.java
URL: http://svn.apache.org/viewvc/incubator/jspwiki/trunk/tests/java/org/apache/wiki/ui/migrator/JspParserTest.java?rev=768626&r1=768625&r2=768626&view=diff
==============================================================================
--- incubator/jspwiki/trunk/tests/java/org/apache/wiki/ui/migrator/JspParserTest.java (original)
+++ incubator/jspwiki/trunk/tests/java/org/apache/wiki/ui/migrator/JspParserTest.java Sat Apr 25 23:47:11 2009
@@ -333,7 +333,7 @@
 
     public void testParse() throws Exception
     {
-        File src = new File( "src/WebContent/LoginForm.jsp" );
+        File src = new File( "tests/etc/TestMigratorForm.jsp" );
         String s = JspMigrator.readSource( src );
 
         // Parse the contents of the file
@@ -412,7 +412,7 @@
         assertEquals( 3, node.getLine() );
         assertEquals( 1, node.getColumn() );
         assertEquals( 190, node.getStart() );
-        assertEquals( 254, node.getEnd() );
+        assertEquals( 257, node.getEnd() );
         assertEquals( 4, node.getChildren().size() );
         assertEquals( NodeType.START_TAG, node.getType() );
         assertEquals( NodeType.ROOT, node.getParent().getType() );
@@ -421,13 +421,13 @@
         assertEquals( 1, ((Tag) node).getAttributes().size() );
         attribute = ((Tag) node).getAttributes().get( 0 );
         assertEquals( "name", attribute.getName() );
-        assertEquals( "/templates/default/ViewLayout.jsp", attribute.getValue() );
+        assertEquals( "/templates/default/DefaultLayout.jsp", attribute.getValue() );
         i++;
         node = nodes.get( i );
         assertEquals( 3, node.getLine() );
-        assertEquals( 65, node.getColumn() );
-        assertEquals( 254, node.getStart() );
-        assertEquals( 257, node.getEnd() );
+        assertEquals( 68, node.getColumn() );
+        assertEquals( 257, node.getStart() );
+        assertEquals( 260, node.getEnd() );
         assertEquals( 0, node.getChildren().size() );
         assertEquals( NodeType.TEXT, node.getType() );
         assertEquals( NodeType.START_TAG, node.getParent().getType() );
@@ -439,8 +439,8 @@
         node = nodes.get( i );
         assertEquals( 4, node.getLine() );
         assertEquals( 3, node.getColumn() );
-        assertEquals( 257, node.getStart() );
-        assertEquals( 298, node.getEnd() );
+        assertEquals( 260, node.getStart() );
+        assertEquals( 301, node.getEnd() );
         assertEquals( 3, node.getChildren().size() );
         assertEquals( NodeType.START_TAG, node.getType() );
         assertEquals( NodeType.START_TAG, node.getParent().getType() );
@@ -454,8 +454,8 @@
         node = nodes.get( i );
         assertEquals( 4, node.getLine() );
         assertEquals( 44, node.getColumn() );
-        assertEquals( 298, node.getStart() );
-        assertEquals( 303, node.getEnd() );
+        assertEquals( 301, node.getStart() );
+        assertEquals( 306, node.getEnd() );
         assertEquals( 0, node.getChildren().size() );
         assertEquals( NodeType.TEXT, node.getType() );
         assertEquals( NodeType.START_TAG, node.getParent().getType() );
@@ -467,8 +467,8 @@
         node = nodes.get( i );
         assertEquals( 5, node.getLine() );
         assertEquals( 5, node.getColumn() );
-        assertEquals( 303, node.getStart() );
-        assertEquals( 361, node.getEnd() );
+        assertEquals( 306, node.getStart() );
+        assertEquals( 364, node.getEnd() );
         assertEquals( 0, node.getChildren().size() );
         assertEquals( NodeType.EMPTY_ELEMENT_TAG, node.getType() );
         assertEquals( NodeType.START_TAG, node.getParent().getType() );
@@ -482,8 +482,8 @@
         node = nodes.get( i );
         assertEquals( 5, node.getLine() );
         assertEquals( 63, node.getColumn() );
-        assertEquals( 361, node.getStart() );
-        assertEquals( 364, node.getEnd() );
+        assertEquals( 364, node.getStart() );
+        assertEquals( 367, node.getEnd() );
         assertEquals( 0, node.getChildren().size() );
         assertEquals( NodeType.TEXT, node.getType() );
         assertEquals( NodeType.START_TAG, node.getParent().getType() );
@@ -495,8 +495,8 @@
         node = nodes.get( i );
         assertEquals( 6, node.getLine() );
         assertEquals( 3, node.getColumn() );
-        assertEquals( 364, node.getStart() );
-        assertEquals( 391, node.getEnd() );
+        assertEquals( 367, node.getStart() );
+        assertEquals( 394, node.getEnd() );
         assertEquals( 0, node.getChildren().size() );
         assertEquals( NodeType.END_TAG, node.getType() );
         assertEquals( NodeType.START_TAG, node.getParent().getType() );
@@ -507,8 +507,8 @@
         node = nodes.get( i );
         assertEquals( 6, node.getLine() );
         assertEquals( 30, node.getColumn() );
-        assertEquals( 391, node.getStart() );
-        assertEquals( 392, node.getEnd() );
+        assertEquals( 394, node.getStart() );
+        assertEquals( 395, node.getEnd() );
         assertEquals( 0, node.getChildren().size() );
         assertEquals( NodeType.TEXT, node.getType() );
         assertEquals( NodeType.START_TAG, node.getParent().getType() );
@@ -520,8 +520,8 @@
         node = nodes.get( i );
         assertEquals( 7, node.getLine() );
         assertEquals( 1, node.getColumn() );
-        assertEquals( 392, node.getStart() );
-        assertEquals( 416, node.getEnd() );
+        assertEquals( 395, node.getStart() );
+        assertEquals( 419, node.getEnd() );
         assertEquals( 0, node.getChildren().size() );
         assertEquals( NodeType.END_TAG, node.getType() );
         assertEquals( NodeType.ROOT, node.getParent().getType() );
@@ -532,8 +532,8 @@
         node = nodes.get( i );
         assertEquals( 7, node.getLine() );
         assertEquals( 25, node.getColumn() );
-        assertEquals( 416, node.getStart() );
-        assertEquals( 417, node.getEnd() );
+        assertEquals( 419, node.getStart() );
+        assertEquals( 420, node.getEnd() );
         assertEquals( 0, node.getChildren().size() );
         assertEquals( NodeType.TEXT, node.getType() );
         assertEquals( NodeType.ROOT, node.getParent().getType() );

Modified: incubator/jspwiki/trunk/tests/java/org/apache/wiki/ui/stripes/HandlerInfoTest.java
URL: http://svn.apache.org/viewvc/incubator/jspwiki/trunk/tests/java/org/apache/wiki/ui/stripes/HandlerInfoTest.java?rev=768626&r1=768625&r2=768626&view=diff
==============================================================================
--- incubator/jspwiki/trunk/tests/java/org/apache/wiki/ui/stripes/HandlerInfoTest.java (original)
+++ incubator/jspwiki/trunk/tests/java/org/apache/wiki/ui/stripes/HandlerInfoTest.java Sat Apr 25 23:47:11 2009
@@ -26,6 +26,7 @@
 import java.util.Properties;
 
 import org.apache.wiki.TestEngine;
+import org.apache.wiki.action.EditActionBean;
 import org.apache.wiki.action.GroupActionBean;
 import org.apache.wiki.action.ViewActionBean;
 import org.apache.wiki.auth.permissions.GroupPermission;
@@ -190,25 +191,20 @@
     public void testNotEvaluatedPermissionAnnotation() throws Exception
     {
         MockRoundtrip trip;
-        ViewActionBean bean;
+        EditActionBean bean;
         Method method;
         HandlerInfo handlerInfo;
         Permission perm;
 
-        // Set up a new ViewActionBean with the non-existent page Foobar
-        trip = m_engine.guestTrip( "/Wiki.action" );
-        trip.addParameter( "page", "Foobar" );
-        trip.execute( "view" );
-        bean = trip.getActionBean( ViewActionBean.class );
-        assertNotNull( bean );
+        // Set up a new EditActionBean without a page parameter
+        trip = m_engine.guestTrip( "/Edit.action" );
+        trip.execute( "edit" );
+        bean = trip.getActionBean( EditActionBean.class );
         
-        // The Page should not exist
-        assertNull( bean.getPage() );
-
-        // The view handler should NOT return a "view" PagePermission (because
+        // The view handler should NOT return an "edit" PagePermission (because
         // EL can't evaluate)
-        method = ViewActionBean.class.getMethod( "view", new Class[0] );
-        Map<Method,HandlerInfo> handlerInfos = HandlerInfo.getHandlerInfoCollection( ViewActionBean.class );
+        method = EditActionBean.class.getMethod( "edit", new Class[0] );
+        Map<Method,HandlerInfo> handlerInfos = HandlerInfo.getHandlerInfoCollection( EditActionBean.class );
         handlerInfo = handlerInfos.get( method );
         assertNotNull( handlerInfo );
         perm = handlerInfo.getPermission( bean );