Add nullability annotations to tests in module/spring-boot-integration
See gh-47263
This commit is contained in:
parent
cae3fb578c
commit
7f225a8df5
|
@ -50,3 +50,7 @@ dependencies {
|
||||||
testRuntimeOnly("com.h2database:h2")
|
testRuntimeOnly("com.h2database:h2")
|
||||||
testRuntimeOnly("com.zaxxer:HikariCP")
|
testRuntimeOnly("com.zaxxer:HikariCP")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
tasks.named("compileTestJava") {
|
||||||
|
options.nullability.checking = "tests"
|
||||||
|
}
|
||||||
|
|
|
@ -31,6 +31,7 @@ import io.micrometer.observation.ObservationRegistry;
|
||||||
import io.rsocket.transport.ClientTransport;
|
import io.rsocket.transport.ClientTransport;
|
||||||
import io.rsocket.transport.netty.client.TcpClientTransport;
|
import io.rsocket.transport.netty.client.TcpClientTransport;
|
||||||
import org.assertj.core.api.InstanceOfAssertFactories;
|
import org.assertj.core.api.InstanceOfAssertFactories;
|
||||||
|
import org.jspecify.annotations.Nullable;
|
||||||
import org.junit.jupiter.api.Test;
|
import org.junit.jupiter.api.Test;
|
||||||
import org.junit.jupiter.api.condition.EnabledForJreRange;
|
import org.junit.jupiter.api.condition.EnabledForJreRange;
|
||||||
import org.junit.jupiter.api.condition.JRE;
|
import org.junit.jupiter.api.condition.JRE;
|
||||||
|
@ -38,6 +39,7 @@ import reactor.core.publisher.Mono;
|
||||||
|
|
||||||
import org.springframework.beans.DirectFieldAccessor;
|
import org.springframework.beans.DirectFieldAccessor;
|
||||||
import org.springframework.beans.PropertyAccessorFactory;
|
import org.springframework.beans.PropertyAccessorFactory;
|
||||||
|
import org.springframework.boot.SpringApplication;
|
||||||
import org.springframework.boot.autoconfigure.AutoConfigurations;
|
import org.springframework.boot.autoconfigure.AutoConfigurations;
|
||||||
import org.springframework.boot.autoconfigure.jmx.JmxAutoConfiguration;
|
import org.springframework.boot.autoconfigure.jmx.JmxAutoConfiguration;
|
||||||
import org.springframework.boot.autoconfigure.task.TaskSchedulingAutoConfiguration;
|
import org.springframework.boot.autoconfigure.task.TaskSchedulingAutoConfiguration;
|
||||||
|
@ -421,7 +423,7 @@ class IntegrationAutoConfigurationTests {
|
||||||
.withPropertyValues("spring.integration.channel.auto-create=false",
|
.withPropertyValues("spring.integration.channel.auto-create=false",
|
||||||
"spring.integration.endpoint.read-only-headers=ignoredHeader")
|
"spring.integration.endpoint.read-only-headers=ignoredHeader")
|
||||||
.withInitializer((applicationContext) -> new IntegrationPropertiesEnvironmentPostProcessor()
|
.withInitializer((applicationContext) -> new IntegrationPropertiesEnvironmentPostProcessor()
|
||||||
.postProcessEnvironment(applicationContext.getEnvironment(), null))
|
.postProcessEnvironment(applicationContext.getEnvironment(), new SpringApplication()))
|
||||||
.run((context) -> {
|
.run((context) -> {
|
||||||
assertThat(context).hasSingleBean(org.springframework.integration.context.IntegrationProperties.class);
|
assertThat(context).hasSingleBean(org.springframework.integration.context.IntegrationProperties.class);
|
||||||
org.springframework.integration.context.IntegrationProperties integrationProperties = context
|
org.springframework.integration.context.IntegrationProperties integrationProperties = context
|
||||||
|
@ -644,7 +646,7 @@ class IntegrationAutoConfigurationTests {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Mono<Void> handleMessage(Message<?> message) {
|
public Mono<Void> handleMessage(Message<?> message) {
|
||||||
return null;
|
return Mono.empty();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -707,7 +709,7 @@ class IntegrationAutoConfigurationTests {
|
||||||
this.name = name;
|
this.name = name;
|
||||||
}
|
}
|
||||||
|
|
||||||
Object get(org.springframework.integration.context.IntegrationProperties properties) {
|
@Nullable Object get(org.springframework.integration.context.IntegrationProperties properties) {
|
||||||
return ReflectionTestUtils.invokeMethod(properties, this.name);
|
return ReflectionTestUtils.invokeMethod(properties, this.name);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -36,6 +36,7 @@ import org.springframework.boot.context.properties.bind.Binder;
|
||||||
import org.springframework.boot.origin.Origin;
|
import org.springframework.boot.origin.Origin;
|
||||||
import org.springframework.boot.origin.OriginLookup;
|
import org.springframework.boot.origin.OriginLookup;
|
||||||
import org.springframework.boot.origin.TextResourceOrigin;
|
import org.springframework.boot.origin.TextResourceOrigin;
|
||||||
|
import org.springframework.boot.origin.TextResourceOrigin.Location;
|
||||||
import org.springframework.boot.testsupport.classpath.resources.WithResource;
|
import org.springframework.boot.testsupport.classpath.resources.WithResource;
|
||||||
import org.springframework.core.env.ConfigurableEnvironment;
|
import org.springframework.core.env.ConfigurableEnvironment;
|
||||||
import org.springframework.core.env.MapPropertySource;
|
import org.springframework.core.env.MapPropertySource;
|
||||||
|
@ -141,6 +142,7 @@ class IntegrationPropertiesEnvironmentPostProcessorTests {
|
||||||
.formatted(IntegrationPropertiesEnvironmentPostProcessor.class.getName()), getClass().getClassLoader());
|
.formatted(IntegrationPropertiesEnvironmentPostProcessor.class.getName()), getClass().getClassLoader());
|
||||||
Map<String, String> mappings = (Map<String, String>) ReflectionTestUtils.getField(propertySource,
|
Map<String, String> mappings = (Map<String, String>) ReflectionTestUtils.getField(propertySource,
|
||||||
"KEYS_MAPPING");
|
"KEYS_MAPPING");
|
||||||
|
assertThat(mappings).isNotNull();
|
||||||
assertThat(mappings.values()).containsExactlyInAnyOrderElementsOf(integrationPropertyNames());
|
assertThat(mappings.values()).containsExactlyInAnyOrderElementsOf(integrationPropertyNames());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -148,6 +150,7 @@ class IntegrationPropertiesEnvironmentPostProcessorTests {
|
||||||
List<String> propertiesToMap = new ArrayList<>();
|
List<String> propertiesToMap = new ArrayList<>();
|
||||||
ReflectionUtils.doWithFields(IntegrationProperties.class, (field) -> {
|
ReflectionUtils.doWithFields(IntegrationProperties.class, (field) -> {
|
||||||
String value = (String) ReflectionUtils.getField(field, null);
|
String value = (String) ReflectionUtils.getField(field, null);
|
||||||
|
assertThat(value).isNotNull();
|
||||||
if (value.startsWith(IntegrationProperties.INTEGRATION_PROPERTIES_PREFIX)
|
if (value.startsWith(IntegrationProperties.INTEGRATION_PROPERTIES_PREFIX)
|
||||||
&& value.length() > IntegrationProperties.INTEGRATION_PROPERTIES_PREFIX.length()) {
|
&& value.length() > IntegrationProperties.INTEGRATION_PROPERTIES_PREFIX.length()) {
|
||||||
propertiesToMap.add(value);
|
propertiesToMap.add(value);
|
||||||
|
@ -177,6 +180,7 @@ class IntegrationPropertiesEnvironmentPostProcessorTests {
|
||||||
.formatted(IntegrationPropertiesEnvironmentPostProcessor.class.getName()), null);
|
.formatted(IntegrationPropertiesEnvironmentPostProcessor.class.getName()), null);
|
||||||
Map<String, String> mappings = (Map<String, String>) ReflectionTestUtils.getField(propertySource,
|
Map<String, String> mappings = (Map<String, String>) ReflectionTestUtils.getField(propertySource,
|
||||||
"KEYS_MAPPING");
|
"KEYS_MAPPING");
|
||||||
|
assertThat(mappings).isNotNull();
|
||||||
return mappings.keySet();
|
return mappings.keySet();
|
||||||
}
|
}
|
||||||
catch (Exception ex) {
|
catch (Exception ex) {
|
||||||
|
@ -189,8 +193,10 @@ class IntegrationPropertiesEnvironmentPostProcessorTests {
|
||||||
assertThat(origin).isInstanceOf(TextResourceOrigin.class);
|
assertThat(origin).isInstanceOf(TextResourceOrigin.class);
|
||||||
TextResourceOrigin textOrigin = (TextResourceOrigin) origin;
|
TextResourceOrigin textOrigin = (TextResourceOrigin) origin;
|
||||||
assertThat(textOrigin.getResource()).isEqualTo(resource);
|
assertThat(textOrigin.getResource()).isEqualTo(resource);
|
||||||
assertThat(textOrigin.getLocation().getLine()).isEqualTo(line);
|
Location location = textOrigin.getLocation();
|
||||||
assertThat(textOrigin.getLocation().getColumn()).isEqualTo(column);
|
assertThat(location).isNotNull();
|
||||||
|
assertThat(location.getLine()).isEqualTo(line);
|
||||||
|
assertThat(location.getColumn()).isEqualTo(column);
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue