SinkManager sinkManager = startSinkMakager(injector);
startMessageRouter(injector);
MessageSetProcessor queue = injector.getInstance(MessageSetProcessor.class);
queue.setInput(mock(SuroInput.class));
queue.start();
MessageSetBuilder builder = new MessageSetBuilder(new ClientConfig());
for (int i = 0; i < 10; ++i) {
builder.withMessage("topic1", Integer.toString(i).getBytes());
}
// sink1: 10
// default: 10
queue.process(builder.build());
for (int i = 0; i < 5; ++i) {
builder.withMessage("topic2", Integer.toString(i).getBytes());
}
// sink1: 5
queue.process(builder.build());
for (int i = 0; i < 15; ++i) {
builder.withMessage("topic3", Integer.toString(i).getBytes());
}
queue.process(builder.build());
// sink3: 15 with topic3_alias
for (int i = 0; i < 20; ++i) {
builder.withMessage("topic4", Integer.toString(i).getBytes());
}
// default: 20
queue.process(builder.build());
// total sink1: 15, default: 30
int count = 10;
while (!answer() && count > 0) {
Thread.sleep(1000);
--count;
}
assertTrue(count > 0);
queue.shutdown();
sinkManager.shutdown();
}