protected final void verifyReplicationRequestRejection(HBaseTestingUtil utility,
    boolean expectedRejection) throws Exception {
    HRegionServer regionServer = utility.getRSForFirstRegionInTable(TABLE_NAME);
    AsyncClusterConnection connection = regionServer.getAsyncClusterConnection();
    Entry[] entries = new Entry[10];
    for (int i = 0; i < entries.length; i++) {
      entries[i] =
        new Entry(new WALKeyImpl(HConstants.EMPTY_BYTE_ARRAY, TABLE_NAME, 0), new WALEdit());
    }
    if (!expectedRejection) {
      FutureUtils.get(ReplicationProtobufUtil.replicateWALEntry(
        connection.getRegionServerAdmin(regionServer.getServerName()), entries, null, null, null,
        HConstants.REPLICATION_SOURCE_SHIPEDITS_TIMEOUT_DFAULT));
    } else {
      try {
        FutureUtils.get(ReplicationProtobufUtil.replicateWALEntry(
          connection.getRegionServerAdmin(regionServer.getServerName()), entries, null, null, null,
          HConstants.REPLICATION_SOURCE_SHIPEDITS_TIMEOUT_DFAULT));
        fail("Should throw IOException when sync-replication state is in A or DA");
      } catch (RemoteException e) {
        assertRejection(e.unwrapRemoteException());
      } catch (DoNotRetryIOException e) {
        assertRejection(e);
      }
    }
  }
Base class for testing sync replication.
hbase-server/src/test/java/org/apache/hadoop/hbase/replication/SyncReplicationTestBase.java