XenHypervisor implements HypervisorHost { protected Host getMasterHost(Connection conn) throws BadServerResponse, XenAPIException, XmlRpcException { Iterator<Pool> poolIterator = Pool.getAll(conn).iterator(); if (poolIterator.hasNext()) { return poolIterator.next().getMaster(conn); } throw new CloudRuntimeException("Could not find master server for pool."); }  @Override void shutdownHost(HostVO hostVo); @Override boolean supportsHypervisor(HypervisorType hypervisorType);  }
@Test public void getMasterHostTest() throws Exception { Pool pool = Mockito.mock(Pool.class); pool.getMaster(Mockito.any(Connection.class)); Set<Pool> setOfPools = new HashSet<Pool>(); setOfPools.add(pool); PowerMockito.mockStatic(Pool.class); PowerMockito.doReturn(setOfPools).when(Pool.class, "getAll", conn); xenHypervisor.getMasterHost(conn); }
@Test(expected = CloudRuntimeException.class) public void getMasterHostTestEmptyPool() throws Exception { Set<Pool> setOfPools = new HashSet<Pool>(); PowerMockito.mockStatic(Pool.class); PowerMockito.doReturn(setOfPools).when(Pool.class, "getAll", conn); xenHypervisor.getMasterHost(conn); }