use of org.apache.kafka.connect.util.Callback in project kafka by apache.
the class ConnectorsResourceTest method testCreateConnectorWithASlashInItsName.
@Test(expected = BadRequestException.class)
public void testCreateConnectorWithASlashInItsName() throws Throwable {
String badConnectorName = CONNECTOR_NAME + "/" + "test";
CreateConnectorRequest body = new CreateConnectorRequest(badConnectorName, Collections.singletonMap(ConnectorConfig.NAME_CONFIG, badConnectorName));
final Capture<Callback<Herder.Created<ConnectorInfo>>> cb = Capture.newInstance();
herder.putConnectorConfig(EasyMock.eq(CONNECTOR_NAME), EasyMock.eq(body.config()), EasyMock.eq(false), EasyMock.capture(cb));
expectAndCallbackResult(cb, new Herder.Created<>(true, new ConnectorInfo(CONNECTOR_NAME, CONNECTOR_CONFIG, CONNECTOR_TASK_NAMES)));
PowerMock.replayAll();
connectorsResource.createConnector(FORWARD, body);
PowerMock.verifyAll();
}
use of org.apache.kafka.connect.util.Callback in project kafka by apache.
the class ConnectorsResourceTest method testDeleteConnectorNotFound.
// Not found exceptions should pass through to caller so they can be processed for 404s
@Test(expected = NotFoundException.class)
public void testDeleteConnectorNotFound() throws Throwable {
final Capture<Callback<Herder.Created<ConnectorInfo>>> cb = Capture.newInstance();
herder.deleteConnectorConfig(EasyMock.eq(CONNECTOR_NAME), EasyMock.capture(cb));
expectAndCallbackException(cb, new NotFoundException("not found"));
PowerMock.replayAll();
connectorsResource.destroyConnector(CONNECTOR_NAME, FORWARD);
PowerMock.verifyAll();
}
use of org.apache.kafka.connect.util.Callback in project kafka by apache.
the class ConnectorsResourceTest method testRestartTaskOwnerRedirect.
@Test
public void testRestartTaskOwnerRedirect() throws Throwable {
ConnectorTaskId taskId = new ConnectorTaskId(CONNECTOR_NAME, 0);
final Capture<Callback<Void>> cb = Capture.newInstance();
herder.restartTask(EasyMock.eq(taskId), EasyMock.capture(cb));
String ownerUrl = "http://owner:8083";
expectAndCallbackException(cb, new NotAssignedException("not owner test", ownerUrl));
EasyMock.expect(RestServer.httpRequest(EasyMock.eq("http://owner:8083/connectors/" + CONNECTOR_NAME + "/tasks/0/restart?forward=false"), EasyMock.eq("POST"), EasyMock.isNull(), EasyMock.<TypeReference>anyObject())).andReturn(new RestServer.HttpResponse<>(202, new HashMap<String, List<String>>(), null));
PowerMock.replayAll();
connectorsResource.restartTask(CONNECTOR_NAME, 0, true);
PowerMock.verifyAll();
}
use of org.apache.kafka.connect.util.Callback in project kafka by apache.
the class ConnectorsResourceTest method testCreateConnectorExists.
@Test(expected = AlreadyExistsException.class)
public void testCreateConnectorExists() throws Throwable {
CreateConnectorRequest body = new CreateConnectorRequest(CONNECTOR_NAME, Collections.singletonMap(ConnectorConfig.NAME_CONFIG, CONNECTOR_NAME));
final Capture<Callback<Herder.Created<ConnectorInfo>>> cb = Capture.newInstance();
herder.putConnectorConfig(EasyMock.eq(CONNECTOR_NAME), EasyMock.eq(body.config()), EasyMock.eq(false), EasyMock.capture(cb));
expectAndCallbackException(cb, new AlreadyExistsException("already exists"));
PowerMock.replayAll();
connectorsResource.createConnector(FORWARD, body);
PowerMock.verifyAll();
}
use of org.apache.kafka.connect.util.Callback in project kafka by apache.
the class ConnectorsResourceTest method testGetConnector.
@Test
public void testGetConnector() throws Throwable {
final Capture<Callback<ConnectorInfo>> cb = Capture.newInstance();
herder.connectorInfo(EasyMock.eq(CONNECTOR_NAME), EasyMock.capture(cb));
expectAndCallbackResult(cb, new ConnectorInfo(CONNECTOR_NAME, CONNECTOR_CONFIG, CONNECTOR_TASK_NAMES));
PowerMock.replayAll();
ConnectorInfo connInfo = connectorsResource.getConnector(CONNECTOR_NAME, FORWARD);
assertEquals(new ConnectorInfo(CONNECTOR_NAME, CONNECTOR_CONFIG, CONNECTOR_TASK_NAMES), connInfo);
PowerMock.verifyAll();
}
Aggregations