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();
}
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();
}
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();
}
Aggregations