/** * Test routes: GET /wildcard-a myTestController.wildcardA GET /wildcard-b * myTestController.wildcardB * * @throws Exception */ @Test public void wildcardRouteFiles() throws Exception { MockHttpServletRequest request = new MockHttpServletRequest("GET", "/wildcard-a"); request.addHeader("host", sampleHost); HandlerExecutionChain chain = this.hm.getHandler(request); RouterHandler handler = (RouterHandler) chain.getHandler(); Assert.assertNotNull(handler); Route route = handler.getRoute(); Assert.assertNotNull(route); Assert.assertEquals(this.handlerName + ".wildcardA", route.action); request = new MockHttpServletRequest("GET", "/wildcard-b"); request.addHeader("host", sampleHost); chain = this.hm.getHandler(request); handler = (RouterHandler) chain.getHandler(); Assert.assertNotNull(handler); route = handler.getRoute(); Assert.assertNotNull(route); Assert.assertEquals(this.handlerName + ".wildcardB", route.action); }
/** * Test route: GET /caseinsensitive MyTestCONTROLLER.caseInsensitive * * @throws Exception */ @Test public void caseInsensitiveRoute() throws Exception { MockHttpServletRequest request = new MockHttpServletRequest("GET", "/caseinsensitive"); request.addHeader("host", sampleHost); HandlerExecutionChain chain = this.hm.getHandler(request); RouterHandler handler = (RouterHandler) chain.getHandler(); Assert.assertNotNull(handler); Route route = handler.getRoute(); Assert.assertNotNull(route); Assert.assertTrue((this.handlerName + ".caseInsensitive").equalsIgnoreCase(route.action)); }
/** * Test route: GET /simpleaction myTestController.simpleAction * * @throws Exception */ @Test public void testSimpleRoute() throws Exception { MockHttpServletRequest request = new MockHttpServletRequest("GET", "/simpleaction"); request.addHeader("host", sampleHost); HandlerExecutionChain chain = this.hm.getHandler(request); RouterHandler handler = (RouterHandler) chain.getHandler(); Assert.assertNotNull(handler); Route route = handler.getRoute(); Assert.assertNotNull(route); Assert.assertEquals(this.handlerName + ".simpleAction", route.action); }
/** * Test route: PUT /http myTestController.httpAction(type:'PUT') with a GET request and a * "x-http-method-override" argument in queryString * * @throws Exception */ @Test public void testOverrideQueryStringHTTPAction() throws Exception { MockHttpServletRequest request = new MockHttpServletRequest("GET", "/http"); request.setQueryString("x-http-method-override=PUT"); request.addHeader("host", sampleHost); HandlerExecutionChain chain = this.hm.getHandler(request); RouterHandler handler = (RouterHandler) chain.getHandler(); Assert.assertNotNull(handler); Route route = handler.getRoute(); Assert.assertNotNull(route); Assert.assertEquals(this.handlerName + ".httpAction", route.action); }