From 4572ae5430120a7ff9493bdb89c264fd60f46a3a Mon Sep 17 00:00:00 2001 From: Andy Wilkinson Date: Thu, 24 Jun 2021 11:20:56 +0100 Subject: [PATCH] Use reflection to extract Netty's default level See gh-27046 --- .../boot/autoconfigure/netty/NettyPropertiesTests.java | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/netty/NettyPropertiesTests.java b/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/netty/NettyPropertiesTests.java index 8c3d5ad2cc..df23a8ecb1 100644 --- a/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/netty/NettyPropertiesTests.java +++ b/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/netty/NettyPropertiesTests.java @@ -17,8 +17,11 @@ package org.springframework.boot.autoconfigure.netty; import io.netty.util.ResourceLeakDetector; +import io.netty.util.ResourceLeakDetector.Level; import org.junit.jupiter.api.Test; +import org.springframework.test.util.ReflectionTestUtils; + import static org.assertj.core.api.Assertions.assertThat; /** @@ -31,8 +34,9 @@ class NettyPropertiesTests { @Test void defaultValueShouldMatchNettys() { NettyProperties properties = new NettyProperties(); - assertThat(ResourceLeakDetector.Level.valueOf(properties.getLeakDetection().name())) - .isEqualTo(ResourceLeakDetector.getLevel()); + ResourceLeakDetector.Level defaultLevel = (Level) ReflectionTestUtils.getField(ResourceLeakDetector.class, + "DEFAULT_LEVEL"); + assertThat(ResourceLeakDetector.Level.valueOf(properties.getLeakDetection().name())).isEqualTo(defaultLevel); } }