public static void removeReplicatorTestDoc(CloudantClient account, String replicatorDocId) throws Exception { // Grab replicator doc revision using HTTP HEAD command String replicatorDb = "_replicator"; URI uri = URI.create(account.getBaseUri() + replicatorDb + "/" + replicatorDocId); HttpConnection head = Http.HEAD(uri); // add a response interceptor to allow us to retrieve the ETag revision header final AtomicReference<String> revisionRef = new AtomicReference<String>(); head.responseInterceptors.add( new HttpConnectionResponseInterceptor() { @Override public HttpConnectionInterceptorContext interceptResponse( HttpConnectionInterceptorContext context) { revisionRef.set(context.connection.getConnection().getHeaderField("ETag")); return context; } }); account.executeRequest(head); String revision = revisionRef.get(); assertNotNull("The revision should not be null", revision); Database replicator = account.database(replicatorDb, false); Response removeResponse = replicator.remove(replicatorDocId, revision.replaceAll("\"", "")); assertThat(removeResponse.getError(), is(nullValue())); }