summaryrefslogtreecommitdiffstats
path: root/container-core/src/test/java/com/yahoo/restapi/PathTest.java
diff options
context:
space:
mode:
Diffstat (limited to 'container-core/src/test/java/com/yahoo/restapi/PathTest.java')
-rw-r--r--container-core/src/test/java/com/yahoo/restapi/PathTest.java17
1 files changed, 10 insertions, 7 deletions
diff --git a/container-core/src/test/java/com/yahoo/restapi/PathTest.java b/container-core/src/test/java/com/yahoo/restapi/PathTest.java
index 5cbf80ff2ad..4786eb9775c 100644
--- a/container-core/src/test/java/com/yahoo/restapi/PathTest.java
+++ b/container-core/src/test/java/com/yahoo/restapi/PathTest.java
@@ -6,6 +6,7 @@ import org.junit.Test;
import java.net.URI;
import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertThrows;
import static org.junit.Assert.assertTrue;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.fail;
@@ -34,7 +35,7 @@ public class PathTest {
assertTrue(path.matches("/a/{foo}/bar/{b}/{*}"));
assertEquals("1", path.get("foo"));
assertEquals("fuz", path.get("b"));
- assertEquals("", path.getRest());
+ assertEquals("/", path.getRest().raw());
}
{
@@ -42,7 +43,7 @@ public class PathTest {
assertTrue(path.matches("/a/{foo}/bar/{b}/{*}"));
assertEquals("1", path.get("foo"));
assertEquals("fuz", path.get("b"));
- assertEquals("kanoo", path.getRest());
+ assertEquals("/kanoo", path.getRest().raw());
}
{
@@ -50,7 +51,7 @@ public class PathTest {
assertTrue(path.matches("/a/{foo}/bar/{b}/{*}"));
assertEquals("1", path.get("foo"));
assertEquals("fuz", path.get("b"));
- assertEquals("kanoo/trips", path.getRest());
+ assertEquals("/kanoo/trips", path.getRest().raw());
}
{
@@ -58,17 +59,19 @@ public class PathTest {
assertTrue(path.matches("/a/{foo}/bar/{b}/{*}"));
assertEquals("1", path.get("foo"));
assertEquals("fuz", path.get("b"));
- assertEquals("kanoo/trips/", path.getRest());
+ assertEquals("/kanoo/trips/", path.getRest().raw());
}
}
@Test
public void testUrlEncodedPath() {
assertTrue(new Path(URI.create("/a/%62/c")).matches("/a/b/c"));
- assertFalse(new Path(URI.create("/a/b%2fc")).matches("/a/b/c"));
- assertFalse(new Path(URI.create("/foo")).matches("/foo/bar/%2e%2e"));
+ assertFalse(new Path(URI.create("/a/b%2fc"), __ -> { }).matches("/a/b/c"));
+ assertThrows("path segments cannot be \"\", \".\", or \"..\", but got: '..'",
+ IllegalArgumentException.class,
+ () -> new Path(URI.create("/foo")).matches("/foo/bar/%2e%2e"));
- Path path = new Path(URI.create("/%61/%2f/%63"));
+ Path path = new Path(URI.create("/%61/%2f/%63"), __ -> { });
assertTrue(path.matches("/a/{slash}/{c}"));
assertEquals("/", path.get("slash"));
assertEquals("c", path.get("c"));