Configuration conf = HBaseConfiguration.create();
// setup the conf to match the expected properties
conf.setInt("hbase.client.retries.number", numRetries);
conf.setLong("hbase.client.pause", pauseTime);
// mock the master admin to our mock
HMasterInterface mockMaster = Mockito.mock(HMasterInterface.class);
Mockito.when(mockConnection.getConfiguration()).thenReturn(conf);
Mockito.when(mockConnection.getMaster()).thenReturn(mockMaster);
// set the max wait time for the snapshot to complete
Mockito
.when(
mockMaster.snapshot(
Mockito.any(HSnapshotDescription.class))).thenReturn((long)maxWaitTime);
// first five times, we return false, last we get success
Mockito.when(
mockMaster.isSnapshotDone(
Mockito.any(HSnapshotDescription.class))).thenReturn(false, false,
false, false, false, true);
// setup the admin and run the test
HBaseAdmin admin = new HBaseAdmin(mockConnection);