Skip to content

Commit

Permalink
issue-3561: Add tests for log behavior after removing unnecessary con…
Browse files Browse the repository at this point in the history
…ditional statements
  • Loading branch information
raccoonback committed Dec 30, 2024
1 parent a5a5b98 commit aba22b7
Showing 1 changed file with 24 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,10 @@
import java.util.function.Function;
import java.util.function.Supplier;

import io.netty.channel.Channel;
import io.netty.channel.ChannelOption;
import io.netty.channel.EventLoopGroup;
import io.netty.channel.embedded.EmbeddedChannel;
import io.netty.channel.nio.NioEventLoopGroup;
import io.netty.handler.logging.LoggingHandler;
import io.netty.resolver.AddressResolver;
Expand Down Expand Up @@ -82,6 +84,11 @@

import static org.assertj.core.api.Assertions.assertThat;
import static org.awaitility.Awaitility.await;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.when;
import static reactor.netty.resources.PooledConnectionProvider.logPoolState;
import static reactor.util.Loggers.resetLoggerFactory;
import static reactor.util.Loggers.useVerboseConsoleLoggers;

class DefaultPooledConnectionProviderTest {

Expand Down Expand Up @@ -570,6 +577,23 @@ void testIssue3316() throws ExecutionException, InterruptedException {
}
}

@Test
void testLogFormat() {
Channel channel = new EmbeddedChannel();
useVerboseConsoleLoggers();
try {
InstrumentedPool<? extends Connection> pool = mock(InstrumentedPool.class);
InstrumentedPool.PoolMetrics metrics = mock(InstrumentedPool.PoolMetrics.class);
when(pool.metrics()).thenReturn(metrics);
logPoolState(channel, pool, "log message");
logPoolState(channel, pool, "log message", new Exception("test log format"));
}
finally {
resetLoggerFactory();
Connection.from(channel).dispose();
}
}

static final class PoolImpl extends AtomicInteger implements InstrumentedPool<PooledConnection> {

@Override
Expand Down

0 comments on commit aba22b7

Please sign in to comment.