Program: 104326
Project: 104326
Buggy source:
/** 
 * Will try to register with wrong password and wait for triggered event with status AUTHENTICATION_FAILED. We get the already installed account. Change the password and try to register. After all tests we must return the original password so we don't break the other tests
 * @throws OperationFailedException if register fails for a provider.
 */
public void testRegisterWrongPassword() throws OperationFailedException {
  ServiceReference[] serRefs=null;
  String osgiFilter="String_Node_Str" + ProtocolProviderFactory.PROTOCOL + "String_Node_Str"+ ProtocolNames.ICQ+ "String_Node_Str";
  try {
    serRefs=IcqSlickFixture.bc.getServiceReferences(ProtocolProviderFactory.class.getName(),osgiFilter);
  }
 catch (  InvalidSyntaxException ex) {
    fail(osgiFilter + "String_Node_Str");
  }
  assertTrue("String_Node_Str",serRefs != null || serRefs.length > 0);
  ProtocolProviderFactory icqProviderFactory=(ProtocolProviderFactory)IcqSlickFixture.bc.getService(serRefs[0]);
  String passwd=System.getProperty(IcqProtocolProviderSlick.TESTED_IMPL_PWD_PROP_NAME,null);
  String uin=System.getProperty(IcqProtocolProviderSlick.TESTED_IMPL_USER_ID_PROP_NAME,null);
  passwd="String_Node_Str";
  Hashtable icqAccountProperties=new Hashtable();
  icqAccountProperties.put(ProtocolProviderFactory.PASSWORD,passwd);
  AccountID icqAccountID=icqProviderFactory.installAccount(uin,icqAccountProperties);
  ServiceReference[] icqProviderRefs=null;
  try {
    icqProviderRefs=IcqSlickFixture.bc.getServiceReferences(ProtocolProviderService.class.getName(),"String_Node_Str" + "String_Node_Str" + ProtocolProviderFactory.PROTOCOL + "String_Node_Str"+ ProtocolNames.ICQ+ "String_Node_Str"+ "String_Node_Str"+ ProtocolProviderFactory.USER_ID+ "String_Node_Str"+ icqAccountID.getUserID()+ "String_Node_Str"+ "String_Node_Str");
  }
 catch (  InvalidSyntaxException ex1) {
    logger.error("String_Node_Str",ex1);
  }
  assertNotNull("String_Node_Str" + icqAccountID,icqProviderRefs);
  assertTrue("String_Node_Str" + icqAccountID,icqProviderRefs.length > 0);
  ServiceReference icqServiceRef=icqProviderRefs[0];
  ProtocolProviderService provider=(ProtocolProviderService)IcqSlickFixture.bc.getService(icqServiceRef);
  RegistrationFailedEventCollector regFailedEvtCollector=new RegistrationFailedEventCollector();
  logger.debug("String_Node_Str" + regFailedEvtCollector);
  provider.addRegistrationStateChangeListener(regFailedEvtCollector);
  provider.register(new SecurityAuthorityImpl(passwd.toCharArray()));
  try {
synchronized (registrationLock) {
      logger.debug("String_Node_Str");
      registrationLock.wait(40000);
      logger.debug("String_Node_Str");
    }
  }
 catch (  InterruptedException ex) {
    logger.debug("String_Node_Str",ex);
  }
catch (  Throwable t) {
    logger.debug("String_Node_Str",t);
  }
  assertTrue("String_Node_Str" + "String_Node_Str" + regFailedEvtCollector.collectedNewStates,regFailedEvtCollector.collectedNewStates.contains(RegistrationState.AUTHENTICATION_FAILED));
  assertEquals("String_Node_Str",regFailedEvtCollector.failedCode,RegistrationStateChangeEvent.REASON_AUTHENTICATION_FAILED);
  assertNotNull("String_Node_Str",regFailedEvtCollector.failedReason);
  provider.removeRegistrationStateChangeListener(regFailedEvtCollector);
  icqProviderFactory.uninstallAccount(icqAccountID);
}

Fixed version (ground truth):
/** 
 * Will try to register with wrong password and wait for triggered event with status AUTHENTICATION_FAILED. We get the already installed account. Change the password and try to register. After all tests we must return the original password so we don't break the other tests
 * @throws OperationFailedException if register fails for a provider.
 */
public void testRegisterWrongPassword() throws OperationFailedException {
  ServiceReference[] serRefs=null;
  String osgiFilter="String_Node_Str" + ProtocolProviderFactory.PROTOCOL + "String_Node_Str"+ ProtocolNames.ICQ+ "String_Node_Str";
  try {
    serRefs=IcqSlickFixture.bc.getServiceReferences(ProtocolProviderFactory.class.getName(),osgiFilter);
  }
 catch (  InvalidSyntaxException ex) {
    fail(osgiFilter + "String_Node_Str");
  }
  assertTrue("String_Node_Str",(serRefs != null) && (serRefs.length > 0));
  ProtocolProviderFactory icqProviderFactory=(ProtocolProviderFactory)IcqSlickFixture.bc.getService(serRefs[0]);
  String passwd=System.getProperty(IcqProtocolProviderSlick.TESTED_IMPL_PWD_PROP_NAME,null);
  String uin=System.getProperty(IcqProtocolProviderSlick.TESTED_IMPL_USER_ID_PROP_NAME,null);
  passwd="String_Node_Str";
  Hashtable icqAccountProperties=new Hashtable();
  icqAccountProperties.put(ProtocolProviderFactory.PASSWORD,passwd);
  AccountID icqAccountID=icqProviderFactory.installAccount(uin,icqAccountProperties);
  ServiceReference[] icqProviderRefs=null;
  try {
    icqProviderRefs=IcqSlickFixture.bc.getServiceReferences(ProtocolProviderService.class.getName(),"String_Node_Str" + "String_Node_Str" + ProtocolProviderFactory.PROTOCOL + "String_Node_Str"+ ProtocolNames.ICQ+ "String_Node_Str"+ "String_Node_Str"+ ProtocolProviderFactory.USER_ID+ "String_Node_Str"+ icqAccountID.getUserID()+ "String_Node_Str"+ "String_Node_Str");
  }
 catch (  InvalidSyntaxException ex1) {
    logger.error("String_Node_Str",ex1);
  }
  assertNotNull("String_Node_Str" + icqAccountID,icqProviderRefs);
  assertTrue("String_Node_Str" + icqAccountID,icqProviderRefs.length > 0);
  ServiceReference icqServiceRef=icqProviderRefs[0];
  ProtocolProviderService provider=(ProtocolProviderService)IcqSlickFixture.bc.getService(icqServiceRef);
  RegistrationFailedEventCollector regFailedEvtCollector=new RegistrationFailedEventCollector();
  logger.debug("String_Node_Str" + regFailedEvtCollector);
  provider.addRegistrationStateChangeListener(regFailedEvtCollector);
  provider.register(new SecurityAuthorityImpl(passwd.toCharArray()));
  try {
synchronized (registrationLock) {
      logger.debug("String_Node_Str");
      registrationLock.wait(40000);
      logger.debug("String_Node_Str");
    }
  }
 catch (  InterruptedException ex) {
    logger.debug("String_Node_Str",ex);
  }
catch (  Throwable t) {
    logger.debug("String_Node_Str",t);
  }
  assertTrue("String_Node_Str" + "String_Node_Str" + regFailedEvtCollector.collectedNewStates,regFailedEvtCollector.collectedNewStates.contains(RegistrationState.AUTHENTICATION_FAILED));
  assertEquals("String_Node_Str",regFailedEvtCollector.failedCode,RegistrationStateChangeEvent.REASON_AUTHENTICATION_FAILED);
  assertNotNull("String_Node_Str",regFailedEvtCollector.failedReason);
  provider.removeRegistrationStateChangeListener(regFailedEvtCollector);
  icqProviderFactory.uninstallAccount(icqAccountID);
}