Package feign

Examples of feign.RequestTemplate


      this.request = request;
      setUri(uri);
    }

    Request toRequest() {
      return new RequestTemplate()
          .method(request.method())
          .append(getUri().toASCIIString())
          .headers(request.headers())
          .body(request.body(), request.charset())
          .request();
View Full Code Here


public class DefaultEncoderTest {
  private final Encoder encoder = new Encoder.Default();

  @Test public void testEncodesStrings() throws Exception {
    String content = "This is my content";
    RequestTemplate template = new RequestTemplate();
    encoder.encode(content, template);
    assertEquals(template.body(), content.getBytes(UTF_8));
  }
View Full Code Here

    assertEquals(template.body(), content.getBytes(UTF_8));
  }

  @Test public void testEncodesByteArray() throws Exception {
    byte[] content = {12, 34, 56};
    RequestTemplate template = new RequestTemplate();
    encoder.encode(content, template);
    assertEquals(template.body(), content);
  }
View Full Code Here

    assertEquals(template.body(), content);
  }

  @Test(expectedExceptions = EncodeException.class, expectedExceptionsMessageRegExp = ".* is not a type supported by this encoder.")
  public void testRefusesToEncodeOtherTypes() throws Exception {
    encoder.encode(new Date(), new RequestTemplate());
  }
View Full Code Here

    ObjectGraph.create(bindings).inject(bindings);

    Map<String, Object> map = new LinkedHashMap<String, Object>();
    map.put("foo", 1);

    RequestTemplate template = new RequestTemplate();
    bindings.encoder.encode(map, template);
    assertEquals(new String(template.body(), UTF_8), ""//
        + "{\n" //
        + "  \"foo\" : 1\n" //
        + "}");
  }
View Full Code Here

    Map<String, Object> form = new LinkedHashMap<String, Object>();
    form.put("foo", 1);
    form.put("bar", Arrays.asList(2, 3));

    RequestTemplate template = new RequestTemplate();
    bindings.encoder.encode(form, template);
    assertEquals(new String(template.body(), UTF_8), ""//
        + "{\n" //
        + "  \"foo\" : 1,\n" //
        + "  \"bar\" : [ 2, 3 ]\n" //
        + "}");
  }
View Full Code Here

    ObjectGraph.create(bindings).inject(bindings);

    Map<String, Object> map = new LinkedHashMap<String, Object>();
    map.put("foo", 1);

    RequestTemplate template = new RequestTemplate();
    bindings.encoder.encode(map, template);
    assertEquals(template.body(), expectedBody.getBytes(UTF_8));
  }
View Full Code Here

    Map<String, Object> form = new LinkedHashMap<String, Object>();
    form.put("foo", 1);
    form.put("bar", Arrays.asList(2, 3));

    RequestTemplate template = new RequestTemplate();
    bindings.encoder.encode(form, template);
    assertEquals(template.body(), expectedBody.getBytes(UTF_8));
  }
View Full Code Here

        ObjectGraph.create(bindings).inject(bindings);

        MockObject mock = new MockObject();
        mock.setValue("Test");

        RequestTemplate template = new RequestTemplate();
        bindings.encoder.encode(mock, template);

        assertEquals(new String(template.body(), UTF_8), "<?xml version=\"1.0\" encoding=\"UTF-8\" " +
                "standalone=\"yes\"?><mockObject><value>Test</value></mockObject>");
    }
View Full Code Here

        Encoder encoder = jaxbModule.encoder(new JAXBEncoder(jaxbContextFactory));

        MockObject mock = new MockObject();
        mock.setValue("Test");

        RequestTemplate template = new RequestTemplate();
        encoder.encode(mock, template);

        assertEquals(new String(template.body(), UTF_8), "<?xml version=\"1.0\" encoding=\"UTF-16\" " +
                "standalone=\"yes\"?><mockObject><value>Test</value></mockObject>");
    }
View Full Code Here

TOP

Related Classes of feign.RequestTemplate

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.