Browse Source

Merge branch '2.7.x' into 3.0.x

Closes gh-36043
pull/37018/head
Andy Wilkinson 3 years ago
parent
commit
2fae5de245
  1. 18
      buildSrc/src/main/java/org/springframework/boot/build/architecture/ArchitectureCheck.java
  2. 17
      spring-boot-project/spring-boot-actuator-autoconfigure/src/test/java/org/springframework/boot/actuate/autoconfigure/cloudfoundry/reactive/ReactiveCloudFoundrySecurityInterceptorTests.java
  3. 10
      spring-boot-project/spring-boot-actuator-autoconfigure/src/test/java/org/springframework/boot/actuate/autoconfigure/cloudfoundry/reactive/ReactiveTokenValidatorTests.java
  4. 28
      spring-boot-project/spring-boot-actuator/src/test/java/org/springframework/boot/actuate/cassandra/CassandraDriverReactiveHealthIndicatorTests.java
  5. 7
      spring-boot-project/spring-boot-actuator/src/test/java/org/springframework/boot/actuate/health/HealthIndicatorReactiveAdapterTests.java
  6. 11
      spring-boot-project/spring-boot-actuator/src/test/java/org/springframework/boot/actuate/health/ReactiveHealthIndicatorImplementationTests.java
  7. 17
      spring-boot-project/spring-boot-actuator/src/test/java/org/springframework/boot/actuate/metrics/r2dbc/ConnectionPoolMetricsTests.java
  8. 6
      spring-boot-project/spring-boot-actuator/src/test/java/org/springframework/boot/actuate/mongo/MongoReactiveHealthIndicatorTests.java
  9. 7
      spring-boot-project/spring-boot-actuator/src/test/java/org/springframework/boot/actuate/neo4j/Neo4jReactiveHealthIndicatorTests.java
  10. 20
      spring-boot-project/spring-boot-actuator/src/test/java/org/springframework/boot/actuate/r2dbc/ConnectionFactoryHealthIndicatorTests.java
  11. 15
      spring-boot-project/spring-boot-actuator/src/test/java/org/springframework/boot/actuate/redis/RedisReactiveHealthIndicatorTests.java
  12. 4
      spring-boot-project/spring-boot-actuator/src/test/java/org/springframework/boot/actuate/web/exchanges/reactive/HttpExchangesWebFilterTests.java
  13. 8
      spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/data/r2dbc/R2dbcRepositoriesAutoConfigurationTests.java
  14. 8
      spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/r2dbc/R2dbcTransactionManagerAutoConfigurationTests.java
  15. 8
      spring-boot-project/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/data/neo4j/DataNeo4jTestReactiveIntegrationTests.java
  16. 5
      spring-boot-project/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/data/r2dbc/DataR2dbcTestIntegrationTests.java
  17. 12
      spring-boot-project/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/data/redis/DataRedisTestReactiveIntegrationTests.java
  18. 3
      spring-boot-project/spring-boot/src/test/java/org/springframework/boot/rsocket/netty/NettyRSocketServerFactoryTests.java
  19. 3
      spring-boot-project/spring-boot/src/test/java/org/springframework/boot/web/embedded/netty/NettyReactiveWebServerFactoryTests.java
  20. 3
      spring-boot-project/spring-boot/src/test/java/org/springframework/boot/web/reactive/result/view/MustacheViewTests.java
  21. 3
      spring-boot-project/spring-boot/src/test/java/org/springframework/boot/web/reactive/server/AbstractReactiveWebServerFactoryTests.java
  22. 5
      spring-boot-tests/spring-boot-smoke-tests/spring-boot-smoke-test-data-r2dbc-flyway/src/test/java/smoketest/data/r2dbc/CityRepositoryTests.java
  23. 5
      spring-boot-tests/spring-boot-smoke-tests/spring-boot-smoke-test-data-r2dbc-liquibase/src/test/java/smoketest/data/r2dbc/CityRepositoryTests.java
  24. 5
      spring-boot-tests/spring-boot-smoke-tests/spring-boot-smoke-test-rsocket/src/test/java/smoketest/rsocket/SampleRSocketApplicationTests.java

18
buildSrc/src/main/java/org/springframework/boot/build/architecture/ArchitectureCheck.java

@ -73,7 +73,9 @@ public abstract class ArchitectureCheck extends DefaultTask { @@ -73,7 +73,9 @@ public abstract class ArchitectureCheck extends DefaultTask {
.importPaths(this.classes.getFiles().stream().map(File::toPath).collect(Collectors.toList()));
List<EvaluationResult> violations = Stream.of(allPackagesShouldBeFreeOfTangles(),
allBeanPostProcessorBeanMethodsShouldBeStaticAndHaveParametersThatWillNotCausePrematureInitialization(),
allBeanFactoryPostProcessorBeanMethodsShouldBeStaticAndHaveNoParameters())
allBeanFactoryPostProcessorBeanMethodsShouldBeStaticAndHaveNoParameters(),
noClassesShouldCallStepVerifierStepVerifyComplete(),
noClassesShouldConfigureDefaultStepVerifierTimeout())
.map((rule) -> rule.evaluate(javaClasses))
.filter(EvaluationResult::hasViolation)
.collect(Collectors.toList());
@ -162,6 +164,20 @@ public abstract class ArchitectureCheck extends DefaultTask { @@ -162,6 +164,20 @@ public abstract class ArchitectureCheck extends DefaultTask {
};
}
private ArchRule noClassesShouldCallStepVerifierStepVerifyComplete() {
return ArchRuleDefinition.noClasses()
.should()
.callMethod("reactor.test.StepVerifier$Step", "verifyComplete")
.because("it can block indefinitely and expectComplete().verify(Duration) should be used instead");
}
private ArchRule noClassesShouldConfigureDefaultStepVerifierTimeout() {
return ArchRuleDefinition.noClasses()
.should()
.callMethod("reactor.test.StepVerifier", "setDefaultTimeout", "java.time.Duration")
.because("expectComplete().verify(Duration) should be used instead");
}
public void setClasses(FileCollection classes) {
this.classes = classes;
}

17
spring-boot-project/spring-boot-actuator-autoconfigure/src/test/java/org/springframework/boot/actuate/autoconfigure/cloudfoundry/reactive/ReactiveCloudFoundrySecurityInterceptorTests.java

@ -16,6 +16,7 @@ @@ -16,6 +16,7 @@
package org.springframework.boot.actuate.autoconfigure.cloudfoundry.reactive;
import java.time.Duration;
import java.util.Base64;
import org.junit.jupiter.api.BeforeEach;
@ -67,7 +68,8 @@ class ReactiveCloudFoundrySecurityInterceptorTests { @@ -67,7 +68,8 @@ class ReactiveCloudFoundrySecurityInterceptorTests {
.build());
StepVerifier.create(this.interceptor.preHandle(request, "/a"))
.consumeNextWith((response) -> assertThat(response.getStatus()).isEqualTo(HttpStatus.OK))
.verifyComplete();
.expectComplete()
.verify(Duration.ofSeconds(30));
}
@Test
@ -76,7 +78,8 @@ class ReactiveCloudFoundrySecurityInterceptorTests { @@ -76,7 +78,8 @@ class ReactiveCloudFoundrySecurityInterceptorTests {
StepVerifier.create(this.interceptor.preHandle(request, "/a"))
.consumeNextWith(
(response) -> assertThat(response.getStatus()).isEqualTo(Reason.MISSING_AUTHORIZATION.getStatus()))
.verifyComplete();
.expectComplete()
.verify(Duration.ofSeconds(30));
}
@Test
@ -86,7 +89,8 @@ class ReactiveCloudFoundrySecurityInterceptorTests { @@ -86,7 +89,8 @@ class ReactiveCloudFoundrySecurityInterceptorTests {
StepVerifier.create(this.interceptor.preHandle(request, "/a"))
.consumeNextWith(
(response) -> assertThat(response.getStatus()).isEqualTo(Reason.MISSING_AUTHORIZATION.getStatus()))
.verifyComplete();
.expectComplete()
.verify(Duration.ofSeconds(30));
}
@Test
@ -122,7 +126,8 @@ class ReactiveCloudFoundrySecurityInterceptorTests { @@ -122,7 +126,8 @@ class ReactiveCloudFoundrySecurityInterceptorTests {
.build());
StepVerifier.create(this.interceptor.preHandle(request, "/a"))
.consumeNextWith((response) -> assertThat(response.getStatus()).isEqualTo(Reason.ACCESS_DENIED.getStatus()))
.verifyComplete();
.expectComplete()
.verify(Duration.ofSeconds(30));
}
@Test
@ -136,7 +141,7 @@ class ReactiveCloudFoundrySecurityInterceptorTests { @@ -136,7 +141,7 @@ class ReactiveCloudFoundrySecurityInterceptorTests {
StepVerifier.create(this.interceptor.preHandle(exchange, "/a")).consumeNextWith((response) -> {
assertThat(response.getStatus()).isEqualTo(HttpStatus.OK);
assertThat((AccessLevel) exchange.getAttribute("cloudFoundryAccessLevel")).isEqualTo(AccessLevel.FULL);
}).verifyComplete();
}).expectComplete().verify(Duration.ofSeconds(30));
}
@Test
@ -152,7 +157,7 @@ class ReactiveCloudFoundrySecurityInterceptorTests { @@ -152,7 +157,7 @@ class ReactiveCloudFoundrySecurityInterceptorTests {
assertThat(response.getStatus()).isEqualTo(HttpStatus.OK);
assertThat((AccessLevel) exchange.getAttribute("cloudFoundryAccessLevel"))
.isEqualTo(AccessLevel.RESTRICTED);
}).verifyComplete();
}).expectComplete().verify(Duration.ofSeconds(30));
}
private String mockAccessToken() {

10
spring-boot-project/spring-boot-actuator-autoconfigure/src/test/java/org/springframework/boot/actuate/autoconfigure/cloudfoundry/reactive/ReactiveTokenValidatorTests.java

@ -25,6 +25,7 @@ import java.security.PrivateKey; @@ -25,6 +25,7 @@ import java.security.PrivateKey;
import java.security.Signature;
import java.security.spec.InvalidKeySpecException;
import java.security.spec.PKCS8EncodedKeySpec;
import java.time.Duration;
import java.util.Base64;
import java.util.Collections;
import java.util.Map;
@ -125,7 +126,8 @@ class ReactiveTokenValidatorTests { @@ -125,7 +126,8 @@ class ReactiveTokenValidatorTests {
String claims = "{\"exp\": 2147483647, \"iss\": \"http://localhost:8080/uaa/oauth/token\", \"scope\": [\"actuator.read\"]}";
StepVerifier
.create(this.tokenValidator.validate(new Token(getSignedToken(header.getBytes(), claims.getBytes()))))
.verifyComplete();
.expectComplete()
.verify(Duration.ofSeconds(30));
assertThat(this.tokenValidator).hasFieldOrPropertyWithValue("cachedTokenKeys", VALID_KEYS);
fetchTokenKeys.assertWasSubscribed();
}
@ -139,7 +141,8 @@ class ReactiveTokenValidatorTests { @@ -139,7 +141,8 @@ class ReactiveTokenValidatorTests {
String claims = "{\"exp\": 2147483647, \"iss\": \"http://localhost:8080/uaa/oauth/token\", \"scope\": [\"actuator.read\"]}";
StepVerifier
.create(this.tokenValidator.validate(new Token(getSignedToken(header.getBytes(), claims.getBytes()))))
.verifyComplete();
.expectComplete()
.verify(Duration.ofSeconds(30));
assertThat(this.tokenValidator).hasFieldOrPropertyWithValue("cachedTokenKeys", VALID_KEYS);
fetchTokenKeys.assertWasSubscribed();
}
@ -171,7 +174,8 @@ class ReactiveTokenValidatorTests { @@ -171,7 +174,8 @@ class ReactiveTokenValidatorTests {
String claims = "{\"exp\": 2147483647, \"iss\": \"http://localhost:8080/uaa/oauth/token\", \"scope\": [\"actuator.read\"]}";
StepVerifier
.create(this.tokenValidator.validate(new Token(getSignedToken(header.getBytes(), claims.getBytes()))))
.verifyComplete();
.expectComplete()
.verify(Duration.ofSeconds(30));
fetchTokenKeys.assertWasNotSubscribed();
}

28
spring-boot-project/spring-boot-actuator/src/test/java/org/springframework/boot/actuate/cassandra/CassandraDriverReactiveHealthIndicatorTests.java

@ -16,6 +16,7 @@ @@ -16,6 +16,7 @@
package org.springframework.boot.actuate.cassandra;
import java.time.Duration;
import java.util.ArrayList;
import java.util.Collections;
import java.util.HashMap;
@ -61,7 +62,8 @@ class CassandraDriverReactiveHealthIndicatorTests { @@ -61,7 +62,8 @@ class CassandraDriverReactiveHealthIndicatorTests {
Mono<Health> health = healthIndicator.health();
StepVerifier.create(health)
.consumeNextWith((h) -> assertThat(h.getStatus()).isEqualTo(Status.UP))
.verifyComplete();
.expectComplete()
.verify(Duration.ofSeconds(30));
}
@Test
@ -71,7 +73,8 @@ class CassandraDriverReactiveHealthIndicatorTests { @@ -71,7 +73,8 @@ class CassandraDriverReactiveHealthIndicatorTests {
Mono<Health> health = healthIndicator.health();
StepVerifier.create(health)
.consumeNextWith((h) -> assertThat(h.getStatus()).isEqualTo(Status.DOWN))
.verifyComplete();
.expectComplete()
.verify(Duration.ofSeconds(30));
}
@Test
@ -81,7 +84,8 @@ class CassandraDriverReactiveHealthIndicatorTests { @@ -81,7 +84,8 @@ class CassandraDriverReactiveHealthIndicatorTests {
Mono<Health> health = healthIndicator.health();
StepVerifier.create(health)
.consumeNextWith((h) -> assertThat(h.getStatus()).isEqualTo(Status.DOWN))
.verifyComplete();
.expectComplete()
.verify(Duration.ofSeconds(30));
}
@Test
@ -91,7 +95,8 @@ class CassandraDriverReactiveHealthIndicatorTests { @@ -91,7 +95,8 @@ class CassandraDriverReactiveHealthIndicatorTests {
Mono<Health> health = healthIndicator.health();
StepVerifier.create(health)
.consumeNextWith((h) -> assertThat(h.getStatus()).isEqualTo(Status.DOWN))
.verifyComplete();
.expectComplete()
.verify(Duration.ofSeconds(30));
}
@Test
@ -101,7 +106,8 @@ class CassandraDriverReactiveHealthIndicatorTests { @@ -101,7 +106,8 @@ class CassandraDriverReactiveHealthIndicatorTests {
Mono<Health> health = healthIndicator.health();
StepVerifier.create(health)
.consumeNextWith((h) -> assertThat(h.getStatus()).isEqualTo(Status.UP))
.verifyComplete();
.expectComplete()
.verify(Duration.ofSeconds(30));
}
@Test
@ -111,7 +117,8 @@ class CassandraDriverReactiveHealthIndicatorTests { @@ -111,7 +117,8 @@ class CassandraDriverReactiveHealthIndicatorTests {
Mono<Health> health = healthIndicator.health();
StepVerifier.create(health)
.consumeNextWith((h) -> assertThat(h.getStatus()).isEqualTo(Status.UP))
.verifyComplete();
.expectComplete()
.verify(Duration.ofSeconds(30));
}
@Test
@ -121,7 +128,8 @@ class CassandraDriverReactiveHealthIndicatorTests { @@ -121,7 +128,8 @@ class CassandraDriverReactiveHealthIndicatorTests {
Mono<Health> health = healthIndicator.health();
StepVerifier.create(health)
.consumeNextWith((h) -> assertThat(h.getStatus()).isEqualTo(Status.UP))
.verifyComplete();
.expectComplete()
.verify(Duration.ofSeconds(30));
}
@Test
@ -139,7 +147,7 @@ class CassandraDriverReactiveHealthIndicatorTests { @@ -139,7 +147,7 @@ class CassandraDriverReactiveHealthIndicatorTests {
assertThat(h.getStatus()).isEqualTo(Status.UP);
assertThat(h.getDetails()).containsOnlyKeys("version");
assertThat(h.getDetails()).containsEntry("version", Version.V4_0_0);
}).verifyComplete();
}).expectComplete().verify(Duration.ofSeconds(30));
}
@Test
@ -150,7 +158,7 @@ class CassandraDriverReactiveHealthIndicatorTests { @@ -150,7 +158,7 @@ class CassandraDriverReactiveHealthIndicatorTests {
StepVerifier.create(health).consumeNextWith((h) -> {
assertThat(h.getStatus()).isEqualTo(Status.UP);
assertThat(h.getDetails()).doesNotContainKey("version");
}).verifyComplete();
}).expectComplete().verify(Duration.ofSeconds(30));
}
@Test
@ -165,7 +173,7 @@ class CassandraDriverReactiveHealthIndicatorTests { @@ -165,7 +173,7 @@ class CassandraDriverReactiveHealthIndicatorTests {
assertThat(h.getDetails()).containsOnlyKeys("error");
assertThat(h.getDetails()).containsEntry("error",
DriverTimeoutException.class.getName() + ": Test Exception");
}).verifyComplete();
}).expectComplete().verify(Duration.ofSeconds(30));
}
private CqlSession mockCqlSessionWithNodeState(NodeState... nodeStates) {

7
spring-boot-project/spring-boot-actuator/src/test/java/org/springframework/boot/actuate/health/HealthIndicatorReactiveAdapterTests.java

@ -37,7 +37,7 @@ class HealthIndicatorReactiveAdapterTests { @@ -37,7 +37,7 @@ class HealthIndicatorReactiveAdapterTests {
HealthIndicatorReactiveAdapter adapter = new HealthIndicatorReactiveAdapter(delegate);
Health status = Health.up().build();
given(delegate.health()).willReturn(status);
StepVerifier.create(adapter.health()).expectNext(status).verifyComplete();
StepVerifier.create(adapter.health()).expectNext(status).expectComplete().verify(Duration.ofSeconds(30));
}
@Test
@ -55,7 +55,10 @@ class HealthIndicatorReactiveAdapterTests { @@ -55,7 +55,10 @@ class HealthIndicatorReactiveAdapterTests {
.status(Thread.currentThread().getName().equals(currentThread) ? Status.DOWN : Status.UP)
.build();
HealthIndicatorReactiveAdapter adapter = new HealthIndicatorReactiveAdapter(delegate);
StepVerifier.create(adapter.health()).expectNext(Health.status(Status.UP).build()).verifyComplete();
StepVerifier.create(adapter.health())
.expectNext(Health.status(Status.UP).build())
.expectComplete()
.verify(Duration.ofSeconds(30));
}
}

11
spring-boot-project/spring-boot-actuator/src/test/java/org/springframework/boot/actuate/health/ReactiveHealthIndicatorImplementationTests.java

@ -16,6 +16,8 @@ @@ -16,6 +16,8 @@
package org.springframework.boot.actuate.health;
import java.time.Duration;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith;
import reactor.core.publisher.Mono;
@ -40,7 +42,8 @@ class ReactiveHealthIndicatorImplementationTests { @@ -40,7 +42,8 @@ class ReactiveHealthIndicatorImplementationTests {
void healthUp(CapturedOutput output) {
StepVerifier.create(new SimpleReactiveHealthIndicator().health())
.consumeNextWith((health) -> assertThat(health).isEqualTo(Health.up().build()))
.verifyComplete();
.expectComplete()
.verify(Duration.ofSeconds(30));
assertThat(output).doesNotContain("Health check failed for simple");
}
@ -49,7 +52,8 @@ class ReactiveHealthIndicatorImplementationTests { @@ -49,7 +52,8 @@ class ReactiveHealthIndicatorImplementationTests {
StepVerifier.create(new CustomErrorMessageReactiveHealthIndicator().health())
.consumeNextWith(
(health) -> assertThat(health).isEqualTo(Health.down(new UnsupportedOperationException()).build()))
.verifyComplete();
.expectComplete()
.verify(Duration.ofSeconds(30));
assertThat(output).contains("Health check failed for custom");
}
@ -57,7 +61,8 @@ class ReactiveHealthIndicatorImplementationTests { @@ -57,7 +61,8 @@ class ReactiveHealthIndicatorImplementationTests {
void healthDownWithCustomErrorMessageFunction(CapturedOutput output) {
StepVerifier.create(new CustomErrorMessageFunctionReactiveHealthIndicator().health())
.consumeNextWith((health) -> assertThat(health).isEqualTo(Health.down(new RuntimeException()).build()))
.verifyComplete();
.expectComplete()
.verify(Duration.ofSeconds(30));
assertThat(output).contains("Health check failed with RuntimeException");
}

17
spring-boot-project/spring-boot-actuator/src/test/java/org/springframework/boot/actuate/metrics/r2dbc/ConnectionPoolMetricsTests.java

@ -1,5 +1,5 @@ @@ -1,5 +1,5 @@
/*
* Copyright 2012-2021 the original author or authors.
* Copyright 2012-2023 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@ -16,6 +16,7 @@ @@ -16,6 +16,7 @@
package org.springframework.boot.actuate.metrics.r2dbc;
import java.time.Duration;
import java.util.Collections;
import java.util.UUID;
@ -59,7 +60,7 @@ class ConnectionPoolMetricsTests { @@ -59,7 +60,7 @@ class ConnectionPoolMetricsTests {
@AfterEach
void close() {
if (this.connectionFactory != null) {
StepVerifier.create(this.connectionFactory.close()).verifyComplete();
StepVerifier.create(this.connectionFactory.close()).expectComplete().verify(Duration.ofSeconds(30));
}
}
@ -72,8 +73,16 @@ class ConnectionPoolMetricsTests { @@ -72,8 +73,16 @@ class ConnectionPoolMetricsTests {
Tags.of(testTag, regionTag));
metrics.bindTo(registry);
// acquire two connections
connectionPool.create().as(StepVerifier::create).expectNextCount(1).verifyComplete();
connectionPool.create().as(StepVerifier::create).expectNextCount(1).verifyComplete();
connectionPool.create()
.as(StepVerifier::create)
.expectNextCount(1)
.expectComplete()
.verify(Duration.ofSeconds(30));
connectionPool.create()
.as(StepVerifier::create)
.expectNextCount(1)
.expectComplete()
.verify(Duration.ofSeconds(30));
assertGauge(registry, "r2dbc.pool.acquired", 2);
assertGauge(registry, "r2dbc.pool.allocated", 3);
assertGauge(registry, "r2dbc.pool.idle", 1);

6
spring-boot-project/spring-boot-actuator/src/test/java/org/springframework/boot/actuate/mongo/MongoReactiveHealthIndicatorTests.java

@ -16,6 +16,8 @@ @@ -16,6 +16,8 @@
package org.springframework.boot.actuate.mongo;
import java.time.Duration;
import com.mongodb.MongoException;
import org.bson.Document;
import org.junit.jupiter.api.Test;
@ -51,7 +53,7 @@ class MongoReactiveHealthIndicatorTests { @@ -51,7 +53,7 @@ class MongoReactiveHealthIndicatorTests {
assertThat(h.getStatus()).isEqualTo(Status.UP);
assertThat(h.getDetails()).containsOnlyKeys("maxWireVersion");
assertThat(h.getDetails()).containsEntry("maxWireVersion", 10);
}).verifyComplete();
}).expectComplete().verify(Duration.ofSeconds(30));
}
@Test
@ -66,7 +68,7 @@ class MongoReactiveHealthIndicatorTests { @@ -66,7 +68,7 @@ class MongoReactiveHealthIndicatorTests {
assertThat(h.getStatus()).isEqualTo(Status.DOWN);
assertThat(h.getDetails()).containsOnlyKeys("error");
assertThat(h.getDetails()).containsEntry("error", MongoException.class.getName() + ": Connection failed");
}).verifyComplete();
}).expectComplete().verify(Duration.ofSeconds(30));
}
}

7
spring-boot-project/spring-boot-actuator/src/test/java/org/springframework/boot/actuate/neo4j/Neo4jReactiveHealthIndicatorTests.java

@ -16,6 +16,7 @@ @@ -16,6 +16,7 @@
package org.springframework.boot.actuate.neo4j;
import java.time.Duration;
import java.util.concurrent.atomic.AtomicInteger;
import org.junit.jupiter.api.Test;
@ -61,7 +62,7 @@ class Neo4jReactiveHealthIndicatorTests { @@ -61,7 +62,7 @@ class Neo4jReactiveHealthIndicatorTests {
assertThat(health.getStatus()).isEqualTo(Status.UP);
assertThat(health.getDetails()).containsEntry("server", "4711@My Home");
assertThat(health.getDetails()).containsEntry("edition", "ultimate collectors edition");
}).verifyComplete();
}).expectComplete().verify(Duration.ofSeconds(30));
}
@Test
@ -83,7 +84,7 @@ class Neo4jReactiveHealthIndicatorTests { @@ -83,7 +84,7 @@ class Neo4jReactiveHealthIndicatorTests {
assertThat(health.getStatus()).isEqualTo(Status.UP);
assertThat(health.getDetails()).containsEntry("server", "4711@My Home");
assertThat(health.getDetails()).containsEntry("edition", "some edition");
}).verifyComplete();
}).expectComplete().verify(Duration.ofSeconds(30));
then(session).should(times(2)).close();
}
@ -96,7 +97,7 @@ class Neo4jReactiveHealthIndicatorTests { @@ -96,7 +97,7 @@ class Neo4jReactiveHealthIndicatorTests {
healthIndicator.health().as(StepVerifier::create).consumeNextWith((health) -> {
assertThat(health.getStatus()).isEqualTo(Status.DOWN);
assertThat(health.getDetails()).containsKeys("error");
}).verifyComplete();
}).expectComplete().verify(Duration.ofSeconds(30));
}
private ReactiveResult mockStatementResult(ResultSummary resultSummary, String version, String edition) {

20
spring-boot-project/spring-boot-actuator/src/test/java/org/springframework/boot/actuate/r2dbc/ConnectionFactoryHealthIndicatorTests.java

@ -16,6 +16,7 @@ @@ -16,6 +16,7 @@
package org.springframework.boot.actuate.r2dbc;
import java.time.Duration;
import java.util.Collections;
import java.util.UUID;
@ -56,10 +57,10 @@ class ConnectionFactoryHealthIndicatorTests { @@ -56,10 +57,10 @@ class ConnectionFactoryHealthIndicatorTests {
assertThat(actual.getStatus()).isEqualTo(Status.UP);
assertThat(actual.getDetails()).containsOnly(entry("database", "H2"),
entry("validationQuery", "validate(REMOTE)"));
}).verifyComplete();
}).expectComplete().verify(Duration.ofSeconds(30));
}
finally {
StepVerifier.create(connectionFactory.close()).verifyComplete();
StepVerifier.create(connectionFactory.close()).expectComplete().verify(Duration.ofSeconds(30));
}
}
@ -74,7 +75,7 @@ class ConnectionFactoryHealthIndicatorTests { @@ -74,7 +75,7 @@ class ConnectionFactoryHealthIndicatorTests {
assertThat(actual.getStatus()).isEqualTo(Status.DOWN);
assertThat(actual.getDetails()).containsOnly(entry("database", "mock"),
entry("validationQuery", "validate(REMOTE)"), entry("error", "java.lang.RuntimeException: test"));
}).verifyComplete();
}).expectComplete().verify(Duration.ofSeconds(30));
}
@Test
@ -90,7 +91,7 @@ class ConnectionFactoryHealthIndicatorTests { @@ -90,7 +91,7 @@ class ConnectionFactoryHealthIndicatorTests {
assertThat(actual.getStatus()).isEqualTo(Status.DOWN);
assertThat(actual.getDetails()).containsOnly(entry("database", "mock"),
entry("validationQuery", "validate(REMOTE)"));
}).verifyComplete();
}).expectComplete().verify(Duration.ofSeconds(30));
}
@Test
@ -104,17 +105,18 @@ class ConnectionFactoryHealthIndicatorTests { @@ -104,17 +105,18 @@ class ConnectionFactoryHealthIndicatorTests {
.flatMap(Result::getRowsUpdated)
.thenMany(it.close()))
.as(StepVerifier::create)
.verifyComplete();
.expectComplete()
.verify(Duration.ofSeconds(30));
ReactiveHealthIndicator healthIndicator = new ConnectionFactoryHealthIndicator(connectionFactory,
customValidationQuery);
healthIndicator.health().as(StepVerifier::create).assertNext((actual) -> {
assertThat(actual.getStatus()).isEqualTo(Status.UP);
assertThat(actual.getDetails()).containsOnly(entry("database", "H2"), entry("result", 0L),
entry("validationQuery", customValidationQuery));
}).verifyComplete();
}).expectComplete().verify(Duration.ofSeconds(30));
}
finally {
StepVerifier.create(connectionFactory.close()).verifyComplete();
StepVerifier.create(connectionFactory.close()).expectComplete().verify(Duration.ofSeconds(30));
}
}
@ -131,10 +133,10 @@ class ConnectionFactoryHealthIndicatorTests { @@ -131,10 +133,10 @@ class ConnectionFactoryHealthIndicatorTests {
assertThat(actual.getDetails()).contains(entry("database", "H2"),
entry("validationQuery", invalidValidationQuery));
assertThat(actual.getDetails()).containsOnlyKeys("database", "error", "validationQuery");
}).verifyComplete();
}).expectComplete().verify(Duration.ofSeconds(30));
}
finally {
StepVerifier.create(connectionFactory.close()).verifyComplete();
StepVerifier.create(connectionFactory.close()).expectComplete().verify(Duration.ofSeconds(30));
}
}

15
spring-boot-project/spring-boot-actuator/src/test/java/org/springframework/boot/actuate/redis/RedisReactiveHealthIndicatorTests.java

@ -16,6 +16,7 @@ @@ -16,6 +16,7 @@
package org.springframework.boot.actuate.redis;
import java.time.Duration;
import java.util.Properties;
import io.lettuce.core.RedisConnectionException;
@ -63,7 +64,7 @@ class RedisReactiveHealthIndicatorTests { @@ -63,7 +64,7 @@ class RedisReactiveHealthIndicatorTests {
assertThat(h.getStatus()).isEqualTo(Status.UP);
assertThat(h.getDetails()).containsOnlyKeys("version");
assertThat(h.getDetails()).containsEntry("version", "2.8.9");
}).verifyComplete();
}).expectComplete().verify(Duration.ofSeconds(30));
then(redisConnection).should().closeLater();
}
@ -77,7 +78,7 @@ class RedisReactiveHealthIndicatorTests { @@ -77,7 +78,7 @@ class RedisReactiveHealthIndicatorTests {
assertThat(h.getDetails()).containsEntry("cluster_size", 4L);
assertThat(h.getDetails()).containsEntry("slots_up", 4L);
assertThat(h.getDetails()).containsEntry("slots_fail", 0L);
}).verifyComplete();
}).expectComplete().verify(Duration.ofSeconds(30));
then(redisConnectionFactory.getReactiveConnection()).should().closeLater();
}
@ -91,7 +92,7 @@ class RedisReactiveHealthIndicatorTests { @@ -91,7 +92,7 @@ class RedisReactiveHealthIndicatorTests {
assertThat(h.getDetails()).containsEntry("cluster_size", 4L);
assertThat(h.getDetails()).containsEntry("slots_up", 4L);
assertThat(h.getDetails()).containsEntry("slots_fail", 0L);
}).verifyComplete();
}).expectComplete().verify(Duration.ofSeconds(30));
}
@Test
@ -103,7 +104,7 @@ class RedisReactiveHealthIndicatorTests { @@ -103,7 +104,7 @@ class RedisReactiveHealthIndicatorTests {
assertThat(h.getStatus()).isEqualTo(Status.DOWN);
assertThat(h.getDetails()).containsEntry("slots_up", 3L);
assertThat(h.getDetails()).containsEntry("slots_fail", 1L);
}).verifyComplete();
}).expectComplete().verify(Duration.ofSeconds(30));
}
@Test
@ -116,7 +117,8 @@ class RedisReactiveHealthIndicatorTests { @@ -116,7 +117,8 @@ class RedisReactiveHealthIndicatorTests {
Mono<Health> health = healthIndicator.health();
StepVerifier.create(health)
.consumeNextWith((h) -> assertThat(h.getStatus()).isEqualTo(Status.DOWN))
.verifyComplete();
.expectComplete()
.verify(Duration.ofSeconds(30));
then(redisConnection).should().closeLater();
}
@ -129,7 +131,8 @@ class RedisReactiveHealthIndicatorTests { @@ -129,7 +131,8 @@ class RedisReactiveHealthIndicatorTests {
Mono<Health> health = healthIndicator.health();
StepVerifier.create(health)
.consumeNextWith((h) -> assertThat(h.getStatus()).isEqualTo(Status.DOWN))
.verifyComplete();
.expectComplete()
.verify(Duration.ofSeconds(30));
}
private RedisReactiveHealthIndicator createHealthIndicator(ReactiveRedisConnection redisConnection,

4
spring-boot-project/spring-boot-actuator/src/test/java/org/springframework/boot/actuate/web/exchanges/reactive/HttpExchangesWebFilterTests.java

@ -17,6 +17,7 @@ @@ -17,6 +17,7 @@
package org.springframework.boot.actuate.web.exchanges.reactive;
import java.security.Principal;
import java.time.Duration;
import java.util.EnumSet;
import org.junit.jupiter.api.Test;
@ -102,7 +103,8 @@ class HttpExchangesWebFilterTests { @@ -102,7 +103,8 @@ class HttpExchangesWebFilterTests {
private void executeFilter(ServerWebExchange exchange, WebFilterChain chain) {
StepVerifier
.create(this.filter.filter(exchange, chain).then(Mono.defer(() -> exchange.getResponse().setComplete())))
.verifyComplete();
.expectComplete()
.verify(Duration.ofSeconds(30));
}
}

8
spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/data/r2dbc/R2dbcRepositoriesAutoConfigurationTests.java

@ -16,6 +16,8 @@ @@ -16,6 +16,8 @@
package org.springframework.boot.autoconfigure.data.r2dbc;
import java.time.Duration;
import io.r2dbc.spi.ConnectionFactory;
import org.junit.jupiter.api.Test;
import reactor.test.StepVerifier;
@ -80,7 +82,8 @@ class R2dbcRepositoriesAutoConfigurationTests { @@ -80,7 +82,8 @@ class R2dbcRepositoriesAutoConfigurationTests {
.findById(2000L)
.as(StepVerifier::create)
.expectNextCount(1)
.verifyComplete();
.expectComplete()
.verify(Duration.ofSeconds(30));
});
}
@ -103,7 +106,8 @@ class R2dbcRepositoriesAutoConfigurationTests { @@ -103,7 +106,8 @@ class R2dbcRepositoriesAutoConfigurationTests {
.findById(2000L)
.as(StepVerifier::create)
.expectNextCount(1)
.verifyComplete();
.expectComplete()
.verify(Duration.ofSeconds(30));
});
}

8
spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/r2dbc/R2dbcTransactionManagerAutoConfigurationTests.java

@ -16,6 +16,8 @@ @@ -16,6 +16,8 @@
package org.springframework.boot.autoconfigure.r2dbc;
import java.time.Duration;
import io.r2dbc.spi.Connection;
import io.r2dbc.spi.ConnectionFactory;
import io.r2dbc.spi.TransactionDefinition;
@ -67,7 +69,11 @@ class R2dbcTransactionManagerAutoConfigurationTests { @@ -67,7 +69,11 @@ class R2dbcTransactionManagerAutoConfigurationTests {
this.contextRunner.withUserConfiguration(SingleConnectionFactoryConfiguration.class, BaseConfiguration.class)
.run((context) -> {
TransactionalService bean = context.getBean(TransactionalService.class);
bean.isTransactionActive().as(StepVerifier::create).expectNext(true).verifyComplete();
bean.isTransactionActive()
.as(StepVerifier::create)
.expectNext(true)
.expectComplete()
.verify(Duration.ofSeconds(30));
});
}

8
spring-boot-project/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/data/neo4j/DataNeo4jTestReactiveIntegrationTests.java

@ -79,8 +79,12 @@ class DataNeo4jTestReactiveIntegrationTests { @@ -79,8 +79,12 @@ class DataNeo4jTestReactiveIntegrationTests {
.flatMap(this.exampleRepository::save)
.as(StepVerifier::create)
.expectNextCount(1)
.verifyComplete();
StepVerifier.create(this.neo4jTemplate.count(ExampleGraph.class)).expectNext(1L).verifyComplete();
.expectComplete()
.verify(Duration.ofSeconds(30));
StepVerifier.create(this.neo4jTemplate.count(ExampleGraph.class))
.expectNext(1L)
.expectComplete()
.verify(Duration.ofSeconds(30));
}
@Test

5
spring-boot-project/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/data/r2dbc/DataR2dbcTestIntegrationTests.java

@ -1,5 +1,5 @@ @@ -1,5 +1,5 @@
/*
* Copyright 2012-2022 the original author or authors.
* Copyright 2012-2023 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@ -16,6 +16,7 @@ @@ -16,6 +16,7 @@
package org.springframework.boot.test.autoconfigure.data.r2dbc;
import java.time.Duration;
import java.util.Map;
import io.r2dbc.spi.ConnectionFactory;
@ -50,7 +51,7 @@ class DataR2dbcTestIntegrationTests { @@ -50,7 +51,7 @@ class DataR2dbcTestIntegrationTests {
@Test
void testDatabaseClient() {
Flux<Map<String, Object>> all = this.databaseClient.sql("SELECT * FROM example").fetch().all();
StepVerifier.create(all).expectNextCount(1).verifyComplete();
StepVerifier.create(all).expectNextCount(1).expectComplete().verify(Duration.ofSeconds(30));
}
@Test

12
spring-boot-project/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/data/redis/DataRedisTestReactiveIntegrationTests.java

@ -16,6 +16,7 @@ @@ -16,6 +16,7 @@
package org.springframework.boot.test.autoconfigure.data.redis;
import java.time.Duration;
import java.util.UUID;
import org.junit.jupiter.api.Test;
@ -62,11 +63,16 @@ class DataRedisTestReactiveIntegrationTests { @@ -62,11 +63,16 @@ class DataRedisTestReactiveIntegrationTests {
String id = UUID.randomUUID().toString();
StepVerifier.create(this.operations.opsForValue().set(id, "Hello World"))
.expectNext(Boolean.TRUE)
.verifyComplete();
StepVerifier.create(this.operations.opsForValue().get(id)).expectNext("Hello World").verifyComplete();
.expectComplete()
.verify(Duration.ofSeconds(30));
StepVerifier.create(this.operations.opsForValue().get(id))
.expectNext("Hello World")
.expectComplete()
.verify(Duration.ofSeconds(30));
StepVerifier.create(this.operations.execute((action) -> action.serverCommands().flushDb()))
.expectNext("OK")
.verifyComplete();
.expectComplete()
.verify(Duration.ofSeconds(30));
}
@Test

3
spring-boot-project/spring-boot/src/test/java/org/springframework/boot/rsocket/netty/NettyRSocketServerFactoryTests.java

@ -18,6 +18,7 @@ package org.springframework.boot.rsocket.netty; @@ -18,6 +18,7 @@ package org.springframework.boot.rsocket.netty;
import java.net.InetSocketAddress;
import java.nio.channels.ClosedChannelException;
import java.time.Duration;
import java.util.Arrays;
import java.util.concurrent.Callable;
@ -194,7 +195,7 @@ class NettyRSocketServerFactoryTests { @@ -194,7 +195,7 @@ class NettyRSocketServerFactoryTests {
private void checkEchoRequest() {
String payload = "test payload";
Mono<String> response = this.requester.route("test").data(payload).retrieveMono(String.class);
StepVerifier.create(response).expectNext(payload).verifyComplete();
StepVerifier.create(response).expectNext(payload).expectComplete().verify(Duration.ofSeconds(30));
}
private void testBasicSslWithKeyStore(String keyStore, String keyPassword, Transport transport) {

3
spring-boot-project/spring-boot/src/test/java/org/springframework/boot/web/embedded/netty/NettyReactiveWebServerFactoryTests.java

@ -109,8 +109,7 @@ class NettyReactiveWebServerFactoryTests extends AbstractReactiveWebServerFactor @@ -109,8 +109,7 @@ class NettyReactiveWebServerFactoryTests extends AbstractReactiveWebServerFactor
@Test
void whenSslIsConfiguredWithAValidAliasARequestSucceeds() {
Mono<String> result = testSslWithAlias("test-alias");
StepVerifier.setDefaultTimeout(Duration.ofSeconds(30));
StepVerifier.create(result).expectNext("Hello World").verifyComplete();
StepVerifier.create(result).expectNext("Hello World").expectComplete().verify(Duration.ofSeconds(30));
}
@Test

3
spring-boot-project/spring-boot/src/test/java/org/springframework/boot/web/reactive/result/view/MustacheViewTests.java

@ -55,7 +55,8 @@ class MustacheViewTests { @@ -55,7 +55,8 @@ class MustacheViewTests {
.block(Duration.ofSeconds(30));
StepVerifier.create(exchange.getResponse().getBodyAsString())
.assertNext((body) -> assertThat(body).isEqualToIgnoringWhitespace("Hello Spring"))
.verifyComplete();
.expectComplete()
.verify(Duration.ofSeconds(30));
}
}

3
spring-boot-project/spring-boot/src/test/java/org/springframework/boot/web/reactive/server/AbstractReactiveWebServerFactoryTests.java

@ -193,8 +193,7 @@ public abstract class AbstractReactiveWebServerFactoryTests { @@ -193,8 +193,7 @@ public abstract class AbstractReactiveWebServerFactoryTests {
.retrieve()
.bodyToMono(String.class);
StepVerifier.setDefaultTimeout(Duration.ofSeconds(30));
StepVerifier.create(result).expectNext("Hello World").verifyComplete();
StepVerifier.create(result).expectNext("Hello World").expectComplete().verify(Duration.ofSeconds(30));
}
@Test

5
spring-boot-tests/spring-boot-smoke-tests/spring-boot-smoke-test-data-r2dbc-flyway/src/test/java/smoketest/data/r2dbc/CityRepositoryTests.java

@ -16,6 +16,8 @@ @@ -16,6 +16,8 @@
package smoketest.data.r2dbc;
import java.time.Duration;
import org.junit.jupiter.api.Test;
import org.testcontainers.containers.PostgreSQLContainer;
import org.testcontainers.junit.jupiter.Container;
@ -60,7 +62,8 @@ class CityRepositoryTests { @@ -60,7 +62,8 @@ class CityRepositoryTests {
void databaseHasBeenInitialized() {
StepVerifier.create(this.repository.findByState("DC").filter((city) -> city.getName().equals("Washington")))
.consumeNextWith((city) -> assertThat(city.getId()).isNotNull())
.verifyComplete();
.expectComplete()
.verify(Duration.ofSeconds(30));
}
private static String r2dbcUrl() {

5
spring-boot-tests/spring-boot-smoke-tests/spring-boot-smoke-test-data-r2dbc-liquibase/src/test/java/smoketest/data/r2dbc/CityRepositoryTests.java

@ -16,6 +16,8 @@ @@ -16,6 +16,8 @@
package smoketest.data.r2dbc;
import java.time.Duration;
import org.junit.jupiter.api.Test;
import org.testcontainers.containers.PostgreSQLContainer;
import org.testcontainers.junit.jupiter.Container;
@ -60,7 +62,8 @@ class CityRepositoryTests { @@ -60,7 +62,8 @@ class CityRepositoryTests {
void databaseHasBeenInitialized() {
StepVerifier.create(this.repository.findByState("DC").filter((city) -> city.getName().equals("Washington")))
.consumeNextWith((city) -> assertThat(city.getId()).isNotNull())
.verifyComplete();
.expectComplete()
.verify(Duration.ofSeconds(30));
}
private static String r2dbcUrl() {

5
spring-boot-tests/spring-boot-smoke-tests/spring-boot-smoke-test-rsocket/src/test/java/smoketest/rsocket/SampleRSocketApplicationTests.java

@ -16,6 +16,8 @@ @@ -16,6 +16,8 @@
package smoketest.rsocket;
import java.time.Duration;
import io.rsocket.metadata.WellKnownMimeType;
import org.junit.jupiter.api.Test;
import reactor.core.publisher.Mono;
@ -57,7 +59,8 @@ class SampleRSocketApplicationTests { @@ -57,7 +59,8 @@ class SampleRSocketApplicationTests {
Mono<Project> result = requester.route("find.project.spring-boot").retrieveMono(Project.class);
StepVerifier.create(result)
.assertNext((project) -> assertThat(project.getName()).isEqualTo("spring-boot"))
.verifyComplete();
.expectComplete()
.verify(Duration.ofSeconds(30));
}
}

Loading…
Cancel
Save