This is an automated email from the ASF dual-hosted git repository. juanpablo pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/jspwiki.git
commit dfd502ef80c626bb2843f4bfc6a104cce4a5d0e1 Author: juanpablo <[email protected]> AuthorDate: Sun Mar 1 21:17:34 2020 +0100 JSPWIKI-303: move PluginManager back to o.a.w.plugin package public plugin api is meant to develop new plugins, so it doesn't make sense to have the PluginManager on the o.a.w.api.engine package --- .../src/main/java/org/apache/wiki/WikiEngine.java | 2 +- .../apache/wiki/api/plugin/ParserStagePlugin.java | 2 +- .../java/org/apache/wiki/parser/PluginContent.java | 2 +- .../apache/wiki/plugin/DefaultPluginManager.java | 1 - .../wiki/{api/engine => plugin}/PluginManager.java | 101 +++++++++------------ .../wiki/ui/admin/DefaultAdminBeanManager.java | 2 +- .../org/apache/wiki/ui/admin/beans/PluginBean.java | 8 +- .../src/main/resources/ini/classmappings.xml | 2 +- .../org/apache/wiki/plugin/PageViewPluginTest.java | 1 - .../wiki/plugin/RecentChangesPluginTest.java | 14 ++- .../wiki/plugin/ReferringPagesPluginTest.java | 40 ++++---- .../plugin/ReferringUndefinedPagesPluginTest.java | 14 ++- .../wiki/plugin/UndefinedPagesPluginTest.java | 1 - 13 files changed, 83 insertions(+), 107 deletions(-) diff --git a/jspwiki-main/src/main/java/org/apache/wiki/WikiEngine.java b/jspwiki-main/src/main/java/org/apache/wiki/WikiEngine.java index f9c6a85..a090109 100644 --- a/jspwiki-main/src/main/java/org/apache/wiki/WikiEngine.java +++ b/jspwiki-main/src/main/java/org/apache/wiki/WikiEngine.java @@ -23,7 +23,6 @@ import org.apache.log4j.Logger; import org.apache.log4j.PropertyConfigurator; import org.apache.wiki.api.core.Engine; import org.apache.wiki.api.engine.FilterManager; -import org.apache.wiki.api.engine.PluginManager; import org.apache.wiki.api.exceptions.ProviderException; import org.apache.wiki.api.exceptions.WikiException; import org.apache.wiki.attachment.AttachmentManager; @@ -40,6 +39,7 @@ import org.apache.wiki.event.WikiEventManager; import org.apache.wiki.event.WikiPageEvent; import org.apache.wiki.i18n.InternationalizationManager; import org.apache.wiki.pages.PageManager; +import org.apache.wiki.plugin.PluginManager; import org.apache.wiki.references.ReferenceManager; import org.apache.wiki.render.RenderingManager; import org.apache.wiki.rss.RSSGenerator; diff --git a/jspwiki-main/src/main/java/org/apache/wiki/api/plugin/ParserStagePlugin.java b/jspwiki-main/src/main/java/org/apache/wiki/api/plugin/ParserStagePlugin.java index 1e38c5c..cea2144 100644 --- a/jspwiki-main/src/main/java/org/apache/wiki/api/plugin/ParserStagePlugin.java +++ b/jspwiki-main/src/main/java/org/apache/wiki/api/plugin/ParserStagePlugin.java @@ -23,7 +23,7 @@ import org.apache.wiki.WikiContext; import java.util.Map; /** - * Implements a Plugin interface for the parser stage. Please see {@link org.apache.wiki.api.engine.PluginManager} + * Implements a Plugin interface for the parser stage. Please see {@link org.apache.wiki.plugin.PluginManager PluginManager} * for further documentation. */ public interface ParserStagePlugin { diff --git a/jspwiki-main/src/main/java/org/apache/wiki/parser/PluginContent.java b/jspwiki-main/src/main/java/org/apache/wiki/parser/PluginContent.java index 506da58..cf81189 100644 --- a/jspwiki-main/src/main/java/org/apache/wiki/parser/PluginContent.java +++ b/jspwiki-main/src/main/java/org/apache/wiki/parser/PluginContent.java @@ -25,11 +25,11 @@ import org.apache.oro.text.regex.Perl5Matcher; import org.apache.wiki.InternalWikiException; import org.apache.wiki.WikiContext; import org.apache.wiki.api.core.Engine; -import org.apache.wiki.api.engine.PluginManager; import org.apache.wiki.api.exceptions.PluginException; import org.apache.wiki.api.plugin.ParserStagePlugin; import org.apache.wiki.api.plugin.PluginElement; import org.apache.wiki.api.plugin.WikiPlugin; +import org.apache.wiki.plugin.PluginManager; import org.apache.wiki.preferences.Preferences; import org.apache.wiki.variables.VariableManager; import org.jdom2.Text; diff --git a/jspwiki-main/src/main/java/org/apache/wiki/plugin/DefaultPluginManager.java b/jspwiki-main/src/main/java/org/apache/wiki/plugin/DefaultPluginManager.java index f07950f..5d7aecc 100644 --- a/jspwiki-main/src/main/java/org/apache/wiki/plugin/DefaultPluginManager.java +++ b/jspwiki-main/src/main/java/org/apache/wiki/plugin/DefaultPluginManager.java @@ -34,7 +34,6 @@ import org.apache.wiki.WikiContext; import org.apache.wiki.ajax.WikiAjaxDispatcherServlet; import org.apache.wiki.ajax.WikiAjaxServlet; import org.apache.wiki.api.core.Engine; -import org.apache.wiki.api.engine.PluginManager; import org.apache.wiki.api.exceptions.PluginException; import org.apache.wiki.api.plugin.InitializablePlugin; import org.apache.wiki.api.plugin.WikiPlugin; diff --git a/jspwiki-main/src/main/java/org/apache/wiki/api/engine/PluginManager.java b/jspwiki-main/src/main/java/org/apache/wiki/plugin/PluginManager.java similarity index 60% rename from jspwiki-main/src/main/java/org/apache/wiki/api/engine/PluginManager.java rename to jspwiki-main/src/main/java/org/apache/wiki/plugin/PluginManager.java index 7ed71ff..3a0b330 100644 --- a/jspwiki-main/src/main/java/org/apache/wiki/api/engine/PluginManager.java +++ b/jspwiki-main/src/main/java/org/apache/wiki/plugin/PluginManager.java @@ -16,19 +16,18 @@ specific language governing permissions and limitations under the License. */ -package org.apache.wiki.api.engine; - -import java.io.IOException; -import java.util.Collection; -import java.util.Map; -import java.util.ResourceBundle; +package org.apache.wiki.plugin; import org.apache.oro.text.regex.Pattern; import org.apache.wiki.WikiContext; import org.apache.wiki.api.exceptions.PluginException; import org.apache.wiki.api.plugin.WikiPlugin; import org.apache.wiki.modules.WikiModuleInfo; -import org.apache.wiki.plugin.DefaultPluginManager.WikiPluginInfo; + +import java.io.IOException; +import java.util.Collection; +import java.util.Map; +import java.util.ResourceBundle; public interface PluginManager { @@ -42,18 +41,15 @@ public interface PluginManager { /** This is the default package to try in case the instantiation fails. */ String DEFAULT_PACKAGE = "org.apache.wiki.plugin"; - /** - * The name of the body content. Current value is "_body". - */ + /** The name of the body content. Current value is "_body". */ String PARAM_BODY = "_body"; /** The name of the command line content parameter. The value is "_cmdline". */ String PARAM_CMDLINE = "_cmdline"; /** - * The name of the parameter containing the start and end positions in the - * read stream of the plugin text (stored as a two-element int[], start - * and end resp.). + * The name of the parameter containing the start and end positions in the read stream of the plugin text (stored as a two-element + * int[], start and end resp.). */ String PARAM_BOUNDS = "_bounds"; @@ -68,8 +64,7 @@ public interface PluginManager { void enablePlugins( boolean enabled ); /** - * Returns plugin execution status. If false, plugins are not - * executed when they are encountered on a WikiPage, and an + * Returns plugin execution status. If false, plugins are not executed when they are encountered on a WikiPage, and an * empty string is returned in their place. * * @return True, if plugins are enabled; false otherwise. @@ -91,80 +86,66 @@ public interface PluginManager { String getPluginSearchPath(); /** - * Executes a plugin class in the given context. - * <P>Used to be private, but is public since 1.9.21. - * - * @param context The current WikiContext. - * @param classname The name of the class. Can also be a - * shortened version without the package name, since the class name is searched from the - * package search path. - * - * @param params A parsed map of key-value pairs. + * Executes a plugin class in the given context. + * <P>Used to be private, but is public since 1.9.21. * - * @return Whatever the plugin returns. + * @param context The current WikiContext. + * @param classname The name of the class. Can also be a shortened version without the package name, since the class name is + * searched from the package search path. + * @param params A parsed map of key-value pairs. + * @return Whatever the plugin returns. + * @throws PluginException If the plugin execution failed for some reason. * - * @throws PluginException If the plugin execution failed for - * some reason. - * - * @since 2.0 + * @since 2.0 */ String execute( WikiContext context, String classname, Map< String, String > params ) throws PluginException; /** - * Parses plugin arguments. Handles quotes and all other kewl stuff. - * - * <h3>Special parameters</h3> - * The plugin body is put into a special parameter defined by {@link #PARAM_BODY}; - * the plugin's command line into a parameter defined by {@link #PARAM_CMDLINE}; - * and the bounds of the plugin within the wiki page text by a parameter defined - * by {@link #PARAM_BOUNDS}, whose value is stored as a two-element int[] array, - * i.e., <tt>[start,end]</tt>. + * Parses plugin arguments. Handles quotes and all other kewl stuff. * - * @param argstring The argument string to the plugin. This is - * typically a list of key-value pairs, using "'" to escape - * spaces in strings, followed by an empty line and then the - * plugin body. In case the parameter is null, will return an - * empty parameter list. + * <h3>Special parameters</h3> + * The plugin body is put into a special parameter defined by {@link #PARAM_BODY}; the plugin's command line into a parameter defined + * by {@link #PARAM_CMDLINE}; and the bounds of the plugin within the wiki page text by a parameter defined by {@link #PARAM_BOUNDS}, + * whose value is stored as a two-element int[] array, i.e., <tt>[start,end]</tt>. * + * @param argstring The argument string to the plugin. This is typically a list of key-value pairs, using "'" to escape + * spaces in strings, followed by an empty line and then the plugin body. In case the parameter is null, will return an + * empty parameter list. * @return A parsed list of parameters. - * * @throws IOException If the parsing fails. */ Map< String, String > parseArgs( String argstring ) throws IOException; /** - * Parses a plugin. Plugin commands are of the form: - * [{INSERT myplugin WHERE param1=value1, param2=value2}] - * myplugin may either be a class name or a plugin alias. - * <P> - * This is the main entry point that is used. + * Parses a plugin. Plugin commands are of the form: + * {@code [{INSERT myplugin WHERE param1=value1, param2=value2}] } + * myplugin may either be a class name or a plugin alias. + * <P> + * This is the main entry point that is used. * - * @param context The current WikiContext. - * @param commandline The full command line, including plugin - * name, parameters and body. + * @param context The current WikiContext. + * @param commandline The full command line, including plugin name, parameters and body. + * @return HTML as returned by the plugin, or possibly an error message. * - * @return HTML as returned by the plugin, or possibly an error - * message. - * - * @throws PluginException From the plugin itself, it propagates, waah! + * @throws PluginException From the plugin itself, it propagates, waah! */ String execute( WikiContext context, String commandline ) throws PluginException; /** - * Returns a collection of modules currently managed by this ModuleManager. Each - * entry is an instance of the {@link WikiModuleInfo} class. This method should return something - * which is safe to iterate over, even if the underlying collection changes. + * Returns a collection of modules currently managed by this ModuleManager. Each entry is an instance of the {@link WikiModuleInfo} + * class. This method should return something which is safe to iterate over, even if the underlying collection changes. * * @return A Collection of {@link WikiModuleInfo} instances. */ Collection< WikiModuleInfo > modules(); /** - * Returns the {@link WikiPluginInfo} information about the provided pluginName. + * Returns the {@link WikiModuleInfo} information about the provided pluginName. + * * @param pluginName * @return The wikiPluginInfo */ - WikiPluginInfo getModuleInfo(String pluginName); + WikiModuleInfo getModuleInfo(String pluginName); /** * Creates a {@link WikiPlugin}. diff --git a/jspwiki-main/src/main/java/org/apache/wiki/ui/admin/DefaultAdminBeanManager.java b/jspwiki-main/src/main/java/org/apache/wiki/ui/admin/DefaultAdminBeanManager.java index 5240be5..7c131b0 100644 --- a/jspwiki-main/src/main/java/org/apache/wiki/ui/admin/DefaultAdminBeanManager.java +++ b/jspwiki-main/src/main/java/org/apache/wiki/ui/admin/DefaultAdminBeanManager.java @@ -22,11 +22,11 @@ import org.apache.log4j.Logger; import org.apache.wiki.Release; import org.apache.wiki.api.core.Engine; import org.apache.wiki.api.engine.FilterManager; -import org.apache.wiki.api.engine.PluginManager; import org.apache.wiki.event.WikiEngineEvent; import org.apache.wiki.event.WikiEvent; import org.apache.wiki.event.WikiEventListener; import org.apache.wiki.modules.WikiModuleInfo; +import org.apache.wiki.plugin.PluginManager; import org.apache.wiki.ui.EditorManager; import org.apache.wiki.ui.TemplateManager; import org.apache.wiki.ui.admin.beans.CoreBean; diff --git a/jspwiki-main/src/main/java/org/apache/wiki/ui/admin/beans/PluginBean.java b/jspwiki-main/src/main/java/org/apache/wiki/ui/admin/beans/PluginBean.java index 704567b..5cc95ca 100644 --- a/jspwiki-main/src/main/java/org/apache/wiki/ui/admin/beans/PluginBean.java +++ b/jspwiki-main/src/main/java/org/apache/wiki/ui/admin/beans/PluginBean.java @@ -19,9 +19,9 @@ package org.apache.wiki.ui.admin.beans; import org.apache.wiki.api.core.Engine; -import org.apache.wiki.api.engine.PluginManager; import org.apache.wiki.modules.WikiModuleInfo; import org.apache.wiki.plugin.DefaultPluginManager.WikiPluginInfo; +import org.apache.wiki.plugin.PluginManager; import org.apache.wiki.util.XHTML; import org.apache.wiki.util.XhtmlUtil; import org.jdom2.Element; @@ -39,14 +39,16 @@ public class PluginBean extends ModuleBean { /** * {@inheritDoc} */ - @Override public String getTitle() { + @Override + public String getTitle() { return "Plugins"; } /** * {@inheritDoc} */ - @Override public int getType() { + @Override + public int getType() { return CORE; } diff --git a/jspwiki-main/src/main/resources/ini/classmappings.xml b/jspwiki-main/src/main/resources/ini/classmappings.xml index 8ef5164..acb5601 100644 --- a/jspwiki-main/src/main/resources/ini/classmappings.xml +++ b/jspwiki-main/src/main/resources/ini/classmappings.xml @@ -56,7 +56,7 @@ <mappedClass>org.apache.wiki.filters.DefaultFilterManager</mappedClass> </mapping> <mapping> - <requestedClass>org.apache.wiki.api.engine.PluginManager</requestedClass> + <requestedClass>org.apache.wiki.plugin.PluginManager</requestedClass> <mappedClass>org.apache.wiki.plugin.DefaultPluginManager</mappedClass> </mapping> <mapping> diff --git a/jspwiki-main/src/test/java/org/apache/wiki/plugin/PageViewPluginTest.java b/jspwiki-main/src/test/java/org/apache/wiki/plugin/PageViewPluginTest.java index 638732d..020bc93 100644 --- a/jspwiki-main/src/test/java/org/apache/wiki/plugin/PageViewPluginTest.java +++ b/jspwiki-main/src/test/java/org/apache/wiki/plugin/PageViewPluginTest.java @@ -22,7 +22,6 @@ import net.sf.ehcache.CacheManager; import org.apache.wiki.TestEngine; import org.apache.wiki.WikiContext; import org.apache.wiki.WikiPage; -import org.apache.wiki.api.engine.PluginManager; import org.apache.wiki.pages.PageManager; import org.junit.jupiter.api.AfterEach; import org.junit.jupiter.api.Assertions; diff --git a/jspwiki-main/src/test/java/org/apache/wiki/plugin/RecentChangesPluginTest.java b/jspwiki-main/src/test/java/org/apache/wiki/plugin/RecentChangesPluginTest.java index 4611bb6..fcc8f47 100644 --- a/jspwiki-main/src/test/java/org/apache/wiki/plugin/RecentChangesPluginTest.java +++ b/jspwiki-main/src/test/java/org/apache/wiki/plugin/RecentChangesPluginTest.java @@ -19,18 +19,16 @@ under the License. package org.apache.wiki.plugin; -import java.util.Properties; - +import net.sf.ehcache.CacheManager; import org.apache.wiki.TestEngine; import org.apache.wiki.WikiContext; import org.apache.wiki.WikiPage; -import org.apache.wiki.api.engine.PluginManager; import org.junit.jupiter.api.AfterEach; import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; -import net.sf.ehcache.CacheManager; +import java.util.Properties; public class RecentChangesPluginTest { Properties props = TestEngine.getTestProperties(); @@ -73,7 +71,7 @@ public class RecentChangesPluginTest { public void testSimple() throws Exception { context = new WikiContext(testEngine, new WikiPage(testEngine, "TestPage01")); - String res = manager.execute(context, "{INSERT org.apache.wiki.plugin.RecentChangesPlugin}"); + final String res = manager.execute(context, "{INSERT org.apache.wiki.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 @@ -92,7 +90,7 @@ public class RecentChangesPluginTest { public void testParmInClude() throws Exception { context = new WikiContext(testEngine, new WikiPage(testEngine, "TestPage02")); - String res = manager.execute( context, + final String res = manager.execute( context, "{INSERT org.apache.wiki.plugin.RecentChangesPlugin include='TestPage02*'}" ); Assertions.assertTrue(res.contains("<table class=\"recentchanges\" cellpadding=\"4\">")); @@ -110,7 +108,7 @@ public class RecentChangesPluginTest { public void testParmExClude() throws Exception { context = new WikiContext(testEngine, new WikiPage(testEngine, "TestPage03")); - String res = manager.execute( context, + final String res = manager.execute( context, "{INSERT org.apache.wiki.plugin.RecentChangesPlugin exclude='TestPage03*'}" ); Assertions.assertTrue(res.contains("<table class=\"recentchanges\" cellpadding=\"4\">")); @@ -128,7 +126,7 @@ public class RecentChangesPluginTest { public void testNoRecentChanges() throws Exception { context = new WikiContext(testEngine, new WikiPage(testEngine, "TestPage04")); - String res = manager.execute( context, + final String res = manager.execute( context, "{INSERT org.apache.wiki.plugin.RecentChangesPlugin since='-1'}" ); Assertions.assertTrue( "<table class=\"recentchanges\" cellpadding=\"4\"></table>".equals( res ) ); diff --git a/jspwiki-main/src/test/java/org/apache/wiki/plugin/ReferringPagesPluginTest.java b/jspwiki-main/src/test/java/org/apache/wiki/plugin/ReferringPagesPluginTest.java index 46aaab9..cdf40fe 100644 --- a/jspwiki-main/src/test/java/org/apache/wiki/plugin/ReferringPagesPluginTest.java +++ b/jspwiki-main/src/test/java/org/apache/wiki/plugin/ReferringPagesPluginTest.java @@ -18,19 +18,19 @@ */ package org.apache.wiki.plugin; -import java.text.SimpleDateFormat; -import java.util.Properties; import org.apache.wiki.TestEngine; import org.apache.wiki.WikiContext; import org.apache.wiki.WikiPage; -import org.apache.wiki.api.engine.PluginManager; import org.apache.wiki.api.exceptions.PluginException; import org.junit.jupiter.api.AfterEach; import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; +import java.text.SimpleDateFormat; +import java.util.Properties; + public class ReferringPagesPluginTest { Properties props = TestEngine.getTestProperties(); @@ -71,12 +71,12 @@ public class ReferringPagesPluginTest engine.deleteTestPage( "Foobar7" ); } - private String mkLink( String page ) + private String mkLink( final String page ) { return mkFullLink( page, page ); } - private String mkFullLink( String page, String link ) + private String mkFullLink( final String page, final String link ) { return "<a class=\"wikipage\" href=\"/test/Wiki.jsp?page="+link+"\">"+page+"</a>"; } @@ -85,9 +85,9 @@ public class ReferringPagesPluginTest public void testSingleReferral() throws Exception { - WikiContext context2 = new WikiContext( engine, new WikiPage(engine, "Foobar") ); + final WikiContext context2 = new WikiContext( engine, new WikiPage(engine, "Foobar") ); - String res = manager.execute( context2, + final String res = manager.execute( context2, "{INSERT org.apache.wiki.plugin.ReferringPagesPlugin WHERE max=5}"); Assertions.assertEquals( mkLink( "TestPage" )+"<br />", @@ -98,7 +98,7 @@ public class ReferringPagesPluginTest public void testMaxReferences() throws Exception { - String res = manager.execute( context, + final String res = manager.execute( context, "{INSERT org.apache.wiki.plugin.ReferringPagesPlugin WHERE max=5}"); int count = 0; @@ -115,7 +115,7 @@ public class ReferringPagesPluginTest // there is one extra "<a" in the result Assertions.assertEquals( 5+1, count ); - String expected = ">...and 2 more</a>"; + final String expected = ">...and 2 more</a>"; count =0; while( (index = res.indexOf(expected,index+1)) != -1 ) { @@ -128,9 +128,9 @@ public class ReferringPagesPluginTest public void testReferenceWidth() throws Exception { - WikiContext context2 = new WikiContext( engine, new WikiPage(engine, "Foobar") ); + final WikiContext context2 = new WikiContext( engine, new WikiPage(engine, "Foobar") ); - String res = manager.execute( context2, + final String res = manager.execute( context2, "{INSERT org.apache.wiki.plugin.ReferringPagesPlugin WHERE maxwidth=5}"); Assertions.assertEquals( mkFullLink( "TestP...", "TestPage" )+"<br />", @@ -141,7 +141,7 @@ public class ReferringPagesPluginTest public void testInclude() throws Exception { - String res = manager.execute( context, + final String res = manager.execute( context, "{ReferringPagesPlugin include='*7'}" ); Assertions.assertTrue( res.indexOf("Foobar7") != -1, "7" ); @@ -156,7 +156,7 @@ public class ReferringPagesPluginTest public void testExclude() throws Exception { - String res = manager.execute( context, "{ReferringPagesPlugin exclude='*'}"); + final String res = manager.execute( context, "{ReferringPagesPlugin exclude='*'}"); Assertions.assertEquals( "...nobody", res ); } @@ -164,7 +164,7 @@ public class ReferringPagesPluginTest public void testExclude2() throws Exception { - String res = manager.execute( context, + final String res = manager.execute( context, "{ReferringPagesPlugin exclude='*7'}"); Assertions.assertTrue( res.indexOf("Foobar7") == -1 ); @@ -174,7 +174,7 @@ public class ReferringPagesPluginTest public void testExclude3() throws Exception { - String res = manager.execute( context, + final String res = manager.execute( context, "{ReferringPagesPlugin exclude='*7,*5,*4'}"); Assertions.assertTrue( res.indexOf("Foobar7") == -1, "7" ); @@ -196,22 +196,22 @@ public class ReferringPagesPluginTest Assertions.assertEquals("6",result); result = manager.execute(context, "{ReferringPagesPlugin,exclude='*7',show=count,showLastModified=true}"); - String numberResult=result.substring(0,result.indexOf(" ")); + final String numberResult=result.substring(0,result.indexOf(" ")); Assertions.assertEquals("6",numberResult); - String dateString = result.substring(result.indexOf("(")+1,result.indexOf(")")); + final String dateString = result.substring(result.indexOf("(")+1,result.indexOf(")")); // the date should be parseable: - SimpleDateFormat df = new SimpleDateFormat("HH:mm:ss dd-MMM-yyyy zzz", engine.newHttpRequest().getLocale()); + final SimpleDateFormat df = new SimpleDateFormat("HH:mm:ss dd-MMM-yyyy zzz", engine.newHttpRequest().getLocale()); df.parse(dateString); // test if the proper exception is thrown: - String expectedExceptionString = "showLastModified=true is only valid if show=count is also specified"; + final String expectedExceptionString = "showLastModified=true is only valid if show=count is also specified"; String exceptionString = null; try { result = manager.execute(context, "{ReferringPagesPlugin,showLastModified=true}"); } - catch (PluginException pe) + catch ( final PluginException pe) { exceptionString = pe.getMessage(); } diff --git a/jspwiki-main/src/test/java/org/apache/wiki/plugin/ReferringUndefinedPagesPluginTest.java b/jspwiki-main/src/test/java/org/apache/wiki/plugin/ReferringUndefinedPagesPluginTest.java index e852b5e..b217e57 100644 --- a/jspwiki-main/src/test/java/org/apache/wiki/plugin/ReferringUndefinedPagesPluginTest.java +++ b/jspwiki-main/src/test/java/org/apache/wiki/plugin/ReferringUndefinedPagesPluginTest.java @@ -19,18 +19,16 @@ under the License. package org.apache.wiki.plugin; -import java.util.Properties; - +import net.sf.ehcache.CacheManager; import org.apache.wiki.TestEngine; import org.apache.wiki.WikiContext; import org.apache.wiki.WikiPage; -import org.apache.wiki.api.engine.PluginManager; import org.junit.jupiter.api.AfterEach; import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; -import net.sf.ehcache.CacheManager; +import java.util.Properties; public class ReferringUndefinedPagesPluginTest { Properties props = TestEngine.getTestProperties(); @@ -69,7 +67,7 @@ public class ReferringUndefinedPagesPluginTest { */ @Test public void testSimple() throws Exception { - String res = manager.execute(context, "{INSERT ReferringUndefinedPagesPlugin}"); + final String res = manager.execute(context, "{INSERT ReferringUndefinedPagesPlugin}"); Assertions.assertTrue(res.contains("href=\"/test/Wiki.jsp?page=TestPage01\"")); } @@ -80,7 +78,7 @@ public class ReferringUndefinedPagesPluginTest { */ @Test public void testParmInClude() throws Exception { - String res = manager.execute(context, "{INSERT ReferringUndefinedPagesPlugin} include='TestPage02*'}"); + final String res = manager.execute(context, "{INSERT ReferringUndefinedPagesPlugin} include='TestPage02*'}"); Assertions.assertFalse(res.contains("href=\"/test/Wiki.jsp?page=TestPage01\"")); Assertions.assertTrue(res.contains("href=\"/test/Wiki.jsp?page=TestPage02\"")); Assertions.assertFalse(res.contains("href=\"/test/Wiki.jsp?page=TestPage03\"")); @@ -93,7 +91,7 @@ public class ReferringUndefinedPagesPluginTest { */ @Test public void testParmExClude() throws Exception { - String res = manager.execute(context,"{INSERT ReferringUndefinedPagesPlugin} exclude='TestPage02*'}"); + final String res = manager.execute(context,"{INSERT ReferringUndefinedPagesPlugin} exclude='TestPage02*'}"); Assertions.assertTrue(res.contains("href=\"/test/Wiki.jsp?page=TestPage01\"")); Assertions.assertFalse(res.contains("href=\"/test/Wiki.jsp?page=TestPage02\"")); @@ -107,7 +105,7 @@ public class ReferringUndefinedPagesPluginTest { */ @Test public void testParmMax() throws Exception { - String res = manager.execute(context,"{INSERT ReferringUndefinedPagesPlugin} max='2'}"); + final String res = manager.execute(context,"{INSERT ReferringUndefinedPagesPlugin} max='2'}"); Assertions.assertTrue(res.contains("href=\"/test/Wiki.jsp?page=TestPage01\"")); Assertions.assertTrue(res.contains("href=\"/test/Wiki.jsp?page=TestPage02\"")); diff --git a/jspwiki-main/src/test/java/org/apache/wiki/plugin/UndefinedPagesPluginTest.java b/jspwiki-main/src/test/java/org/apache/wiki/plugin/UndefinedPagesPluginTest.java index c63198a..1b0c938 100644 --- a/jspwiki-main/src/test/java/org/apache/wiki/plugin/UndefinedPagesPluginTest.java +++ b/jspwiki-main/src/test/java/org/apache/wiki/plugin/UndefinedPagesPluginTest.java @@ -23,7 +23,6 @@ import net.sf.ehcache.CacheManager; import org.apache.wiki.TestEngine; import org.apache.wiki.WikiContext; import org.apache.wiki.WikiPage; -import org.apache.wiki.api.engine.PluginManager; import org.apache.wiki.api.exceptions.PluginException; import org.apache.wiki.render.RenderingManager; import org.junit.jupiter.api.AfterEach;
