You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@sling.apache.org by bd...@apache.org on 2016/12/07 08:04:46 UTC
svn commit: r1773019 -
/sling/trunk/bundles/api/src/test/java/org/apache/sling/api/resource/path/PathTest.java
Author: bdelacretaz
Date: Wed Dec 7 08:04:46 2016
New Revision: 1773019
URL: http://svn.apache.org/viewvc?rev=1773019&view=rev
Log:
SLING-6350 - improve test coverage
Modified:
sling/trunk/bundles/api/src/test/java/org/apache/sling/api/resource/path/PathTest.java
Modified: sling/trunk/bundles/api/src/test/java/org/apache/sling/api/resource/path/PathTest.java
URL: http://svn.apache.org/viewvc/sling/trunk/bundles/api/src/test/java/org/apache/sling/api/resource/path/PathTest.java?rev=1773019&r1=1773018&r2=1773019&view=diff
==============================================================================
--- sling/trunk/bundles/api/src/test/java/org/apache/sling/api/resource/path/PathTest.java (original)
+++ sling/trunk/bundles/api/src/test/java/org/apache/sling/api/resource/path/PathTest.java Wed Dec 7 08:04:46 2016
@@ -18,6 +18,7 @@
*/
package org.apache.sling.api.resource.path;
+import java.util.UUID;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue;
import static org.junit.Assert.fail;
@@ -86,6 +87,8 @@ public class PathTest {
}
@Test public void testIllegalArgumentException() {
+ final Path path = new Path("/libs/foo");
+
try {
new Path("foo");
fail();
@@ -98,6 +101,13 @@ public class PathTest {
} catch ( final IllegalArgumentException iae) {
// this should happen!
}
+
+ try {
+ path.matches("invalid-no-slash");
+ fail();
+ } catch ( final IllegalArgumentException iae) {
+ // this should happen!
+ }
}
@Test public void testPathMatchingTrailingSlash() {
@@ -111,4 +121,32 @@ public class PathTest {
assertTrue(glob.matches("glob:/*/foo"));
assertFalse(glob.matches("glob:/*/**/foo"));
}
+
+ @Test public void testIsPatternWithGlob() {
+ assertTrue(new Path("glob:/*/foo").isPattern());
+ }
+
+ @Test public void testIsPatternWithPath() {
+ assertFalse(new Path("/libs/foo").isPattern());
+ }
+
+ @Test public void testEquals() {
+ final Path path = new Path("/foo/bar");
+ assertTrue(path.equals(path));
+ assertFalse(path.equals(null));
+ assertFalse(path.equals("a string"));
+ }
+
+ @Test public void testCompareTo() {
+ final Path p1 = new Path("/1");
+ final Path p2 = new Path("/2");
+ assertTrue(p1.compareTo(p2) < 0);
+ assertTrue(p2.compareTo(p1) > 0);
+ assertTrue(p1.compareTo(p1) == 0);
+ }
+
+ @Test public void testToString() {
+ final Path path = new Path("/" + UUID.randomUUID());
+ assertTrue(path.toString().contains(path.getPath()));
+ }
}