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 21c46bb89311a2c3662ab866236f2991f29e7968 Author: juanpablo <[email protected]> AuthorDate: Wed Jan 22 23:21:44 2020 +0100 JSPWIKI-1127: remove getViewURL from WikiEngine + remove absolute parameter from url constructors --- .../src/main/java/org/apache/wiki/WikiContext.java | 4 +- .../src/main/java/org/apache/wiki/WikiEngine.java | 20 +-- .../org/apache/wiki/url/DefaultURLConstructor.java | 38 ++-- .../org/apache/wiki/url/ShortURLConstructor.java | 200 ++++++++------------- .../apache/wiki/url/ShortViewURLConstructor.java | 82 +++------ .../java/org/apache/wiki/url/URLConstructor.java | 3 +- .../test/java/org/apache/wiki/WikiEngineTest.java | 5 - .../apache/wiki/url/DefaultURLConstructorTest.java | 30 ++-- .../apache/wiki/url/ShortURLConstructorTest.java | 30 ++-- .../wiki/url/ShortViewURLConstructorTest.java | 30 ++-- 10 files changed, 164 insertions(+), 278 deletions(-) diff --git a/jspwiki-main/src/main/java/org/apache/wiki/WikiContext.java b/jspwiki-main/src/main/java/org/apache/wiki/WikiContext.java index 6fa1dab..13a2d11 100644 --- a/jspwiki-main/src/main/java/org/apache/wiki/WikiContext.java +++ b/jspwiki-main/src/main/java/org/apache/wiki/WikiContext.java @@ -576,10 +576,8 @@ public class WikiContext implements Cloneable, Command { * @return An URL to the given context and page. */ public String getURL( final String context, final String page, final String params ) { - final boolean absolute = "absolute".equals(m_engine.getVariableManager().getVariable( this, WikiEngine.PROP_REFSTYLE )); - // FIXME: is rather slow - return m_engine.getURL( context, page, params, absolute ); + return m_engine.getURL( context, page, params ); } /** 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 a2846ac..67c1d4d 100644 --- a/jspwiki-main/src/main/java/org/apache/wiki/WikiEngine.java +++ b/jspwiki-main/src/main/java/org/apache/wiki/WikiEngine.java @@ -706,34 +706,18 @@ public class WikiEngine { } /** - * <p>Returns the basic absolute URL to a page, without any modifications. You may add any parameters to this.</p> - * <p>Since 2.3.90 it is safe to call this method with {@code null} pageName, in which case it will default to the front page.</p> - * - * @since 2.0.3 - * @param pageName The name of the page. May be null, in which case defaults to the front page. - * @return An absolute URL to the page. - */ - public String getViewURL( String pageName ) { - if( pageName == null ) { - pageName = getFrontPage(); - } - return getURLConstructor().makeURL( WikiContext.VIEW, pageName, true, null ); - } - - /** * Returns an URL if a WikiContext is not available. * * @param context The WikiContext (VIEW, EDIT, etc...) * @param pageName Name of the page, as usual * @param params List of parameters. May be null, if no parameters. - * @param absolute If true, will generate an absolute URL regardless of properties setting. * @return An URL (absolute or relative). */ - public String getURL( final String context, String pageName, final String params, final boolean absolute ) { + public String getURL( final String context, String pageName, final String params ) { if( pageName == null ) { pageName = getFrontPage(); } - return m_urlConstructor.makeURL( context, pageName, absolute, params ); + return m_urlConstructor.makeURL( context, pageName, params ); } /** diff --git a/jspwiki-main/src/main/java/org/apache/wiki/url/DefaultURLConstructor.java b/jspwiki-main/src/main/java/org/apache/wiki/url/DefaultURLConstructor.java index 9a72a4d..f35200e 100644 --- a/jspwiki-main/src/main/java/org/apache/wiki/url/DefaultURLConstructor.java +++ b/jspwiki-main/src/main/java/org/apache/wiki/url/DefaultURLConstructor.java @@ -29,9 +29,9 @@ import javax.servlet.http.HttpServletRequest; import java.nio.charset.Charset; import java.util.Properties; + /** - * Implements the default URL constructor using links directly to the - * JSP pages. This is what JSPWiki by default is using. For example, + * Implements the default URL constructor using links directly to the JSP pages. This is what JSPWiki by default is using. For example, * WikiContext.VIEW points at "Wiki.jsp", etc. * * @since 2.2 @@ -41,8 +41,7 @@ public class DefaultURLConstructor implements URLConstructor { protected WikiEngine m_engine; /** - * Contains the absolute path of the JSPWiki Web application without the - * actual servlet (which is the m_urlPrefix). + * Contains the absolute path of the JSPWiki Web application without the actual servlet (which is the m_urlPrefix). */ protected String m_pathPrefix = ""; @@ -59,8 +58,7 @@ public class DefaultURLConstructor implements URLConstructor { * Does replacement of some particular variables. The variables are: * * <ul> - * <li> "%u" - inserts either the base URL (when absolute is required), or the base path - * (which is an absolute path without the host name). + * <li> "%u" - inserts either the base URL (when absolute is required), or the base path (which is an absolute path without the host name). * <li> "%U" - always inserts the base URL * <li> "%p" - always inserts the base path * <li> "%n" - inserts the page name @@ -68,16 +66,10 @@ public class DefaultURLConstructor implements URLConstructor { * * @param baseptrn The pattern to use * @param name The page name - * @param absolute If true, %u is always the entire base URL, otherwise it depends on - * the setting in jspwiki.properties. * @return A replacement. */ - protected final String doReplacement( String baseptrn, final String name, final boolean absolute ) { - String baseurl = m_pathPrefix; - - if( absolute ) { - baseurl = m_engine.getBaseURL() + "/"; - } + protected final String doReplacement( String baseptrn, final String name ) { + final String baseurl = m_pathPrefix; baseptrn = TextUtil.replaceString( baseptrn, "%u", baseurl ); baseptrn = TextUtil.replaceString( baseptrn, "%U", m_engine.getBaseURL() ); @@ -88,8 +80,7 @@ public class DefaultURLConstructor implements URLConstructor { } /** - * URLEncoder returns pluses, when we want to have the percent - * encoding. See http://issues.apache.org/bugzilla/show_bug.cgi?id=39278 + * URLEncoder returns pluses, when we want to have the percent 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. @@ -124,8 +115,8 @@ public class DefaultURLConstructor implements URLConstructor { /** * Constructs the actual URL based on the context. */ - private String makeURL( final String context, final String name, final boolean absolute ) { - return doReplacement( getURLPattern(context,name), name, absolute ); + private String makeURL( final String context, final String name ) { + return doReplacement( getURLPattern( context, name ), name ); } /** @@ -134,7 +125,7 @@ public class DefaultURLConstructor implements URLConstructor { * * {@inheritDoc} */ - public String makeURL( final String context, final String name, final boolean absolute, String parameters ) { + public String makeURL( final String context, final String name, String parameters ) { if( parameters != null && parameters.length() > 0 ) { if( context.equals(WikiContext.ATTACH) ) { parameters = "?"+parameters; @@ -146,12 +137,11 @@ public class DefaultURLConstructor implements URLConstructor { } else { parameters = ""; } - return makeURL( context, name, absolute ) + parameters; + return makeURL( context, name ) + parameters; } /** - * Should parse the "page" parameter from the actual - * request. + * Should parse the "page" parameter from the actual request. * * {@inheritDoc} */ @@ -165,9 +155,7 @@ public class DefaultURLConstructor implements URLConstructor { } /** - * Takes the name of the page from the request URI. - * The initial slash is also removed. If there is no page, - * returns null. + * Takes the name of the page from the request URI. The initial slash is also removed. If there is no page, returns null. * * @param request The request to parse * @param encoding The encoding to use diff --git a/jspwiki-main/src/main/java/org/apache/wiki/url/ShortURLConstructor.java b/jspwiki-main/src/main/java/org/apache/wiki/url/ShortURLConstructor.java index f686d50..7b988f6 100644 --- a/jspwiki-main/src/main/java/org/apache/wiki/url/ShortURLConstructor.java +++ b/jspwiki-main/src/main/java/org/apache/wiki/url/ShortURLConstructor.java @@ -32,38 +32,30 @@ import java.util.Properties; /** * Provides a way to do short URLs of the form /wiki/PageName. * - * * @since 2.2 */ -public class ShortURLConstructor - extends DefaultURLConstructor -{ +public class ShortURLConstructor extends DefaultURLConstructor { + private static final String DEFAULT_PREFIX = "wiki/"; - - static Logger log = Logger.getLogger( ShortURLConstructor.class ); + private static final Logger log = Logger.getLogger( ShortURLConstructor.class ); - /** - * Contains the path part after the JSPWiki base URL - */ + /** Contains the path part after the JSPWiki base URL */ protected String m_urlPrefix = ""; /** - * This corresponds to your WikiServlet path. By default, it is assumed to - * be "wiki/", but you can set it to whatever you like - including an empty - * name. + * This corresponds to your WikiServlet path. By default, it is assumed to be "wiki/", but you can set it to whatever you + * like - including an empty name. */ public static final String PROP_PREFIX = "jspwiki.shortURLConstructor.prefix"; /** {@inheritDoc} */ - public void initialize( WikiEngine engine, - Properties properties ) - { + @Override + public void initialize( final WikiEngine engine, final Properties properties ) { super.initialize( engine, properties ); m_urlPrefix = TextUtil.getStringProperty( properties, PROP_PREFIX, null ); - if( m_urlPrefix == null ) - { + if( m_urlPrefix == null ) { m_urlPrefix = DEFAULT_PREFIX; } @@ -73,131 +65,82 @@ public class ShortURLConstructor /** * Constructs the actual URL based on the context. */ - private String makeURL( String context, - String name, - boolean absolute ) - { - String viewurl = "%p"+m_urlPrefix+"%n"; - - if( absolute ) - viewurl = "%u"+m_urlPrefix+"%n"; + private String makeURL( final String context, final String name ) { + final String viewurl = "%p" + m_urlPrefix + "%n"; - if( context.equals(WikiContext.VIEW) ) - { - if( name == null ) return doReplacement("%u","",absolute); - return doReplacement( viewurl, name, absolute ); - } - else if( context.equals(WikiContext.PREVIEW) ) - { - if( name == null ) return doReplacement("%u","",absolute); - return doReplacement( viewurl+"?do=Preview", name, absolute); - } - else if( context.equals(WikiContext.EDIT) ) - { - return doReplacement( viewurl+"?do=Edit", name, absolute ); - } - else if( context.equals(WikiContext.ATTACH) ) - { - return doReplacement( "%uattach/%n", name, absolute ); - } - else if( context.equals(WikiContext.INFO) ) - { - return doReplacement( viewurl+"?do=PageInfo", name, absolute ); - } - else if( context.equals(WikiContext.DIFF) ) - { - return doReplacement( viewurl+"?do=Diff", name, absolute ); - } - else if( context.equals(WikiContext.NONE) ) - { - return doReplacement( "%u%n", name, absolute ); - } - else if( context.equals(WikiContext.UPLOAD) ) - { - return doReplacement( viewurl+"?do=Upload", name, absolute ); - } - else if( context.equals(WikiContext.COMMENT) ) - { - return doReplacement( viewurl+"?do=Comment", name, absolute ); - } - else if( context.equals(WikiContext.LOGIN) ) - { - String loginUrl = absolute ? "%uLogin.jsp?redirect=%n" : "%pLogin.jsp?redirect=%n"; - return doReplacement( loginUrl, name, absolute ); - } - else if( context.equals(WikiContext.DELETE) ) - { - return doReplacement( viewurl+"?do=Delete", name, absolute ); - } - else if( context.equals(WikiContext.CONFLICT) ) - { - return doReplacement( viewurl+"?do=PageModified", name, absolute ); - } - else if( context.equals(WikiContext.PREFS) ) - { - return doReplacement( viewurl+"?do=UserPreferences", name, absolute ); - } - else if( context.equals(WikiContext.FIND) ) - { - return doReplacement( viewurl+"?do=Search", name, absolute ); - } - else if( context.equals(WikiContext.ERROR) ) - { - return doReplacement( "%uError.jsp", name, absolute ); - } - else if( context.equals(WikiContext.CREATE_GROUP) ) - { - return doReplacement( viewurl+"?do=NewGroup", name, absolute ); - } - else if( context.equals(WikiContext.DELETE_GROUP) ) - { - return doReplacement( viewurl+"?do=DeleteGroup", name, absolute ); - } - else if( context.equals(WikiContext.EDIT_GROUP) ) - { - return doReplacement( viewurl+"?do=EditGroup", name, absolute ); - } - else if( context.equals(WikiContext.VIEW_GROUP) ) - { - return doReplacement( viewurl+"?do=Group&group=%n", name, absolute ); + if( context.equals( WikiContext.VIEW ) ) { + if( name == null ) { + return doReplacement("%u","" ); + } + return doReplacement( viewurl, name ); + } else if( context.equals( WikiContext.PREVIEW ) ) { + if( name == null ) { + return doReplacement("%u","" ); + } + return doReplacement( viewurl + "?do=Preview", name ); + } else if( context.equals( WikiContext.EDIT ) ) { + return doReplacement( viewurl + "?do=Edit", name ); + } else if( context.equals( WikiContext.ATTACH ) ) { + return doReplacement( "%uattach/%n", name ); + } else if( context.equals( WikiContext.INFO ) ) { + return doReplacement( viewurl + "?do=PageInfo", name ); + } else if( context.equals( WikiContext.DIFF ) ) { + return doReplacement( viewurl + "?do=Diff", name ); + } else if( context.equals( WikiContext.NONE ) ) { + return doReplacement( "%u%n", name ); + } else if( context.equals( WikiContext.UPLOAD ) ) { + return doReplacement( viewurl + "?do=Upload", name ); + } else if( context.equals( WikiContext.COMMENT ) ) { + return doReplacement( viewurl + "?do=Comment", name ); + } else if( context.equals( WikiContext.LOGIN ) ) { + final String loginUrl = "%pLogin.jsp?redirect=%n"; + return doReplacement( loginUrl, name ); + } else if( context.equals( WikiContext.DELETE ) ) { + return doReplacement( viewurl + "?do=Delete", name ); + } else if( context.equals( WikiContext.CONFLICT ) ) { + return doReplacement( viewurl + "?do=PageModified", name ); + } else if( context.equals( WikiContext.PREFS ) ) { + return doReplacement( viewurl + "?do=UserPreferences", name ); + } else if( context.equals( WikiContext.FIND ) ) { + return doReplacement( viewurl + "?do=Search", name ); + } else if( context.equals( WikiContext.ERROR ) ) { + return doReplacement( "%uError.jsp", name ); + } else if( context.equals( WikiContext.CREATE_GROUP ) ) { + return doReplacement( viewurl + "?do=NewGroup", name ); + } else if( context.equals( WikiContext.DELETE_GROUP ) ) { + return doReplacement( viewurl + "?do=DeleteGroup", name ); + } else if( context.equals( WikiContext.EDIT_GROUP ) ) { + return doReplacement( viewurl + "?do=EditGroup", name ); + } else if( context.equals( WikiContext.VIEW_GROUP ) ) { + return doReplacement( viewurl + "?do=Group&group=%n", name ); } - throw new InternalWikiException("Requested unsupported context "+context); + throw new InternalWikiException( "Requested unsupported context " + context ); } /** * {@inheritDoc} */ - public String makeURL( String context, - String name, - boolean absolute, - String parameters ) - { - if( parameters != null && parameters.length() > 0 ) - { - if( context.equals(WikiContext.ATTACH) || context.equals(WikiContext.VIEW) ) - { - parameters = "?"+parameters; - } - else if( context.equals(WikiContext.NONE) ) - { + @Override + public String makeURL( final String context, final String name, String parameters ) { + if( parameters != null && parameters.length() > 0 ) { + if( context.equals( WikiContext.ATTACH ) || context.equals( WikiContext.VIEW ) ) { + parameters = "?" + parameters; + } else if( context.equals(WikiContext.NONE) ) { parameters = (name.indexOf('?') != -1 ) ? "&" : "?" + parameters; - } - else - { + } else { parameters = "&"+parameters; } - } - else - { + } else { parameters = ""; } - return makeURL( context, name, absolute )+parameters; + return makeURL( context, name )+parameters; } /** * {@inheritDoc} */ + @Override public String parsePage( final String context, final HttpServletRequest request, final Charset encoding ) { final String pagereq = request.getParameter( "page" ); if( pagereq == null ) { @@ -210,11 +153,14 @@ public class ShortURLConstructor /** * {@inheritDoc} */ - public String getForwardPage( HttpServletRequest req ) - { + @Override + public String getForwardPage( final HttpServletRequest req ) { String jspPage = req.getParameter( "do" ); - if( jspPage == null ) jspPage = "Wiki"; + if( jspPage == null ) { + jspPage = "Wiki"; + } return jspPage+".jsp"; } + } diff --git a/jspwiki-main/src/main/java/org/apache/wiki/url/ShortViewURLConstructor.java b/jspwiki-main/src/main/java/org/apache/wiki/url/ShortViewURLConstructor.java index 3215290..8265c31 100644 --- a/jspwiki-main/src/main/java/org/apache/wiki/url/ShortViewURLConstructor.java +++ b/jspwiki-main/src/main/java/org/apache/wiki/url/ShortViewURLConstructor.java @@ -18,91 +18,67 @@ */ package org.apache.wiki.url; -import java.util.Properties; - -import javax.servlet.http.HttpServletRequest; - import org.apache.wiki.WikiContext; import org.apache.wiki.WikiEngine; +import javax.servlet.http.HttpServletRequest; +import java.util.Properties; + /** - * A specific URL constructor that returns easy-to-grok URLs for - * VIEW and ATTACH contexts, but goes through JSP pages otherwise. + * A specific URL constructor that returns easy-to-grok URLs for VIEW and ATTACH contexts, but goes through JSP pages otherwise. * - * * @since 2.2 */ -public class ShortViewURLConstructor - extends ShortURLConstructor -{ +public class ShortViewURLConstructor extends ShortURLConstructor { + /** * {@inheritDoc} */ - public void initialize( WikiEngine engine, - Properties properties ) - { + public void initialize( final WikiEngine engine, final Properties properties ) { super.initialize( engine, properties ); } - private String makeURL( String context, - String name, - boolean absolute ) - { - String viewurl = "%p"+m_urlPrefix+"%n"; - - if( absolute ) - viewurl = "%u"+m_urlPrefix+"%n"; - - if( context.equals(WikiContext.VIEW) ) - { - if( name == null ) return doReplacement("%u","",absolute); - return doReplacement( viewurl, name, absolute ); + private String makeURL( final String context, final String name ) { + final String viewurl = "%p" + m_urlPrefix + "%n"; + if( context.equals( WikiContext.VIEW ) ) { + if( name == null ) { + return doReplacement("%u","" ); + } + return doReplacement( viewurl, name ); } - return doReplacement( DefaultURLConstructor.getURLPattern(context,name), - name, - absolute ); + return doReplacement( DefaultURLConstructor.getURLPattern( context, name ), name ); } /** * {@inheritDoc} */ - public String makeURL( String context, - String name, - boolean absolute, - String parameters ) - { - if( parameters != null && parameters.length() > 0 ) - { - if( context.equals(WikiContext.ATTACH) || context.equals(WikiContext.VIEW) || name == null ) - { - parameters = "?"+parameters; - } - else if( context.equals(WikiContext.NONE) ) - { + @Override + public String makeURL( final String context, final String name, String parameters ) { + if( parameters != null && parameters.length() > 0 ) { + if( context.equals( WikiContext.ATTACH ) || context.equals( WikiContext.VIEW ) || name == null ) { + parameters = "?" + parameters; + } else if( context.equals(WikiContext.NONE) ) { parameters = (name.indexOf('?') != -1 ) ? "&" : "?" + parameters; + } else { + parameters = "&" + parameters; } - else - { - parameters = "&"+parameters; - } - } - else - { + } else { parameters = ""; } - return makeURL( context, name, absolute )+parameters; + return makeURL( context, name ) + parameters; } /** - * Since we're only called from WikiServlet, where we get the VIEW requests, - * we can safely return this. + * Since we're only called from WikiServlet, where we get the VIEW requests, we can safely return this. * * @param request The HTTP Request that was used to end up in this page. * @return always returns "Wiki.jsp" */ - public String getForwardPage( HttpServletRequest request ) + @Override + public String getForwardPage( final HttpServletRequest request ) { return "Wiki.jsp"; } + } diff --git a/jspwiki-main/src/main/java/org/apache/wiki/url/URLConstructor.java b/jspwiki-main/src/main/java/org/apache/wiki/url/URLConstructor.java index 67c7da5..6035750 100644 --- a/jspwiki-main/src/main/java/org/apache/wiki/url/URLConstructor.java +++ b/jspwiki-main/src/main/java/org/apache/wiki/url/URLConstructor.java @@ -51,11 +51,10 @@ public interface URLConstructor { * @param context The request context (@see WikiContext) that you want the URL for * @param name The page name (or in case of WikiContext.NONE, the auxiliary JSP page * or resource you want to point at). This must be URL encoded. Null is NOT safe. - * @param absolute True, if you need an absolute URL. False, if both relative and absolute URLs are fine. * @param parameters An URL parameter string (these must be URL-encoded, and separated with &amp;) * @return An URL pointing to the resource. Must never return null - throw an InternalWikiException if something goes wrong. */ - String makeURL( String context, String name, boolean absolute, String parameters ); + String makeURL( String context, String name, String parameters ); /** * Should parse the "page" parameter from the actual request. This is essentially the reverse of makeURL() - whenever diff --git a/jspwiki-main/src/test/java/org/apache/wiki/WikiEngineTest.java b/jspwiki-main/src/test/java/org/apache/wiki/WikiEngineTest.java index c3ea115..69d3f0e 100644 --- a/jspwiki-main/src/test/java/org/apache/wiki/WikiEngineTest.java +++ b/jspwiki-main/src/test/java/org/apache/wiki/WikiEngineTest.java @@ -322,9 +322,4 @@ public class WikiEngineTest { Assertions.assertNull( p3.getAttribute( WikiPage.CHANGENOTE ) ); } - @Test - public void testGetViewURL() { - Assertions.assertEquals( "/test/Wiki.jsp?page=" + NAME1, m_engine.getViewURL( NAME1 ) ); - } - } diff --git a/jspwiki-main/src/test/java/org/apache/wiki/url/DefaultURLConstructorTest.java b/jspwiki-main/src/test/java/org/apache/wiki/url/DefaultURLConstructorTest.java index c6c9764..c08ee80 100644 --- a/jspwiki-main/src/test/java/org/apache/wiki/url/DefaultURLConstructorTest.java +++ b/jspwiki-main/src/test/java/org/apache/wiki/url/DefaultURLConstructorTest.java @@ -22,14 +22,14 @@ */ package org.apache.wiki.url; -import java.util.Properties; - import org.apache.wiki.TestEngine; import org.apache.wiki.WikiContext; import org.apache.wiki.api.exceptions.WikiException; import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Test; +import java.util.Properties; + public class DefaultURLConstructorTest { @@ -56,7 +56,7 @@ public class DefaultURLConstructorTest { URLConstructor c = getConstructor("wiki/" ); - Assertions.assertEquals( "/test/Wiki.jsp?page=Main", c.makeURL(WikiContext.VIEW,"Main",true,null) ); + Assertions.assertEquals( "/test/Wiki.jsp?page=Main", c.makeURL(WikiContext.VIEW,"Main",null) ); } @Test @@ -65,7 +65,7 @@ public class DefaultURLConstructorTest { URLConstructor c = getConstructor( null ); - Assertions.assertEquals( "/test/Wiki.jsp?page=Main", c.makeURL(WikiContext.VIEW,"Main",true,null) ); + Assertions.assertEquals( "/test/Wiki.jsp?page=Main", c.makeURL(WikiContext.VIEW,"Main",null) ); } @Test @@ -74,7 +74,7 @@ public class DefaultURLConstructorTest { URLConstructor c = getConstructor( null ); - Assertions.assertEquals( "/test/Wiki.jsp?page=Main", c.makeURL(WikiContext.VIEW,"Main",true,null) ); + Assertions.assertEquals( "/test/Wiki.jsp?page=Main", c.makeURL(WikiContext.VIEW,"Main",null) ); } @Test @@ -83,7 +83,7 @@ public class DefaultURLConstructorTest { URLConstructor c = getConstructor( null ); - Assertions.assertEquals( "/test/Wiki.jsp?page=Main", c.makeURL(WikiContext.VIEW,"Main",false,null) ); + Assertions.assertEquals( "/test/Wiki.jsp?page=Main", c.makeURL(WikiContext.VIEW,"Main",null) ); } @Test @@ -92,7 +92,7 @@ public class DefaultURLConstructorTest { URLConstructor c = getConstructor( "" ); - Assertions.assertEquals( "/test/Wiki.jsp?page=Main", c.makeURL(WikiContext.VIEW,"Main",true,null) ); + Assertions.assertEquals( "/test/Wiki.jsp?page=Main", c.makeURL(WikiContext.VIEW,"Main",null) ); } @Test @@ -101,7 +101,7 @@ public class DefaultURLConstructorTest { URLConstructor c = getConstructor( null ); - Assertions.assertEquals( "/test/Wiki.jsp?page=Main", c.makeURL(WikiContext.VIEW,"Main",true,null) ); + Assertions.assertEquals( "/test/Wiki.jsp?page=Main", c.makeURL(WikiContext.VIEW,"Main",null) ); } @Test @@ -110,7 +110,7 @@ public class DefaultURLConstructorTest { URLConstructor c = getConstructor( "view/" ); - Assertions.assertEquals( "/test/Wiki.jsp?page=Main", c.makeURL(WikiContext.VIEW,"Main",true,null) ); + Assertions.assertEquals( "/test/Wiki.jsp?page=Main", c.makeURL(WikiContext.VIEW,"Main",null) ); } @Test @@ -119,7 +119,7 @@ public class DefaultURLConstructorTest { URLConstructor c = getConstructor( null ); - Assertions.assertEquals( "/test/Edit.jsp?page=Main", c.makeURL(WikiContext.EDIT,"Main",true,null) ); + Assertions.assertEquals( "/test/Edit.jsp?page=Main", c.makeURL(WikiContext.EDIT,"Main",null) ); } @Test @@ -128,7 +128,7 @@ public class DefaultURLConstructorTest { URLConstructor c = getConstructor( null ); - Assertions.assertEquals( "/test/attach/Main/foo.txt", c.makeURL(WikiContext.ATTACH,"Main/foo.txt",true,null) ); + Assertions.assertEquals( "/test/attach/Main/foo.txt", c.makeURL(WikiContext.ATTACH,"Main/foo.txt",null) ); } @Test @@ -137,7 +137,7 @@ public class DefaultURLConstructorTest { URLConstructor c = getConstructor( null ); - Assertions.assertEquals( "/test/attach/Main/foo.txt", c.makeURL(WikiContext.ATTACH,"Main/foo.txt",false,null) ); + Assertions.assertEquals( "/test/attach/Main/foo.txt", c.makeURL(WikiContext.ATTACH,"Main/foo.txt",null) ); } @Test @@ -146,7 +146,7 @@ public class DefaultURLConstructorTest { URLConstructor c = getConstructor( null ); - Assertions.assertEquals( "/test/foo.jsp", c.makeURL(WikiContext.NONE,"foo.jsp",true,null) ); + Assertions.assertEquals( "/test/foo.jsp", c.makeURL(WikiContext.NONE,"foo.jsp",null) ); } @Test @@ -155,7 +155,7 @@ public class DefaultURLConstructorTest { URLConstructor c = getConstructor( null ); - Assertions.assertEquals( "/test/foo.jsp?a=1&b=2", c.makeURL(WikiContext.NONE,"foo.jsp",true,"a=1&b=2") ); + Assertions.assertEquals( "/test/foo.jsp?a=1&b=2", c.makeURL(WikiContext.NONE,"foo.jsp","a=1&b=2") ); } @Test @@ -164,7 +164,7 @@ public class DefaultURLConstructorTest { URLConstructor c = getConstructor( null ); - Assertions.assertEquals( "/test/Wiki.jsp?page=", c.makeURL(WikiContext.VIEW,"",true,null) ); + Assertions.assertEquals( "/test/Wiki.jsp?page=", c.makeURL(WikiContext.VIEW,"",null) ); } } diff --git a/jspwiki-main/src/test/java/org/apache/wiki/url/ShortURLConstructorTest.java b/jspwiki-main/src/test/java/org/apache/wiki/url/ShortURLConstructorTest.java index 3443bb2..fd0a1c9 100644 --- a/jspwiki-main/src/test/java/org/apache/wiki/url/ShortURLConstructorTest.java +++ b/jspwiki-main/src/test/java/org/apache/wiki/url/ShortURLConstructorTest.java @@ -22,14 +22,14 @@ */ package org.apache.wiki.url; -import java.util.Properties; - import org.apache.wiki.TestEngine; import org.apache.wiki.WikiContext; import org.apache.wiki.api.exceptions.WikiException; import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Test; +import java.util.Properties; + public class ShortURLConstructorTest { @@ -56,7 +56,7 @@ public class ShortURLConstructorTest { URLConstructor c = getConstructor("wiki/" ); - Assertions.assertEquals( "/test/wiki/Main", c.makeURL(WikiContext.VIEW,"Main",true,null) ); + Assertions.assertEquals( "/test/wiki/Main", c.makeURL(WikiContext.VIEW,"Main",null) ); } @Test @@ -65,7 +65,7 @@ public class ShortURLConstructorTest { URLConstructor c = getConstructor(null ); - Assertions.assertEquals( "/test/wiki/Main", c.makeURL(WikiContext.VIEW,"Main",true,null) ); + Assertions.assertEquals( "/test/wiki/Main", c.makeURL(WikiContext.VIEW,"Main",null) ); } @Test @@ -74,7 +74,7 @@ public class ShortURLConstructorTest { URLConstructor c = getConstructor(null ); - Assertions.assertEquals( "/test/wiki/Main", c.makeURL(WikiContext.VIEW,"Main",true,null) ); + Assertions.assertEquals( "/test/wiki/Main", c.makeURL(WikiContext.VIEW,"Main",null) ); } @Test @@ -83,7 +83,7 @@ public class ShortURLConstructorTest { URLConstructor c = getConstructor(null ); - Assertions.assertEquals( "/test/wiki/Main", c.makeURL(WikiContext.VIEW,"Main",false,null) ); + Assertions.assertEquals( "/test/wiki/Main", c.makeURL(WikiContext.VIEW,"Main",null) ); } @Test @@ -92,7 +92,7 @@ public class ShortURLConstructorTest { URLConstructor c = getConstructor("" ); - Assertions.assertEquals( "/test/Main", c.makeURL(WikiContext.VIEW,"Main",true,null) ); + Assertions.assertEquals( "/test/Main", c.makeURL(WikiContext.VIEW,"Main",null) ); } @Test @@ -101,7 +101,7 @@ public class ShortURLConstructorTest { URLConstructor c = getConstructor(null ); - Assertions.assertEquals( "/test/wiki/Main", c.makeURL(WikiContext.VIEW,"Main",true,null) ); + Assertions.assertEquals( "/test/wiki/Main", c.makeURL(WikiContext.VIEW,"Main",null) ); } @Test @@ -110,7 +110,7 @@ public class ShortURLConstructorTest { URLConstructor c = getConstructor("view/" ); - Assertions.assertEquals( "/test/view/Main", c.makeURL(WikiContext.VIEW,"Main",true,null) ); + Assertions.assertEquals( "/test/view/Main", c.makeURL(WikiContext.VIEW,"Main",null) ); } @Test @@ -119,7 +119,7 @@ public class ShortURLConstructorTest { URLConstructor c = getConstructor(null ); - Assertions.assertEquals( "/test/wiki/Main?do=Edit", c.makeURL(WikiContext.EDIT,"Main",true,null) ); + Assertions.assertEquals( "/test/wiki/Main?do=Edit", c.makeURL(WikiContext.EDIT,"Main",null) ); } @Test @@ -128,7 +128,7 @@ public class ShortURLConstructorTest { URLConstructor c = getConstructor(null ); - Assertions.assertEquals( "/test/attach/Main/foo.txt", c.makeURL(WikiContext.ATTACH,"Main/foo.txt",true,null) ); + Assertions.assertEquals( "/test/attach/Main/foo.txt", c.makeURL(WikiContext.ATTACH,"Main/foo.txt",null) ); } @Test @@ -137,7 +137,7 @@ public class ShortURLConstructorTest { URLConstructor c = getConstructor(null ); - Assertions.assertEquals( "/test/attach/Main/foo.txt", c.makeURL(WikiContext.ATTACH,"Main/foo.txt",false,null) ); + Assertions.assertEquals( "/test/attach/Main/foo.txt", c.makeURL(WikiContext.ATTACH,"Main/foo.txt",null) ); } @Test @@ -146,7 +146,7 @@ public class ShortURLConstructorTest { URLConstructor c = getConstructor(null ); - Assertions.assertEquals( "/test/foo.jsp", c.makeURL(WikiContext.NONE,"foo.jsp",true,null) ); + Assertions.assertEquals( "/test/foo.jsp", c.makeURL(WikiContext.NONE,"foo.jsp",null) ); } @Test @@ -155,7 +155,7 @@ public class ShortURLConstructorTest { URLConstructor c = getConstructor(null ); - Assertions.assertEquals( "/test/foo.jsp?a=1&b=2", c.makeURL(WikiContext.NONE,"foo.jsp",true,"a=1&b=2") ); + Assertions.assertEquals( "/test/foo.jsp?a=1&b=2", c.makeURL(WikiContext.NONE,"foo.jsp","a=1&b=2") ); } @Test @@ -164,7 +164,7 @@ public class ShortURLConstructorTest { URLConstructor c = getConstructor("wiki/" ); - Assertions.assertEquals( "/test/wiki/", c.makeURL(WikiContext.VIEW,"",true,null) ); + Assertions.assertEquals( "/test/wiki/", c.makeURL(WikiContext.VIEW,"",null) ); } } diff --git a/jspwiki-main/src/test/java/org/apache/wiki/url/ShortViewURLConstructorTest.java b/jspwiki-main/src/test/java/org/apache/wiki/url/ShortViewURLConstructorTest.java index bef9155..3f9b763 100644 --- a/jspwiki-main/src/test/java/org/apache/wiki/url/ShortViewURLConstructorTest.java +++ b/jspwiki-main/src/test/java/org/apache/wiki/url/ShortViewURLConstructorTest.java @@ -22,14 +22,14 @@ */ package org.apache.wiki.url; -import java.util.Properties; - import org.apache.wiki.TestEngine; import org.apache.wiki.WikiContext; import org.apache.wiki.api.exceptions.WikiException; import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Test; +import java.util.Properties; + public class ShortViewURLConstructorTest { @@ -56,7 +56,7 @@ public class ShortViewURLConstructorTest { URLConstructor c = getConstructor("wiki/" ); - Assertions.assertEquals( "/test/wiki/Main", c.makeURL(WikiContext.VIEW,"Main",true,null) ); + Assertions.assertEquals( "/test/wiki/Main", c.makeURL(WikiContext.VIEW,"Main",null) ); } @Test @@ -65,7 +65,7 @@ public class ShortViewURLConstructorTest { URLConstructor c = getConstructor(null ); - Assertions.assertEquals( "/test/wiki/Main", c.makeURL(WikiContext.VIEW,"Main",true,null) ); + Assertions.assertEquals( "/test/wiki/Main", c.makeURL(WikiContext.VIEW,"Main",null) ); } @Test @@ -74,7 +74,7 @@ public class ShortViewURLConstructorTest { URLConstructor c = getConstructor(null ); - Assertions.assertEquals( "/test/wiki/Main", c.makeURL(WikiContext.VIEW,"Main",true,null) ); + Assertions.assertEquals( "/test/wiki/Main", c.makeURL(WikiContext.VIEW,"Main",null) ); } @Test @@ -83,7 +83,7 @@ public class ShortViewURLConstructorTest { URLConstructor c = getConstructor(null ); - Assertions.assertEquals( "/test/wiki/Main", c.makeURL(WikiContext.VIEW,"Main",false,null) ); + Assertions.assertEquals( "/test/wiki/Main", c.makeURL(WikiContext.VIEW,"Main",null) ); } @Test @@ -92,7 +92,7 @@ public class ShortViewURLConstructorTest { URLConstructor c = getConstructor("" ); - Assertions.assertEquals( "/test/Main", c.makeURL(WikiContext.VIEW,"Main",true,null) ); + Assertions.assertEquals( "/test/Main", c.makeURL(WikiContext.VIEW,"Main",null) ); } @Test @@ -101,7 +101,7 @@ public class ShortViewURLConstructorTest { URLConstructor c = getConstructor(null ); - Assertions.assertEquals( "/test/wiki/Main", c.makeURL(WikiContext.VIEW,"Main",true,null) ); + Assertions.assertEquals( "/test/wiki/Main", c.makeURL(WikiContext.VIEW,"Main",null) ); } @Test @@ -110,7 +110,7 @@ public class ShortViewURLConstructorTest { URLConstructor c = getConstructor("view/" ); - Assertions.assertEquals( "/test/view/Main", c.makeURL(WikiContext.VIEW,"Main",true,null) ); + Assertions.assertEquals( "/test/view/Main", c.makeURL(WikiContext.VIEW,"Main",null) ); } @Test @@ -119,7 +119,7 @@ public class ShortViewURLConstructorTest { URLConstructor c = getConstructor(null ); - Assertions.assertEquals( "/test/Edit.jsp?page=Main", c.makeURL(WikiContext.EDIT,"Main",true,null) ); + Assertions.assertEquals( "/test/Edit.jsp?page=Main", c.makeURL(WikiContext.EDIT,"Main",null) ); } @Test @@ -128,7 +128,7 @@ public class ShortViewURLConstructorTest { URLConstructor c = getConstructor(null ); - Assertions.assertEquals( "/test/attach/Main/foo.txt", c.makeURL(WikiContext.ATTACH,"Main/foo.txt",true,null) ); + Assertions.assertEquals( "/test/attach/Main/foo.txt", c.makeURL(WikiContext.ATTACH,"Main/foo.txt",null) ); } @Test @@ -137,7 +137,7 @@ public class ShortViewURLConstructorTest { URLConstructor c = getConstructor(null ); - Assertions.assertEquals( "/test/attach/Main/foo.txt", c.makeURL(WikiContext.ATTACH,"Main/foo.txt",false,null) ); + Assertions.assertEquals( "/test/attach/Main/foo.txt", c.makeURL(WikiContext.ATTACH,"Main/foo.txt",null) ); } @Test @@ -146,7 +146,7 @@ public class ShortViewURLConstructorTest { URLConstructor c = getConstructor(null ); - Assertions.assertEquals( "/test/foo.jsp", c.makeURL(WikiContext.NONE,"foo.jsp",true,null) ); + Assertions.assertEquals( "/test/foo.jsp", c.makeURL(WikiContext.NONE,"foo.jsp",null) ); } @Test @@ -155,7 +155,7 @@ public class ShortViewURLConstructorTest { URLConstructor c = getConstructor(null ); - Assertions.assertEquals( "/test/foo.jsp?a=1&b=2", c.makeURL(WikiContext.NONE,"foo.jsp",true,"a=1&b=2") ); + Assertions.assertEquals( "/test/foo.jsp?a=1&b=2", c.makeURL(WikiContext.NONE,"foo.jsp","a=1&b=2") ); } @Test @@ -164,7 +164,7 @@ public class ShortViewURLConstructorTest { URLConstructor c = getConstructor("wiki/" ); - Assertions.assertEquals( "/test/wiki/", c.makeURL(WikiContext.VIEW,"",true,null) ); + Assertions.assertEquals( "/test/wiki/", c.makeURL(WikiContext.VIEW,"",null) ); } }
