Search in sources :

Example 16 with RequestTemplate

use of feign.RequestTemplate in project feign by OpenFeign.

the class BasicAuthRequestInterceptorTest method addsAuthorizationHeader_longUserAndPassword.

@Test
public void addsAuthorizationHeader_longUserAndPassword() {
    RequestTemplate template = new RequestTemplate();
    BasicAuthRequestInterceptor interceptor = new BasicAuthRequestInterceptor("IOIOIOIOIOIOIOIOIOIOIOIOIOIOIOIOIOIOIO", "101010101010101010101010101010101010101010");
    interceptor.apply(template);
    assertThat(template).hasHeaders(entry("Authorization", asList("Basic SU9JT0lPSU9JT0lPSU9JT0lPSU9JT0lPSU9JT0lPSU9JT0lPSU86MTAxMDEwMTAxMDEwMTAxMDEwMTAxMDEwMTAxMDEwMTAxMDEwMTAxMDEw")));
}
Also used : RequestTemplate(feign.RequestTemplate) Test(org.junit.Test)

Example 17 with RequestTemplate

use of feign.RequestTemplate in project feign by OpenFeign.

the class BasicAuthRequestInterceptorTest method addsAuthorizationHeader.

@Test
public void addsAuthorizationHeader() {
    RequestTemplate template = new RequestTemplate();
    BasicAuthRequestInterceptor interceptor = new BasicAuthRequestInterceptor("Aladdin", "open sesame");
    interceptor.apply(template);
    assertThat(template).hasHeaders(entry("Authorization", asList("Basic QWxhZGRpbjpvcGVuIHNlc2FtZQ==")));
}
Also used : RequestTemplate(feign.RequestTemplate) Test(org.junit.Test)

Example 18 with RequestTemplate

use of feign.RequestTemplate in project feign by OpenFeign.

the class JAXBCodecTest method doesntEncodeParameterizedTypes.

@Test
public void doesntEncodeParameterizedTypes() throws Exception {
    thrown.expect(UnsupportedOperationException.class);
    thrown.expectMessage("JAXB only supports encoding raw types. Found java.util.Map<java.lang.String, ?>");
    class ParameterizedHolder {

        Map<String, ?> field;
    }
    Type parameterized = ParameterizedHolder.class.getDeclaredField("field").getGenericType();
    RequestTemplate template = new RequestTemplate();
    new JAXBEncoder(new JAXBContextFactory.Builder().build()).encode(Collections.emptyMap(), parameterized, template);
}
Also used : XmlAccessorType(javax.xml.bind.annotation.XmlAccessorType) XmlAccessType(javax.xml.bind.annotation.XmlAccessType) Type(java.lang.reflect.Type) RequestTemplate(feign.RequestTemplate) Map(java.util.Map) Test(org.junit.Test)

Aggregations

RequestTemplate (feign.RequestTemplate)18 Test (org.junit.Test)18 Encoder (feign.codec.Encoder)4 LinkedHashMap (java.util.LinkedHashMap)4 TypeReference (com.fasterxml.jackson.core.type.TypeReference)2 TypeToken (com.google.gson.reflect.TypeToken)2 LinkedList (java.util.LinkedList)2 SimpleModule (com.fasterxml.jackson.databind.module.SimpleModule)1 Type (java.lang.reflect.Type)1 Date (java.util.Date)1 Map (java.util.Map)1 XmlAccessType (javax.xml.bind.annotation.XmlAccessType)1 XmlAccessorType (javax.xml.bind.annotation.XmlAccessorType)1