Package feign

Examples of feign.RequestTemplate


        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


        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

        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)
                .append("<mockObject>").append(NEWLINE)
                .append("    <value>Test</value>").append(NEWLINE)
                .append("</mockObject>").append(NEWLINE);

        assertEquals(new String(template.body(), UTF_8), expectedXml.toString());
    }
View Full Code Here

public class BasicAuthRequestInterceptorTest {
  /**
   * Tests that request headers are added as expected.
   */
  @Test public void testAuthentication() {
    RequestTemplate template = new RequestTemplate();
    BasicAuthRequestInterceptor interceptor = new BasicAuthRequestInterceptor("Aladdin", "open sesame");
    interceptor.apply(template);
    Collection<String> actualValue = template.headers().get("Authorization");
    Collection<String> expectedValue = Collections.singletonList("Basic QWxhZGRpbjpvcGVuIHNlc2FtZQ==");
    assertEquals(actualValue, expectedValue);
  }
View Full Code Here

  /**
   * Tests that requests headers are added as expected when user and pass are too long
   */
  @Test public void testAuthenticationWhenUserPassAreTooLong() {
    RequestTemplate template = new RequestTemplate();
    BasicAuthRequestInterceptor interceptor = new BasicAuthRequestInterceptor("IOIOIOIOIOIOIOIOIOIOIOIOIOIOIOIOIOIOIO",
              "101010101010101010101010101010101010101010");
    interceptor.apply(template);
    Collection<String> actualValue = template.headers().get("Authorization");
    Collection<String> expectedValue = Collections.
        singletonList("Basic SU9JT0lPSU9JT0lPSU9JT0lPSU9JT0lPSU9JT0lPSU9JT0lPSU86MTAxMDEwMTAxMDEwMTAxMDEwMTAxMDEwMTAxMDEwMTAxMDEwMTAxMDEw");
    assertEquals(actualValue, expectedValue);
  }
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.