Program: 3860
Project: 3860
Buggy source:
/** 
 * Tests the edge functionality of the can resolve case.  First resolve but with a  non connectable address.  Next force fire an IOE event to the then non relevant resolve handler and make sure things are handled accordingly. <p> Tests tryToResolveAndBrowse() and handleFailedResolution().
 */
public void testBrowseWhenCanResolveButCantConnectPlusIOE(){
  final Mockery context=new Mockery(){
{
      setImposteriser(ClassImposteriser.INSTANCE);
    }
  }
;
  final SocketsManager socketsManager=context.mock(SocketsManager.class);
  final PresenceLibrary presenceLibrary=context.mock(PresenceLibrary.class);
  final Address resolvedAddress=context.mock(Address.class);
  final PresenceLibraryBrowser presenceLibraryBrowser=new PresenceLibraryBrowser(null,null,socketsManager,null);
  final MatchAndCopy<AddressResolutionObserver> observerCollector=new MatchAndCopy<AddressResolutionObserver>(AddressResolutionObserver.class);
  context.checking(new Expectations(){
{
      FriendPresence presence=context.mock(FriendPresence.class);
      allowing(presenceLibrary).getPresence();
      will(returnValue(presence));
      allowing(presence).hasFeatures(AddressFeature.ID);
      will(returnValue(false));
      AddressFeature addressFeature=context.mock(AddressFeature.class);
      allowing(presence).getFeature(AddressFeature.ID);
      will(returnValue(addressFeature));
      Address address=context.mock(Address.class);
      allowing(addressFeature).getFeature();
      will(returnValue(address));
      allowing(socketsManager).canResolve(address);
      will(returnValue(true));
      allowing(socketsManager).canConnect(resolvedAddress);
      will(returnValue(false));
      allowing(presenceLibrary);
      allowing(presence);
      exactly(1).of(socketsManager).resolve(with(same(address)),with(observerCollector));
    }
  }
);
  presenceLibraryBrowser.tryToResolveAndBrowse(presenceLibrary,0);
  observerCollector.getLastMatch().resolved(resolvedAddress);
  assertContains(presenceLibraryBrowser.librariesToBrowse,presenceLibrary);
  observerCollector.getLastMatch().handleIOException(new IOException("String_Node_Str"));
  assertContains(presenceLibraryBrowser.librariesToBrowse,presenceLibrary);
  observerCollector.getLastMatch().shutdown();
  context.assertIsSatisfied();
}

Fixed version (ground truth):
/** 
 * Tests the edge functionality of the can resolve case.  First resolve but with a  non connectable address.  Next force fire an IOE event to the then non relevant resolve handler and make sure things are handled accordingly. <p> Tests tryToResolveAndBrowse() and handleFailedResolution().
 */
public void testBrowseWhenCanResolveButCantConnectPlusIOE(){
  final Mockery context=new Mockery(){
{
      setImposteriser(ClassImposteriser.INSTANCE);
    }
  }
;
  final SocketsManager socketsManager=context.mock(SocketsManager.class);
  final PresenceLibrary presenceLibrary=context.mock(PresenceLibrary.class);
  final Address resolvedAddress=context.mock(Address.class);
  final PresenceLibraryBrowser presenceLibraryBrowser=new PresenceLibraryBrowser(null,null,socketsManager,null);
  final MatchAndCopy<AddressResolutionObserver> observerCollector=new MatchAndCopy<AddressResolutionObserver>(AddressResolutionObserver.class);
  context.checking(new Expectations(){
{
      FriendPresence presence=context.mock(FriendPresence.class);
      allowing(presenceLibrary).getPresence();
      will(returnValue(presence));
      allowing(presence).hasFeatures(AddressFeature.ID);
      will(returnValue(false));
      AddressFeature addressFeature=context.mock(AddressFeature.class);
      allowing(presence).getFeature(AddressFeature.ID);
      will(returnValue(addressFeature));
      Address address=context.mock(Address.class);
      allowing(addressFeature).getFeature();
      will(returnValue(address));
      allowing(socketsManager).canResolve(address);
      will(returnValue(true));
      allowing(socketsManager).canConnect(resolvedAddress);
      will(returnValue(false));
      allowing(presenceLibrary);
      allowing(presence);
      exactly(1).of(socketsManager).resolve(with(same(address)),with(observerCollector));
    }
  }
);
  presenceLibraryBrowser.tryToResolveAndBrowse(presenceLibrary,0);
  observerCollector.getLastMatch().resolved(resolvedAddress);
  assertContains(presenceLibraryBrowser.librariesToBrowse,presenceLibrary);
  presenceLibraryBrowser.librariesToBrowse.remove(presenceLibrary);
  observerCollector.getLastMatch().handleIOException(new IOException("String_Node_Str"));
  assertContains(presenceLibraryBrowser.librariesToBrowse,presenceLibrary);
  observerCollector.getLastMatch().shutdown();
  context.assertIsSatisfied();
}