Program: 166390
Project: 166390
Buggy source:
@Test public void testAuditBatchQueueDestDownFlipFlop(){
  logger.debug("String_Node_Str");
  int messageToSend=10;
  String basePropName="String_Node_Str" + MiscUtil.generateUniqueId();
  int batchSize=messageToSend / 3;
  int queueSize=messageToSend * 2;
  int intervalMS=3000;
  Properties props=new Properties();
  props.put(basePropName + "String_Node_Str" + BaseAuditHandler.PROP_NAME,"String_Node_Str" + MiscUtil.generateUniqueId());
  props.put(basePropName + "String_Node_Str" + AuditQueue.PROP_BATCH_SIZE,"String_Node_Str" + batchSize);
  props.put(basePropName + "String_Node_Str" + AuditQueue.PROP_QUEUE_SIZE,"String_Node_Str" + queueSize);
  props.put(basePropName + "String_Node_Str" + AuditQueue.PROP_BATCH_INTERVAL,"String_Node_Str" + intervalMS);
  int destRetryMS=10;
  props.put(basePropName + "String_Node_Str" + AuditQueue.PROP_FILE_SPOOL_ENABLE,"String_Node_Str" + true);
  props.put(basePropName + "String_Node_Str" + AuditFileSpool.PROP_FILE_SPOOL_LOCAL_DIR,"String_Node_Str");
  props.put(basePropName + "String_Node_Str" + AuditFileSpool.PROP_FILE_SPOOL_DEST_RETRY_MS,"String_Node_Str" + destRetryMS);
  TestConsumer testConsumer=new TestConsumer();
  testConsumer.isDown=false;
  AuditBatchQueue queue=new AuditBatchQueue(testConsumer);
  queue.init(props,basePropName);
  queue.start();
  try {
    queue.log(createEvent());
    queue.log(createEvent());
    queue.log(createEvent());
    Thread.sleep(1000);
    testConsumer.isDown=true;
    Thread.sleep(1000);
    queue.log(createEvent());
    queue.log(createEvent());
    queue.log(createEvent());
    Thread.sleep(1000);
    testConsumer.isDown=false;
    Thread.sleep(1000);
    queue.log(createEvent());
    queue.log(createEvent());
    queue.log(createEvent());
    Thread.sleep(1000);
    testConsumer.isDown=true;
    Thread.sleep(1000);
    queue.log(createEvent());
    Thread.sleep(1000);
    testConsumer.isDown=false;
    Thread.sleep(1000);
  }
 catch (  InterruptedException e) {
  }
  try {
    Thread.sleep(2000);
  }
 catch (  InterruptedException e) {
  }
  queue.waitToComplete(5000);
  queue.stop();
  queue.waitToComplete();
  assertEquals("String_Node_Str",messageToSend,testConsumer.getCountTotal());
  assertEquals("String_Node_Str",messageToSend,testConsumer.getSumTotal());
  assertNull("String_Node_Str",testConsumer.isInSequence());
}

Fixed version (ground truth):
@Test public void testAuditBatchQueueDestDownFlipFlop(){
  logger.debug("String_Node_Str");
  int messageToSend=10;
  String basePropName="String_Node_Str" + MiscUtil.generateUniqueId();
  int batchSize=messageToSend / 3;
  int queueSize=messageToSend * 2;
  int intervalMS=5000;
  Properties props=new Properties();
  props.put(basePropName + "String_Node_Str" + BaseAuditHandler.PROP_NAME,"String_Node_Str" + MiscUtil.generateUniqueId());
  props.put(basePropName + "String_Node_Str" + AuditQueue.PROP_BATCH_SIZE,"String_Node_Str" + batchSize);
  props.put(basePropName + "String_Node_Str" + AuditQueue.PROP_QUEUE_SIZE,"String_Node_Str" + queueSize);
  props.put(basePropName + "String_Node_Str" + AuditQueue.PROP_BATCH_INTERVAL,"String_Node_Str" + intervalMS);
  int destRetryMS=10;
  props.put(basePropName + "String_Node_Str" + AuditQueue.PROP_FILE_SPOOL_ENABLE,"String_Node_Str" + true);
  props.put(basePropName + "String_Node_Str" + AuditFileSpool.PROP_FILE_SPOOL_LOCAL_DIR,"String_Node_Str");
  props.put(basePropName + "String_Node_Str" + AuditFileSpool.PROP_FILE_SPOOL_DEST_RETRY_MS,"String_Node_Str" + destRetryMS);
  TestConsumer testConsumer=new TestConsumer();
  testConsumer.isDown=false;
  AuditBatchQueue queue=new AuditBatchQueue(testConsumer);
  queue.init(props,basePropName);
  queue.start();
  try {
    queue.log(createEvent());
    queue.log(createEvent());
    queue.log(createEvent());
    Thread.sleep(1000);
    testConsumer.isDown=true;
    Thread.sleep(1000);
    queue.log(createEvent());
    queue.log(createEvent());
    queue.log(createEvent());
    Thread.sleep(1000);
    testConsumer.isDown=false;
    Thread.sleep(1000);
    queue.log(createEvent());
    queue.log(createEvent());
    queue.log(createEvent());
    Thread.sleep(1000);
    testConsumer.isDown=true;
    Thread.sleep(1000);
    queue.log(createEvent());
    Thread.sleep(1000);
    testConsumer.isDown=false;
    Thread.sleep(1000);
  }
 catch (  InterruptedException e) {
  }
  try {
    Thread.sleep(2000);
  }
 catch (  InterruptedException e) {
  }
  queue.waitToComplete(5000);
  queue.stop();
  queue.waitToComplete();
  assertEquals("String_Node_Str",messageToSend,testConsumer.getCountTotal());
  assertEquals("String_Node_Str",messageToSend,testConsumer.getSumTotal());
  assertNull("String_Node_Str",testConsumer.isInSequence());
}