Skip to content

Commit

Permalink
Use reflection to extract Netty's default level
Browse files Browse the repository at this point in the history
  • Loading branch information
wilkinsona committed Jun 24, 2021
1 parent f7140d0 commit 4572ae5
Showing 1 changed file with 6 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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;

/**
Expand All @@ -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);
}

}

0 comments on commit 4572ae5

Please sign in to comment.