Package br.com.caelum.vraptor.resource

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


    String webMethod = request.getParameter("webMethod");
    String typeName = type.apply("webLogic", webLogic);
    try {
      DefaultResourceClass resource = new DefaultResourceClass(Class.forName(typeName));
      Method resourceMethod = method(resource.getType(), this.method.apply("webMethod", webMethod));
      return new DefaultResourceMethod(resource, resourceMethod);
    } catch (ClassNotFoundException e) {
      logger.debug("Unable to find type " + typeName + " for strategy " + this);
      throw new IllegalStateException("You must call canHandle before calling this method");
    }
  }
View Full Code Here


  public FixedMethodStrategy(String originalUri, Class<?> type, Method method, Set<HttpMethod> methods,
      ParametersControl control, int priority) {
    this.originalUri = originalUri;
    this.methods = methods.isEmpty() ? EnumSet.allOf(HttpMethod.class) : EnumSet.copyOf(methods);
    this.parameters = control;
    this.resourceMethod = new DefaultResourceMethod(new DefaultResourceClass(type), method);
    this.priority = priority;
  }
View Full Code Here

  public void setUp() throws Exception {
    MockitoAnnotations.initMocks(this);

    when(provider.parameterNamesFor(any(Method.class))).thenReturn(new String[] { "abc", "def", "ghi" });

    method = new DefaultResourceMethod(new DefaultResourceClass(MyResource.class), MyResource.class.getMethod(
        "method", String.class, Integer.class, BigDecimal.class));

    proxifier = new JavassistProxifier(new ObjenesisInstanceCreator());

    typeFinder = new DefaultTypeFinder(provider);
View Full Code Here

   
  deserializer = new JsonDeserializer(provider, extractor, XStreamBuilderImpl.cleanInstance());
 
    ResourceClass resourceClass = new DefaultResourceClass(CatController.class);

    meow = new DefaultResourceMethod(resourceClass, CatController.class.getDeclaredMethod("meow"));
    roll = new DefaultResourceMethod(resourceClass, CatController.class.getDeclaredMethod("roll", Cat.class));
    jump = new DefaultResourceMethod(resourceClass, CatController.class.getDeclaredMethod("jump", Cat.class, Integer.class));
    sleep = new DefaultResourceMethod(resourceClass, CatController.class.getDeclaredMethod("sleep", Integer.class, Cat.class));
    annotated = new DefaultResourceMethod(resourceClass, CatController.class.getDeclaredMethod("annotated", CatWithAnnotations.class));
  }
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

  }

  @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

TOP

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

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.