diff options
author | toby <smorgrav@yahoo-inc.com> | 2019-03-15 16:58:02 +0100 |
---|---|---|
committer | toby <smorgrav@yahoo-inc.com> | 2019-03-15 16:58:02 +0100 |
commit | 5039958f9fa1d692d913ac97a5c179605f83b07e (patch) | |
tree | 80ea5812a36c68843beb94addd82ddf1f15616ed /container-core/src/test | |
parent | d0c0baba17829572ee5af428fcf6b068f013d55d (diff) |
Add support for an optional prefix to path matching
Diffstat (limited to 'container-core/src/test')
-rw-r--r-- | container-core/src/test/java/com/yahoo/restapi/PathTest.java | 15 |
1 files changed, 14 insertions, 1 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 9e77dc7b3f0..566209d941b 100644 --- a/container-core/src/test/java/com/yahoo/restapi/PathTest.java +++ b/container-core/src/test/java/com/yahoo/restapi/PathTest.java @@ -11,7 +11,20 @@ import static org.junit.Assert.assertEquals; * @author bratseth */ public class PathTest { - + + @Test + public void testWithPrefix() { + // Test that a path with a prefix matches spec + Path path = new Path("/ball/a/1/bar/fuz", "/ball"); + assertTrue(path.matches("/a/{foo}/bar/{b}")); + assertEquals("1", path.get("foo")); + assertEquals("fuz", path.get("b")); + + // One negative test where the prefix should not count + assertFalse(path.matches("/ball/a/{foo}/zoo/{b}")); + } + + @Test public void testPath() { assertFalse(new Path("").matches("/a/{foo}/bar/{b}")); |