@Test public void testBug() throws Exception { Router router = new Router(); Route a = router.append("/{p}", Collections.singletonMap(Names.P, PathParam.matching("[^_]+"))); // This is a *known* bug assertNull(router.route("/_")); // This is expected assertEquals("/_", a.matches(Collections.singletonMap(Names.P, "/")).render()); // This is expected assertNull(router.route("/%5F")); assertNull(a.matches(Collections.singletonMap(Names.P, "_"))); }
@Test public void testBug() throws Exception { Router router = new Router(); Route a = router.append("/{p}", Collections.singletonMap(Names.P, PathParam.matching("[^_]+"))); // This is a *known* bug assertNull(router.route("/_")); // This is expected assertEquals("/_", a.matches(Collections.singletonMap(Names.P, "/")).render()); // This is expected assertNull(router.route("/%5F")); assertNull(a.matches(Collections.singletonMap(Names.P, "_"))); }
@Test public void testClear() throws Exception { Router router = new Router(); Route foo = router.append("/foo"); RouteMatch match = router.route("/foo"); assertNotNull(match); assertSame(foo, match.getRoute()); Route bar = foo.append("/bar"); // /*RouteMatch*/ match = router.route("/foo/bar"); assertNotNull(match); assertSame(bar, match.getRoute()); // foo.clearChildren(); match = router.route("/foo/bar"); assertNull(match); match = router.route("/foo"); assertNotNull(match); assertSame(foo, match.getRoute()); }
@Test public void testClear() throws Exception { Router router = new Router(); Route foo = router.append("/foo"); RouteMatch match = router.route("/foo"); assertNotNull(match); assertSame(foo, match.getRoute()); Route bar = foo.append("/bar"); // /*RouteMatch*/ match = router.route("/foo/bar"); assertNotNull(match); assertSame(bar, match.getRoute()); // foo.clearChildren(); match = router.route("/foo/bar"); assertNull(match); match = router.route("/foo"); assertNotNull(match); assertSame(foo, match.getRoute()); }