You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@jspwiki.apache.org by me...@apache.org on 2008/11/18 18:43:33 UTC

svn commit: r718663 - in /incubator/jspwiki/branches/JSPWIKI_2_8_BRANCH: ChangeLog src/com/ecyrd/jspwiki/Release.java src/com/ecyrd/jspwiki/plugin/InsertPage.java tests/com/ecyrd/jspwiki/plugin/InsertPageTest.java

Author: metskem
Date: Tue Nov 18 09:43:33 2008
New Revision: 718663

URL: http://svn.apache.org/viewvc?rev=718663&view=rev
Log:
2.8.1-svn-15 JSPWIKI-415: Favorites not displayed properly when blank in userName, added 2 JUnit tests for InsertPage plugin

Modified:
    incubator/jspwiki/branches/JSPWIKI_2_8_BRANCH/ChangeLog
    incubator/jspwiki/branches/JSPWIKI_2_8_BRANCH/src/com/ecyrd/jspwiki/Release.java
    incubator/jspwiki/branches/JSPWIKI_2_8_BRANCH/src/com/ecyrd/jspwiki/plugin/InsertPage.java
    incubator/jspwiki/branches/JSPWIKI_2_8_BRANCH/tests/com/ecyrd/jspwiki/plugin/InsertPageTest.java

Modified: incubator/jspwiki/branches/JSPWIKI_2_8_BRANCH/ChangeLog
URL: http://svn.apache.org/viewvc/incubator/jspwiki/branches/JSPWIKI_2_8_BRANCH/ChangeLog?rev=718663&r1=718662&r2=718663&view=diff
==============================================================================
--- incubator/jspwiki/branches/JSPWIKI_2_8_BRANCH/ChangeLog (original)
+++ incubator/jspwiki/branches/JSPWIKI_2_8_BRANCH/ChangeLog Tue Nov 18 09:43:33 2008
@@ -1,3 +1,11 @@
+2008-11-18  Harry Metske <me...@apache.org>
+
+        * 2.8.1-svn-15
+         
+        * JSPWIKI-415: Favorites not displayed properly when blank in userName, reported by Trevor Harrison
+          Backport from 3.0 to 2.8 on request of Erik Bunn.
+          Added 2 JUnit tests for InsertPage plugin
+  
 2008-11-15  Dirk Frederickx <di...@gmail.com>
 
         * 2.8.1-svn-14

Modified: incubator/jspwiki/branches/JSPWIKI_2_8_BRANCH/src/com/ecyrd/jspwiki/Release.java
URL: http://svn.apache.org/viewvc/incubator/jspwiki/branches/JSPWIKI_2_8_BRANCH/src/com/ecyrd/jspwiki/Release.java?rev=718663&r1=718662&r2=718663&view=diff
==============================================================================
--- incubator/jspwiki/branches/JSPWIKI_2_8_BRANCH/src/com/ecyrd/jspwiki/Release.java (original)
+++ incubator/jspwiki/branches/JSPWIKI_2_8_BRANCH/src/com/ecyrd/jspwiki/Release.java Tue Nov 18 09:43:33 2008
@@ -77,7 +77,7 @@
      *  <p>
      *  If the build identifier is empty, it is not added.
      */
-    public static final String     BUILD         = "14";
+    public static final String     BUILD         = "15";
     
     /**
      *  This is the generic version string you should use

Modified: incubator/jspwiki/branches/JSPWIKI_2_8_BRANCH/src/com/ecyrd/jspwiki/plugin/InsertPage.java
URL: http://svn.apache.org/viewvc/incubator/jspwiki/branches/JSPWIKI_2_8_BRANCH/src/com/ecyrd/jspwiki/plugin/InsertPage.java?rev=718663&r1=718662&r2=718663&view=diff
==============================================================================
--- incubator/jspwiki/branches/JSPWIKI_2_8_BRANCH/src/com/ecyrd/jspwiki/plugin/InsertPage.java (original)
+++ incubator/jspwiki/branches/JSPWIKI_2_8_BRANCH/src/com/ecyrd/jspwiki/plugin/InsertPage.java Tue Nov 18 09:43:33 2008
@@ -23,6 +23,7 @@
 import com.ecyrd.jspwiki.*;
 import com.ecyrd.jspwiki.auth.*;
 import com.ecyrd.jspwiki.auth.permissions.PermissionFactory;
+import com.ecyrd.jspwiki.providers.ProviderException;
 
 import java.util.*;
 
@@ -91,8 +92,24 @@
 
         if( includedPage != null )
         {
-            WikiPage page = engine.getPage( includedPage );
-
+            WikiPage page = null;
+            try
+            {
+                String pageName = engine.getFinalPageName( includedPage );
+                if( pageName != null )
+                {
+                    page = engine.getPage( pageName );
+                }
+                else
+                {
+                    page = engine.getPage( includedPage );
+                }
+            }
+            catch( ProviderException e )
+            {
+                res.append( "<span class=\"error\">Page could not be found by the page provider.</span>" );
+                return res.toString();
+            }
             
             if( page != null )
             {

Modified: incubator/jspwiki/branches/JSPWIKI_2_8_BRANCH/tests/com/ecyrd/jspwiki/plugin/InsertPageTest.java
URL: http://svn.apache.org/viewvc/incubator/jspwiki/branches/JSPWIKI_2_8_BRANCH/tests/com/ecyrd/jspwiki/plugin/InsertPageTest.java?rev=718663&r1=718662&r2=718663&view=diff
==============================================================================
--- incubator/jspwiki/branches/JSPWIKI_2_8_BRANCH/tests/com/ecyrd/jspwiki/plugin/InsertPageTest.java (original)
+++ incubator/jspwiki/branches/JSPWIKI_2_8_BRANCH/tests/com/ecyrd/jspwiki/plugin/InsertPageTest.java Tue Nov 18 09:43:33 2008
@@ -25,6 +25,8 @@
         TestEngine.deleteTestPage( "ThisPage" );
         TestEngine.deleteTestPage( "ThisPage2" );
         TestEngine.deleteTestPage( "Test_Page" );
+        TestEngine.deleteTestPage( "TestPage" );
+        TestEngine.deleteTestPage( "Test Page" );
     }
 
     public void testRecursive() throws Exception
@@ -79,6 +81,32 @@
         assertEquals( "found != 1", "<div style=\"\">foo\n</div>\n", testEngine.getHTML("ThisPage") );    
     }
     
+    
+    /**
+     * a link containing a blank should work if there is a page with exact the
+     * same name ('Test Page')
+     */
+    public void testWithBlanks1() throws Exception
+    {
+        testEngine.saveText( "ThisPage", "[{InsertPage page='Test Page'}]" );
+        testEngine.saveText( "Test Page", "foo[{ALLOW view Anonymous}]" );
+
+        assertEquals( "found != 1", "<div style=\"\">foo\n</div>\n", testEngine.getHTML( "ThisPage" ) );
+    }
+
+    /**
+     * same as testWithBlanks1, but it should still work if the page does not
+     * have the blank in it ( 'Test Page' should work if the included page is
+     * called 'TestPage')
+     */
+    public void testWithBlanks2() throws Exception
+    {
+        testEngine.saveText( "ThisPage", "[{InsertPage page='Test Page'}]" );
+        testEngine.saveText( "TestPage", "foo[{ALLOW view Anonymous}]" );
+
+        assertEquals( "found != 1", "<div style=\"\">foo\n</div>\n", testEngine.getHTML( "ThisPage" ) );
+    }
+    
     public static Test suite()
     {
         return new TestSuite( InsertPageTest.class );