XenHypervisor implements HypervisorHost { protected void waitChangePoolMasterHost(Host master, Connection conn, String hostUuid) throws BadServerResponse, XenAPIException, XmlRpcException { int count = 0; while (hostUuid.equals(master.getUuid(conn))) { threadUtils.sleepThread(3); count++; if (count > 90) { throw new CloudRuntimeException(String.format("Could not shut down host [uuid=%s]; It was not possible to assign a new master to its pool", hostUuid)); } } }  @Override void shutdownHost(HostVO hostVo); @Override boolean supportsHypervisor(HypervisorType hypervisorType);  }
@Test public void waitChangePoolMasterHostTest() throws Exception { setupWaitChangePoolMasterHost("uuidDifferentFromHost"); xenHypervisor.waitChangePoolMasterHost(host, conn, "uuid"); }
@Test(expected = CloudRuntimeException.class) public void waitChangePoolMasterHostTestExpectCloudRuntimeException() throws Exception { setupWaitChangePoolMasterHost("uuid"); xenHypervisor.waitChangePoolMasterHost(host, conn, "uuid"); Mockito.verify(threadUtils, Mockito.times(90)).sleepThread(Mockito.anyInt()); }