Search in sources :

Example 1 with RegistrationListener

use of org.apache.bookkeeper.discover.RegistrationManager.RegistrationListener 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);
}
Also used : RegistrationListener(org.apache.bookkeeper.discover.RegistrationManager.RegistrationListener) ZKRegistrationManager(org.apache.bookkeeper.discover.ZKRegistrationManager) RegistrationManager(org.apache.bookkeeper.discover.RegistrationManager) ZKRegistrationManager(org.apache.bookkeeper.discover.ZKRegistrationManager) Test(org.junit.Test) PrepareForTest(org.powermock.core.classloader.annotations.PrepareForTest)

Aggregations

RegistrationManager (org.apache.bookkeeper.discover.RegistrationManager)1 RegistrationListener (org.apache.bookkeeper.discover.RegistrationManager.RegistrationListener)1 ZKRegistrationManager (org.apache.bookkeeper.discover.ZKRegistrationManager)1 Test (org.junit.Test)1 PrepareForTest (org.powermock.core.classloader.annotations.PrepareForTest)1