use of org.apache.bookkeeper.discover.ZKRegistrationManager in project bookkeeper by apache.
the class ZKMetadataBookieDriverTest method testGetRegManager.
@Test
public void testGetRegManager() throws Exception {
RegistrationListener listener = mock(RegistrationListener.class);
driver.initialize(conf, listener, NullStatsLogger.INSTANCE);
assertSame(conf, driver.serverConf);
assertSame(listener, driver.listener);
assertNull(driver.regManager);
ZKRegistrationManager mockRegManager = PowerMockito.mock(ZKRegistrationManager.class);
PowerMockito.whenNew(ZKRegistrationManager.class).withParameterTypes(ServerConfiguration.class, ZooKeeper.class, RegistrationListener.class).withArguments(any(ServerConfiguration.class), any(ZooKeeper.class), any(RegistrationListener.class)).thenReturn(mockRegManager);
RegistrationManager manager = driver.getRegistrationManager();
assertSame(mockRegManager, manager);
assertSame(mockRegManager, driver.regManager);
PowerMockito.verifyNew(ZKRegistrationManager.class, times(1)).withArguments(same(conf), same(mockZkc), same(listener));
driver.close();
verify(mockRegManager, times(1)).close();
assertNull(driver.regManager);
}
Aggregations