### Question:
PreferCurrentEventLoopHolder extends IdleConnectionsHolder<W, R> { @Override public Observable<PooledConnection<R, W>> poll() { return pollObservable; } PreferCurrentEventLoopHolder(PreferCurrentEventLoopGroup eventLoopGroup);   PreferCurrentEventLoopHolder(PreferCurrentEventLoopGroup eventLoopGroup,
                                 final IdleConnectionsHolderFactory<W, R> holderFactory); @Override Observable<PooledConnection<R, W>> poll(); @Override Observable<PooledConnection<R, W>> pollThisEventLoopConnections(); @Override Observable<PooledConnection<R, W>> peek(); @Override void add(final PooledConnection<R, W> toAdd); @Override boolean remove(PooledConnection<R, W> toRemove);  }### Answer:
@Test(timeout = 60000) public void testPollOutOfEventloop() throws Exception { PooledConnection<String, String> connection1 = preferCurrentELHolderRule.addConnection(); PooledConnection<String, String> connection = preferCurrentELHolderRule.holder.poll() .defaultIfEmpty(null).toBlocking() .single(); assertThat("Unexpected connection.", connection, is(connection1)); }
@Test(timeout = 60000) public void testPollInEventloop() throws Exception { final PooledConnection<String, String> connection1 = preferCurrentELHolderRule.addConnection(); preferCurrentELHolderRule.runFromChannelEventLoop(new Callable<Void>() { @Override public Void call() throws Exception { PooledConnection<String, String> connection = preferCurrentELHolderRule.holder.poll() .defaultIfEmpty(null) .toBlocking() .single(); assertThat("Connection available in the eventloop.", connection, is(connection1)); return null; } }).get(1, TimeUnit.MINUTES); }
@Test(timeout = 60000) public void testPollRemovesItem() throws Exception { PooledConnection<String, String> connection1 = preferCurrentELHolderRule.addConnection(); PooledConnection<String, String> connection = preferCurrentELHolderRule.holder.poll() .defaultIfEmpty(null) .toBlocking().single(); assertThat("Connection not available with poll.", connection, is(connection1)); connection = preferCurrentELHolderRule.holder.poll() .defaultIfEmpty(null) .toBlocking().single(); assertThat("Connection available after poll.", connection, is(nullValue())); }