use of org.apache.kafka.connect.util.FutureCallback in project kafka by apache.
the class StandaloneHerderTest method testDestroyConnector.
@Test
public void testDestroyConnector() throws Exception {
connector = PowerMock.createMock(BogusSourceConnector.class);
expectAdd(SourceSink.SOURCE);
Map<String, String> config = connectorConfig(SourceSink.SOURCE);
expectConfigValidation(config);
EasyMock.expect(statusBackingStore.getAll(CONNECTOR_NAME)).andReturn(Collections.<TaskStatus>emptyList());
statusBackingStore.put(new ConnectorStatus(CONNECTOR_NAME, AbstractStatus.State.DESTROYED, WORKER_ID, 0));
expectDestroy();
PowerMock.replayAll();
herder.putConnectorConfig(CONNECTOR_NAME, config, false, createCallback);
FutureCallback<Herder.Created<ConnectorInfo>> futureCb = new FutureCallback<>();
herder.deleteConnectorConfig(CONNECTOR_NAME, futureCb);
futureCb.get(1000L, TimeUnit.MILLISECONDS);
// Second deletion should fail since the connector is gone
futureCb = new FutureCallback<>();
herder.deleteConnectorConfig(CONNECTOR_NAME, futureCb);
try {
futureCb.get(1000L, TimeUnit.MILLISECONDS);
fail("Should have thrown NotFoundException");
} catch (ExecutionException e) {
assertTrue(e.getCause() instanceof NotFoundException);
}
PowerMock.verifyAll();
}
Aggregations