Package br.com.caelum.vraptor.resource

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


 
  @Test
  public void shouldAddVariousHeaderInformationsToRequestWhenHeaderParamAnnotationIsPresent() throws Exception {
    Object[] values = new Object[] { new Object() };
    Method method = HeaderParamComponent.class.getDeclaredMethod("otherMethod", String.class, String.class, String.class);
    ResourceMethod resouceMethod = DefaultResourceMethod.instanceFor(HeaderParamComponent.class, method);
   
    when(request.getHeader("X-MyApp-User")).thenReturn("user");
    when(request.getHeader("X-MyApp-Password")).thenReturn("123");
    when(request.getHeader("X-MyApp-Token")).thenReturn("daek2321");
    when(parametersProvider.getParametersFor(resouceMethod, errors, bundle)).thenReturn(values);
View Full Code Here


            if (componentToRegister != null && !isAppScoped(secondContainer, componentToRegister)) {
              ComponentRegistry registry = secondContainer.instanceFor(ComponentRegistry.class);
              registry.register(componentToRegister, componentToRegister);
            }

            ResourceMethod secondMethod = mock(ResourceMethod.class, "rm" + counter);
            secondContainer.instanceFor(MethodInfo.class).setResourceMethod(secondMethod);
            return instanceFor(component, secondContainer);
          }
        });
View Full Code Here

  }
 
  @Test
  public void shouldInvokeTheMethodAndNotProceedWithInterceptorStack() throws SecurityException,
      NoSuchMethodException, IOException, InterceptionException {
    ResourceMethod method = new DefaultResourceMethod(null, DogAlike.class.getMethod("bark"));
    DogAlike auau = mock(DogAlike.class);
    when(info.getParameters()).thenReturn(new Object[0]);
   
    interceptor.intercept(stack, method, auau);
   
View Full Code Here

          public T insideRequest(Container firstContainer) {
            if (componentToRegister != null) {
              ComponentRegistry registry = firstContainer.instanceFor(ComponentRegistry.class);
              registry.register(componentToRegister, componentToRegister);
            }
            ResourceMethod firstMethod = mock(ResourceMethod.class, "rm" + counter);
            firstContainer.instanceFor(MethodInfo.class).setResourceMethod(firstMethod);
            return instanceFor(componentToBeRetrieved,firstContainer);
          }
        });
View Full Code Here

  }

  @Test
  public void shouldThrowMethodExceptionIfThereIsAnInvocationException() throws IOException, SecurityException,
      NoSuchMethodException {
    ResourceMethod method = new DefaultResourceMethod(null, DogAlike.class.getMethod("bark"));
    final DogAlike auau = mock(DogAlike.class);
    final RuntimeException exception = new RuntimeException();
   
    doThrow(exception).when(auau).bark();
    when(info.getParameters()).thenReturn(new Object[0]);
View Full Code Here

  }

  @Test
  public void shouldUseTheProvidedArguments() throws SecurityException, NoSuchMethodException, InterceptionException,
      IOException {
    ResourceMethod method = new DefaultResourceMethod(null, DogAlike.class.getMethod("bark", int.class));
    DogAlike auau = mock(DogAlike.class);

    when(info.getParameters()).thenReturn(new Object[] { 3 });

    interceptor.intercept(stack, method, auau);
View Full Code Here

  }

  @Test
  public void shouldSetResultReturnedValueFromInvokedMethod() throws SecurityException, NoSuchMethodException,
      InterceptionException, IOException {
    ResourceMethod method = new DefaultResourceMethod(null, XController.class.getMethod("method", Object.class));
    final XController x = new XController();
   
    when(info.getParameters()).thenReturn(new Object[] { "string" });

    interceptor.intercept(stack, method, x);
View Full Code Here

  }

  @Test
  public void shouldSetNullWhenNullReturnedFromInvokedMethod() throws SecurityException, NoSuchMethodException,
      InterceptionException, IOException {
    ResourceMethod method = new DefaultResourceMethod(null, XController.class.getMethod("method", Object.class));
    final XController x = new XController();
   
    when(info.getParameters()).thenReturn(new Object[] { null });

    interceptor.intercept(stack, method, x);
View Full Code Here

  }

  @Test
  public void shouldSetOkWhenVoidReturnedFromInvokedMethod() throws SecurityException, NoSuchMethodException,
      InterceptionException, IOException {
    ResourceMethod method = new DefaultResourceMethod(null, XController.class.getMethod("method"));
    XController x = new XController();
   
    when(info.getParameters()).thenReturn(new Object[] {});
   
    interceptor.intercept(stack, method, x);
View Full Code Here

  @Test
  public void shouldBeOkIfThereIsValidationErrorsAndYouSpecifiedWhereToGo() throws SecurityException,
      NoSuchMethodException, InterceptionException, IOException {
    Method specifiedWhereToGo = AnyController.class.getMethod("specifiedWhereToGo");
    ResourceMethod method = DefaultResourceMethod.instanceFor(AnyController.class, specifiedWhereToGo);
    AnyController controller = new AnyController(validator);
   
    when(info.getParameters()).thenReturn(new Object[0]);
    doThrow(new ValidationException(Collections.<Message> emptyList())).when(validator).onErrorUse(nothing());
    when(validator.hasErrors()).thenReturn(true);
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.