RandomJmsQueueRecordWriter implements RecordWriter<P> { @Override public void writeRecords(Batch<P> batch) throws Exception { for (Record<P> record : batch) { QueueSender queue = queues.get(random.nextInt(queuesNumber)); queue.send((Message) record.getPayload()); } } RandomJmsQueueRecordWriter(List<QueueSender> queues); @Override void writeRecords(Batch<P> batch);  }
@Test public void recordsShouldBeWrittenRandomlyToOneOfTheQueues() throws Exception { randomJmsQueueRecordWriter.writeRecords(new Batch(record)); verify(queue1, atMost(1)).send(message); verify(queue2, atMost(1)).send(message); }