Author: metskem
Date: Sun Dec 28 08:41:25 2008
New Revision: 729753
URL: http://svn.apache.org/viewvc?rev=729753&view=rev
Log:
3.0.0-svn-40 JSPWIKI-459 PluginIndexPlugin
cleaned up the test version of jspwiki.properties.tmpl
if you want to run individual junit tests from within eclipse, you can add
log4j to the classpath of the test config (this is not necessary if you run
'ant tests')
Added:
incubator/jspwiki/trunk/src/com/ecyrd/jspwiki/plugin/PluginIndexPlugin.java
incubator/jspwiki/trunk/tests/com/ecyrd/jspwiki/plugin/PluginIndexPluginTest.java
Removed:
incubator/jspwiki/trunk/etc/commons-logging.properties
Modified:
incubator/jspwiki/trunk/ChangeLog
incubator/jspwiki/trunk/ReleaseNotes
incubator/jspwiki/trunk/src/com/ecyrd/jspwiki/Release.java
incubator/jspwiki/trunk/tests/com/ecyrd/jspwiki/plugin/AllTests.java
incubator/jspwiki/trunk/tests/etc/jspwiki.properties.tmpl
Modified: incubator/jspwiki/trunk/ChangeLog
URL:
http://svn.apache.org/viewvc/incubator/jspwiki/trunk/ChangeLog?rev=729753&r1=729752&r2=729753&view=diff
==============================================================================
--- incubator/jspwiki/trunk/ChangeLog (original)
+++ incubator/jspwiki/trunk/ChangeLog Sun Dec 28 08:41:25 2008
@@ -1,3 +1,9 @@
+2008-12-28 Harry Metske <[email protected]>
+
+ * 3.0.0-svn-40
+
+ * JSPWIKI-459 PluginIndexPlugin
+
2008-12-22 Andrew Jaquith <ajaquith AT apache DOT org>
* 3.0.0-svn-39
Modified: incubator/jspwiki/trunk/ReleaseNotes
URL:
http://svn.apache.org/viewvc/incubator/jspwiki/trunk/ReleaseNotes?rev=729753&r1=729752&r2=729753&view=diff
==============================================================================
--- incubator/jspwiki/trunk/ReleaseNotes (original)
+++ incubator/jspwiki/trunk/ReleaseNotes Sun Dec 28 08:41:25 2008
@@ -13,7 +13,7 @@
* JSPWiki now requires JDK 1.5 to run.
-* Simplified Chinese, Dutch and Italian localizations added!
+* Simplified Chinese, Dutch, Russian and Italian localizations added!
* Logging by JSPWiki is now done with slf4j, see http://www.slf4j.org for
details.
You can now decide at runtime which logging implementation you want, just
pick
@@ -22,6 +22,8 @@
you have a good reason.
The log4j configuration statements have been moved to a separate file
log4j.properties,
this file should be on your CLASSPATH, by default it is placed in
WEB-INF/classes
+
+* A new plugin was added that shows you all plugins that are available:
PluginIndexPlugin
The full log of any issues fixed can be found at:
Modified: incubator/jspwiki/trunk/src/com/ecyrd/jspwiki/Release.java
URL:
http://svn.apache.org/viewvc/incubator/jspwiki/trunk/src/com/ecyrd/jspwiki/Release.java?rev=729753&r1=729752&r2=729753&view=diff
==============================================================================
--- incubator/jspwiki/trunk/src/com/ecyrd/jspwiki/Release.java (original)
+++ incubator/jspwiki/trunk/src/com/ecyrd/jspwiki/Release.java Sun Dec 28
08:41:25 2008
@@ -77,7 +77,7 @@
* <p>
* If the build identifier is empty, it is not added.
*/
- public static final String BUILD = "39";
+ public static final String BUILD = "40";
/**
* This is the generic version string you should use
Added:
incubator/jspwiki/trunk/src/com/ecyrd/jspwiki/plugin/PluginIndexPlugin.java
URL:
http://svn.apache.org/viewvc/incubator/jspwiki/trunk/src/com/ecyrd/jspwiki/plugin/PluginIndexPlugin.java?rev=729753&view=auto
==============================================================================
--- incubator/jspwiki/trunk/src/com/ecyrd/jspwiki/plugin/PluginIndexPlugin.java
(added)
+++ incubator/jspwiki/trunk/src/com/ecyrd/jspwiki/plugin/PluginIndexPlugin.java
Sun Dec 28 08:41:25 2008
@@ -0,0 +1,117 @@
+/*
+ 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.Collection;
+import java.util.Map;
+
+import org.apache.jspwiki.api.ModuleData;
+import org.apache.jspwiki.api.PluginException;
+
+import com.ecyrd.jspwiki.WikiContext;
+import com.ecyrd.jspwiki.plugin.PluginManager.WikiPluginInfo;
+
+/**
+ * <p>
+ * Displays which plugins are available in this wiki. Also shows all metadata
+ * available for each plugin in an HTML table
+ * <p>
+ * Parameters :
+ * </p>
+ * <ul>
+ * <li><b>details</b> - value can be true or false, default is false, in which
+ * case only the name of the plugin is listed. If true, then all available meta
+ * data of the plugin is shown</li>
+ * </ul>
+ *
+ * @since 3.0
+ * @author Harry Metske
+ */
+...@moduledata( author = "Harry Metske", minVersion = "3.0", maxVersion =
"1000000", minAPIVersion = "2.8" )
+public class PluginIndexPlugin extends AbstractReferralPlugin implements
WikiPlugin
+{
+ /** Parameter name for the details parameter. Value is
<tt>{...@value}</tt>. */
+ public static final String PARAM_DETAILS = "details";
+
+ private static final String BLANK = " ";
+
+ /**
+ * {...@inheritdoc}
+ */
+ public String execute( WikiContext context, Map params ) throws
PluginException
+ {
+ super.initialize( context, params );
+
+ String details = (String) params.get( PARAM_DETAILS );
+
+ String summaryHeader = "\n||name";
+ String detailHeader = "\n||Name||Class
Name||alias's||author||minVersion||maxVersion||adminBean Class";
+
+ Collection<WikiPluginInfo> plugins =
context.getEngine().getPluginManager().modules();
+
+ StringBuilder wikitext = new StringBuilder();
+
+ if( "true".equals( details ) )
+ {
+ wikitext.append( detailHeader );
+ for( WikiPluginInfo pluginInfo : plugins )
+ {
+ String name = pluginInfo.getName();
+ String clazz = pluginInfo.getClassName();
+ String[] aliass = pluginInfo.getAliases();
+ String author = pluginInfo.getAuthor();
+ if( author == null )
+ author = BLANK;
+ String minVersion = pluginInfo.getMinVersion();
+ if( minVersion == null )
+ minVersion = BLANK;
+ String maxVersion = pluginInfo.getMaxVersion();
+ if( maxVersion == null )
+ maxVersion = BLANK;
+ String adminBeanClazz = pluginInfo.getAdminBeanClass();
+ if( adminBeanClazz == null )
+ adminBeanClazz = BLANK;
+ StringBuilder aliassString = new StringBuilder( BLANK );
+
+ if( aliass != null )
+ {
+ for( int i = 0; i < aliass.length; i++ )
+ {
+ aliassString.append( " " + aliass[i] );
+ }
+ }
+
+ wikitext.append( "\n|" + name + "|" + clazz + "|" +
aliassString + "|" + author + "|" + minVersion + "|"
+ + maxVersion + "|" + adminBeanClazz );
+ }
+ }
+ else
+ {
+ wikitext.append( summaryHeader );
+ for( WikiPluginInfo pluginInfo : plugins )
+ {
+ String name = pluginInfo.getName();
+ wikitext.append( "\n|" + name );
+ }
+ }
+ return makeHTML( context, wikitext.toString() );
+ }
+}
Modified: incubator/jspwiki/trunk/tests/com/ecyrd/jspwiki/plugin/AllTests.java
URL:
http://svn.apache.org/viewvc/incubator/jspwiki/trunk/tests/com/ecyrd/jspwiki/plugin/AllTests.java?rev=729753&r1=729752&r2=729753&view=diff
==============================================================================
--- incubator/jspwiki/trunk/tests/com/ecyrd/jspwiki/plugin/AllTests.java
(original)
+++ incubator/jspwiki/trunk/tests/com/ecyrd/jspwiki/plugin/AllTests.java Sun
Dec 28 08:41:25 2008
@@ -41,6 +41,7 @@
suite.addTest( CounterPluginTest.suite() );
suite.addTest( GroupsTest.suite() );
suite.addTest( InsertPageTest.suite() );
+ suite.addTest( PluginIndexPluginTest.suite() );
suite.addTest( PluginManagerTest.suite() );
suite.addTest( ReferringPagesPluginTest.suite() );
suite.addTest( TableOfContentsTest.suite() );
Added:
incubator/jspwiki/trunk/tests/com/ecyrd/jspwiki/plugin/PluginIndexPluginTest.java
URL:
http://svn.apache.org/viewvc/incubator/jspwiki/trunk/tests/com/ecyrd/jspwiki/plugin/PluginIndexPluginTest.java?rev=729753&view=auto
==============================================================================
---
incubator/jspwiki/trunk/tests/com/ecyrd/jspwiki/plugin/PluginIndexPluginTest.java
(added)
+++
incubator/jspwiki/trunk/tests/com/ecyrd/jspwiki/plugin/PluginIndexPluginTest.java
Sun Dec 28 08:41:25 2008
@@ -0,0 +1,81 @@
+package com.ecyrd.jspwiki.plugin;
+
+import java.util.Properties;
+
+import org.apache.jspwiki.api.PluginException;
+
+import junit.framework.Test;
+import junit.framework.TestCase;
+import junit.framework.TestSuite;
+
+import com.ecyrd.jspwiki.TestEngine;
+import com.ecyrd.jspwiki.WikiContext;
+
+public class PluginIndexPluginTest extends TestCase
+{
+ Properties props = new Properties();
+
+ TestEngine engine;
+
+ WikiContext context;
+
+ PluginManager manager;
+
+ public PluginIndexPluginTest( String s )
+ {
+ super( s );
+ }
+
+ public void setUp() throws Exception
+ {
+ props.load( TestEngine.findTestProperties() );
+
+ // prevent "create" links :
+ props.setProperty( "jspwiki.translatorReader.camelCaseLinks", "false"
);
+
+ engine = new TestEngine( props );
+
+ manager = new PluginManager( engine, props );
+
+ context = engine.getWikiContextFactory().newViewContext(
engine.createPage( "TestPage" ) );
+ }
+
+ public void tearDown()
+ {
+ TestEngine.emptyWorkDir();
+ }
+
+ public static Test suite()
+ {
+ return new TestSuite( PluginIndexPluginTest.class );
+ }
+
+ /**
+ * Test for : PluginIndexPlugin details=false Shows only the plugin names
+ *
+ * @throws PluginException
+ */
+ public void testDetailsFalse() throws PluginException
+ {
+ String expectedResult = "<p />\n<table class=\"wikitable\"
border=\"1\"><tr
class=\"odd\"><th>name</th></tr>\n<tr><td>BugReportHandler</td></tr>\n<tr
class=\"odd\"><td>Counter</td></tr>\n<tr><td>CurrentTimePlugin</td></tr>\n<tr
class=\"odd\"><td>Denounce</td></tr>\n<tr><td>FormClose</td></tr>\n<tr
class=\"odd\"><td>FormInput</td></tr>\n<tr><td>FormOpen</td></tr>\n<tr
class=\"odd\"><td>FormOutput</td></tr>\n<tr><td>FormSelect</td></tr>\n<tr
class=\"odd\"><td>FormSet</td></tr>\n<tr><td>FormTextarea</td></tr>\n<tr
class=\"odd\"><td>Groups</td></tr>\n<tr><td>IfPlugin</td></tr>\n<tr
class=\"odd\"><td>Image</td></tr>\n<tr><td>IndexPlugin</td></tr>\n<tr
class=\"odd\"><td>InsertPage</td></tr>\n<tr><td>JavaScriptPlugin</td></tr>\n<tr
class=\"odd\"><td>ListLocksPlugin</td></tr>\n<tr><td>Note</td></tr>\n<tr
class=\"odd\"><td>PluginIndexPlugin</td></tr>\n<tr><td>RPCSamplePlugin</td></tr>\n<tr
class=\"odd\"><td>RecentChangesPlugin</td></tr>\n<tr><td>ReferredPagesPlugin</td></tr>\
n<tr
class=\"odd\"><td>ReferringPagesPlugin</td></tr>\n<tr><td>SamplePlugin</td></tr>\n<tr
class=\"odd\"><td>Search</td></tr>\n<tr><td>SessionsPlugin</td></tr>\n<tr
class=\"odd\"><td>TableOfContents</td></tr>\n<tr><td>UndefinedPagesPlugin</td></tr>\n<tr
class=\"odd\"><td>UnusedPagesPlugin</td></tr>\n<tr><td>WeblogArchivePlugin</td></tr>\n<tr
class=\"odd\"><td>WeblogEntryPlugin</td></tr>\n<tr><td>WeblogPlugin</td></tr></table>";
+ String result = manager.execute( context, "{PluginIndexPlugin
details=false}" );
+
+ // now this is a very straightforward test, if a new plugin is added,
a plugin is removed, this test will have to be modified
+ assertEquals( expectedResult, result );
+ }
+
+ /**
+ * Test for : PluginIndexPlugin details=true Shows the plugin names
+ * including all attributes
+ *
+ * @throws PluginException
+ */
+ public void testDetailsTrue() throws PluginException
+ {
+ String expectedResult = "<p />\n<table class=\"wikitable\"
border=\"1\"><tr class=\"odd\"><th>Name</th><th>Class
Name</th><th>alias's</th><th>author</th><th>minVersion</th><th>maxVersion</th><th>adminBean
Class</th></tr>\n<tr><td>BugReportHandler</td><td>com.ecyrd.jspwiki.plugin.BugReportHandler</td><td> </td><td> </td><td> </td><td> </td><td> </td></tr>\n<tr
class=\"odd\"><td>Counter</td><td>com.ecyrd.jspwiki.plugin.Counter</td><td> </td><td> </td><td> </td><td> </td><td> </td></tr>\n<tr><td>CurrentTimePlugin</td><td>com.ecyrd.jspwiki.plugin.CurrentTimePlugin</td><td> </td><td> </td><td> </td><td> </td><td> </td></tr>\n<tr
class=\"odd\"><td>Denounce</td><td>com.ecyrd.jspwiki.plugin.Denounce</td><td> </td><td> </td><td> </td><td> </td><td> </td></tr>\n<tr><td>FormClose</td><td>com.ecyrd.jspwiki.forms.FormClose</td><td> </td><td> </td><td> </td><td>
</td><td> </td></tr>\n<tr
class=\"odd\"><td>FormInput</td><td>com.ecyrd.jspwiki.forms.FormInput</td><td> </td><td> </td><td> </td><td> </td><td> </td></tr>\n<tr><td>FormOpen</td><td>com.ecyrd.jspwiki.forms.FormOpen</td><td> </td><td> </td><td> </td><td> </td><td> </td></tr>\n<tr
class=\"odd\"><td>FormOutput</td><td>com.ecyrd.jspwiki.forms.FormOutput</td><td> </td><td> </td><td> </td><td> </td><td> </td></tr>\n<tr><td>FormSelect</td><td>com.ecyrd.jspwiki.forms.FormSelect</td><td> </td><td> </td><td> </td><td> </td><td> </td></tr>\n<tr
class=\"odd\"><td>FormSet</td><td>com.ecyrd.jspwiki.forms.FormSet</td><td> </td><td> </td><td> </td><td> </td><td> </td></tr>\n<tr><td>FormTextarea</td><td>com.ecyrd.jspwiki.forms.FormTextarea</td><td> </td><td> </td><td> </td><td> </td><td> </td></tr>\n<tr
class=\"odd\"><td>Groups</td><td>com
.ecyrd.jspwiki.plugin.Groups</td><td> </td><td> </td><td> </td><td> </td><td> </td></tr>\n<tr><td>IfPlugin</td><td>com.ecyrd.jspwiki.plugin.IfPlugin</td><td>
If</td><td>AnonymousCoward</td><td>0.0</td><td>1000000.0</td><td /></tr>\n<tr
class=\"odd\"><td>Image</td><td>com.ecyrd.jspwiki.plugin.Image</td><td>
</td><td>JSPWiki development group</td><td>0.0</td><td>1000000.0</td><td
/></tr>\n<tr><td>IndexPlugin</td><td>com.ecyrd.jspwiki.plugin.IndexPlugin</td><td> </td><td> </td><td> </td><td> </td><td> </td></tr>\n<tr
class=\"odd\"><td>InsertPage</td><td>com.ecyrd.jspwiki.plugin.InsertPage</td><td> </td><td> </td><td> </td><td> </td><td> </td></tr>\n<tr><td>JavaScriptPlugin</td><td>com.ecyrd.jspwiki.plugin.JavaScriptPlugin</td><td> </td><td> </td><td> </td><td> </td><td> </td></tr>\n<tr
class=\"odd\"><td>ListLocksPlugin</td><td>com.ecyrd.jspwiki.plugin.ListLocksPlugin<
/td><td> </td><td> </td><td> </td><td> </td><td> </td></tr>\n<tr><td>Note</td><td>com.ecyrd.jspwiki.plugin.Note</td><td> </td><td> </td><td> </td><td> </td><td> </td></tr>\n<tr
class=\"odd\"><td>PluginIndexPlugin</td><td>com.ecyrd.jspwiki.plugin.PluginIndexPlugin</td><td>
</td><td>Harry Metske</td><td>3.0</td><td>1000000</td><td
/></tr>\n<tr><td>RPCSamplePlugin</td><td>com.ecyrd.jspwiki.plugin.RPCSamplePlugin</td><td> </td><td> </td><td> </td><td> </td><td> </td></tr>\n<tr
class=\"odd\"><td>RecentChangesPlugin</td><td>com.ecyrd.jspwiki.plugin.RecentChangesPlugin</td><td> </td><td> </td><td> </td><td> </td><td> </td></tr>\n<tr><td>ReferredPagesPlugin</td><td>com.ecyrd.jspwiki.plugin.ReferredPagesPlugin</td><td> </td><td> </td><td> </td><td> </td><td> </td></tr>\n<tr
class=\"odd\"><td>ReferringPagesPlugin</td><td>com.ecyrd.jspwiki.plugin.ReferringP
agesPlugin</td><td> </td><td> </td><td> </td><td> </td><td> </td></tr>\n<tr><td>SamplePlugin</td><td>com.ecyrd.jspwiki.plugin.SamplePlugin</td><td>
samplealias2 samplealias</td><td>Urgle
Burgle</td><td>0.0</td><td>1000000.0</td><td /></tr>\n<tr
class=\"odd\"><td>Search</td><td>com.ecyrd.jspwiki.plugin.Search</td><td> </td><td> </td><td> </td><td> </td><td> </td></tr>\n<tr><td>SessionsPlugin</td><td>com.ecyrd.jspwiki.plugin.SessionsPlugin</td><td> </td><td> </td><td> </td><td> </td><td> </td></tr>\n<tr
class=\"odd\"><td>TableOfContents</td><td>com.ecyrd.jspwiki.plugin.TableOfContents</td><td> </td><td> </td><td> </td><td> </td><td> </td></tr>\n<tr><td>UndefinedPagesPlugin</td><td>com.ecyrd.jspwiki.plugin.UndefinedPagesPlugin</td><td> </td><td> </td><td> </td><td> </td><td> </td></tr>\n<tr
class=\"odd\"><td>UnusedPagesPlugin</td><td>com.ecyrd.jspwi
ki.plugin.UnusedPagesPlugin</td><td> </td><td> </td><td> </td><td> </td><td> </td></tr>\n<tr><td>WeblogArchivePlugin</td><td>com.ecyrd.jspwiki.plugin.WeblogArchivePlugin</td><td> </td><td> </td><td> </td><td> </td><td> </td></tr>\n<tr
class=\"odd\"><td>WeblogEntryPlugin</td><td>com.ecyrd.jspwiki.plugin.WeblogEntryPlugin</td><td> </td><td> </td><td> </td><td> </td><td> </td></tr>\n<tr><td>WeblogPlugin</td><td>com.ecyrd.jspwiki.plugin.WeblogPlugin</td><td> </td><td> </td><td> </td><td> </td><td> </td></tr></table>";
+ String result = manager.execute( context, "{PluginIndexPlugin
details=true}" );
+
+ // now this is a very straightforward test, if a new plugin is added,
a plugin is removed, this test will have to be modified
+ assertEquals( expectedResult, result );
+ }
+}
Modified: incubator/jspwiki/trunk/tests/etc/jspwiki.properties.tmpl
URL:
http://svn.apache.org/viewvc/incubator/jspwiki/trunk/tests/etc/jspwiki.properties.tmpl?rev=729753&r1=729752&r2=729753&view=diff
==============================================================================
--- incubator/jspwiki/trunk/tests/etc/jspwiki.properties.tmpl (original)
+++ incubator/jspwiki/trunk/tests/etc/jspwiki.properties.tmpl Sun Dec 28
08:41:25 2008
@@ -103,47 +103,6 @@
jspwiki.groupdatabase.modified=modified
jspwiki.groupdatabase.modifier=modifier
-#
-# Configure logs.
-#
-# Send mail on alerts
-#
-#
-# Log only interesting stuff on screen.
-#
-#log4j.appender.console = org.apache.log4j.ConsoleAppender
-#log4j.appender.console.Threshold = WARN
-
-#log4j.appender.console.layout = org.apache.log4j.PatternLayout
-#log4j.appender.console.layout.ConversionPattern = %-5p: %m%n
-
-#
-# Log everything into a file.
-log4j.rootCategory=INFO,FileLog
-log4j.logger.com.ecyrd.jspwiki=INFO, FileLog
-log4j.logger.org.mortbay=INFO, TestContainerLog
-log4j.logger.SecurityLog=INFO, SecurityAppender
-
-log4j.appender.FileLog = org.apache.log4j.RollingFileAppender
-log4j.appender.FileLog.MaxFileSize = 10MB
-log4j.appender.FileLog.MaxBackupIndex = 14
-log4j.appender.FileLog.File = @tests.logfile@
-log4j.appender.FileLog.layout = org.apache.log4j.PatternLayout
-log4j.appender.FileLog.layout.ConversionPattern=%d [%t] %p %c %x - %m%n
-
-log4j.appender.SecurityAppender = org.apache.log4j.RollingFileAppender
-log4j.appender.SecurityAppender.MaxFileSize = 10MB
-log4j.appender.SecurityAppender.MaxBackupIndex = 14
-log4j.appender.SecurityAppender.File = @securitylog@
-log4j.appender.SecurityAppender.layout = org.apache.log4j.PatternLayout
-log4j.appender.SecurityAppender.layout.ConversionPattern=%d %p - %m%n
-
-log4j.appender.TestContainerLog = org.apache.log4j.RollingFileAppender
-log4j.appender.TestContainerLog.MaxFileSize = 10MB
-log4j.appender.TestContainerLog.MaxBackupIndex = 14
-log4j.appender.TestContainerLog.layout = org.apache.log4j.PatternLayout
-log4j.appender.TestContainerLog.layout.ConversionPattern=%d [%t] %p %c %x -
%m%n
-
# JavaMail properties
mail.smtp.host = 127.0.0.1
mail.smtp.port = 25