app.stop();
}
}
@Test public void testCustomRoutes() throws Exception {
WebApp app = WebApps.$for("test", this).start(new WebApp() {
@Override public void setup() {
route("/:foo", FooController.class);
route("/bar/foo", FooController.class, "bar");
route("/foo/:foo", DefaultController.class);
route("/foo/bar/:foo", DefaultController.class, "index");
}
});
String baseUrl = baseUrl(app);
try {
assertEquals("foo", getContent(baseUrl).trim());
assertEquals("foo", getContent(baseUrl +"test").trim());
assertEquals("foo1", getContent(baseUrl +"test/1").trim());
assertEquals("bar", getContent(baseUrl +"test/bar/foo").trim());
assertEquals("default", getContent(baseUrl +"test/foo/bar").trim());
assertEquals("default1", getContent(baseUrl +"test/foo/1").trim());
assertEquals("default2", getContent(baseUrl +"test/foo/bar/2").trim());
assertEquals(404, getResponseCode(baseUrl +"test/goo"));
} finally {
app.stop();
}
}