예제 #1
0
 @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);
 }
예제 #2
0
 @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());
 }
예제 #3
0
 @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());
 }
예제 #4
0
 @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));
   }
 }