Properties p = new Properties();
p.put(WorkloadManager.ZK_SERVER_LIST, "localhost:8888");
SimpleMessageHandler sh = new SimpleMessageHandler();
WorkloadManager m = new WorkloadManager(p);
m.init();
producer.send(new ProducerData<Integer, String>(topic, "1"));
producer.send(new ProducerData<Integer, String>(topic, "2"));
producer.send(new ProducerData<Integer, String>(topic, "3"));
m.applyWorkload(w);
try {
Thread.sleep(6000);
} catch (InterruptedException ex) {
}
Assert.assertEquals(1, m.getWorkerThreads().size());
Assert.assertEquals(3,sh.messageCount.get());
w.active = false;
m.applyWorkload(w);
try {
Thread.sleep(3000);
} catch (InterruptedException ex) {
}
Assert.assertEquals(0, m.getWorkerThreads().size());
m.deleteWorkload(w);
try {
Thread.sleep(3000);
} catch (InterruptedException ex) {
}
producer.send(new ProducerData<Integer, String>(topic, "4"));
producer.send(new ProducerData<Integer, String>(topic, "5"));
producer.send(new ProducerData<Integer, String>(topic, "6"));
try {
Thread.sleep(1000);
} catch (InterruptedException ex) { }
Assert.assertEquals(0, m.getWorkerThreads().size());
w.active=true;
m.applyWorkload(w);
producer.send(new ProducerData<Integer, String>(topic, "7"));
producer.send(new ProducerData<Integer, String>(topic, "8"));
producer.send(new ProducerData<Integer, String>(topic, "9"));
try {
Thread.sleep(3000);
} catch (InterruptedException ex) { }
Assert.assertEquals(9,sh.messageCount.get());
m.shutdown();
}