use of com.spotify.apollo.Request in project apollo by spotify.
the class RequestTrackerTest method droppedAfterExpiration.
@Test
public void droppedAfterExpiration() {
Request requestMessage = Request.forUri("http://service/path");
OngoingRequest ongoingRequest = mock(OngoingRequest.class);
when(ongoingRequest.request()).thenReturn(requestMessage);
when(ongoingRequest.isExpired()).thenReturn(true);
new TrackedOngoingRequestImpl(ongoingRequest, tracker);
tracker.reap();
verify(ongoingRequest).drop();
}
use of com.spotify.apollo.Request in project apollo by spotify.
the class RequestTrackerTest method shouldFailRequestsWhenClosed.
@Test
public void shouldFailRequestsWhenClosed() throws Exception {
Request requestMessage = Request.forUri("http://service/path");
TrackedOngoingRequest ongoingRequest = mock(TrackedOngoingRequest.class);
when(ongoingRequest.request()).thenReturn(requestMessage);
when(ongoingRequest.isExpired()).thenReturn(false);
tracker.register(ongoingRequest);
tracker.close();
verify(ongoingRequest).reply(argThat(hasStatus(Status.SERVICE_UNAVAILABLE)));
}
use of com.spotify.apollo.Request in project apollo by spotify.
the class RouteEndpointTest method setUp.
@Before
public void setUp() throws Exception {
pathArgs = ImmutableMap.of("arg", "one", "and", "value2");
request = mock(Request.class);
// noinspection unchecked
syncEndpointHandler = mock(SyncHandler.class);
// noinspection unchecked
asyncHandler = mock(AsyncHandler.class);
Request request = Request.forUri("http://foo");
requestContext = RequestContexts.create(request, mock(Client.class), pathArgs, 0L, RequestMetadataImpl.create(Instant.EPOCH, Optional.empty(), Optional.empty()));
theData = ByteString.encodeUtf8("theString");
response = Response.forPayload(theData);
}
use of com.spotify.apollo.Request in project apollo by spotify.
the class RouteRuleBuilderTest method shouldCreateRule.
@Theory
public void shouldCreateRule(String method) throws Exception {
RouteProvider provider = () -> Stream.of(Route.sync(method, "/test/<arg>", newHandler1("foo")));
Request request = request(method, "/test/" + "bar");
ApplicationRouter<Endpoint> router = Routers.newRouterFromInspecting(provider);
assertRequestResponse(router, "foo", "bar", request);
}
use of com.spotify.apollo.Request in project apollo by spotify.
the class EndpointInvocationHandlerTest method setUp.
@Before
public void setUp() throws Exception {
handler = new EndpointInvocationHandler();
Request requestMessage = Request.forUri("http://foo/bar").withService("nameless-registry");
when(ongoingRequest.request()).thenReturn(requestMessage);
when(requestContext.request()).thenReturn(requestMessage);
future = new CompletableFuture<>();
}
Aggregations