use of feign.RequestTemplate in project feign by OpenFeign.
the class JAXBCodecTest method encodesXmlWithCustomJAXBEncoding.
@Test
public void encodesXmlWithCustomJAXBEncoding() throws Exception {
JAXBContextFactory jaxbContextFactory = new JAXBContextFactory.Builder().withMarshallerJAXBEncoding("UTF-16").build();
Encoder encoder = new JAXBEncoder(jaxbContextFactory);
MockObject mock = new MockObject();
mock.value = "Test";
RequestTemplate template = new RequestTemplate();
encoder.encode(mock, MockObject.class, template);
assertThat(template).hasBody("<?xml version=\"1.0\" encoding=\"UTF-16\" " + "standalone=\"yes\"?><mockObject><value>Test</value></mockObject>");
}
use of feign.RequestTemplate in project feign by OpenFeign.
the class DefaultEncoderTest method testEncodesStrings.
@Test
public void testEncodesStrings() throws Exception {
String content = "This is my content";
RequestTemplate template = new RequestTemplate();
encoder.encode(content, String.class, template);
assertEquals(content, new String(template.body(), UTF_8));
}
use of feign.RequestTemplate in project feign by OpenFeign.
the class DefaultEncoderTest method testEncodesByteArray.
@Test
public void testEncodesByteArray() throws Exception {
byte[] content = { 12, 34, 56 };
RequestTemplate template = new RequestTemplate();
encoder.encode(content, byte[].class, template);
assertTrue(Arrays.equals(content, template.body()));
}
use of feign.RequestTemplate in project feign by OpenFeign.
the class JAXBCodecTest method encodesXmlWithCustomJAXBSchemaLocation.
@Test
public void encodesXmlWithCustomJAXBSchemaLocation() throws Exception {
JAXBContextFactory jaxbContextFactory = new JAXBContextFactory.Builder().withMarshallerSchemaLocation("http://apihost http://apihost/schema.xsd").build();
Encoder encoder = new JAXBEncoder(jaxbContextFactory);
MockObject mock = new MockObject();
mock.value = "Test";
RequestTemplate template = new RequestTemplate();
encoder.encode(mock, MockObject.class, template);
assertThat(template).hasBody("<?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>");
}
use of feign.RequestTemplate in project feign by OpenFeign.
the class JAXBCodecTest method encodesXml.
@Test
public void encodesXml() throws Exception {
MockObject mock = new MockObject();
mock.value = "Test";
RequestTemplate template = new RequestTemplate();
new JAXBEncoder(new JAXBContextFactory.Builder().build()).encode(mock, MockObject.class, template);
assertThat(template).hasBody("<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?><mockObject><value>Test</value></mockObject>");
}
Aggregations