Package br.com.caelum.vraptor.resource

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


    deserializer = new XStreamXMLDeserializer(provider, XStreamBuilderImpl.cleanInstance());
    DefaultResourceClass resourceClass = new DefaultResourceClass(DogController.class);
    DefaultResourceClass resourcePersonClass = new DefaultResourceClass(PersonController.class);

    woof = new DefaultResourceMethod(resourceClass, DogController.class.getDeclaredMethod("woof"));
    bark = new DefaultResourceMethod(resourceClass, DogController.class.getDeclaredMethod("bark", Dog.class));
    jump = new DefaultResourceMethod(resourceClass, DogController.class.getDeclaredMethod("jump", Dog.class, Integer.class));
    dropDead = new DefaultResourceMethod(resourceClass, DogController.class.getDeclaredMethod("dropDead", Integer.class, Dog.class));
    annotated = new DefaultResourceMethod(resourceClass, DogController.class.getDeclaredMethod("annotated", DogWithAnnotations.class));
    walk = new DefaultResourceMethod(resourcePersonClass, PersonController.class.getDeclaredMethod("walk", Person.class));
  }
View Full Code Here


    CalendarDeserializer calendarDeserializer = new CalendarDeserializer(localization);
    deserializers.add(calendarDeserializer);
    deserializer = new GsonDeserialization(provider, new DefaultJsonDeserializers(deserializers), request);
    DefaultResourceClass resourceClass = new DefaultResourceClass(DogController.class);

    woof = new DefaultResourceMethod(resourceClass, DogController.class.getDeclaredMethod("woof"));
    bark = new DefaultResourceMethod(resourceClass, DogController.class.getDeclaredMethod("bark", Dog.class));
    jump = new DefaultResourceMethod(resourceClass, DogController.class.getDeclaredMethod("jump", Dog.class,
        Integer.class));
    dropDead = new DefaultResourceMethod(resourceClass, DogController.class.getDeclaredMethod("dropDead",
        Integer.class, Dog.class));
    adopt = new DefaultResourceMethod(resourceClass, DogController.class.getDeclaredMethod("adopt",
        List.class));
    sell = new DefaultResourceMethod(resourceClass, DogController.class.getDeclaredMethod("sell",
        List.class, String.class));
  }
View Full Code Here

  public void shouldDeserializeFromGenericTypeOneParam() {
    InputStream stream = new ByteArrayInputStream(
        "{'entity':{'name':'Brutus','age':7,'birthday':'06/01/1987'}}".getBytes());
    ResourceClass resourceClass = new DefaultResourceClass(ExtGenericController.class);
    Method method = new Mirror().on(GenericController.class).reflect().method("method").withAnyArgs();
    ResourceMethod resource = new DefaultResourceMethod(resourceClass, method);
    when(provider.parameterNamesFor(resource.getMethod())).thenReturn(new String[] { "entity" });

    Object[] deserialized = deserializer.deserialize(stream, resource);

    Dog dog = (Dog) deserialized[0];
View Full Code Here

  public void shouldDeserializeFromGenericTypeTwoParams() {
    InputStream stream = new ByteArrayInputStream(
        "{'entity':{'name':'Brutus','age':7,'birthday':'06/01/1987'}, 'param': 'test'}".getBytes());
    ResourceClass resourceClass = new DefaultResourceClass(ExtGenericController.class);
    Method method = new Mirror().on(GenericController.class).reflect().method("anotherMethod").withAnyArgs();
    ResourceMethod resource = new DefaultResourceMethod(resourceClass, method);
    when(provider.parameterNamesFor(resource.getMethod())).thenReturn(new String[] { "entity", "param" });

    Object[] deserialized = deserializer.deserialize(stream, resource);

    Dog dog = (Dog) deserialized[0];
    String param = (String) deserialized[1];
View Full Code Here

  public void shouldDeserializeWithoutGenericType() {
    InputStream stream = new ByteArrayInputStream(
        "{'param': 'test'}".getBytes());
    ResourceClass resourceClass = new DefaultResourceClass(ExtGenericController.class);
    Method method = new Mirror().on(GenericController.class).reflect().method("methodWithoutGenericType").withArgs(String.class);
    ResourceMethod resource = new DefaultResourceMethod(resourceClass, method);
    when(provider.parameterNamesFor(resource.getMethod())).thenReturn(new String[] { "param" });

    Object[] deserialized = deserializer.deserialize(stream, resource);

    String param = (String) deserialized[0];
View Full Code Here

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

    methodInfo = new DefaultMethodInfo();
    interceptor = new DeserializingInterceptor(request, deserializers, methodInfo, container, status);
    consumeXml = new DefaultResourceMethod(null, DummyResource.class.getDeclaredMethod("consumeXml"));
    doesntConsume = new DefaultResourceMethod(null, DummyResource.class.getDeclaredMethod("doesntConsume"));
  }
View Full Code Here

  @Test
  public void willDeserializeForAnyContentTypeIfPossible() throws Exception {
    when(request.getContentType()).thenReturn("application/xml");

    methodInfo.setParameters(new Object[2]);
    final DefaultResourceMethod consumesAnything = new DefaultResourceMethod(null, DummyResource.class.getDeclaredMethod("consumesAnything"));

    final Deserializer deserializer = mock(Deserializer.class);
    when(deserializer.deserialize(null, consumesAnything)).thenReturn(new Object[] {"abc", "def"});

    when(deserializers.deserializerFor("application/xml", container)).thenReturn(deserializer);
View Full Code Here

  @Test
  public void shouldNotDeserializeIfHasNoContentType() throws Exception {
    when(request.getContentType()).thenReturn(null);
   
    methodInfo.setParameters(new Object[2]);
    final DefaultResourceMethod consumesAnything = new DefaultResourceMethod(null, DummyResource.class.getDeclaredMethod("consumesAnything"));
   
    interceptor.intercept(stack, consumesAnything, null);

    assertEquals(methodInfo.getParameters()[0], null);
    assertEquals(methodInfo.getParameters()[1], null);
View Full Code Here

    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

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.