jspwiki-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mets...@apache.org
Subject svn commit: r742695 - in /incubator/jspwiki/branches/JSPWIKI_2_8_BRANCH: ./ src/com/ecyrd/jspwiki/ src/com/ecyrd/jspwiki/plugin/ tests/com/ecyrd/jspwiki/plugin/
Date Mon, 09 Feb 2009 19:37:03 GMT
Author: metskem
Date: Mon Feb  9 19:37:02 2009
New Revision: 742695

URL: http://svn.apache.org/viewvc?rev=742695&view=rev
Log:
2.8.2-svn-10 JSPWIKI-496 RecentChangesPlugin should filter pages

Added:
    incubator/jspwiki/branches/JSPWIKI_2_8_BRANCH/tests/com/ecyrd/jspwiki/plugin/RecentChangesPluginTest.java
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/AbstractReferralPlugin.java
    incubator/jspwiki/branches/JSPWIKI_2_8_BRANCH/src/com/ecyrd/jspwiki/plugin/RecentChangesPlugin.java
    incubator/jspwiki/branches/JSPWIKI_2_8_BRANCH/tests/com/ecyrd/jspwiki/plugin/AllTests.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=742695&r1=742694&r2=742695&view=diff
==============================================================================
--- incubator/jspwiki/branches/JSPWIKI_2_8_BRANCH/ChangeLog (original)
+++ incubator/jspwiki/branches/JSPWIKI_2_8_BRANCH/ChangeLog Mon Feb  9 19:37:02 2009
@@ -1,3 +1,9 @@
+2009-02-09  Harry Metske <metskem@apache.org>
+
+        * 2.8.2-svn-10
+        
+        * JSPWIKI-496 RecentChangesPlugin should filter pages
+
 2009-02-06  Harry Metske <metskem@apache.org>
 
         * 2.8.2-svn-9

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=742695&r1=742694&r2=742695&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 Mon Feb
 9 19:37:02 2009
@@ -77,7 +77,7 @@
      *  <p>
      *  If the build identifier is empty, it is not added.
      */
-    public static final String     BUILD         = "9";
+    public static final String     BUILD         = "10";
     
     /**
      *  This is the generic version string you should use

Modified: incubator/jspwiki/branches/JSPWIKI_2_8_BRANCH/src/com/ecyrd/jspwiki/plugin/AbstractReferralPlugin.java
URL: http://svn.apache.org/viewvc/incubator/jspwiki/branches/JSPWIKI_2_8_BRANCH/src/com/ecyrd/jspwiki/plugin/AbstractReferralPlugin.java?rev=742695&r1=742694&r2=742695&view=diff
==============================================================================
--- incubator/jspwiki/branches/JSPWIKI_2_8_BRANCH/src/com/ecyrd/jspwiki/plugin/AbstractReferralPlugin.java
(original)
+++ incubator/jspwiki/branches/JSPWIKI_2_8_BRANCH/src/com/ecyrd/jspwiki/plugin/AbstractReferralPlugin.java
Mon Feb  9 19:37:02 2009
@@ -28,7 +28,6 @@
 import org.apache.log4j.Logger;
 import org.apache.oro.text.GlobCompiler;
 import org.apache.oro.text.regex.*;
-
 import com.ecyrd.jspwiki.*;
 import com.ecyrd.jspwiki.parser.MarkupParser;
 import com.ecyrd.jspwiki.parser.WikiDocument;
@@ -230,13 +229,22 @@
      */
     protected Collection filterCollection( Collection c )
     {
-        ArrayList<String> result = new ArrayList<String>();
+        ArrayList<Object> result = new ArrayList<Object>();
 
         PatternMatcher pm = new Perl5Matcher();
 
         for( Iterator i = c.iterator(); i.hasNext(); )
         {
-            String pageName = (String) i.next();
+            String pageName = null;
+            Object objectje = i.next();
+            if( objectje instanceof WikiPage )
+            {
+                pageName = ((WikiPage) objectje).getName();
+            }
+            else
+            {
+                pageName = (String) objectje;
+            }
 
             //
             //  If include parameter exists, then by default we include only those
@@ -272,7 +280,14 @@
 
             if( includeThis )
             {
-                result.add( pageName );
+                if( objectje instanceof WikiPage )
+                {
+                    result.add( objectje );
+                }
+                else
+                {
+                    result.add( pageName );
+                }
                 //
                 //  if we want to show the last modified date of the most recently change
page, we keep a "high watermark" here:
                 WikiPage page = null;

Modified: incubator/jspwiki/branches/JSPWIKI_2_8_BRANCH/src/com/ecyrd/jspwiki/plugin/RecentChangesPlugin.java
URL: http://svn.apache.org/viewvc/incubator/jspwiki/branches/JSPWIKI_2_8_BRANCH/src/com/ecyrd/jspwiki/plugin/RecentChangesPlugin.java?rev=742695&r1=742694&r2=742695&view=diff
==============================================================================
--- incubator/jspwiki/branches/JSPWIKI_2_8_BRANCH/src/com/ecyrd/jspwiki/plugin/RecentChangesPlugin.java
(original)
+++ incubator/jspwiki/branches/JSPWIKI_2_8_BRANCH/src/com/ecyrd/jspwiki/plugin/RecentChangesPlugin.java
Mon Feb  9 19:37:02 2009
@@ -48,8 +48,7 @@
  *  </ul>
  *  
  */
-public class RecentChangesPlugin
-    implements WikiPlugin
+public class RecentChangesPlugin extends AbstractReferralPlugin implements WikiPlugin
 {
     /** Parameter name for the separator format.  Value is <tt>{@value}</tt>.
*/
     public static final String PARAM_FORMAT = "format";
@@ -80,8 +79,7 @@
     public String execute( WikiContext context, Map params )
         throws PluginException
     {
-        int      since    = TextUtil.parseIntParameter( (String) params.get("since"),
-                                                        DEFAULT_DAYS );
+        int since = TextUtil.parseIntParameter( (String) params.get( "since" ), DEFAULT_DAYS
);
         int      spacing  = 4;
         boolean  showAuthor = true;
         boolean  showChangenote = true;
@@ -108,7 +106,9 @@
         // FIXME: Should really have a since date on the getRecentChanges
         // method.
         Collection   changes = engine.getRecentChanges();
-
+        super.initialize( context, params );
+        changes = super.filterCollection( changes );
+        
         if( changes != null )
         {
             Date olddate   = new Date(0);

Modified: incubator/jspwiki/branches/JSPWIKI_2_8_BRANCH/tests/com/ecyrd/jspwiki/plugin/AllTests.java
URL: http://svn.apache.org/viewvc/incubator/jspwiki/branches/JSPWIKI_2_8_BRANCH/tests/com/ecyrd/jspwiki/plugin/AllTests.java?rev=742695&r1=742694&r2=742695&view=diff
==============================================================================
--- incubator/jspwiki/branches/JSPWIKI_2_8_BRANCH/tests/com/ecyrd/jspwiki/plugin/AllTests.java
(original)
+++ incubator/jspwiki/branches/JSPWIKI_2_8_BRANCH/tests/com/ecyrd/jspwiki/plugin/AllTests.java
Mon Feb  9 19:37:02 2009
@@ -25,6 +25,7 @@
         suite.addTest( ReferringPagesPluginTest.suite() );
         suite.addTest( TableOfContentsTest.suite() );
         suite.addTest( UndefinedPagesPluginTest.suite() );
+        suite.addTest( RecentChangesPluginTest.suite() );
 
         return suite;
     }

Added: incubator/jspwiki/branches/JSPWIKI_2_8_BRANCH/tests/com/ecyrd/jspwiki/plugin/RecentChangesPluginTest.java
URL: http://svn.apache.org/viewvc/incubator/jspwiki/branches/JSPWIKI_2_8_BRANCH/tests/com/ecyrd/jspwiki/plugin/RecentChangesPluginTest.java?rev=742695&view=auto
==============================================================================
--- incubator/jspwiki/branches/JSPWIKI_2_8_BRANCH/tests/com/ecyrd/jspwiki/plugin/RecentChangesPluginTest.java
(added)
+++ incubator/jspwiki/branches/JSPWIKI_2_8_BRANCH/tests/com/ecyrd/jspwiki/plugin/RecentChangesPluginTest.java
Mon Feb  9 19:37:02 2009
@@ -0,0 +1,130 @@
+/*
+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.plugin;
+
+import java.util.Properties;
+
+import com.ecyrd.jspwiki.TestEngine;
+import com.ecyrd.jspwiki.WikiContext;
+import com.ecyrd.jspwiki.WikiPage;
+import com.ecyrd.jspwiki.plugin.PluginManager;
+
+import junit.framework.Test;
+import junit.framework.TestCase;
+import junit.framework.TestSuite;
+
+
+public class RecentChangesPluginTest extends TestCase
+{
+Properties props = new Properties();
+
+TestEngine engine;
+
+WikiContext context;
+
+PluginManager manager;
+
+public void setUp() throws Exception
+{
+    props.load( TestEngine.findTestProperties() );
+
+    engine = new TestEngine( props );
+
+    engine.saveText( "TestPage01", "Some Text for testing 01" );
+    engine.saveText( "TestPage02", "Some Text for testing 02" );
+    engine.saveText( "TestPage03", "Some Text for testing 03" );
+
+    manager = new PluginManager( engine, props );
+}
+
+public void tearDown()
+{
+    TestEngine.deleteTestPage( "TestPage01" );
+    TestEngine.deleteTestPage( "TestPage02" );
+    TestEngine.deleteTestPage( "TestPage03" );
+    
+    TestEngine.emptyWorkDir();
+}
+
+/**
+ * Plain test without parameters
+ * 
+ * @throws Exception
+ */
+public void testSimple() throws Exception
+{
+    context = new WikiContext( engine, new WikiPage(engine,"TestPage01") );
+
+    String res = manager.execute( context, "{INSERT com.ecyrd.jspwiki.plugin.RecentChangesPlugin}"
);
+
+    // we don't want to compare the complete html returned, but check if certain Strings
are present and other 
+    // Strings are not present
+    assertTrue(res.contains( "<table cellpadding='4' class='recentchanges'>"));
+    assertTrue(res.contains( "<a href='/Wiki.jsp?page=TestPage01'>Test Page 01</a>"
));
+    assertTrue(res.contains( "<a href='/Wiki.jsp?page=TestPage02'>Test Page 02</a>"
));
+    assertTrue(res.contains( "<a href='/Wiki.jsp?page=TestPage03'>Test Page 03</a>"
));
+
+}
+
+/**
+ * Test with the include parameter
+ * 
+ * @throws Exception
+ */
+public void testParmInClude() throws Exception
+{
+    context = new WikiContext( engine, new WikiPage(engine,"TestPage02") );
+
+    String res = manager.execute( context,
+                                  "{INSERT com.ecyrd.jspwiki.plugin.RecentChangesPlugin include='TestPage02*'}"
);
+    
+    assertTrue(res.contains( "<table cellpadding='4' class='recentchanges'>"));
+    assertFalse(res.contains( "<a href='/Wiki.jsp?page=TestPage01'>Test Page 01</a>"
));
+    assertTrue(res.contains( "<a href='/Wiki.jsp?page=TestPage02'>Test Page 02</a>"
));
+    assertFalse(res.contains( "<a href='/Wiki.jsp?page=TestPage03'>Test Page 03</a>"
));
+
+}
+
+/**
+ * Test with the exclude parameter
+ * 
+ * @throws Exception
+ */
+public void testParmExClude() throws Exception
+{
+    context = new WikiContext( engine, new WikiPage(engine,"TestPage03") );
+
+    String res = manager.execute( context,
+                                  "{INSERT com.ecyrd.jspwiki.plugin.RecentChangesPlugin exclude='TestPage03*'}"
);
+    
+    assertTrue(res.contains( "<table cellpadding='4' class='recentchanges'>"));
+    assertTrue(res.contains( "<a href='/Wiki.jsp?page=TestPage01'>Test Page 01</a>"
));
+    assertTrue(res.contains( "<a href='/Wiki.jsp?page=TestPage02'>Test Page 02</a>"
));
+    assertFalse(res.contains( "<a href='/Wiki.jsp?page=TestPage03'>Test Page 03</a>"
));
+
+}
+
+public static Test suite()
+{
+    return new TestSuite( RecentChangesPluginTest.class );
+}
+}



Mime
View raw message