@Test
public void testPortRetrievalFailureHandling() throws Exception {

	DispatcherGateway mockGateway = mock(DispatcherGateway.class);
	when(mockGateway.getBlobServerPort(any(Time.class)))
		.thenReturn(FutureUtils.completedExceptionally(new TestException()));
	GatewayRetriever<DispatcherGateway> mockGatewayRetriever = mock(GatewayRetriever.class);
	BlobServerPortHandler handler = new BlobServerPortHandler(
		CompletableFuture.completedFuture("http://localhost:1234"),
		mockGatewayRetriever,
		RpcUtils.INF_TIMEOUT);
	try {
		handler
			.handleRequest(new HandlerRequest<>(EmptyRequestBody.getInstance(), EmptyMessageParameters.getInstance()), mockGateway)
			.get();
		Assert.fail();
	} catch (ExecutionException ee) {
		RestHandlerException rhe = (RestHandlerException) ee.getCause();
		Assert.assertEquals(TestException.class, rhe.getCause().getClass());
		Assert.assertEquals(HttpResponseStatus.INTERNAL_SERVER_ERROR, rhe.getHttpResponseStatus());
	}
}