use of org.apache.druid.java.util.emitter.service.UnitEvent in project druid by druid-io.
the class ParametrizedUriEmitterTest method testEmitterWithFeedUriExtractor.
@Test
public void testEmitterWithFeedUriExtractor() throws Exception {
Emitter emitter = parametrizedEmmiter("http://example.com/{feed}");
final List<UnitEvent> events = Arrays.asList(new UnitEvent("test", 1), new UnitEvent("test", 2));
httpClient.setGoHandler(new GoHandler() {
@Override
public ListenableFuture<Response> go(Request request) throws JsonProcessingException {
Assert.assertEquals("http://example.com/test", request.getUrl());
Assert.assertEquals(StringUtils.format("[%s,%s]\n", JSON_MAPPER.writeValueAsString(events.get(0)), JSON_MAPPER.writeValueAsString(events.get(1))), StandardCharsets.UTF_8.decode(request.getByteBufferData().slice()).toString());
return GoHandlers.immediateFuture(EmitterTest.okResponse());
}
}.times(1));
for (UnitEvent event : events) {
emitter.emit(event);
}
emitter.flush();
Assert.assertTrue(httpClient.succeeded());
}
use of org.apache.druid.java.util.emitter.service.UnitEvent in project druid by druid-io.
the class ParametrizedUriEmitterTest method testEmitterWithParametrizedUriExtractor.
@Test
public void testEmitterWithParametrizedUriExtractor() throws Exception {
Emitter emitter = parametrizedEmmiter("http://example.com/{key1}/{key2}");
final List<UnitEvent> events = Arrays.asList(new UnitEvent("test", 1, ImmutableMap.of("key1", "val1", "key2", "val2")), new UnitEvent("test", 2, ImmutableMap.of("key1", "val1", "key2", "val2")));
httpClient.setGoHandler(new GoHandler() {
@Override
protected ListenableFuture<Response> go(Request request) throws JsonProcessingException {
Assert.assertEquals("http://example.com/val1/val2", request.getUrl());
Assert.assertEquals(StringUtils.format("[%s,%s]\n", JSON_MAPPER.writeValueAsString(events.get(0)), JSON_MAPPER.writeValueAsString(events.get(1))), StandardCharsets.UTF_8.decode(request.getByteBufferData().slice()).toString());
return GoHandlers.immediateFuture(EmitterTest.okResponse());
}
}.times(1));
for (UnitEvent event : events) {
emitter.emit(event);
}
emitter.flush();
Assert.assertTrue(httpClient.succeeded());
}
Aggregations