Search in sources :

Example 1 with WorkerConfig

use of org.apache.kafka.connect.runtime.WorkerConfig in project kafka by apache.

the class RestServerTest method checkCORSRequest.

public void checkCORSRequest(String corsDomain, String origin, String expectedHeader, String method) {
    // To be able to set the Origin, we need to toggle this flag
    System.setProperty("sun.net.http.allowRestrictedHeaders", "true");
    final Capture<Callback<Collection<String>>> connectorsCallback = EasyMock.newCapture();
    herder.connectors(EasyMock.capture(connectorsCallback));
    PowerMock.expectLastCall().andAnswer(new IAnswer<Object>() {

        @Override
        public Object answer() throws Throwable {
            connectorsCallback.getValue().onCompletion(null, Arrays.asList("a", "b"));
            return null;
        }
    });
    PowerMock.replayAll();
    Map<String, String> workerProps = baseWorkerProps();
    workerProps.put(WorkerConfig.ACCESS_CONTROL_ALLOW_ORIGIN_CONFIG, corsDomain);
    workerProps.put(WorkerConfig.ACCESS_CONTROL_ALLOW_METHODS_CONFIG, method);
    WorkerConfig workerConfig = new StandaloneConfig(workerProps);
    server = new RestServer(workerConfig);
    server.start(herder);
    Response response = request("/connectors").header("Referer", origin + "/page").header("Origin", origin).get();
    assertEquals(200, response.getStatus());
    assertEquals(expectedHeader, response.getHeaderString("Access-Control-Allow-Origin"));
    response = request("/connector-plugins/FileStreamSource/validate").header("Referer", origin + "/page").header("Origin", origin).header("Access-Control-Request-Method", method).options();
    assertEquals(404, response.getStatus());
    assertEquals(expectedHeader, response.getHeaderString("Access-Control-Allow-Origin"));
    assertEquals(method, response.getHeaderString("Access-Control-Allow-Methods"));
    PowerMock.verifyAll();
}
Also used : Response(javax.ws.rs.core.Response) Callback(org.apache.kafka.connect.util.Callback) WorkerConfig(org.apache.kafka.connect.runtime.WorkerConfig) StandaloneConfig(org.apache.kafka.connect.runtime.standalone.StandaloneConfig)

Example 2 with WorkerConfig

use of org.apache.kafka.connect.runtime.WorkerConfig in project ignite by apache.

the class IgniteSourceConnectorTest method beforeTest.

/** {@inheritDoc} */
@Override
protected void beforeTest() throws Exception {
    kafkaBroker = new TestKafkaBroker();
    WorkerConfig workerCfg = new StandaloneConfig(makeWorkerProps());
    MemoryOffsetBackingStore offBackingStore = new MemoryOffsetBackingStore();
    offBackingStore.configure(workerCfg);
    worker = new Worker(WORKER_ID, new SystemTime(), workerCfg, offBackingStore);
    worker.start();
    herder = new StandaloneHerder(worker);
    herder.start();
}
Also used : StandaloneHerder(org.apache.kafka.connect.runtime.standalone.StandaloneHerder) WorkerConfig(org.apache.kafka.connect.runtime.WorkerConfig) Worker(org.apache.kafka.connect.runtime.Worker) TestKafkaBroker(org.apache.ignite.stream.kafka.TestKafkaBroker) StandaloneConfig(org.apache.kafka.connect.runtime.standalone.StandaloneConfig) MemoryOffsetBackingStore(org.apache.kafka.connect.storage.MemoryOffsetBackingStore) SystemTime(org.apache.kafka.common.utils.SystemTime)

Example 3 with WorkerConfig

use of org.apache.kafka.connect.runtime.WorkerConfig in project ignite by apache.

the class IgniteSinkConnectorTest method beforeTest.

/** {@inheritDoc} */
@SuppressWarnings("unchecked")
@Override
protected void beforeTest() throws Exception {
    kafkaBroker = new TestKafkaBroker();
    for (String topic : TOPICS) kafkaBroker.createTopic(topic, PARTITIONS, REPLICATION_FACTOR);
    WorkerConfig workerCfg = new StandaloneConfig(makeWorkerProps());
    OffsetBackingStore offBackingStore = mock(OffsetBackingStore.class);
    offBackingStore.configure(workerCfg);
    worker = new Worker(WORKER_ID, new SystemTime(), workerCfg, offBackingStore);
    worker.start();
    herder = new StandaloneHerder(worker);
    herder.start();
}
Also used : OffsetBackingStore(org.apache.kafka.connect.storage.OffsetBackingStore) StandaloneHerder(org.apache.kafka.connect.runtime.standalone.StandaloneHerder) WorkerConfig(org.apache.kafka.connect.runtime.WorkerConfig) Worker(org.apache.kafka.connect.runtime.Worker) TestKafkaBroker(org.apache.ignite.stream.kafka.TestKafkaBroker) StandaloneConfig(org.apache.kafka.connect.runtime.standalone.StandaloneConfig) SystemTime(org.apache.kafka.common.utils.SystemTime)

Aggregations

WorkerConfig (org.apache.kafka.connect.runtime.WorkerConfig)3 StandaloneConfig (org.apache.kafka.connect.runtime.standalone.StandaloneConfig)3 TestKafkaBroker (org.apache.ignite.stream.kafka.TestKafkaBroker)2 SystemTime (org.apache.kafka.common.utils.SystemTime)2 Worker (org.apache.kafka.connect.runtime.Worker)2 StandaloneHerder (org.apache.kafka.connect.runtime.standalone.StandaloneHerder)2 Response (javax.ws.rs.core.Response)1 MemoryOffsetBackingStore (org.apache.kafka.connect.storage.MemoryOffsetBackingStore)1 OffsetBackingStore (org.apache.kafka.connect.storage.OffsetBackingStore)1 Callback (org.apache.kafka.connect.util.Callback)1