Package feign.codec

Examples of feign.codec.Encoder$Default


    MockWebServer server = new MockWebServer();
    server.enqueue(new MockResponse().setBody("response data"));
    server.play();

    String url = "http://localhost:" + server.getPort();
    Encoder encoder = new Encoder() {
      @Override
      public void encode(Object object, RequestTemplate template) throws EncodeException {
        template.body(object.toString());
      }
    };
View Full Code Here


        JAXBContextFactory jaxbContextFactory = new JAXBContextFactory.Builder()
                .withMarshallerJAXBEncoding("UTF-16")
                .build();

        JAXBModule jaxbModule = new JAXBModule(jaxbContextFactory);
        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

        JAXBContextFactory jaxbContextFactory = new JAXBContextFactory.Builder()
                .withMarshallerSchemaLocation("http://apihost http://apihost/schema.xsd")
                .build();

        JAXBModule jaxbModule = new JAXBModule(jaxbContextFactory);
        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-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

        JAXBContextFactory jaxbContextFactory = new JAXBContextFactory.Builder()
                .withMarshallerNoNamespaceSchemaLocation("http://apihost/schema.xsd")
                .build();

        JAXBModule jaxbModule = new JAXBModule(jaxbContextFactory);
        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-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

        JAXBContextFactory jaxbContextFactory = new JAXBContextFactory.Builder()
                .withMarshallerFormattedOutput(true)
                .build();

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

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

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

        String NEWLINE = System.getProperty("line.separator");

        StringBuilder expectedXml = new StringBuilder();
        expectedXml.append("<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?>").append(NEWLINE)
View Full Code Here

      @Provides Decoder defaultDecoder() {
        return new Decoder.Default();
      }

      @Provides Encoder defaultEncoder() {
        return new Encoder() {
          @Override public void encode(Object object, RequestTemplate template) {
            if (object instanceof Map) {
              template.body(Joiner.on(',').withKeyValueSeparator("=").join((Map) object));
            } else {
              template.body(object.toString());
View Full Code Here

TOP

Related Classes of feign.codec.Encoder$Default

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.