Author: hboutemy Date: Sun Jan 3 19:25:28 2016 New Revision: 1722750 URL: http://svn.apache.org/viewvc?rev=1722750&view=rev Log: added explanations and tests about Maven-specific urls like dav: and scm:
Modified: maven/doxia/doxia-sitetools/trunk/doxia-integration-tools/src/main/java/org/apache/maven/doxia/tools/SiteTool.java maven/doxia/doxia-sitetools/trunk/doxia-integration-tools/src/test/java/org/apache/maven/doxia/tools/SiteToolTest.java Modified: maven/doxia/doxia-sitetools/trunk/doxia-integration-tools/src/main/java/org/apache/maven/doxia/tools/SiteTool.java URL: http://svn.apache.org/viewvc/maven/doxia/doxia-sitetools/trunk/doxia-integration-tools/src/main/java/org/apache/maven/doxia/tools/SiteTool.java?rev=1722750&r1=1722749&r2=1722750&view=diff ============================================================================== --- maven/doxia/doxia-sitetools/trunk/doxia-integration-tools/src/main/java/org/apache/maven/doxia/tools/SiteTool.java (original) +++ maven/doxia/doxia-sitetools/trunk/doxia-integration-tools/src/main/java/org/apache/maven/doxia/tools/SiteTool.java Sun Jan 3 19:25:28 2016 @@ -180,6 +180,8 @@ public interface SiteTool * <dd>return "../myproject-module1"</dd> * </dl> * <b>Note</b>: The file separator depends on the system. + * Maven-specific urls are supported, like <code>dav:https://dav.codehaus.org/</code> or + * <code>scm:svn:https://svn.apache.org/repos/asf</code>. * * @param to the <code>to</code> url of file as string * @param from the <code>from</code> url of file as string Modified: maven/doxia/doxia-sitetools/trunk/doxia-integration-tools/src/test/java/org/apache/maven/doxia/tools/SiteToolTest.java URL: http://svn.apache.org/viewvc/maven/doxia/doxia-sitetools/trunk/doxia-integration-tools/src/test/java/org/apache/maven/doxia/tools/SiteToolTest.java?rev=1722750&r1=1722749&r2=1722750&view=diff ============================================================================== --- maven/doxia/doxia-sitetools/trunk/doxia-integration-tools/src/test/java/org/apache/maven/doxia/tools/SiteToolTest.java (original) +++ maven/doxia/doxia-sitetools/trunk/doxia-integration-tools/src/test/java/org/apache/maven/doxia/tools/SiteToolTest.java Sun Jan 3 19:25:28 2016 @@ -112,6 +112,14 @@ public class SiteToolTest decorationModel ) ); } + private void checkGetRelativePathDirectory( SiteTool tool, String relative, String to, String from ) + { + assertEquals( relative, tool.getRelativePath( to, from ) ); + assertEquals( relative, tool.getRelativePath( to + '/', from ) ); + assertEquals( relative, tool.getRelativePath( to, from + '/' ) ); + assertEquals( relative, tool.getRelativePath( to + '/', from + '/' ) ); + } + /** * @throws Exception */ @@ -121,37 +129,28 @@ public class SiteToolTest SiteTool tool = (SiteTool) lookup( SiteTool.ROLE ); assertNotNull( tool ); - String to = "http://maven.apache.org"; - String from = "http://maven.apache.org"; - assertEquals( tool.getRelativePath( to, from ), "" ); - - to = "http://maven.apache.org"; - from = "http://maven.apache.org/"; - assertEquals( tool.getRelativePath( to, from ), "" ); - - to = "http://maven.apache.org/"; - from = "http://maven.apache.org"; - assertEquals( tool.getRelativePath( to, from ), "" ); - - to = "http://maven.apache.org/"; - from = "http://maven.apache.org/"; - assertEquals( tool.getRelativePath( to, from ), "" ); - - to = "http://maven.apache.org/"; - from = "http://maven.apache.org/plugins/maven-site-plugin"; - assertEquals( tool.getRelativePath( to, from ), ".." + File.separator + ".." ); - to = "http://maven.apache.org"; - from = "http://maven.apache.org/plugins/maven-site-plugin/"; - assertEquals( tool.getRelativePath( to, from ), ".." + File.separator + ".." ); - to = "http://maven.apache.org/"; - from = "http://maven.apache.org/plugins/maven-site-plugin/"; - assertEquals( tool.getRelativePath( to, from ), ".." + File.separator + ".." ); - to = "http://maven.apache.org"; - from = "http://maven.apache.org/plugins/maven-site-plugin"; - assertEquals( tool.getRelativePath( to, from ), ".." + File.separator + ".." ); + checkGetRelativePathDirectory( tool, "", "http://maven.apache.org", "http://maven.apache.org" ); + + checkGetRelativePathDirectory( tool, ".." + File.separator + "..", "http://maven.apache.org", + "http://maven.apache.org/plugins/maven-site-plugin" ); + + checkGetRelativePathDirectory( tool, "plugins" + File.separator + "maven-site-plugin", + "http://maven.apache.org/plugins/maven-site-plugin", "http://maven.apache.org" ); - to = "http://maven.apache.org/downloads.html"; - from = "http://maven.apache.org/index.html"; + checkGetRelativePathDirectory( tool, "", "dav:https://maven.apache.org", "dav:https://maven.apache.org" ); + + checkGetRelativePathDirectory( tool, "plugins" + File.separator + "maven-site-plugin", + "dav:http://maven.apache.org/plugins/maven-site-plugin", + "dav:http://maven.apache.org" ); + + checkGetRelativePathDirectory( tool, "", "scm:svn:https://maven.apache.org", "scm:svn:https://maven.apache.org" ); + + checkGetRelativePathDirectory( tool, "plugins" + File.separator + "maven-site-plugin", + "scm:svn:https://maven.apache.org/plugins/maven-site-plugin", + "scm:svn:https://maven.apache.org" ); + + String to = "http://maven.apache.org/downloads.html"; + String from = "http://maven.apache.org/index.html"; // FIXME! assertEquals( "downloads.html", tool.getRelativePath( to, from ) ); // MSITE-600, MSHARED-203 @@ -162,20 +161,7 @@ public class SiteToolTest // note: 'tmp' is the host here which is probably not the intention, but at least the result is correct to = "file://tmp/bloop"; from = "scp://localhost:/tmp/blop"; - assertEquals( tool.getRelativePath( to, from ), to ); - - to = "http://maven.apache.org/plugins/maven-site-plugin/"; - from = "http://maven.apache.org"; - assertEquals( tool.getRelativePath( to, from ), "plugins" + File.separator + "maven-site-plugin" ); - to = "http://maven.apache.org/plugins/maven-site-plugin/"; - from = "http://maven.apache.org/"; - assertEquals( tool.getRelativePath( to, from ), "plugins" + File.separator + "maven-site-plugin" ); - to = "http://maven.apache.org/plugins/maven-site-plugin"; - from = "http://maven.apache.org"; - assertEquals( tool.getRelativePath( to, from ), "plugins" + File.separator + "maven-site-plugin" ); - to = "http://maven.apache.org/plugins/maven-site-plugin"; - from = "http://maven.apache.org/"; - assertEquals( tool.getRelativePath( to, from ), "plugins" + File.separator + "maven-site-plugin" ); + assertEquals( to, tool.getRelativePath( to, from ) ); // Tests between files as described in MIDEA-102 to = "C:/dev/voca/gateway/parser/gateway-parser.iml";