You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@maven.apache.org by st...@apache.org on 2011/08/15 01:06:29 UTC

svn commit: r1157683 - /maven/sandbox/trunk/plexus-utils-commons-bridge/plexus-utils-tck/src/test/java/org/codehaus/plexus/util/PathToolTest.java

Author: struberg
Date: Sun Aug 14 23:06:29 2011
New Revision: 1157683

URL: http://svn.apache.org/viewvc?rev=1157683&view=rev
Log:
MSANDBOX-51 PathToolTest continued

Modified:
    maven/sandbox/trunk/plexus-utils-commons-bridge/plexus-utils-tck/src/test/java/org/codehaus/plexus/util/PathToolTest.java

Modified: maven/sandbox/trunk/plexus-utils-commons-bridge/plexus-utils-tck/src/test/java/org/codehaus/plexus/util/PathToolTest.java
URL: http://svn.apache.org/viewvc/maven/sandbox/trunk/plexus-utils-commons-bridge/plexus-utils-tck/src/test/java/org/codehaus/plexus/util/PathToolTest.java?rev=1157683&r1=1157682&r2=1157683&view=diff
==============================================================================
--- maven/sandbox/trunk/plexus-utils-commons-bridge/plexus-utils-tck/src/test/java/org/codehaus/plexus/util/PathToolTest.java (original)
+++ maven/sandbox/trunk/plexus-utils-commons-bridge/plexus-utils-tck/src/test/java/org/codehaus/plexus/util/PathToolTest.java Sun Aug 14 23:06:29 2011
@@ -107,7 +107,62 @@ public class PathToolTest extends Assert
 
         assertThat( PathTool.getRelativeFilePath( "/bin", "/usr/local/" )
                   , is( "../usr/local/" ) );
+    }
+
+    @Test
+    public void testGetRelativePath_2parm()
+    {
+        assertThat( PathTool.getRelativePath( null, null )
+                  , is( "" ) );
+
+        assertThat( PathTool.getRelativePath( null, "/usr/local/java/bin" )
+                  , is( "" ) );
+
+        assertThat( PathTool.getRelativePath( "/usr/local/", null )
+                  , is( "" ) );
+
+        assertThat( PathTool.getRelativePath( "/usr/local/", "/usr/local/java/bin" )
+                  , is( ".." ) );
 
+        assertThat( PathTool.getRelativePath( "/usr/local/", "/usr/local/java/bin/java.sh" )
+                  , is( "../.." ) );
+
+        assertThat( PathTool.getRelativePath( "/usr/local/java/bin/java.sh", "/usr/local/" )
+                  , is( "" ) );
     }
-        
+
+    @Test
+    public void testGetRelativePath_1parm()
+    {
+        assertThat( PathTool.getRelativePath( null )
+                  , is( "" ) );
+
+/*X TODO create temp dir structure and set user.dir to it
+        assertThat( PathTool.getRelativePath("/usr/local/java/bin" )
+                  , is( "" ) );
+*/
+
+    }
+
+    @Test
+    public void testGetRelativeWebPath()
+    {
+        assertThat( PathTool.getRelativeWebPath( null, null )
+                  , is( "" ) );
+
+        assertThat( PathTool.getRelativeWebPath( null, "http://plexus.codehaus.org/" )
+                  , is( "" ) );
+
+        assertThat( PathTool.getRelativeWebPath( "http://plexus.codehaus.org/", null )
+                  , is( "" ) );
+
+        assertThat( PathTool.getRelativeWebPath( "http://plexus.codehaus.org/"
+                                               , "http://plexus.codehaus.org/plexus-utils/index.html" )
+                  , is( "plexus-utils/index.html" ) );
+
+        assertThat( PathTool.getRelativeWebPath( "http://plexus.codehaus.org/plexus-utils/index.html"
+                                               , "http://plexus.codehaus.org/" )
+                  , is( "../../" ) );
+    }
+
 }