use of org.apache.ranger.audit.provider.MultiDestAuditProvider in project ranger by apache.
the class TestAuditQueue method testMultipleQueue.
@Test
public void testMultipleQueue() {
logger.debug("testAuditAsyncQueue()...");
int destCount = 3;
TestConsumer[] testConsumer = new TestConsumer[destCount];
MultiDestAuditProvider multiQueue = new MultiDestAuditProvider();
for (int i = 0; i < destCount; i++) {
testConsumer[i] = new TestConsumer();
multiQueue.addAuditProvider(testConsumer[i]);
}
AuditAsyncQueue queue = new AuditAsyncQueue(multiQueue);
Properties props = new Properties();
queue.init(props);
queue.start();
int messageToSend = 10;
for (int i = 0; i < messageToSend; i++) {
queue.log(createEvent());
}
queue.stop();
queue.waitToComplete();
// Let's wait for second
try {
Thread.sleep(1000);
} catch (InterruptedException e) {
// ignore
}
for (int i = 0; i < destCount; i++) {
assertEquals("consumer" + i, messageToSend, testConsumer[i].getCountTotal());
assertEquals("consumer" + i, messageToSend, testConsumer[i].getSumTotal());
}
}
Aggregations