private void doTest() throws IOException {
    Admin admin = UTIL.getAdmin();
    String peerId = "1";
    ReplicationPeerConfig peerConfig = ReplicationPeerConfig.newBuilder()
      .setClusterKey(UTIL.getZkCluster().getAddress().toString() + ":/hbase2").build();
    admin.addReplicationPeer(peerId, peerConfig, true);

    assertEquals(peerConfig.getClusterKey(),
      admin.getReplicationPeerConfig(peerId).getClusterKey());
    ReplicationPeerConfig newPeerConfig =
      ReplicationPeerConfig.newBuilder(peerConfig).setBandwidth(123456).build();
    admin.updateReplicationPeerConfig(peerId, newPeerConfig);
    assertEquals(newPeerConfig.getBandwidth(),
      admin.getReplicationPeerConfig(peerId).getBandwidth());

    admin.disableReplicationPeer(peerId);
    assertFalse(admin.listReplicationPeers().get(0).isEnabled());

    admin.enableReplicationPeer(peerId);
    assertTrue(admin.listReplicationPeers().get(0).isEnabled());

    admin.removeReplicationPeer(peerId);
    assertTrue(admin.listReplicationPeers().isEmpty());

    // make sure that we have run into the mocked method
    MockHMaster master = (MockHMaster) UTIL.getHBaseCluster().getMaster();
    assertTrue(master.addPeerCalled);
    assertTrue(master.removePeerCalled);
    assertTrue(master.updatePeerConfigCalled);
    assertTrue(master.enablePeerCalled);
    assertTrue(master.disablePeerCalled);
  }
All the modification method will fail once in the test and should finally succeed.
hbase-server/src/test/java/org/apache/hadoop/hbase/replication/TestReplicationProcedureRetry.java