use of javax.ws.rs.client.ClientRequestContext in project robozonky by RoboZonky.
the class AuthenticationFilterTest method wasAuthorizationAdded.
@Test
void wasAuthorizationAdded() throws URISyntaxException {
final ClientRequestContext crc = mock(ClientRequestContext.class);
when(crc.getHeaders()).thenReturn(new MultivaluedHashMap<>());
when(crc.getUri()).thenReturn(new URI("http://somewhere"));
this.getTestedFilter().filter(crc);
assertThat(crc.getHeaders()).containsKey("Authorization");
}
use of javax.ws.rs.client.ClientRequestContext in project robozonky by RoboZonky.
the class RoboZonkyFilterTest method request.
@Test
void request() throws URISyntaxException {
final MultivaluedMap<String, Object> map = mock(MultivaluedMap.class);
final ClientRequestContext ctx = mock(ClientRequestContext.class);
when(ctx.getHeaders()).thenReturn(map);
when(ctx.getUri()).thenReturn(new URI("http://localhost"));
final RoboZonkyFilter filter = new RoboZonkyFilter();
filter.setQueryParam("something", "value");
filter.filter(ctx);
verify(ctx).setUri(new URI("http://localhost?something=value"));
verify(map).putSingle(eq("User-Agent"), eq(Defaults.ROBOZONKY_USER_AGENT));
}
use of javax.ws.rs.client.ClientRequestContext in project robozonky by RoboZonky.
the class AbstractCommonFilterTest method userAgent.
@Test
void userAgent() throws URISyntaxException {
final MultivaluedMap<String, Object> map = new MultivaluedMapImpl<>();
final ClientRequestContext ctx = mock(ClientRequestContext.class);
when(ctx.getUri()).thenReturn(new URI("http://localhost/"));
when(ctx.getHeaders()).thenReturn(map);
getTestedFilter().filter(ctx);
assertThat(map.get("User-Agent").get(0)).isEqualTo(Defaults.ROBOZONKY_USER_AGENT);
}
use of javax.ws.rs.client.ClientRequestContext in project dropwizard by dropwizard.
the class ConfiguredGZipEncoderTest method gzipParametersSpec.
@Test
void gzipParametersSpec() throws IOException {
ClientRequestContext context = mock(ClientRequestContext.class);
MultivaluedMap<String, Object> headers = new MultivaluedHashMap<>();
when(context.getHeaders()).thenReturn(headers);
headers.put(HttpHeaders.CONTENT_ENCODING, null);
when(context.hasEntity()).thenReturn(true);
new ConfiguredGZipEncoder(true).filter(context);
assertThat(headers.getFirst(HttpHeaders.CONTENT_ENCODING)).hasToString("gzip");
}
use of javax.ws.rs.client.ClientRequestContext in project instrumentation-java by census-instrumentation.
the class JaxrsClientExtractorTest method testExtraction.
@Test
public void testExtraction() {
URI uri = URI.create("https://myhost/resource");
ClientRequestContext requestContext = mock(ClientRequestContext.class);
when(requestContext.getUri()).thenReturn(uri);
when(requestContext.getMethod()).thenReturn("GET");
when(requestContext.getHeaderString("user-agent")).thenReturn("java/1.8");
ClientResponseContext responseContext = mock(ClientResponseContext.class);
when(responseContext.getStatus()).thenReturn(200);
JaxrsClientExtractor extractor = new JaxrsClientExtractor();
assertEquals("myhost", extractor.getHost(requestContext));
assertEquals("GET", extractor.getMethod(requestContext));
assertEquals("/resource", extractor.getPath(requestContext));
assertNull(extractor.getRoute(requestContext));
assertEquals("https://myhost/resource", extractor.getUrl(requestContext));
assertEquals("java/1.8", extractor.getUserAgent(requestContext));
assertEquals(200, extractor.getStatusCode(responseContext));
}
Aggregations