Package br.com.caelum.vraptor.resource

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


    return proxifier.proxify(type, handler);
  }

  public void is(Class<?> type, Method method) {
    addParametersInfo(method);
    ResourceMethod resourceMethod = DefaultResourceMethod.instanceFor(type, method);
    String[] parameterNames = nameProvider.parameterNamesFor(method);
    this.strategy = new FixedMethodStrategy(originalUri, resourceMethod, this.supportedMethods, builder.build(), priority, parameterNames);

    logger.info(String.format("%-50s%s -> %10s", originalUri,
        this.supportedMethods.isEmpty() ? "[ALL]" : this.supportedMethods,
View Full Code Here


  public <T> T of(final Class<T> controllerType) {
    return proxifier.proxify(controllerType, new MethodInvocation<T>() {
            public Object intercept(T proxy, Method method, Object[] args, SuperMethod superMethod) {
                try {
                    ResourceMethod resourceMethod = DefaultResourceMethod.instanceFor(controllerType, method);
                    forwardTo(resourceMethod);
                    return null;
                } catch (Exception e) {
                    throw new ProxyInvocationException(e);
        }
View Full Code Here

  }

  public void is(Class<?> type, Method method) {
    addParametersInfo(method);
    ResourceMethod resourceMethod = DefaultResourceMethod.instanceFor(type, method);
    String[] parameterNames = nameProvider.parameterNamesFor(method);
    this.strategy = new FixedMethodStrategy(originalUri, resourceMethod, this.supportedMethods, builder.build(), priority, parameterNames);

    logger.info(String.format("%-50s%s -> %10s", originalUri,
        this.supportedMethods.isEmpty() ? "[ALL]" : this.supportedMethods,
View Full Code Here

  @Test
  public void shouldObeyPriorityOfRoutes() throws Exception {
    Route first = mock(Route.class);
    Route second = mock(Route.class);
   
    ResourceMethod method2 = second.resourceMethod(request, "second");
   
    router.add(second);
    router.add(first);

    when(first.getPriority()).thenReturn(Path.HIGH);
    when(second.getPriority()).thenReturn(Path.LOW);
   
    EnumSet<HttpMethod> get = EnumSet.of(HttpMethod.GET);
    when(first.allowedMethods()).thenReturn(get);
    when(second.allowedMethods()).thenReturn(get);
   
    when(first.canHandle(anyString())).thenReturn(false);
    when(second.canHandle(anyString())).thenReturn(true);
   
    ResourceMethod found = router.parse("anything", HttpMethod.GET, request);
    assertThat(found, is(method2));
  }
View Full Code Here

    when(route.canHandle("/clients/add")).thenReturn(true);
    when(route.allowedMethods()).thenReturn(EnumSet.of(HttpMethod.POST));
    when(route.resourceMethod(request, "/clients/add")).thenReturn(method);

    router.add(route);
    ResourceMethod found = router.parse("/clients/add", HttpMethod.POST, request);
   
    assertThat(found, is(equalTo(method)));
    verify(route, atLeastOnce()).getPriority();
  }
View Full Code Here

    when(route.canHandle("/clients/add")).thenReturn(true);
    when(route.allowedMethods()).thenReturn(EnumSet.of(delete));
    when(route.resourceMethod(request, "/clients/add")).thenReturn(method);

    router.add(route);
    ResourceMethod found = router.parse("/clients/add", delete, request);
    assertThat(found, is(equalTo(method)));
    verify(route, atLeastOnce()).getPriority();
  }
View Full Code Here

    when(second.getPriority()).thenReturn(Path.LOWEST);

    router.add(route);
    router.add(second);
   
    ResourceMethod found = router.parse("/clients/add", HttpMethod.POST, request);
    assertThat(found, is(equalTo(method)));
  }
View Full Code Here

  @Test
  public void canTranslate() {
    FixedMethodStrategy strategy = new FixedMethodStrategy("abc", list,
        methods(HttpMethod.POST), control, 0, new String[] {});
    when(control.matches("/clients/add")).thenReturn(true);
    ResourceMethod match = strategy.resourceMethod(request, "/clients/add");
    assertThat(match, is(VRaptorMatchers.resourceMethod(method("list"))));
    verify(control, only()).fillIntoRequest("/clients/add", request);
  }
View Full Code Here

    when(request.getAttribute(RequestInfo.INCLUDE_REQUEST_URI)).thenReturn("/url");
    when(request.getMethod()).thenReturn("POST");
    when(router.parse("/url", HttpMethod.POST, webRequest)).thenReturn(method);

  ResourceMethod resource = translator.translate(info);
  assertThat(resource, is(sameInstance(method)));
  }
View Full Code Here

    when(request.getRequestURI()).thenReturn("/url");
    when(request.getMethod()).thenReturn("POST");
    when(router.parse("/url", HttpMethod.POST,webRequest)).thenReturn(method);

  ResourceMethod resource = translator.translate(info);
  assertThat(resource, is(equalTo(method)));
  }
View Full Code Here

TOP

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

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.