Search in sources :

Example 1 with NotLeaderException

use of org.apache.kafka.connect.runtime.distributed.NotLeaderException in project kafka by apache.

the class ConnectorsResourceTest method testCompleteOrForwardWithErrorAndNoForwardUrl.

@Test
public void testCompleteOrForwardWithErrorAndNoForwardUrl() {
    final Capture<Callback<Herder.Created<ConnectorInfo>>> cb = Capture.newInstance();
    herder.deleteConnectorConfig(EasyMock.eq(CONNECTOR_NAME), EasyMock.capture(cb));
    String leaderUrl = null;
    expectAndCallbackException(cb, new NotLeaderException("not leader", leaderUrl));
    PowerMock.replayAll();
    ConnectRestException e = assertThrows(ConnectRestException.class, () -> connectorsResource.destroyConnector(CONNECTOR_NAME, NULL_HEADERS, FORWARD));
    assertTrue(e.getMessage().contains("no known leader URL"));
    PowerMock.verifyAll();
}
Also used : ConnectRestException(org.apache.kafka.connect.runtime.rest.errors.ConnectRestException) NotLeaderException(org.apache.kafka.connect.runtime.distributed.NotLeaderException) Callback(org.apache.kafka.connect.util.Callback) ConnectorInfo(org.apache.kafka.connect.runtime.rest.entities.ConnectorInfo) Herder(org.apache.kafka.connect.runtime.Herder) PrepareForTest(org.powermock.core.classloader.annotations.PrepareForTest) Test(org.junit.Test)

Aggregations

Herder (org.apache.kafka.connect.runtime.Herder)1 NotLeaderException (org.apache.kafka.connect.runtime.distributed.NotLeaderException)1 ConnectorInfo (org.apache.kafka.connect.runtime.rest.entities.ConnectorInfo)1 ConnectRestException (org.apache.kafka.connect.runtime.rest.errors.ConnectRestException)1 Callback (org.apache.kafka.connect.util.Callback)1 Test (org.junit.Test)1 PrepareForTest (org.powermock.core.classloader.annotations.PrepareForTest)1