use of com.metamx.http.client.response.SequenceInputStreamResponseHandler in project druid by druid-io.
the class LookupCoordinatorManagerTest method testUpdateAllOnHostFailsWhenServerReturnsWeird.
@Test
public void testUpdateAllOnHostFailsWhenServerReturnsWeird() throws Exception {
final HttpResponseHandler<InputStream, InputStream> responseHandler = EasyMock.createStrictMock(HttpResponseHandler.class);
final String failedLookup = "failedLookup";
final URL url = LookupCoordinatorManager.getLookupsURL(HostAndPort.fromString("localhost"));
final SettableFuture<InputStream> future = SettableFuture.create();
future.set(new ByteArrayInputStream(StringUtils.toUtf8(mapper.writeValueAsString(ImmutableMap.of("status", "accepted")))));
EasyMock.expect(client.go(EasyMock.<Request>anyObject(), EasyMock.<SequenceInputStreamResponseHandler>anyObject(), EasyMock.<Duration>anyObject())).andReturn(future).once();
EasyMock.replay(client, responseHandler);
final LookupCoordinatorManager manager = new LookupCoordinatorManager(client, discoverer, mapper, configManager, lookupCoordinatorManagerConfig) {
@Override
HttpResponseHandler<InputStream, InputStream> makeResponseHandler(final AtomicInteger returnCode, final AtomicReference<String> reasonString) {
returnCode.set(200);
reasonString.set("");
return responseHandler;
}
};
expectedException.expectMessage(String.format("Update result did not have field for [%s]", LookupModule.FAILED_UPDATES_KEY));
try {
manager.updateAllOnHost(url, SINGLE_LOOKUP_MAP);
} finally {
EasyMock.verify(client, responseHandler);
}
}
use of com.metamx.http.client.response.SequenceInputStreamResponseHandler in project druid by druid-io.
the class LookupCoordinatorManagerTest method testDeleteAllTier.
@Test
public void testDeleteAllTier() throws Exception {
final HttpResponseHandler<InputStream, InputStream> responseHandler = EasyMock.createStrictMock(HttpResponseHandler.class);
final LookupCoordinatorManager manager = new LookupCoordinatorManager(client, discoverer, mapper, configManager, lookupCoordinatorManagerConfig) {
@Override
HttpResponseHandler<InputStream, InputStream> makeResponseHandler(final AtomicInteger returnCode, final AtomicReference<String> reasonString) {
returnCode.set(200);
reasonString.set("");
return responseHandler;
}
};
final HostAndPort hostAndPort = HostAndPort.fromParts("someHost", 8080);
final Collection<String> drop = ImmutableList.of("lookup1");
EasyMock.expect(discoverer.getNodes(LookupModule.getTierListenerPath(LOOKUP_TIER))).andReturn(ImmutableList.of(hostAndPort)).once();
final SettableFuture<InputStream> future = SettableFuture.create();
future.set(new ByteArrayInputStream(new byte[0]));
EasyMock.expect(client.go(EasyMock.<Request>anyObject(), EasyMock.<SequenceInputStreamResponseHandler>anyObject(), EasyMock.<Duration>anyObject())).andReturn(future).once();
EasyMock.replay(client, discoverer, responseHandler);
manager.deleteAllOnTier(LOOKUP_TIER, drop);
EasyMock.verify(client, discoverer, responseHandler);
}
Aggregations