Package feign

Examples of feign.RequestTemplate.body()


  @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));
  }

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


  @Test public void testEncodesByteArray() throws Exception {
    byte[] content = {12, 34, 56};
    RequestTemplate template = new RequestTemplate();
    encoder.encode(content, template);
    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

    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

    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

    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));
  }

  @Test public void encodesFormParams() throws Exception {
    String expectedBody = ""//
        + "{\n" //
View Full Code Here

    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));
  }

  static class Zone extends LinkedHashMap<String, Object> {
    Zone() {
      // for reflective instantiation.
View Full Code Here

        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>");
    }

    @Test
    public void encodesXmlWithCustomJAXBEncoding() throws Exception {
View Full Code Here

        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>");
    }

    @Test
    public void encodesXmlWithCustomJAXBSchemaLocation() throws Exception {
View Full Code Here

        mock.setValue("Test");

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

        assertEquals(new String(template.body(), UTF_8), "<?xml version=\"1.0\" encoding=\"UTF-8\" " +
                "standalone=\"yes\"?><mockObject xsi:schemaLocation=\"http://apihost " +
                "http://apihost/schema.xsd\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\">" +
                "<value>Test</value></mockObject>");
    }
View Full Code Here

        mock.setValue("Test");

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

        assertEquals(new String(template.body(), UTF_8), "<?xml version=\"1.0\" encoding=\"UTF-8\" " +
                "standalone=\"yes\"?><mockObject xsi:noNamespaceSchemaLocation=\"http://apihost/schema.xsd\" " +
                "xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\">" +
                "<value>Test</value></mockObject>");
    }
View Full Code Here

TOP
Copyright © 2018 www.massapi.com. 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.