@Test
public void testRandomNoFailure() throws Exception {

  Channel ch = new MockChannel();
  int n = 10000;
  int numEvents = n;
  for (int i = 0; i < numEvents; i++) {
    ch.put(new MockEvent("test" + i));
  }
  MockSink s1 = new MockSink(1);
  s1.setChannel(ch);
  MockSink s2 = new MockSink(2);
  s2.setChannel(ch);
  MockSink s3 = new MockSink(3);
  s3.setChannel(ch);
  MockSink s4 = new MockSink(4);
  s4.setChannel(ch);
  MockSink s5 = new MockSink(5);
  s5.setChannel(ch);
  MockSink s6 = new MockSink(6);
  s6.setChannel(ch);
  MockSink s7 = new MockSink(7);
  s7.setChannel(ch);
  MockSink s8 = new MockSink(8);
  s8.setChannel(ch);
  MockSink s9 = new MockSink(9);
  s9.setChannel(ch);
  MockSink s0 = new MockSink(0);
  s0.setChannel(ch);
  List<Sink> sinks = new ArrayList<Sink>();
  sinks.add(s1);
  sinks.add(s2);
  sinks.add(s3);
  sinks.add(s4);
  sinks.add(s5);
  sinks.add(s6);
  sinks.add(s7);
  sinks.add(s8);
  sinks.add(s9);
  sinks.add(s0);
  LoadBalancingSinkProcessor lbsp = getProcessor("random",sinks, false);
  Status s = Status.READY;
  while (s != Status.BACKOFF) {
    s = lbsp.process();
  }
  Set<Integer> sizeSet = new HashSet<Integer>();
  int sum = 0;
  for (Sink ms : sinks) {
    int count = ((MockSink) ms).getEvents().size();
    sum += count;
    sizeSet.add(count);
  }
  // Assert that all the events were accounted for
  Assert.assertEquals(n, sum);
  // Assert that at least two sinks came with different event sizes.
  // This makes sense if the total number of events is evenly divisible by
  // the total number of sinks. In which case the round-robin policy will
  // end up causing all sinks to get the same number of events where as
  // the random policy will have very low probability of doing that.
  Assert.assertTrue("Miraculous distribution", sizeSet.size() > 1);
}