jackrabbit-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From thom...@apache.org
Subject svn commit: r1214312 - in /jackrabbit/sandbox/microkernel/src: main/java/org/apache/jackrabbit/mk/util/PathUtils.java test/java/org/apache/jackrabbit/mk/util/PathTest.java
Date Wed, 14 Dec 2011 16:00:19 GMT
Author: thomasm
Date: Wed Dec 14 16:00:18 2011
New Revision: 1214312

URL: http://svn.apache.org/viewvc?rev=1214312&view=rev
Log:
Add test cases and simplify the code.

Modified:
    jackrabbit/sandbox/microkernel/src/main/java/org/apache/jackrabbit/mk/util/PathUtils.java
    jackrabbit/sandbox/microkernel/src/test/java/org/apache/jackrabbit/mk/util/PathTest.java

Modified: jackrabbit/sandbox/microkernel/src/main/java/org/apache/jackrabbit/mk/util/PathUtils.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/microkernel/src/main/java/org/apache/jackrabbit/mk/util/PathUtils.java?rev=1214312&r1=1214311&r2=1214312&view=diff
==============================================================================
--- jackrabbit/sandbox/microkernel/src/main/java/org/apache/jackrabbit/mk/util/PathUtils.java
(original)
+++ jackrabbit/sandbox/microkernel/src/main/java/org/apache/jackrabbit/mk/util/PathUtils.java
Wed Dec 14 16:00:18 2011
@@ -244,11 +244,8 @@ public class PathUtils {
         } else if (isAbsolutePath(subPath)) {
             throw new IllegalArgumentException("Cannot append absolute path " + subPath);
         }
-        int parentLen = parentPath.length();
-        StringBuilder buff = new StringBuilder(
-                parentLen + 1 + subPath.length());
-        buff.append(parentPath);
-        if (parentLen > 0 && !denotesRootPath(parentPath)) {
+        StringBuilder buff = new StringBuilder(parentPath);
+        if (!denotesRootPath(parentPath)) {
             buff.append('/');
         }
         buff.append(subPath);

Modified: jackrabbit/sandbox/microkernel/src/test/java/org/apache/jackrabbit/mk/util/PathTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/microkernel/src/test/java/org/apache/jackrabbit/mk/util/PathTest.java?rev=1214312&r1=1214311&r2=1214312&view=diff
==============================================================================
--- jackrabbit/sandbox/microkernel/src/test/java/org/apache/jackrabbit/mk/util/PathTest.java
(original)
+++ jackrabbit/sandbox/microkernel/src/test/java/org/apache/jackrabbit/mk/util/PathTest.java
Wed Dec 14 16:00:18 2011
@@ -76,6 +76,28 @@ public class PathTest extends TestCase {
         assertEquals(child + "/" + child, PathUtils.concat("", child, child));
         assertEquals(child, PathUtils.concat("", child, ""));
         assertEquals(child, PathUtils.concat("", "", child));
+        assertEquals(child, PathUtils.concat("", child));
+
+        assertEquals("/" + child, PathUtils.concat("", "/" + child));
+        assertEquals(parent + "/" + child, PathUtils.concat(parent, child));
+        try {
+            PathUtils.concat("/" + parent, "/" + child);
+            fail();
+        } catch (IllegalArgumentException e) {
+            // expected
+        }
+        try {
+            PathUtils.concat("", "//");
+            fail();
+        } catch (IllegalArgumentException e) {
+            // expected
+        }
+        try {
+            PathUtils.concat("/", "/");
+            fail();
+        } catch (IllegalArgumentException e) {
+            // expected
+        }
 
         // denotesRoot
         assertTrue(PathUtils.denotesRoot("/"));



Mime
View raw message