use of com.spotify.apollo.Request in project apollo by spotify.
the class HttpClientTest method testSendWeirdStatus.
@Test
public void testSendWeirdStatus() throws Exception {
mockServerClient.when(request().withMethod("GET").withPath("/foo.php")).respond(response().withStatusCode(299));
String uri = format("http://localhost:%d/foo.php", mockServerRule.getHttpPort());
Request request = Request.forUri(uri, "GET");
final Response<ByteString> response = HttpClient.createUnconfigured().send(request, empty()).toCompletableFuture().get();
assertThat(response.status(), withCode(299));
assertThat(response.payload(), is(empty()));
}
use of com.spotify.apollo.Request in project apollo by spotify.
the class HttpClientTest method testTimeoutFail.
@Test
public void testTimeoutFail() throws Exception {
mockServerClient.when(request().withMethod("GET").withPath("/foo.php")).callback(callback().withCallbackClass(SleepCallback.class.getCanonicalName()));
String uri = format("http://localhost:%d/foo.php", mockServerRule.getHttpPort());
Request request = Request.forUri(uri, "GET").withTtl(Duration.ofMillis(200));
thrown.expect(hasCause(instanceOf(SocketTimeoutException.class)));
HttpClient.createUnconfigured().send(request, empty()).toCompletableFuture().get();
}
use of com.spotify.apollo.Request in project apollo by spotify.
the class RuleRouterTest method shouldReturnEmptyCollectionOnNonRoute.
@Test
public void shouldReturnEmptyCollectionOnNonRoute() throws Exception {
Rule<Integer> rule = Rule.fromUri("/foo/bar", "GET", TARGET);
final RuleRouter<Integer> router = RuleRouter.of(ImmutableList.of(rule));
final Request message = Request.forUri("/foo/notbar", "GET");
final Collection<String> methodsForValidRules = router.getMethodsForValidRules(message);
assertTrue(methodsForValidRules.isEmpty());
}
use of com.spotify.apollo.Request in project apollo by spotify.
the class RuleRouterTest method shouldReturnMethodsOnValidRoute.
@Test
public void shouldReturnMethodsOnValidRoute() throws Exception {
Rule<Integer> rule = Rule.fromUri("/foo/bar", "GET", TARGET);
final RuleRouter<Integer> router = RuleRouter.of(ImmutableList.of(rule));
final Request message = Request.forUri("/foo/bar", "POST");
final Collection<String> methodsForValidRules = router.getMethodsForValidRules(message);
assertThat(methodsForValidRules, hasItem("GET"));
}
use of com.spotify.apollo.Request in project apollo by spotify.
the class RuleRouterTest method shouldThrowInvalidUriExceptionForBadParameterEncoding.
@Test
public void shouldThrowInvalidUriExceptionForBadParameterEncoding() throws Exception {
Rule<Integer> rule = Rule.fromUri("/bar/<baz>", "GET", TARGET);
final RuleRouter<Integer> router = RuleRouter.of(ImmutableList.of(rule));
final Request message = Request.forUri("/bar/c%F6", "GET");
thrown.expect(InvalidUriException.class);
router.match(message);
}
Aggregations