Skip to content

Commit ac1d60e

Browse files
committed
Add additional autoconfiguration tests
Signed-off-by: Dmitry Sulman <[email protected]>
1 parent d09ab41 commit ac1d60e

File tree

2 files changed

+52
-1
lines changed

2 files changed

+52
-1
lines changed

logback-access-reactor-netty-spring-boot-starter/src/test/kotlin/io/github/dmitrysulman/logback/access/reactor/netty/autoconfigure/ReactorNettyAccessLogFactoryAutoConfigurationTests.kt

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
package io.github.dmitrysulman.logback.access.reactor.netty.autoconfigure
22

3+
import ch.qos.logback.core.status.OnConsoleStatusListener
34
import io.github.dmitrysulman.logback.access.reactor.netty.ReactorNettyAccessLogFactory
5+
import io.kotest.matchers.booleans.shouldBeTrue
46
import io.mockk.mockk
57
import io.mockk.verify
68
import org.assertj.core.api.AssertionsForInterfaceTypes.assertThat
@@ -59,6 +61,55 @@ class ReactorNettyAccessLogFactoryAutoConfigurationTests {
5961
}
6062
}
6163

64+
@Test
65+
fun `should supply beans when explicitly enabled by the property`() {
66+
ReactiveWebApplicationContextRunner()
67+
.withConfiguration(AutoConfigurations.of(ReactorNettyAccessLogFactoryAutoConfiguration::class.java))
68+
.withPropertyValues("logback.access.reactor.netty.enabled=true")
69+
.run { context ->
70+
assertThat(context).hasSingleBean(ReactorNettyAccessLogFactory::class.java)
71+
assertThat(context).hasSingleBean(ReactorNettyAccessLogWebServerFactoryCustomizer::class.java)
72+
}
73+
}
74+
75+
@Test
76+
fun `should enable debug mode by the property`() {
77+
ReactiveWebApplicationContextRunner()
78+
.withConfiguration(AutoConfigurations.of(ReactorNettyAccessLogFactoryAutoConfiguration::class.java))
79+
.withPropertyValues("logback.access.reactor.netty.debug=true")
80+
.run { context ->
81+
val factory = context.getBean<ReactorNettyAccessLogFactory>()
82+
factory.accessContext.statusManager.copyOfStatusListenerList
83+
.any { it::class == OnConsoleStatusListener::class }
84+
.shouldBeTrue()
85+
}
86+
}
87+
88+
@Test
89+
fun `should not enable debug mode when debug false`() {
90+
ReactiveWebApplicationContextRunner()
91+
.withConfiguration(AutoConfigurations.of(ReactorNettyAccessLogFactoryAutoConfiguration::class.java))
92+
.withPropertyValues("logback.access.reactor.netty.debug=false")
93+
.run { context ->
94+
val factory = context.getBean<ReactorNettyAccessLogFactory>()
95+
factory.accessContext.statusManager.copyOfStatusListenerList
96+
.none { it::class == OnConsoleStatusListener::class }
97+
.shouldBeTrue()
98+
}
99+
}
100+
101+
@Test
102+
fun `should not enable debug mode when no debug property provided`() {
103+
ReactiveWebApplicationContextRunner()
104+
.withConfiguration(AutoConfigurations.of(ReactorNettyAccessLogFactoryAutoConfiguration::class.java))
105+
.run { context ->
106+
val factory = context.getBean<ReactorNettyAccessLogFactory>()
107+
factory.accessContext.statusManager.copyOfStatusListenerList
108+
.none { it::class == OnConsoleStatusListener::class }
109+
.shouldBeTrue()
110+
}
111+
}
112+
62113
@Test
63114
fun `should not supply beans when already has user defined beans in the context`() {
64115
ReactiveWebApplicationContextRunner()

logback-access-reactor-netty-spring-boot-starter/src/test/kotlin/io/github/dmitrysulman/logback/access/reactor/netty/joran/LogbackAccessJoranConfiguratorTests.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ class LogbackAccessJoranConfiguratorTests {
5858
"logback-access-springprofile-dev-prod.xml",
5959
],
6060
)
61-
fun `should not log event with prod springProfile configuration`(filename: String) {
61+
fun `should not log event with springProfile configuration`(filename: String) {
6262
ReactiveWebApplicationContextRunner()
6363
.withConfiguration(AutoConfigurations.of(ReactorNettyAccessLogFactoryAutoConfiguration::class.java))
6464
.withPropertyValues("spring.profiles.active=stg")

0 commit comments

Comments
 (0)