Program: 104325
Project: 104325
Buggy source:
/** 
 * We try to register with wrong uin which must fire event with status AUTHENTICATION_FAILED. As the uin is new (not existing and not registered) we first install this account, then try to register and wait for the supposed event. After all we unregister this account
 * @throws OperationFailedException if register () fails for a provider.
 */
public void testRegisterWrongUsername() 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);
  uin=uin + "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"+ uin+ "String_Node_Str"+ "String_Node_Str");
  }
 catch (  InvalidSyntaxException ex) {
    logger.debug("String_Node_Str",ex);
  }
  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" + "String_Node_Str",regFailedEvtCollector.failedCode,RegistrationStateChangeEvent.REASON_NON_EXISTING_USER_ID);
  assertNotNull("String_Node_Str",regFailedEvtCollector.failedReason);
  provider.removeRegistrationStateChangeListener(regFailedEvtCollector);
  icqProviderFactory.uninstallAccount(icqAccountID);
}

Fixed version (ground truth):
/** 
 * We try to register with wrong uin which must fire event with status AUTHENTICATION_FAILED. As the uin is new (not existing and not registered) we first install this account, then try to register and wait for the supposed event. After all we unregister this account
 * @throws OperationFailedException if register () fails for a provider.
 */
public void testRegisterWrongUsername() 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);
  uin=uin + "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"+ uin+ "String_Node_Str"+ "String_Node_Str");
  }
 catch (  InvalidSyntaxException ex) {
    logger.debug("String_Node_Str",ex);
  }
  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" + "String_Node_Str",regFailedEvtCollector.failedCode,RegistrationStateChangeEvent.REASON_NON_EXISTING_USER_ID);
  assertNotNull("String_Node_Str",regFailedEvtCollector.failedReason);
  provider.removeRegistrationStateChangeListener(regFailedEvtCollector);
  icqProviderFactory.uninstallAccount(icqAccountID);
}