Program: 160302
Project: 160302
Buggy source:
public void testOnlineOfflinePusher() throws Exception {
  URL remote=getReplicationURL();
  final CustomizableMockHttpClient mockHttpClient=new CustomizableMockHttpClient();
  mockHttpClient.addResponderFakeLocalDocumentUpdate404();
  mockHttpClient.addResponderRevDiffsSmartResponder();
  HttpClientFactory mockHttpClientFactory=mockFactoryFactory(mockHttpClient);
  manager.setDefaultHttpClientFactory(mockHttpClientFactory);
  Replication pusher=database.createPushReplication(remote);
  pusher.setContinuous(true);
  pusher.start();
  for (int i=0; i < 5; i++) {
    Log.d(Database.TAG,"String_Node_Str" + i);
    putReplicationOffline(pusher);
    String docFieldName="String_Node_Str" + i;
    String docFieldVal="String_Node_Str" + i;
    Map<String,Object> properties=new HashMap<String,Object>();
    properties.put(docFieldName,docFieldVal);
    createDocumentWithProperties(database,properties);
    final CountDownLatch gotBulkDocsRequest=new CountDownLatch(1);
    CustomizableMockHttpClient.ResponseListener bulkDocsListener=new CustomizableMockHttpClient.ResponseListener(){
      @Override public void responseSent(      HttpUriRequest httpUriRequest,      HttpResponse response){
        if (httpUriRequest.getURI().getPath().endsWith("String_Node_Str")) {
          gotBulkDocsRequest.countDown();
        }
      }
    }
;
    mockHttpClient.addResponseListener(bulkDocsListener);
    putReplicationOnline(pusher);
    boolean succeeded=gotBulkDocsRequest.await(30,TimeUnit.SECONDS);
    assertTrue(succeeded);
    mockHttpClient.removeResponseListener(bulkDocsListener);
    boolean foundExpectedDoc=false;
    List<HttpRequest> capturedRequests=mockHttpClient.getCapturedRequests();
    for (    HttpRequest capturedRequest : capturedRequests) {
      Log.d(Database.TAG,"String_Node_Str" + capturedRequest);
      if (capturedRequest instanceof HttpPost) {
        HttpPost capturedPostRequest=(HttpPost)capturedRequest;
        if (capturedPostRequest.getURI().getPath().endsWith("String_Node_Str")) {
          ArrayList docs=extractDocsFromBulkDocsPost(capturedRequest);
          if (docs.size() != 1) {
            Log.d(Database.TAG,"String_Node_Str");
          }
          assertEquals(1,docs.size());
          Map<String,Object> doc=(Map)docs.get(0);
          assertEquals(docFieldVal,doc.get(docFieldName));
          foundExpectedDoc=true;
        }
      }
    }
    assertTrue(foundExpectedDoc);
    mockHttpClient.clearCapturedRequests();
  }
}

Fixed version (ground truth):
public void testOnlineOfflinePusher() throws Exception {
  URL remote=getReplicationURL();
  final CustomizableMockHttpClient mockHttpClient=new CustomizableMockHttpClient();
  mockHttpClient.addResponderFakeLocalDocumentUpdate404();
  mockHttpClient.addResponderRevDiffsSmartResponder();
  HttpClientFactory mockHttpClientFactory=mockFactoryFactory(mockHttpClient);
  manager.setDefaultHttpClientFactory(mockHttpClientFactory);
  Replication pusher=database.createPushReplication(remote);
  pusher.setContinuous(true);
  pusher.start();
  for (int i=0; i < 5; i++) {
    Log.d(Database.TAG,"String_Node_Str" + i);
    putReplicationOffline(pusher);
    String docFieldName="String_Node_Str" + i;
    String docFieldVal="String_Node_Str" + i;
    Map<String,Object> properties=new HashMap<String,Object>();
    properties.put(docFieldName,docFieldVal);
    createDocumentWithProperties(database,properties);
    final CountDownLatch gotBulkDocsRequest=new CountDownLatch(1);
    CustomizableMockHttpClient.ResponseListener bulkDocsListener=new CustomizableMockHttpClient.ResponseListener(){
      @Override public void responseSent(      HttpUriRequest httpUriRequest,      HttpResponse response){
        if (httpUriRequest.getURI().getPath().endsWith("String_Node_Str")) {
          gotBulkDocsRequest.countDown();
        }
      }
    }
;
    mockHttpClient.addResponseListener(bulkDocsListener);
    putReplicationOnline(pusher);
    boolean succeeded=gotBulkDocsRequest.await(30,TimeUnit.SECONDS);
    assertTrue(succeeded);
    mockHttpClient.removeResponseListener(bulkDocsListener);
    boolean foundExpectedDoc=false;
    List<HttpRequest> capturedRequests=mockHttpClient.getCapturedRequests();
    for (    HttpRequest capturedRequest : capturedRequests) {
      Log.d(Database.TAG,"String_Node_Str" + capturedRequest);
      if (capturedRequest instanceof HttpPost) {
        HttpPost capturedPostRequest=(HttpPost)capturedRequest;
        if (capturedPostRequest.getURI().getPath().endsWith("String_Node_Str")) {
          ArrayList docs=CustomizableMockHttpClient.extractDocsFromBulkDocsPost(capturedRequest);
          if (docs.size() != 1) {
            Log.d(Database.TAG,"String_Node_Str");
          }
          assertEquals(1,docs.size());
          Map<String,Object> doc=(Map)docs.get(0);
          assertEquals(docFieldVal,doc.get(docFieldName));
          foundExpectedDoc=true;
        }
      }
    }
    assertTrue(foundExpectedDoc);
    mockHttpClient.clearCapturedRequests();
  }
}