Package br.com.caelum.vraptor.resource

Examples of br.com.caelum.vraptor.resource.DefaultResourceClass


  }

  @Test
  public void dontRegisterRouteIfMethodIsStatic() {
    List<Route> routes = parser.rulesFor(new DefaultResourceClass(ClientsController.class));
    Route route = getRouteMatching(routes, "/staticMe");
    assertNull(route);

  }
View Full Code Here


  }
  @Test(expected=IllegalArgumentException.class)
  public void shouldThrowExceptionIfPathAnnotationHasEmptyArray()
    throws Exception {
  parser.rulesFor(new DefaultResourceClass(NoPath.class));
  }
View Full Code Here


  @Test
  public void shouldFindNonAnnotatedNonStaticPublicMethodWithComponentNameInVariableCamelCaseConventionAsURI()
    throws Exception {
    List<Route> routes = parser.rulesFor(new DefaultResourceClass(ClientsController.class));
    Route route = getRouteMatching(routes, "/clients/add");

    assertThat(route, canHandle(ClientsController.class, "add"));

View Full Code Here

  }

  @Test
  public void shouldFindSeveralPathsForMethodWithManyValue()
    throws Exception {
    List<Route> routes = parser.rulesFor(new DefaultResourceClass(ClientsController.class));

    Route route = getRouteMatching(routes, "/path1");
    assertThat(route, canHandle(ClientsController.class, "manyPaths"));
    Route route2 = getRouteMatching(routes, "/path2");
    assertThat(route2, canHandle(ClientsController.class, "manyPaths"));
View Full Code Here



  @Test
  public void shouldNotMatchIfAResourceHasTheWrongWebMethod() throws SecurityException {
    List<Route> routes = parser.rulesFor(new DefaultResourceClass(ClientsController.class));
    Route route = getRouteMatching(routes, "/clients/remove");

    assertThat(route.allowedMethods(), not(contains(HttpMethod.POST)));

  }
View Full Code Here

  }

  @Test
  public void shouldAcceptAResultWithASpecificWebMethod() throws SecurityException, NoSuchMethodException {
    List<Route> routes = parser.rulesFor(new DefaultResourceClass(ClientsController.class));
    Route route = getRouteMatching(routes, "/clients/head");

    assertThat(route.allowedMethods(), is(EnumSet.of(HttpMethod.HEAD)));

  }
View Full Code Here

  }


  @Test
  public void shouldAcceptAResultWithOptionsWebMethod() throws SecurityException, NoSuchMethodException {
    List<Route> routes = parser.rulesFor(new DefaultResourceClass(ClientsController.class));
    Route route = getRouteMatching(routes, "/clients/options");

    assertThat(route.allowedMethods(), is(EnumSet.of(HttpMethod.OPTIONS)));
  }
View Full Code Here

    assertThat(route.allowedMethods(), is(EnumSet.of(HttpMethod.OPTIONS)));
  }
 
  @Test
  public void shouldAcceptAResultWithPatchWebMethod() throws SecurityException, NoSuchMethodException {
    List<Route> routes = parser.rulesFor(new DefaultResourceClass(ClientsController.class));
    Route route = getRouteMatching(routes, "/clients/update");

    assertThat(route.allowedMethods(), is(EnumSet.of(HttpMethod.PATCH)));
  }
View Full Code Here

    }
  }

  @Test
  public void findsInheritedMethodsWithDefaultNames() throws SecurityException, NoSuchMethodException {
    List<Route> routes = parser.rulesFor(new DefaultResourceClass(NiceClients.class));
    Route route = getRouteMatching(routes, "/niceClients/toInherit");

    assertTrue(route.canHandle(NiceClients.class, ClientsController.class.getDeclaredMethod("toInherit")));
  }
View Full Code Here

    assertTrue(route.canHandle(NiceClients.class, ClientsController.class.getDeclaredMethod("toInherit")));
  }
  @Test
  public void supportMethodOverriding() throws SecurityException, NoSuchMethodException {
    List<Route> routes = parser.rulesFor(new DefaultResourceClass(NiceClients.class));
    Route route = getRouteMatching(routes, "/niceClients/add");

    assertThat(route, canHandle(NiceClients.class, "add"));
  }
View Full Code Here

TOP

Related Classes of br.com.caelum.vraptor.resource.DefaultResourceClass

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.