use of feign.codec.Encoder 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>");
}
Aggregations