use of com.linkedin.r2.event.EventProviderRegistry in project rest.li by linkedin.
the class TestEventChannelPoolManagerFactory method testBuildChannelPoolManagers.
@Test
public void testBuildChannelPoolManagers() {
ChannelPoolManagerFactory channelPoolManagerFactory = getChannelPoolManagerFactory();
EventProviderRegistry eventProviderRegistry = mock(EventProviderRegistry.class);
ChannelPoolManagerKey anyChannelPoolManagerKey = mock(ChannelPoolManagerKey.class);
EventAwareChannelPoolManagerFactory factory = new EventAwareChannelPoolManagerFactory(channelPoolManagerFactory, eventProviderRegistry);
ChannelPoolManager actualRestManager = factory.buildRest(anyChannelPoolManagerKey);
ChannelPoolManager actualStreamManager = factory.buildStream(anyChannelPoolManagerKey);
ChannelPoolManager actualHttp2StreamManager = factory.buildHttp2Stream(anyChannelPoolManagerKey);
// Expects event provider to have been registered for three times and none is unregistered
verify(eventProviderRegistry, times(3)).registerChannelPoolEventProvider(any());
verify(eventProviderRegistry, times(0)).unregisterChannelPoolEventProvider(any());
actualRestManager.shutdown(Callbacks.empty(), mock(Runnable.class), mock(Runnable.class), 0L);
actualStreamManager.shutdown(Callbacks.empty(), mock(Runnable.class), mock(Runnable.class), 0L);
actualHttp2StreamManager.shutdown(Callbacks.empty(), mock(Runnable.class), mock(Runnable.class), 0L);
// Expects event provider to have been registered for three times and unregistered for three times
verify(eventProviderRegistry, times(3)).registerChannelPoolEventProvider(any());
verify(eventProviderRegistry, times(3)).unregisterChannelPoolEventProvider(any());
}
Aggregations