@Test(expected = MethodNotAllowedException.class) public void shouldThrowMethodNotAllowed() { FullHttpRequest httpRequest = new DefaultFullHttpRequest( HttpVersion.HTTP_1_1, HttpMethod.OPTIONS, "/foo/foo23.json?value=ignored"); httpRequest.headers().add("Host", "testing-host"); Request request = new Request(httpRequest, null); resolver.resolve(request); }
@Test public void shouldResolveAliasFooPostRoute() { FullHttpRequest httpRequest = new DefaultFullHttpRequest( HttpVersion.HTTP_1_1, HttpMethod.POST, "/yada/yada.json?value=ignored"); httpRequest.headers().add("Host", "testing-host"); Request request = new Request(httpRequest, null); Action action = resolver.resolve(request); assertNotNull(action); assertEquals(HttpMethod.POST, action.getRoute().getMethod()); assertEquals("/foo", action.getRoute().getPattern()); }
@Test public void shouldResolveAliasCrudRouteForDelete() { FullHttpRequest httpRequest = new DefaultFullHttpRequest( HttpVersion.HTTP_1_1, HttpMethod.DELETE, "/blah/foo/foo23.json?value=ignored"); httpRequest.headers().add("Host", "testing-host"); Request request = new Request(httpRequest, null); Action action = resolver.resolve(request); assertNotNull(action); assertEquals(HttpMethod.DELETE, action.getRoute().getMethod()); assertEquals("/foo/{fooId}", action.getRoute().getPattern()); }
@Test public void shouldSendAllowedMethodsForGetRoute() { FullHttpRequest httpRequest = new DefaultFullHttpRequest( HttpVersion.HTTP_1_1, HttpMethod.OPTIONS, "/foo/bar/bar23.json?value=ignored"); httpRequest.headers().add("Host", "testing-host"); Request request = new Request(httpRequest, null); try { resolver.resolve(request); } catch (MethodNotAllowedException e) { List<HttpMethod> allowed = e.getAllowedMethods(); assertEquals(1, allowed.size()); assertTrue(allowed.contains(HttpMethod.GET)); } }