Program: 104408
Project: 104408
Buggy source:
/** 
 * The method would add a subscription for a contact, wait for a subscription event confirming the subscription, then change the status of the newly added contact (which is actually the testerAgent) and make sure that the corresponding notification events have been generated.
 * @throws java.lang.Exception if an exception occurs during testing.
 */
public void postTestSubscribe() throws Exception {
  logger.debug("String_Node_Str");
  SubscriptionEventCollector subEvtCollector=new SubscriptionEventCollector();
  this.operationSetPresence1.addSubsciptionListener(subEvtCollector);
synchronized (subEvtCollector) {
    this.operationSetPresence1.subscribe(this.fixture.userID2);
    subEvtCollector.waitForEvent(10000);
  }
  assertEquals("String_Node_Str",1,subEvtCollector.collectedEvents.size());
  SubscriptionEvent subEvt=(SubscriptionEvent)subEvtCollector.collectedEvents.get(0);
  assertEquals("String_Node_Str",this.fixture.userID2,((Contact)subEvt.getSource()).getAddress());
  assertEquals("String_Node_Str",this.fixture.userID2,subEvt.getSourceContact().getAddress());
  assertSame("String_Node_Str",this.fixture.provider1,subEvt.getSourceProvider());
  subEvtCollector.collectedEvents.clear();
synchronized (subEvtCollector) {
    subEvtCollector.waitForEvent(10000);
    this.operationSetPresence1.removeSubscriptionListener(subEvtCollector);
  }
  subEvtCollector.collectedEvents.clear();
  logger.debug("String_Node_Str");
  PresenceStatus oldStatus=this.operationSetPresence2.getPresenceStatus();
  PresenceStatus newStatus=getSampleStatus1();
  if (oldStatus.equals(newStatus)) {
    newStatus=getSampleStatus2();
  }
  logger.debug("String_Node_Str" + newStatus + "String_Node_Str");
  ContactPresenceEventCollector contactPresEvtCollector=new ContactPresenceEventCollector(this.fixture.userID2,newStatus);
  this.operationSetPresence1.addContactPresenceStatusListener(contactPresEvtCollector);
synchronized (contactPresEvtCollector) {
    this.operationSetPresence2.publishPresenceStatus(newStatus,"String_Node_Str");
    contactPresEvtCollector.waitForEvent(10000);
    this.operationSetPresence1.removeContactPresenceStatusListener(contactPresEvtCollector);
  }
  assertEquals("String_Node_Str",1,contactPresEvtCollector.collectedEvents.size());
  ContactPresenceStatusChangeEvent presEvt=(ContactPresenceStatusChangeEvent)contactPresEvtCollector.collectedEvents.get(0);
  assertEquals("String_Node_Str",this.fixture.userID2,((Contact)presEvt.getSource()).getAddress());
  assertEquals("String_Node_Str",this.fixture.userID2,presEvt.getSourceContact().getAddress());
  assertSame("String_Node_Str",this.fixture.provider1,presEvt.getSourceProvider());
  PresenceStatus reportedNewStatus=presEvt.getNewStatus();
  PresenceStatus reportedOldStatus=presEvt.getOldStatus();
  assertEquals("String_Node_Str",newStatus,reportedNewStatus);
  assertNotNull("String_Node_Str",reportedOldStatus);
  try {
    subEvtCollector.collectedEvents.clear();
    this.operationSetPresence2.addSubsciptionListener(subEvtCollector);
synchronized (subEvtCollector) {
      this.operationSetPresence2.subscribe(this.fixture.userID1);
      subEvtCollector.waitForEvent(10000);
      subEvtCollector.collectedEvents.clear();
      subEvtCollector.waitForEvent(10000);
      this.operationSetPresence2.removeSubscriptionListener(subEvtCollector);
    }
  }
 catch (  OperationFailedException ex) {
  }
  Object lock=new Object();
synchronized (lock) {
    logger.info("String_Node_Str" + "String_Node_Str");
    lock.wait(3000);
    logger.info("String_Node_Str");
  }
}

Fixed version (ground truth):
/** 
 * The method would add a subscription for a contact, wait for a subscription event confirming the subscription, then change the status of the newly added contact (which is actually the testerAgent) and make sure that the corresponding notification events have been generated.
 * @throws java.lang.Exception if an exception occurs during testing.
 */
public void postTestSubscribe() throws Exception {
  logger.debug("String_Node_Str");
  SubscriptionEventCollector subEvtCollector=new SubscriptionEventCollector();
  this.operationSetPresence1.addSubsciptionListener(subEvtCollector);
synchronized (subEvtCollector) {
    this.operationSetPresence1.subscribe(this.fixture.userID2);
    subEvtCollector.waitForEvent(10000);
  }
  assertEquals("String_Node_Str",1,subEvtCollector.collectedEvents.size());
  SubscriptionEvent subEvt=(SubscriptionEvent)subEvtCollector.collectedEvents.get(0);
  assertEquals("String_Node_Str",this.fixture.userID2,((Contact)subEvt.getSource()).getAddress());
  assertEquals("String_Node_Str",this.fixture.userID2,subEvt.getSourceContact().getAddress());
  assertSame("String_Node_Str",this.fixture.provider1,subEvt.getSourceProvider());
  subEvtCollector.collectedEvents.clear();
synchronized (subEvtCollector) {
    subEvtCollector.waitForEvent(10000);
    this.operationSetPresence1.removeSubscriptionListener(subEvtCollector);
  }
  subEvtCollector.collectedEvents.clear();
  Object lock=new Object();
synchronized (lock) {
    logger.info("String_Node_Str");
    lock.wait(3000);
  }
  logger.debug("String_Node_Str");
  PresenceStatus oldStatus=this.operationSetPresence2.getPresenceStatus();
  PresenceStatus newStatus=getSampleStatus1();
  if (oldStatus.equals(newStatus)) {
    newStatus=getSampleStatus2();
  }
  logger.debug("String_Node_Str" + newStatus + "String_Node_Str");
  ContactPresenceEventCollector contactPresEvtCollector=new ContactPresenceEventCollector(this.fixture.userID2,newStatus);
  this.operationSetPresence1.addContactPresenceStatusListener(contactPresEvtCollector);
synchronized (contactPresEvtCollector) {
    this.operationSetPresence2.publishPresenceStatus(newStatus,"String_Node_Str");
    contactPresEvtCollector.waitForEvent(10000);
    this.operationSetPresence1.removeContactPresenceStatusListener(contactPresEvtCollector);
  }
  assertEquals("String_Node_Str",1,contactPresEvtCollector.collectedEvents.size());
  ContactPresenceStatusChangeEvent presEvt=(ContactPresenceStatusChangeEvent)contactPresEvtCollector.collectedEvents.get(0);
  assertEquals("String_Node_Str",this.fixture.userID2,((Contact)presEvt.getSource()).getAddress());
  assertEquals("String_Node_Str",this.fixture.userID2,presEvt.getSourceContact().getAddress());
  assertSame("String_Node_Str",this.fixture.provider1,presEvt.getSourceProvider());
  PresenceStatus reportedNewStatus=presEvt.getNewStatus();
  PresenceStatus reportedOldStatus=presEvt.getOldStatus();
  assertEquals("String_Node_Str",newStatus,reportedNewStatus);
  assertNotNull("String_Node_Str",reportedOldStatus);
  try {
    subEvtCollector.collectedEvents.clear();
    this.operationSetPresence2.addSubsciptionListener(subEvtCollector);
synchronized (subEvtCollector) {
      this.operationSetPresence2.subscribe(this.fixture.userID1);
      subEvtCollector.waitForEvent(10000);
      subEvtCollector.collectedEvents.clear();
      subEvtCollector.waitForEvent(10000);
      this.operationSetPresence2.removeSubscriptionListener(subEvtCollector);
    }
  }
 catch (  OperationFailedException ex) {
  }
synchronized (lock) {
    logger.info("String_Node_Str" + "String_Node_Str");
    lock.wait(3000);
    logger.info("String_Node_Str");
  }
}