Skip to content

Spring Boot with Webflux dependency breaks logging impl and forces DEBUG when using TestContext via AbstractTestNGSpringContextTests #24523

@majones713

Description

@majones713

ISSUE:

I have a test project which uses Spring Boot Gradle plugin. The project is not a running application but only used to execute set of testng tests, hence, doesn't require application.properties as its just tests. I'm using it this way:

public class CoreBaseTest extends AbstractTestNGSpringContextTests {}

I've been using RestTemplate for a while and now wanting to transition to WebClient.

When I added new WebFLux dependency to project:

implementation 'org.springframework.boot:spring-boot-starter-webflux'

and run my tests, all I see are a bunch of DEBUG logs being generated as if I set logging to DEBUG but I didn't. If I remove dependency, I see only INFO logs which is the normal expected behavior.

I have a log4j2.properties located in src/main/resources as well when using logger within classes. That working as expected but built-in spring classes are outputting DEBUG logs only when using webflux dependency. I tried setting logging level via

-Dlogging.level.org.springframework=INFO

but that doesn't work or help. Its as if webflux breaks AbstractTestNGSpringContextTests logging behavior.

My gradle plugin is as follows:

plugins {
	id "java"
	id "maven"
	id "io.freefair.lombok" version "5.1.0"
	id "org.springframework.boot" version "2.4.0" apply false
	id 'io.spring.dependency-management' version '1.0.10.RELEASE'
	id "com.jfrog.artifactory" version "4.15.2"
	id "maven-publish"
	id 'project-report'
}

My gradle dependencies is as follows:

dependencies {	
    implementation 'org.springframework:spring-test'
    implementation 'org.springframework:spring-context'
    implementation 'org.springframework:spring-web'
    implementation 'com.fasterxml.jackson.core:jackson-annotations'
    implementation 'org.springframework.boot:spring-boot-starter-webflux'
}

Again, if you remove webflux logging works as it did before but when you add somehow the behavior is broken. I'm using Java 11 as well.

DEBUG logs

[RemoteTestNG] detected TestNG version 7.3.0
14:54:45.719 [main] DEBUG org.springframework.test.context.BootstrapUtils - Instantiating CacheAwareContextLoaderDelegate from class [org.springframework.test.context.cache.DefaultCacheAwareContextLoaderDelegate]
14:54:45.736 [main] DEBUG org.springframework.test.context.BootstrapUtils - Instantiating BootstrapContext using constructor [public org.springframework.test.context.support.DefaultBootstrapContext(java.lang.Class,org.springframework.test.context.CacheAwareContextLoaderDelegate)]
14:54:45.772 [main] DEBUG org.springframework.test.context.BootstrapUtils - Instantiating TestContextBootstrapper for test class [com.farmers.test.css.api.security.clients.tests.SecurityBaseTest] from class [org.springframework.test.context.support.DefaultTestContextBootstrapper]
14:54:45.807 [main] DEBUG org.springframework.test.context.support.AbstractDelegatingSmartContextLoader - Delegating to AnnotationConfigContextLoader to process context configuration [ContextConfigurationAttributes@125290e5 declaringClass = 'com.farmers.test.css.api.core.basetest.CoreBaseTest', classes = '{class com.farmers.test.css.api.core.configuration.CorePropertiesConfiguration, class com.farmers.test.css.api.core.configuration.CoreRestTemplateConfiguration, class com.farmers.test.css.api.core.configuration.CoreWebClientConfiguration, class com.farmers.test.css.api.core.configuration.CoreEncryptionConfiguration, class com.farmers.test.css.api.core.configuration.CoreValidatorConfiguration, class com.farmers.test.css.api.core.configuration.CoreGenericConfiguration}', locations = '{}', inheritLocations = true, initializers = '{}', inheritInitializers = true, name = [null], contextLoaderClass = 'org.springframework.test.context.ContextLoader'].
14:54:45.856 [main] DEBUG org.springframework.test.context.support.ActiveProfilesUtils - Could not find an 'annotation declaring class' for annotation type [org.springframework.test.context.ActiveProfiles] and class [com.farmers.test.css.api.security.clients.tests.SecurityBaseTest]
14:54:45.860 [main] DEBUG org.springframework.test.context.support.DefaultTestContextBootstrapper - Skipping candidate TestExecutionListener [org.springframework.test.context.web.ServletTestExecutionListener] due to a missing dependency. Specify custom listener classes or make the default listener classes and their required dependencies available. Offending class: [javax/servlet/ServletContext]
14:54:45.862 [main] INFO org.springframework.test.context.support.DefaultTestContextBootstrapper - Using TestExecutionListeners: [org.springframework.test.context.support.DirtiesContextBeforeModesTestExecutionListener@1e44b638, org.springframework.test.context.support.DependencyInjectionTestExecutionListener@7393222f, org.springframework.test.context.support.DirtiesContextTestExecutionListener@babafc2, org.springframework.test.context.event.EventPublishingTestExecutionListener@31add175, com.farmers.test.css.api.core.listeners.CoreCustomTestExecutionListener@ae3540e]
14:54:45.884 [main] DEBUG org.springframework.test.context.BootstrapUtils - Instantiating CacheAwareContextLoaderDelegate from class [org.springframework.test.context.cache.DefaultCacheAwareContextLoaderDelegate]
14:54:45.884 [main] DEBUG org.springframework.test.context.BootstrapUtils - Instantiating BootstrapContext using constructor [public org.springframework.test.context.support.DefaultBootstrapContext(java.lang.Class,org.springframework.test.context.CacheAwareContextLoaderDelegate)]
14:54:45.885 [main] DEBUG org.springframework.test.context.BootstrapUtils - Instantiating TestContextBootstrapper for test class [com.farmers.test.css.api.security.clients.tests.authn.AuthnTests] from class [org.springframework.test.context.support.DefaultTestContextBootstrapper]
14:54:45.885 [main] DEBUG org.springframework.test.context.support.AbstractDelegatingSmartContextLoader - Delegating to AnnotationConfigContextLoader to process context configuration [ContextConfigurationAttributes@74bf1791 declaringClass = 'com.farmers.test.css.api.core.basetest.CoreBaseTest', classes = '{class com.farmers.test.css.api.core.configuration.CorePropertiesConfiguration, class com.farmers.test.css.api.core.configuration.CoreRestTemplateConfiguration, class com.farmers.test.css.api.core.configuration.CoreWebClientConfiguration, class com.farmers.test.css.api.core.configuration.CoreEncryptionConfiguration, class com.farmers.test.css.api.core.configuration.CoreValidatorConfiguration, class com.farmers.test.css.api.core.configuration.CoreGenericConfiguration}', locations = '{}', inheritLocations = true, initializers = '{}', inheritInitializers = true, name = [null], contextLoaderClass = 'org.springframework.test.context.ContextLoader'].
14:54:45.888 [main] DEBUG org.springframework.test.context.support.ActiveProfilesUtils - Could not find an 'annotation declaring class' for annotation type [org.springframework.test.context.ActiveProfiles] and class [com.farmers.test.css.api.security.clients.tests.authn.AuthnTests]
14:54:45.890 [main] DEBUG org.springframework.test.context.support.DefaultTestContextBootstrapper - Skipping candidate TestExecutionListener [org.springframework.test.context.web.ServletTestExecutionListener] due to a missing dependency. Specify custom listener classes or make the default listener classes and their required dependencies available. Offending class: [javax/servlet/ServletContext]
14:54:45.891 [main] INFO org.springframework.test.context.support.DefaultTestContextBootstrapper - Using TestExecutionListeners: [org.springframework.test.context.support.DirtiesContextBeforeModesTestExecutionListener@54504ecd, org.springframework.test.context.support.DependencyInjectionTestExecutionListener@38b27cdc, org.springframework.test.context.support.DirtiesContextTestExecutionListener@1339e7aa, org.springframework.test.context.event.EventPublishingTestExecutionListener@1fb669c3, com.farmers.test.css.api.core.listeners.CoreCustomTestExecutionListener@49c66ade]
14:54:45.938 [main] DEBUG org.springframework.test.context.support.DependencyInjectionTestExecutionListener - Performing dependency injection for test context [[DefaultTestContext@50d13246 testClass = SecurityBaseTest, testInstance = com.farmers.test.css.api.security.clients.tests.SecurityBaseTest@338c99c8, testMethod = [null], testException = [null], mergedContextConfiguration = [MergedContextConfiguration@2bd08376 testClass = SecurityBaseTest, locations = '{}', classes = '{class com.farmers.test.css.api.core.configuration.CorePropertiesConfiguration, class com.farmers.test.css.api.core.configuration.CoreRestTemplateConfiguration, class com.farmers.test.css.api.core.configuration.CoreWebClientConfiguration, class com.farmers.test.css.api.core.configuration.CoreEncryptionConfiguration, class com.farmers.test.css.api.core.configuration.CoreValidatorConfiguration, class com.farmers.test.css.api.core.configuration.CoreGenericConfiguration}', contextInitializerClasses = '[]', activeProfiles = '{}', propertySourceLocations = '{}', propertySourceProperties = '{}', contextCustomizers = set[[empty]], contextLoader = 'org.springframework.test.context.support.DelegatingSmartContextLoader', parent = [null]], attributes = map[[empty]]]].
14:54:45.939 [main] DEBUG org.springframework.test.context.support.AbstractDelegatingSmartContextLoader - Delegating to AnnotationConfigContextLoader to load context from [MergedContextConfiguration@2bd08376 testClass = SecurityBaseTest, locations = '{}', classes = '{class com.farmers.test.css.api.core.configuration.CorePropertiesConfiguration, class com.farmers.test.css.api.core.configuration.CoreRestTemplateConfiguration, class com.farmers.test.css.api.core.configuration.CoreWebClientConfiguration, class com.farmers.test.css.api.core.configuration.CoreEncryptionConfiguration, class com.farmers.test.css.api.core.configuration.CoreValidatorConfiguration, class com.farmers.test.css.api.core.configuration.CoreGenericConfiguration}', contextInitializerClasses = '[]', activeProfiles = '{}', propertySourceLocations = '{}', propertySourceProperties = '{}', contextCustomizers = set[[empty]], contextLoader = 'org.springframework.test.context.support.DelegatingSmartContextLoader', parent = [null]].
14:54:45.940 [main] DEBUG org.springframework.test.context.support.AbstractGenericContextLoader - Loading ApplicationContext for merged context configuration [[MergedContextConfiguration@2bd08376 testClass = SecurityBaseTest, locations = '{}', classes = '{class com.farmers.test.css.api.core.configuration.CorePropertiesConfiguration, class com.farmers.test.css.api.core.configuration.CoreRestTemplateConfiguration, class com.farmers.test.css.api.core.configuration.CoreWebClientConfiguration, class com.farmers.test.css.api.core.configuration.CoreEncryptionConfiguration, class com.farmers.test.css.api.core.configuration.CoreValidatorConfiguration, class com.farmers.test.css.api.core.configuration.CoreGenericConfiguration}', contextInitializerClasses = '[]', activeProfiles = '{}', propertySourceLocations = '{}', propertySourceProperties = '{}', contextCustomizers = set[[empty]], contextLoader = 'org.springframework.test.context.support.DelegatingSmartContextLoader', parent = [null]]].
14:54:45.983 [main] DEBUG org.springframework.core.env.StandardEnvironment - Activating profiles []
14:54:45.983 [main] DEBUG org.springframework.test.context.support.AnnotationConfigContextLoader - Registering component classes: {class com.farmers.test.css.api.core.configuration.CorePropertiesConfiguration, class com.farmers.test.css.api.core.configuration.CoreRestTemplateConfiguration, class com.farmers.test.css.api.core.configuration.CoreWebClientConfiguration, class com.farmers.test.css.api.core.configuration.CoreEncryptionConfiguration, class com.farmers.test.css.api.core.configuration.CoreValidatorConfiguration, class com.farmers.test.css.api.core.configuration.CoreGenericConfiguration}
14:54:46.051 [main] DEBUG org.springframework.context.support.GenericApplicationContext - Refreshing org.springframework.context.support.GenericApplicationContext@1f010bf0
14:54:46.074 [main] DEBUG org.springframework.beans.factory.support.DefaultListableBeanFactory - Creating shared instance of singleton bean 'org.springframework.context.annotation.internalConfigurationAnnotationProcessor'

Metadata

Metadata

Assignees

Labels

status: invalidAn issue that we don't feel is valid

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions