Merge branch '2.7.x' into 3.0.x

This commit is contained in:
Phillip Webb
2023-02-21 23:15:40 -08:00
1890 changed files with 27173 additions and 21952 deletions

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2012-2019 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.
@@ -40,7 +40,7 @@ public final class AutoConfigurationImportedCondition extends Condition<Applicat
@Override
public boolean matches(ApplicationContext context) {
ConditionEvaluationReport report = ConditionEvaluationReport
.get((ConfigurableListableBeanFactory) context.getAutowireCapableBeanFactory());
.get((ConfigurableListableBeanFactory) context.getAutowireCapableBeanFactory());
return report.getConditionAndOutcomesBySource().containsKey(this.autoConfigurationClass.getName());
}

View File

@@ -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.
@@ -46,8 +46,9 @@ class ConditionReportApplicationContextFailureProcessorTests {
ConfigurableApplicationContext applicationContext = application.run();
ConditionReportApplicationContextFailureProcessor processor = new ConditionReportApplicationContextFailureProcessor();
processor.processLoadFailure(applicationContext, new IllegalStateException());
assertThat(output).contains("CONDITIONS EVALUATION REPORT").contains("Positive matches")
.contains("Negative matches");
assertThat(output).contains("CONDITIONS EVALUATION REPORT")
.contains("Positive matches")
.contains("Negative matches");
}
@Configuration(proxyBeanMethods = false)

View File

@@ -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.
@@ -106,11 +106,12 @@ class ObservabilityContextCustomizerFactoryTests {
try (FilteredClassLoader filteredClassLoader = new FilteredClassLoader("io.micrometer.tracing")) {
ContextCustomizer customizer = createContextCustomizer(NoAnnotation.class);
new ApplicationContextRunner().withClassLoader(filteredClassLoader)
.withInitializer(applyCustomizer(customizer)).run((context) -> {
assertThat(context).doesNotHaveBean(Tracer.class);
assertThatMetricsAreDisabled(context);
assertThatTracingIsDisabled(context);
});
.withInitializer(applyCustomizer(customizer))
.run((context) -> {
assertThat(context).doesNotHaveBean(Tracer.class);
assertThatMetricsAreDisabled(context);
assertThatTracingIsDisabled(context);
});
}
}
@@ -118,18 +119,19 @@ class ObservabilityContextCustomizerFactoryTests {
void shouldBackOffOnCustomTracer() {
ContextCustomizer customizer = createContextCustomizer(NoAnnotation.class);
new ApplicationContextRunner().withConfiguration(UserConfigurations.of(CustomTracer.class))
.withInitializer(applyCustomizer(customizer)).run((context) -> {
assertThat(context).hasSingleBean(Tracer.class);
assertThat(context).hasBean("customTracer");
});
.withInitializer(applyCustomizer(customizer))
.run((context) -> {
assertThat(context).hasSingleBean(Tracer.class);
assertThat(context).hasBean("customTracer");
});
}
@Test
void shouldNotRunIfAotIsEnabled() {
ContextCustomizer customizer = createContextCustomizer(NoAnnotation.class);
new ApplicationContextRunner().withSystemProperties("spring.aot.enabled:true")
.withInitializer(applyCustomizer(customizer))
.run((context) -> assertThat(context).doesNotHaveBean(Tracer.class));
.withInitializer(applyCustomizer(customizer))
.run((context) -> assertThat(context).doesNotHaveBean(Tracer.class));
}
@Test
@@ -160,7 +162,7 @@ class ObservabilityContextCustomizerFactoryTests {
private void assertThatMetricsAreDisabled(ConfigurableApplicationContext context) {
assertThat(context.getEnvironment().getProperty("management.defaults.metrics.export.enabled"))
.isEqualTo("false");
.isEqualTo("false");
assertThat(context.getEnvironment().getProperty("management.simple.metrics.export.enabled")).isEqualTo("true");
}

View File

@@ -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.
@@ -78,7 +78,8 @@ class ImportsContextCustomizerFactoryWithAutoConfigurationTests {
private void executeTests(Class<?> testClass) {
LauncherDiscoveryRequest request = LauncherDiscoveryRequestBuilder.request()
.selectors(DiscoverySelectors.selectClass(testClass)).build();
.selectors(DiscoverySelectors.selectClass(testClass))
.build();
Launcher launcher = LauncherFactory.create();
launcher.execute(request);
}

View File

@@ -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.
@@ -70,7 +70,7 @@ class DataCassandraTestIntegrationTests {
@Test
void didNotInjectExampleService() {
assertThatExceptionOfType(NoSuchBeanDefinitionException.class)
.isThrownBy(() -> this.applicationContext.getBean(ExampleService.class));
.isThrownBy(() -> this.applicationContext.getBean(ExampleService.class));
}
@Test

View File

@@ -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.
@@ -48,8 +48,9 @@ class DataCouchbaseTestIntegrationTests {
@Container
static final CouchbaseContainer couchbase = new CouchbaseContainer(DockerImageNames.couchbase())
.withStartupAttempts(5).withStartupTimeout(Duration.ofMinutes(10))
.withBucket(new BucketDefinition(BUCKET_NAME));
.withStartupAttempts(5)
.withStartupTimeout(Duration.ofMinutes(10))
.withBucket(new BucketDefinition(BUCKET_NAME));
@DynamicPropertySource
static void couchbaseProperties(DynamicPropertyRegistry registry) {
@@ -71,7 +72,7 @@ class DataCouchbaseTestIntegrationTests {
@Test
void didNotInjectExampleService() {
assertThatExceptionOfType(NoSuchBeanDefinitionException.class)
.isThrownBy(() -> this.applicationContext.getBean(ExampleService.class));
.isThrownBy(() -> this.applicationContext.getBean(ExampleService.class));
}
@Test

View File

@@ -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.
@@ -46,8 +46,9 @@ class DataCouchbaseTestReactiveIntegrationTests {
@Container
static final CouchbaseContainer couchbase = new CouchbaseContainer(DockerImageNames.couchbase())
.withStartupAttempts(5).withStartupTimeout(Duration.ofMinutes(10))
.withBucket(new BucketDefinition(BUCKET_NAME));
.withStartupAttempts(5)
.withStartupTimeout(Duration.ofMinutes(10))
.withBucket(new BucketDefinition(BUCKET_NAME));
@DynamicPropertySource
static void couchbaseProperties(DynamicPropertyRegistry registry) {

View File

@@ -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.
@@ -47,8 +47,9 @@ class DataCouchbaseTestWithIncludeFilterIntegrationTests {
@Container
static final CouchbaseContainer couchbase = new CouchbaseContainer(DockerImageNames.couchbase())
.withStartupAttempts(5).withStartupTimeout(Duration.ofMinutes(10))
.withBucket(new BucketDefinition(BUCKET_NAME));
.withStartupAttempts(5)
.withStartupTimeout(Duration.ofMinutes(10))
.withBucket(new BucketDefinition(BUCKET_NAME));
@DynamicPropertySource
static void couchbaseProperties(DynamicPropertyRegistry registry) {

View File

@@ -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.
@@ -46,7 +46,8 @@ class DataElasticsearchTestIntegrationTests {
@Container
static final ElasticsearchContainer elasticsearch = new ElasticsearchContainer(DockerImageNames.elasticsearch())
.withStartupAttempts(5).withStartupTimeout(Duration.ofMinutes(10));
.withStartupAttempts(5)
.withStartupTimeout(Duration.ofMinutes(10));
@DynamicPropertySource
static void elasticsearchProperties(DynamicPropertyRegistry registry) {
@@ -65,7 +66,7 @@ class DataElasticsearchTestIntegrationTests {
@Test
void didNotInjectExampleService() {
assertThatExceptionOfType(NoSuchBeanDefinitionException.class)
.isThrownBy(() -> this.applicationContext.getBean(ExampleService.class));
.isThrownBy(() -> this.applicationContext.getBean(ExampleService.class));
}
@Test

View File

@@ -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.
@@ -43,7 +43,8 @@ class DataElasticsearchTestPropertiesIntegrationTests {
@Container
static final ElasticsearchContainer elasticsearch = new ElasticsearchContainer(DockerImageNames.elasticsearch())
.withStartupAttempts(5).withStartupTimeout(Duration.ofMinutes(10));
.withStartupAttempts(5)
.withStartupTimeout(Duration.ofMinutes(10));
@DynamicPropertySource
static void elasticsearchProperties(DynamicPropertyRegistry registry) {

View File

@@ -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.
@@ -43,7 +43,8 @@ class DataElasticsearchTestReactiveIntegrationTests {
@Container
static final ElasticsearchContainer elasticsearch = new ElasticsearchContainer(DockerImageNames.elasticsearch())
.withStartupAttempts(5).withStartupTimeout(Duration.ofMinutes(10));
.withStartupAttempts(5)
.withStartupTimeout(Duration.ofMinutes(10));
@DynamicPropertySource
static void elasticsearchProperties(DynamicPropertyRegistry registry) {
@@ -63,7 +64,7 @@ class DataElasticsearchTestReactiveIntegrationTests {
exampleDocument = this.exampleReactiveRepository.save(exampleDocument).block(Duration.ofSeconds(30));
assertThat(exampleDocument.getId()).isNotNull();
assertThat(this.elasticsearchTemplate.exists(exampleDocument.getId(), ExampleDocument.class)
.block(Duration.ofSeconds(30))).isTrue();
.block(Duration.ofSeconds(30))).isTrue();
}
}

View File

@@ -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.
@@ -45,7 +45,8 @@ class DataElasticsearchTestWithIncludeFilterIntegrationTests {
@Container
static final ElasticsearchContainer elasticsearch = new ElasticsearchContainer(DockerImageNames.elasticsearch())
.withStartupAttempts(5).withStartupTimeout(Duration.ofMinutes(10));
.withStartupAttempts(5)
.withStartupTimeout(Duration.ofMinutes(10));
@DynamicPropertySource
static void elasticsearchProperties(DynamicPropertyRegistry registry) {

View File

@@ -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.
@@ -70,7 +70,7 @@ class DataJdbcTestIntegrationTests {
@Test
void didNotInjectExampleComponent() {
assertThatExceptionOfType(NoSuchBeanDefinitionException.class)
.isThrownBy(() -> this.applicationContext.getBean(ExampleComponent.class));
.isThrownBy(() -> this.applicationContext.getBean(ExampleComponent.class));
}
@Test

View File

@@ -57,15 +57,15 @@ class DataLdapTestIntegrationTests {
Optional<ExampleEntry> entry = this.exampleRepository.findOne(ldapQuery);
assertThat(entry).isPresent();
assertThat(entry.get().getDn())
.isEqualTo(LdapUtils.newLdapName("cn=Bob Smith,ou=company1,c=Sweden,dc=spring,dc=org"));
.isEqualTo(LdapUtils.newLdapName("cn=Bob Smith,ou=company1,c=Sweden,dc=spring,dc=org"));
assertThat(this.ldapTemplate.findOne(ldapQuery, ExampleEntry.class).getDn())
.isEqualTo(LdapUtils.newLdapName("cn=Bob Smith,ou=company1,c=Sweden,dc=spring,dc=org"));
.isEqualTo(LdapUtils.newLdapName("cn=Bob Smith,ou=company1,c=Sweden,dc=spring,dc=org"));
}
@Test
void didNotInjectExampleService() {
assertThatExceptionOfType(NoSuchBeanDefinitionException.class)
.isThrownBy(() -> this.applicationContext.getBean(ExampleService.class));
.isThrownBy(() -> this.applicationContext.getBean(ExampleService.class));
}
}

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2012-2020 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.
@@ -45,7 +45,7 @@ class DataMongoTestIntegrationTests {
@Container
static final MongoDBContainer mongoDB = new MongoDBContainer(DockerImageNames.mongo()).withStartupAttempts(5)
.withStartupTimeout(Duration.ofMinutes(5));
.withStartupTimeout(Duration.ofMinutes(5));
@Autowired
private MongoTemplate mongoTemplate;
@@ -68,7 +68,7 @@ class DataMongoTestIntegrationTests {
@Test
void didNotInjectExampleService() {
assertThatExceptionOfType(NoSuchBeanDefinitionException.class)
.isThrownBy(() -> this.applicationContext.getBean(ExampleService.class));
.isThrownBy(() -> this.applicationContext.getBean(ExampleService.class));
}
@DynamicPropertySource

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2012-2020 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.
@@ -42,7 +42,7 @@ class DataMongoTestReactiveIntegrationTests {
@Container
static final MongoDBContainer mongoDB = new MongoDBContainer(DockerImageNames.mongo()).withStartupAttempts(5)
.withStartupTimeout(Duration.ofMinutes(5));
.withStartupTimeout(Duration.ofMinutes(5));
@Autowired
private ReactiveMongoTemplate mongoTemplate;

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2012-2020 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.
@@ -43,7 +43,7 @@ class DataMongoTestWithIncludeFilterIntegrationTests {
@Container
static final MongoDBContainer mongoDB = new MongoDBContainer(DockerImageNames.mongo()).withStartupAttempts(5)
.withStartupTimeout(Duration.ofMinutes(5));
.withStartupTimeout(Duration.ofMinutes(5));
@Autowired
private ExampleService service;

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2012-2020 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.
@@ -49,7 +49,7 @@ class TransactionalDataMongoTestIntegrationTests {
@Container
static final MongoDBContainer mongoDB = new MongoDBContainer(DockerImageNames.mongo()).withStartupAttempts(5)
.withStartupTimeout(Duration.ofMinutes(5));
.withStartupTimeout(Duration.ofMinutes(5));
@Autowired
private ExampleRepository exampleRepository;

View File

@@ -47,7 +47,8 @@ class DataNeo4jTestIntegrationTests {
@Container
static final Neo4jContainer<?> neo4j = new Neo4jContainer<>(DockerImageNames.neo4j()).withoutAuthentication()
.withStartupAttempts(5).withStartupTimeout(Duration.ofMinutes(10));
.withStartupAttempts(5)
.withStartupTimeout(Duration.ofMinutes(10));
@DynamicPropertySource
static void neo4jProperties(DynamicPropertyRegistry registry) {
@@ -75,7 +76,7 @@ class DataNeo4jTestIntegrationTests {
@Test
void didNotInjectExampleService() {
assertThatExceptionOfType(NoSuchBeanDefinitionException.class)
.isThrownBy(() -> this.applicationContext.getBean(ExampleService.class));
.isThrownBy(() -> this.applicationContext.getBean(ExampleService.class));
}
}

View File

@@ -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.
@@ -43,7 +43,8 @@ class DataNeo4jTestPropertiesIntegrationTests {
@Container
static final Neo4jContainer<?> neo4j = new Neo4jContainer<>(DockerImageNames.neo4j()).withoutAuthentication()
.withStartupAttempts(5).withStartupTimeout(Duration.ofMinutes(10));
.withStartupAttempts(5)
.withStartupTimeout(Duration.ofMinutes(10));
@DynamicPropertySource
static void neo4jProperties(DynamicPropertyRegistry registry) {

View File

@@ -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.
@@ -56,7 +56,8 @@ class DataNeo4jTestReactiveIntegrationTests {
@Container
static final Neo4jContainer<?> neo4j = new Neo4jContainer<>(DockerImageNames.neo4j()).withoutAuthentication()
.withStartupAttempts(5).withStartupTimeout(Duration.ofMinutes(10));
.withStartupAttempts(5)
.withStartupTimeout(Duration.ofMinutes(10));
@DynamicPropertySource
static void neo4jProperties(DynamicPropertyRegistry registry) {
@@ -74,15 +75,18 @@ class DataNeo4jTestReactiveIntegrationTests {
@Test
void testRepository() {
Mono.just(new ExampleGraph("Look, new @DataNeo4jTest with reactive!")).flatMap(this.exampleRepository::save)
.as(StepVerifier::create).expectNextCount(1).verifyComplete();
Mono.just(new ExampleGraph("Look, new @DataNeo4jTest with reactive!"))
.flatMap(this.exampleRepository::save)
.as(StepVerifier::create)
.expectNextCount(1)
.verifyComplete();
StepVerifier.create(this.neo4jTemplate.count(ExampleGraph.class)).expectNext(1L).verifyComplete();
}
@Test
void didNotInjectExampleService() {
assertThatExceptionOfType(NoSuchBeanDefinitionException.class)
.isThrownBy(() -> this.applicationContext.getBean(ExampleService.class));
.isThrownBy(() -> this.applicationContext.getBean(ExampleService.class));
}
@TestConfiguration(proxyBeanMethods = false)

View File

@@ -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.
@@ -44,7 +44,8 @@ class DataNeo4jTestWithIncludeFilterIntegrationTests {
@Container
static final Neo4jContainer<?> neo4j = new Neo4jContainer<>(DockerImageNames.neo4j()).withoutAuthentication()
.withStartupAttempts(5).withStartupTimeout(Duration.ofMinutes(10));
.withStartupAttempts(5)
.withStartupTimeout(Duration.ofMinutes(10));
@DynamicPropertySource
static void neo4jProperties(DynamicPropertyRegistry registry) {

View File

@@ -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.
@@ -72,14 +72,14 @@ class DataRedisTestIntegrationTests {
PersonHash savedEntity = this.exampleRepository.save(personHash);
assertThat(savedEntity.getId()).isNotNull();
assertThat(this.operations.execute((RedisConnection connection) -> connection.keyCommands()
.exists(("persons:" + savedEntity.getId()).getBytes(CHARSET)))).isTrue();
.exists(("persons:" + savedEntity.getId()).getBytes(CHARSET)))).isTrue();
this.exampleRepository.deleteAll();
}
@Test
void didNotInjectExampleService() {
assertThatExceptionOfType(NoSuchBeanDefinitionException.class)
.isThrownBy(() -> this.applicationContext.getBean(ExampleService.class));
.isThrownBy(() -> this.applicationContext.getBean(ExampleService.class));
}
}

View File

@@ -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.
@@ -60,17 +60,19 @@ class DataRedisTestReactiveIntegrationTests {
@Test
void testRepository() {
String id = UUID.randomUUID().toString();
StepVerifier.create(this.operations.opsForValue().set(id, "Hello World")).expectNext(Boolean.TRUE)
.verifyComplete();
StepVerifier.create(this.operations.opsForValue().set(id, "Hello World"))
.expectNext(Boolean.TRUE)
.verifyComplete();
StepVerifier.create(this.operations.opsForValue().get(id)).expectNext("Hello World").verifyComplete();
StepVerifier.create(this.operations.execute((action) -> action.serverCommands().flushDb())).expectNext("OK")
.verifyComplete();
StepVerifier.create(this.operations.execute((action) -> action.serverCommands().flushDb()))
.expectNext("OK")
.verifyComplete();
}
@Test
void didNotInjectExampleService() {
assertThatExceptionOfType(NoSuchBeanDefinitionException.class)
.isThrownBy(() -> this.applicationContext.getBean(ExampleService.class));
.isThrownBy(() -> this.applicationContext.getBean(ExampleService.class));
}
}

View File

@@ -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.
@@ -41,7 +41,7 @@ public class ExampleService {
public boolean hasRecord(PersonHash personHash) {
return this.operations.execute((RedisConnection connection) -> connection.keyCommands()
.exists(("persons:" + personHash.getId()).getBytes(CHARSET)));
.exists(("persons:" + personHash.getId()).getBytes(CHARSET)));
}
}

View File

@@ -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.
@@ -36,8 +36,8 @@ import static org.mockito.Mockito.mock;
*/
class GraphQlTesterAutoConfigurationTests {
private final ApplicationContextRunner contextRunner = new ApplicationContextRunner().withConfiguration(
AutoConfigurations.of(JacksonAutoConfiguration.class, GraphQlTesterAutoConfiguration.class));
private final ApplicationContextRunner contextRunner = new ApplicationContextRunner()
.withConfiguration(AutoConfigurations.of(JacksonAutoConfiguration.class, GraphQlTesterAutoConfiguration.class));
@Test
void shouldNotContributeTesterIfGraphQlServiceNotPresent() {
@@ -47,7 +47,7 @@ class GraphQlTesterAutoConfigurationTests {
@Test
void shouldContributeTester() {
this.contextRunner.withUserConfiguration(CustomGraphQlServiceConfiguration.class)
.run((context) -> assertThat(context).hasNotFailed().hasSingleBean(GraphQlTester.class));
.run((context) -> assertThat(context).hasNotFailed().hasSingleBean(GraphQlTester.class));
}
@Configuration(proxyBeanMethods = false)

View File

@@ -73,7 +73,7 @@ class JdbcTestIntegrationTests {
@Test
void didNotInjectExampleRepository() {
assertThatExceptionOfType(NoSuchBeanDefinitionException.class)
.isThrownBy(() -> this.applicationContext.getBean(ExampleRepository.class));
.isThrownBy(() -> this.applicationContext.getBean(ExampleRepository.class));
}
@Test

View File

@@ -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.
@@ -40,7 +40,7 @@ import static org.assertj.core.api.Assertions.assertThat;
class TestDatabaseAutoConfigurationTests {
private final ApplicationContextRunner contextRunner = new ApplicationContextRunner()
.withConfiguration(AutoConfigurations.of(TestDatabaseAutoConfiguration.class));
.withConfiguration(AutoConfigurations.of(TestDatabaseAutoConfiguration.class));
@Test
void replaceWithNoDataSourceAvailable() {
@@ -65,8 +65,8 @@ class TestDatabaseAutoConfigurationTests {
@Test
void whenUsingAotGeneratedArtifactsEmbeddedDataSourceFactoryBeanIsNotDefined() {
this.contextRunner.withUserConfiguration(ExistingDataSourceConfiguration.class)
.withSystemProperties("spring.aot.enabled=true")
.run((context) -> assertThat(context).doesNotHaveBean(EmbeddedDataSourceFactoryBean.class));
.withSystemProperties("spring.aot.enabled=true")
.run((context) -> assertThat(context).doesNotHaveBean(EmbeddedDataSourceFactoryBean.class));
}
@Configuration(proxyBeanMethods = false)

View File

@@ -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.
@@ -54,7 +54,7 @@ class JooqTestIntegrationTests {
@Test
void testDSLContext() {
assertThat(this.dsl.selectCount().from("INFORMATION_SCHEMA.TABLES").fetchOne(0, Integer.class))
.isGreaterThan(0);
.isGreaterThan(0);
}
@Test
@@ -67,7 +67,7 @@ class JooqTestIntegrationTests {
@Test
void didNotInjectExampleComponent() {
assertThatExceptionOfType(NoSuchBeanDefinitionException.class)
.isThrownBy(() -> this.applicationContext.getBean(ExampleComponent.class));
.isThrownBy(() -> this.applicationContext.getBean(ExampleComponent.class));
}
@Test

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2012-2019 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.
@@ -98,7 +98,8 @@ class JsonTestIntegrationTests {
ExampleJsonObjectWithView object = new ExampleJsonObjectWithView();
object.setValue("spring");
JsonContent<ExampleJsonObjectWithView> content = this.jacksonWithViewJson
.forView(ExampleJsonObjectWithView.TestView.class).write(object);
.forView(ExampleJsonObjectWithView.TestView.class)
.write(object);
assertThat(content).doesNotHaveJsonPathValue("id");
assertThat(content).isEqualToJson("example.json");
}

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2012-2020 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.
@@ -44,7 +44,7 @@ class DataJpaTestAttributesIntegrationTests {
@Test
void bootstrapModeIsSet() {
assertThat(this.environment.getProperty("spring.data.jpa.repositories.bootstrap-mode"))
.isEqualTo(BootstrapMode.DEFERRED.name());
.isEqualTo(BootstrapMode.DEFERRED.name());
}
}

View File

@@ -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.
@@ -94,7 +94,7 @@ class DataJpaTestIntegrationTests {
@Test
void didNotInjectExampleComponent() {
assertThatExceptionOfType(NoSuchBeanDefinitionException.class)
.isThrownBy(() -> this.applicationContext.getBean(ExampleComponent.class));
.isThrownBy(() -> this.applicationContext.getBean(ExampleComponent.class));
}
@Test
@@ -110,7 +110,7 @@ class DataJpaTestIntegrationTests {
@Test
void bootstrapModeIsDefaultByDefault() {
assertThat(this.applicationContext.getEnvironment().getProperty("spring.data.jpa.repositories.bootstrap-mode"))
.isEqualTo(BootstrapMode.DEFAULT.name());
.isEqualTo(BootstrapMode.DEFAULT.name());
}
}

View File

@@ -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.
@@ -43,7 +43,8 @@ class DataJpaTestSchemaCredentialsIntegrationTests {
String product = this.dataSource.getConnection().getMetaData().getDatabaseProductName();
assertThat(product).isEqualTo("H2");
assertThat(new JdbcTemplate(this.dataSource).queryForList("SELECT TABLE_NAME FROM INFORMATION_SCHEMA.TABLES",
String.class)).contains("EXAMPLE");
String.class))
.contains("EXAMPLE");
}
}

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2012-2019 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.
@@ -42,15 +42,16 @@ import static org.mockito.Mockito.mock;
class TestDatabaseAutoConfigurationNoEmbeddedTests {
private final ApplicationContextRunner contextRunner = new ApplicationContextRunner()
.withUserConfiguration(ExistingDataSourceConfiguration.class)
.withConfiguration(AutoConfigurations.of(TestDatabaseAutoConfiguration.class));
.withUserConfiguration(ExistingDataSourceConfiguration.class)
.withConfiguration(AutoConfigurations.of(TestDatabaseAutoConfiguration.class));
@Test
void applyAnyReplace() {
this.contextRunner.run((context) -> assertThat(context).getFailure().isInstanceOf(BeanCreationException.class)
.hasMessageContaining("Failed to replace DataSource with an embedded database for tests.")
.hasMessageContaining("If you want an embedded database please put a supported one on the classpath")
.hasMessageContaining("or tune the replace attribute of @AutoConfigureTestDatabase."));
this.contextRunner.run((context) -> assertThat(context).getFailure()
.isInstanceOf(BeanCreationException.class)
.hasMessageContaining("Failed to replace DataSource with an embedded database for tests.")
.hasMessageContaining("If you want an embedded database please put a supported one on the classpath")
.hasMessageContaining("or tune the replace attribute of @AutoConfigureTestDatabase."));
}
@Test

View File

@@ -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.
@@ -61,7 +61,7 @@ class TestEntityManagerTests {
@Test
void createWhenEntityManagerIsNullShouldThrowException() {
assertThatIllegalArgumentException().isThrownBy(() -> new TestEntityManager(null))
.withMessageContaining("EntityManagerFactory must not be null");
.withMessageContaining("EntityManagerFactory must not be null");
}
@Test
@@ -191,8 +191,8 @@ class TestEntityManagerTests {
given(this.entityManagerFactory.getPersistenceUnitUtil()).willReturn(this.persistenceUnitUtil);
given(this.persistenceUnitUtil.getIdentifier(entity)).willReturn(123);
assertThatIllegalArgumentException().isThrownBy(() -> this.testEntityManager.getId(entity, Long.class))
.withMessageContaining("ID mismatch: Object of class [java.lang.Integer] "
+ "must be an instance of class java.lang.Long");
.withMessageContaining("ID mismatch: Object of class [java.lang.Integer] "
+ "must be an instance of class java.lang.Long");
}
@Test
@@ -213,7 +213,7 @@ class TestEntityManagerTests {
@Test
void getEntityManagerWhenNotSetShouldThrowException() {
assertThatIllegalStateException().isThrownBy(this.testEntityManager::getEntityManager)
.withMessageContaining("No transactional EntityManager found");
.withMessageContaining("No transactional EntityManager found");
}
private void bindEntityManager() {

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2012-2019 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.
@@ -53,7 +53,7 @@ class OverrideAutoConfigurationEnabledFalseIntegrationTests {
ApplicationContext context = this.context;
assertThat(context.getBean(ExampleTestConfig.class)).isNotNull();
assertThatExceptionOfType(NoSuchBeanDefinitionException.class)
.isThrownBy(() -> context.getBean(ConfigurationPropertiesBindingPostProcessor.class));
.isThrownBy(() -> context.getBean(ConfigurationPropertiesBindingPostProcessor.class));
}
}

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2012-2020 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.
@@ -42,7 +42,7 @@ class AnnotationsPropertySourceTests {
@Test
void createWhenSourceIsNullShouldThrowException() {
assertThatIllegalArgumentException().isThrownBy(() -> new AnnotationsPropertySource(null))
.withMessageContaining("Property source must not be null");
.withMessageContaining("Property source must not be null");
}
@Test

View File

@@ -92,9 +92,9 @@ class PropertyMappingContextCustomizerFactoryTests {
context.register(ConfigMapping.class);
customizer.customizeContext(context, null);
assertThatExceptionOfType(BeanCreationException.class).isThrownBy(context::refresh)
.withMessageContaining("The @PropertyMapping annotation "
+ "@PropertyMappingContextCustomizerFactoryTests.TypeMappingAnnotation "
+ "cannot be used in combination with the @Component annotation @Configuration");
.withMessageContaining("The @PropertyMapping annotation "
+ "@PropertyMappingContextCustomizerFactoryTests.TypeMappingAnnotation "
+ "cannot be used in combination with the @Component annotation @Configuration");
}
@NoMappingAnnotation

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2012-2019 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.
@@ -69,7 +69,8 @@ class MockMvcRestDocsAutoConfigurationAdvancedConfigurationIntegrationTests {
@Test
void snippetGeneration() throws Exception {
this.mvc.perform(get("/")).andDo(this.documentationHandler
this.mvc.perform(get("/"))
.andDo(this.documentationHandler
.document(links(linkWithRel("self").description("Canonical location of this resource"))));
File defaultSnippetsDir = new File(this.generatedSnippets, "snippet-generation");
assertThat(defaultSnippetsDir).exists();
@@ -94,7 +95,7 @@ class MockMvcRestDocsAutoConfigurationAdvancedConfigurationIntegrationTests {
@Bean
RestDocsMockMvcConfigurationCustomizer defaultSnippetsCustomizer() {
return (configurer) -> configurer.snippets()
.withAdditionalDefaults(responseFields(fieldWithPath("_links.self").description("Main URL")));
.withAdditionalDefaults(responseFields(fieldWithPath("_links.self").description("Main URL")));
}
}

View File

@@ -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.
@@ -71,9 +71,14 @@ class RestAssuredRestDocsAutoConfigurationAdvancedConfigurationIntegrationTests
@Test
void snippetGeneration() {
given(this.documentationSpec)
.filter(document("default-snippets",
preprocessRequest(modifyUris().scheme("https").host("api.example.com").removePort())))
.when().port(this.port).get("/").then().assertThat().statusCode(is(200));
.filter(document("default-snippets",
preprocessRequest(modifyUris().scheme("https").host("api.example.com").removePort())))
.when()
.port(this.port)
.get("/")
.then()
.assertThat()
.statusCode(is(200));
File defaultSnippetsDir = new File(this.generatedSnippets, "default-snippets");
assertThat(defaultSnippetsDir).exists();
assertThat(contentOf(new File(defaultSnippetsDir, "curl-request.md"))).contains("'https://api.example.com/'");
@@ -98,7 +103,7 @@ class RestAssuredRestDocsAutoConfigurationAdvancedConfigurationIntegrationTests
@Bean
RestDocsRestAssuredConfigurationCustomizer defaultSnippetsCustomizer() {
return (configurer) -> configurer.snippets()
.withAdditionalDefaults(responseFields(fieldWithPath("_links.self").description("Main URL")));
.withAdditionalDefaults(responseFields(fieldWithPath("_links.self").description("Main URL")));
}
}

View File

@@ -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.
@@ -63,9 +63,14 @@ class RestAssuredRestDocsAutoConfigurationIntegrationTests {
@Test
void defaultSnippetsAreWritten() {
given(this.documentationSpec)
.filter(document("default-snippets",
preprocessRequest(modifyUris().scheme("https").host("api.example.com").removePort())))
.when().port(this.port).get("/").then().assertThat().statusCode(is(200));
.filter(document("default-snippets",
preprocessRequest(modifyUris().scheme("https").host("api.example.com").removePort())))
.when()
.port(this.port)
.get("/")
.then()
.assertThat()
.statusCode(is(200));
File defaultSnippetsDir = new File(this.generatedSnippets, "default-snippets");
assertThat(defaultSnippetsDir).exists();
assertThat(contentOf(new File(defaultSnippetsDir, "curl-request.adoc"))).contains("'https://api.example.com/'");

View File

@@ -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.
@@ -62,8 +62,13 @@ class WebTestClientRestDocsAutoConfigurationAdvancedConfigurationIntegrationTest
@Test
void defaultSnippetsAreWritten() {
this.webTestClient.get().uri("/").exchange().expectStatus().is2xxSuccessful().expectBody()
.consumeWith(document("default-snippets"));
this.webTestClient.get()
.uri("/")
.exchange()
.expectStatus()
.is2xxSuccessful()
.expectBody()
.consumeWith(document("default-snippets"));
File defaultSnippetsDir = new File(this.generatedSnippets, "default-snippets");
assertThat(defaultSnippetsDir).exists();
assertThat(contentOf(new File(defaultSnippetsDir, "curl-request.md"))).contains("'https://api.example.com/'");
@@ -88,7 +93,7 @@ class WebTestClientRestDocsAutoConfigurationAdvancedConfigurationIntegrationTest
@Bean
RestDocsWebTestClientConfigurationCustomizer defaultSnippetsCustomizer() {
return (configurer) -> configurer.snippets()
.withAdditionalDefaults(responseFields(fieldWithPath("_links.self").description("Main URL")));
.withAdditionalDefaults(responseFields(fieldWithPath("_links.self").description("Main URL")));
}
}

View File

@@ -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.
@@ -55,8 +55,13 @@ class WebTestClientRestDocsAutoConfigurationIntegrationTests {
@Test
void defaultSnippetsAreWritten() {
this.webTestClient.get().uri("/").exchange().expectStatus().is2xxSuccessful().expectBody()
.consumeWith(document("default-snippets"));
this.webTestClient.get()
.uri("/")
.exchange()
.expectStatus()
.is2xxSuccessful()
.expectBody()
.consumeWith(document("default-snippets"));
File defaultSnippetsDir = new File(this.generatedSnippets, "default-snippets");
assertThat(defaultSnippetsDir).exists();
assertThat(contentOf(new File(defaultSnippetsDir, "curl-request.adoc"))).contains("'https://api.example.com/'");

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2012-2019 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.
@@ -57,9 +57,9 @@ class MockMvcSecurityIntegrationTests {
@Test
void okResponseWithBasicAuthCredentialsForKnownUser() throws Exception {
this.mockMvc
.perform(get("/").header(HttpHeaders.AUTHORIZATION,
"Basic " + Base64.getEncoder().encodeToString("user:secret".getBytes())))
.andExpect(status().isOk());
.perform(get("/").header(HttpHeaders.AUTHORIZATION,
"Basic " + Base64.getEncoder().encodeToString("user:secret".getBytes())))
.andExpect(status().isOk());
}
}

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2012-2019 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.
@@ -42,7 +42,7 @@ class AutoConfigureMockRestServiceServerEnabledFalseIntegrationTests {
@Test
void mockServerRestTemplateCustomizerShouldNotBeRegistered() {
assertThatExceptionOfType(NoSuchBeanDefinitionException.class)
.isThrownBy(() -> this.applicationContext.getBean(MockServerRestTemplateCustomizer.class));
.isThrownBy(() -> this.applicationContext.getBean(MockServerRestTemplateCustomizer.class));
}
}

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2012-2019 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.
@@ -55,8 +55,9 @@ class RestClientRestIntegrationTests {
@Test
void mockServerCallWithContent() {
this.server.expect(requestTo("/test")).andExpect(content().string("test"))
.andRespond(withSuccess("1", MediaType.TEXT_HTML));
this.server.expect(requestTo("/test"))
.andExpect(content().string("test"))
.andRespond(withSuccess("1", MediaType.TEXT_HTML));
this.client.testPostWithBody("test");
}

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2012-2019 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.
@@ -50,13 +50,13 @@ class RestClientTestNoComponentIntegrationTests {
@Test
void exampleRestClientIsNotInjected() {
assertThatExceptionOfType(NoSuchBeanDefinitionException.class)
.isThrownBy(() -> this.applicationContext.getBean(ExampleRestClient.class));
.isThrownBy(() -> this.applicationContext.getBean(ExampleRestClient.class));
}
@Test
void examplePropertiesIsNotInjected() {
assertThatExceptionOfType(NoSuchBeanDefinitionException.class)
.isThrownBy(() -> this.applicationContext.getBean(ExampleProperties.class));
.isThrownBy(() -> this.applicationContext.getBean(ExampleProperties.class));
}
@Test

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2012-2019 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.
@@ -50,22 +50,25 @@ class RestClientTestTwoComponentsIntegrationTests {
@Test
void serverShouldNotWork() {
assertThatIllegalStateException().isThrownBy(
() -> this.server.expect(requestTo("/test")).andRespond(withSuccess("hello", MediaType.TEXT_HTML)))
.withMessageContaining("Unable to use auto-configured");
assertThatIllegalStateException()
.isThrownBy(
() -> this.server.expect(requestTo("/test")).andRespond(withSuccess("hello", MediaType.TEXT_HTML)))
.withMessageContaining("Unable to use auto-configured");
}
@Test
void client1RestCallViaCustomizer() {
this.customizer.getServer(this.client1.getRestTemplate()).expect(requestTo("/test"))
.andRespond(withSuccess("hello", MediaType.TEXT_HTML));
this.customizer.getServer(this.client1.getRestTemplate())
.expect(requestTo("/test"))
.andRespond(withSuccess("hello", MediaType.TEXT_HTML));
assertThat(this.client1.test()).isEqualTo("hello");
}
@Test
void client2RestCallViaCustomizer() {
this.customizer.getServer(this.client2.getRestTemplate()).expect(requestTo("/test"))
.andRespond(withSuccess("there", MediaType.TEXT_HTML));
this.customizer.getServer(this.client2.getRestTemplate())
.expect(requestTo("/test"))
.andRespond(withSuccess("there", MediaType.TEXT_HTML));
assertThat(this.client2.test()).isEqualTo("there");
}

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2012-2019 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.
@@ -39,7 +39,7 @@ class RestClientTestWithConfigurationPropertiesIntegrationTests {
@Test
void configurationPropertiesCanBeAddedAsComponent() {
assertThat(this.applicationContext.getBeansOfType(ExampleProperties.class).keySet())
.containsOnly("example-org.springframework.boot.test.autoconfigure.web.client.ExampleProperties");
.containsOnly("example-org.springframework.boot.test.autoconfigure.web.client.ExampleProperties");
assertThat(this.applicationContext.getBean(ExampleProperties.class).getName()).isEqualTo("Hello");
}

View File

@@ -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.
@@ -50,7 +50,7 @@ import static org.mockito.Mockito.mock;
class WebTestClientAutoConfigurationTests {
private final ApplicationContextRunner contextRunner = new ApplicationContextRunner()
.withConfiguration(AutoConfigurations.of(WebTestClientAutoConfiguration.class));
.withConfiguration(AutoConfigurations.of(WebTestClientAutoConfiguration.class));
@Test
void shouldNotBeConfiguredWithoutWebHandler() {
@@ -72,10 +72,11 @@ class WebTestClientAutoConfigurationTests {
@Test
void shouldCustomizeTimeout() {
this.contextRunner.withUserConfiguration(BaseConfiguration.class)
.withPropertyValues("spring.test.webtestclient.timeout=15m").run((context) -> {
WebTestClient webTestClient = context.getBean(WebTestClient.class);
assertThat(webTestClient).hasFieldOrPropertyWithValue("responseTimeout", Duration.ofMinutes(15));
});
.withPropertyValues("spring.test.webtestclient.timeout=15m")
.run((context) -> {
WebTestClient webTestClient = context.getBean(WebTestClient.class);
assertThat(webTestClient).hasFieldOrPropertyWithValue("responseTimeout", Duration.ofMinutes(15));
});
}
@Test
@@ -97,17 +98,17 @@ class WebTestClientAutoConfigurationTests {
@SuppressWarnings("unchecked")
void shouldNotApplySpringSecurityConfigurerWhenSpringSecurityNotOnClassPath() {
FilteredClassLoader classLoader = new FilteredClassLoader(SecurityMockServerConfigurers.class);
this.contextRunner.withUserConfiguration(BaseConfiguration.class).withClassLoader(classLoader)
.run((context) -> {
WebTestClient webTestClient = context.getBean(WebTestClient.class);
WebTestClient.Builder builder = (WebTestClient.Builder) ReflectionTestUtils.getField(webTestClient,
"builder");
WebHttpHandlerBuilder httpHandlerBuilder = (WebHttpHandlerBuilder) ReflectionTestUtils
.getField(builder, "httpHandlerBuilder");
List<WebFilter> filters = (List<WebFilter>) ReflectionTestUtils.getField(httpHandlerBuilder,
"filters");
assertThat(filters).isEmpty();
});
this.contextRunner.withUserConfiguration(BaseConfiguration.class)
.withClassLoader(classLoader)
.run((context) -> {
WebTestClient webTestClient = context.getBean(WebTestClient.class);
WebTestClient.Builder builder = (WebTestClient.Builder) ReflectionTestUtils.getField(webTestClient,
"builder");
WebHttpHandlerBuilder httpHandlerBuilder = (WebHttpHandlerBuilder) ReflectionTestUtils.getField(builder,
"httpHandlerBuilder");
List<WebFilter> filters = (List<WebFilter>) ReflectionTestUtils.getField(httpHandlerBuilder, "filters");
assertThat(filters).isEmpty();
});
}
@Configuration(proxyBeanMethods = false)

View File

@@ -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.
@@ -85,7 +85,7 @@ class WebFluxTestAutoConfigurationIntegrationTests {
@Test
void oAuth2ResourceServerAutoConfigurationWasImported() {
assertThat(this.applicationContext)
.has(importedAutoConfiguration(ReactiveOAuth2ResourceServerAutoConfiguration.class));
.has(importedAutoConfiguration(ReactiveOAuth2ResourceServerAutoConfiguration.class));
}
}

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2012-2019 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.
@@ -40,8 +40,13 @@ class WebFluxTestConverterIntegrationTests {
@Test
void shouldFindConverter() {
UUID id = UUID.randomUUID();
this.webClient.get().uri("/two/" + id).exchange().expectStatus().isOk().expectBody(String.class)
.isEqualTo(id + "two");
this.webClient.get()
.uri("/two/" + id)
.exchange()
.expectStatus()
.isOk()
.expectBody(String.class)
.isEqualTo(id + "two");
}
}

View File

@@ -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.
@@ -43,7 +43,7 @@ import static org.mockito.Mockito.mock;
class MockMvcAutoConfigurationTests {
private final WebApplicationContextRunner contextRunner = new WebApplicationContextRunner()
.withConfiguration(AutoConfigurations.of(MockMvcAutoConfiguration.class));
.withConfiguration(AutoConfigurations.of(MockMvcAutoConfiguration.class));
@Test
void registersDispatcherServletFromMockMvc() {
@@ -62,7 +62,7 @@ class MockMvcAutoConfigurationTests {
@Test
void shouldNotRegisterWebTestClientIfWebFluxMissing() {
this.contextRunner.withClassLoader(new FilteredClassLoader(WebClient.class))
.run((context) -> assertThat(context).doesNotHaveBean(WebTestClient.class));
.run((context) -> assertThat(context).doesNotHaveBean(WebTestClient.class));
}
@Test
@@ -71,7 +71,7 @@ class MockMvcAutoConfigurationTests {
assertThat(context).hasSingleBean(WebTestClient.class);
assertThat(context).hasBean("myWebTestClientCustomizer");
then(context.getBean("myWebTestClientCustomizer", WebTestClientBuilderCustomizer.class)).should()
.customize(any(WebTestClient.Builder.class));
.customize(any(WebTestClient.Builder.class));
});
}

View File

@@ -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.
@@ -64,7 +64,7 @@ class SpringBootMockMvcBuilderCustomizerTests {
this.customizer = new SpringBootMockMvcBuilderCustomizer(context);
this.customizer.customize(builder);
FilterRegistrationBean<?> registrationBean = (FilterRegistrationBean<?>) context
.getBean("filterRegistrationBean");
.getBean("filterRegistrationBean");
Filter testFilter = (Filter) context.getBean("testFilter");
Filter otherTestFilter = registrationBean.getFilter();
List<Filter> filters = (List<Filter>) ReflectionTestUtils.getField(builder, "filters");
@@ -98,7 +98,7 @@ class SpringBootMockMvcBuilderCustomizerTests {
assertThat(delegate.allWritten).hasSize(10000);
assertThat(delegate.allWritten)
.allSatisfy((written) -> assertThat(written).containsExactly("1", "2", "3", "4", "5"));
.allSatisfy((written) -> assertThat(written).containsExactly("1", "2", "3", "4", "5"));
}
private static final class CapturingLinesWriter implements LinesWriter {

View File

@@ -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.
@@ -76,7 +76,7 @@ class WebMvcTestAutoConfigurationIntegrationTests {
void asyncTaskExecutorWithApplicationTaskExecutor() {
assertThat(this.applicationContext.getBeansOfType(AsyncTaskExecutor.class)).hasSize(1);
assertThat(this.applicationContext.getBean(RequestMappingHandlerAdapter.class)).extracting("taskExecutor")
.isSameAs(this.applicationContext.getBean("applicationTaskExecutor"));
.isSameAs(this.applicationContext.getBean("applicationTaskExecutor"));
}
@Test

View File

@@ -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.
@@ -71,7 +71,7 @@ class WebMvcTestAllControllersIntegrationTests {
@Test
void shouldRunValidationFailure() {
assertThatExceptionOfType(ServletException.class).isThrownBy(() -> this.mvc.perform(get("/three/invalid")))
.withCauseInstanceOf(ConstraintViolationException.class);
.withCauseInstanceOf(ConstraintViolationException.class);
}
@Test

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2012-2019 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.
@@ -45,8 +45,9 @@ class WebMvcTestCustomDispatcherServletIntegrationTests {
@Test
void dispatcherServletIsCustomized() throws Exception {
this.mvc.perform(get("/does-not-exist")).andExpect(status().isBadRequest())
.andExpect(content().string("Invalid request: /does-not-exist"));
this.mvc.perform(get("/does-not-exist"))
.andExpect(status().isBadRequest())
.andExpect(content().string("Invalid request: /does-not-exist"));
}
}

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2012-2019 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.
@@ -42,13 +42,13 @@ class WebMvcTestHateoasIntegrationTests {
@Test
void plainResponse() throws Exception {
this.mockMvc.perform(get("/hateoas/plain"))
.andExpect(header().string(HttpHeaders.CONTENT_TYPE, "application/json"));
.andExpect(header().string(HttpHeaders.CONTENT_TYPE, "application/json"));
}
@Test
void hateoasResponse() throws Exception {
this.mockMvc.perform(get("/hateoas/resource"))
.andExpect(header().string(HttpHeaders.CONTENT_TYPE, "application/hal+json"));
.andExpect(header().string(HttpHeaders.CONTENT_TYPE, "application/hal+json"));
}
}

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2012-2020 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.
@@ -61,8 +61,9 @@ class WebMvcTestNestedIntegrationTests {
@Test
void shouldFindController2() throws Exception {
WebMvcTestNestedIntegrationTests.this.mvc.perform(get("/two")).andExpect(content().string("hellotwo"))
.andExpect(status().isOk());
WebMvcTestNestedIntegrationTests.this.mvc.perform(get("/two"))
.andExpect(content().string("hellotwo"))
.andExpect(status().isOk());
}
}

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2012-2019 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.
@@ -41,8 +41,9 @@ class WebMvcTestPageableIntegrationTests {
@Test
void shouldSupportPageable() throws Exception {
this.mvc.perform(get("/paged").param("page", "2").param("size", "42")).andExpect(status().isOk())
.andExpect(content().string("2:42"));
this.mvc.perform(get("/paged").param("page", "2").param("size", "42"))
.andExpect(status().isOk())
.andExpect(content().string("2:42"));
}
}

View File

@@ -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.
@@ -63,7 +63,8 @@ class WebMvcTestPrintDefaultIntegrationTests {
private void executeTests(Class<?> testClass) {
LauncherDiscoveryRequest request = LauncherDiscoveryRequestBuilder.request()
.selectors(DiscoverySelectors.selectClass(testClass)).build();
.selectors(DiscoverySelectors.selectClass(testClass))
.build();
Launcher launcher = LauncherFactory.create();
launcher.execute(request);
}

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2012-2019 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.
@@ -56,13 +56,13 @@ class WebMvcTestWithAutoConfigureMockMvcIntegrationTests {
@Test
void shouldNotHaveWebDriver() {
assertThatExceptionOfType(NoSuchBeanDefinitionException.class)
.isThrownBy(() -> this.context.getBean(WebDriver.class));
.isThrownBy(() -> this.context.getBean(WebDriver.class));
}
@Test
void shouldNotHaveWebClient() {
assertThatExceptionOfType(NoSuchBeanDefinitionException.class)
.isThrownBy(() -> this.context.getBean(WebClient.class));
.isThrownBy(() -> this.context.getBean(WebClient.class));
}
}

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2012-2020 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.
@@ -41,7 +41,7 @@ class AutoConfigureMockWebServiceServerEnabledIntegrationTests {
@Test
void mockWebServiceServerShouldNotBeRegistered() {
assertThatExceptionOfType(NoSuchBeanDefinitionException.class)
.isThrownBy(() -> this.applicationContext.getBean(MockWebServiceServer.class));
.isThrownBy(() -> this.applicationContext.getBean(MockWebServiceServer.class));
}
}

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2012-2020 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.
@@ -49,7 +49,7 @@ class AutoConfigureWebServiceClientWebServiceTemplateIntegrationTests {
@Test
void webServiceTemplateTest() {
this.server.expect(payload(new StringSource("<request/>")))
.andRespond(withPayload(new StringSource("<response/>")));
.andRespond(withPayload(new StringSource("<response/>")));
this.webServiceTemplate.marshalSendAndReceive("https://example.com", new Request());
}

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2012-2020 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.
@@ -48,7 +48,7 @@ class WebServiceClientIntegrationTests {
@Test
void mockServerCall() {
this.server.expect(payload(new StringSource("<request/>")))
.andRespond(withPayload(new StringSource("<response><status>200</status></response>")));
.andRespond(withPayload(new StringSource("<response><status>200</status></response>")));
assertThat(this.client.test()).extracting(Response::getStatus).isEqualTo(200);
}
@@ -56,14 +56,14 @@ class WebServiceClientIntegrationTests {
void mockServerCall1() {
this.server.expect(connectionTo("https://example1")).andRespond(withPayload(new StringSource("<response/>")));
assertThatExceptionOfType(SourceAssertionError.class).isThrownBy(this.client::test)
.withMessageContaining("Unexpected connection expected");
.withMessageContaining("Unexpected connection expected");
}
@Test
void mockServerCall2() {
this.server.expect(payload(new StringSource("<request/>"))).andRespond(withError("Invalid Request"));
assertThatExceptionOfType(WebServiceTransportException.class).isThrownBy(this.client::test)
.withMessageContaining("Invalid Request");
.withMessageContaining("Invalid Request");
}
}

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2012-2020 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.
@@ -50,14 +50,14 @@ class WebServiceClientNoComponentIntegrationTests {
@Test
void exampleClientIsNotInjected() {
assertThatExceptionOfType(NoSuchBeanDefinitionException.class)
.isThrownBy(() -> this.applicationContext.getBean(ExampleWebServiceClient.class));
.isThrownBy(() -> this.applicationContext.getBean(ExampleWebServiceClient.class));
}
@Test
void manuallyCreateBean() {
ExampleWebServiceClient client = new ExampleWebServiceClient(this.webServiceTemplateBuilder);
this.server.expect(payload(new StringSource("<request/>")))
.andRespond(withPayload(new StringSource("<response><status>200</status></response>")));
.andRespond(withPayload(new StringSource("<response><status>200</status></response>")));
assertThat(client.test()).extracting(Response::getStatus).isEqualTo(200);
}

View File

@@ -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.
@@ -33,7 +33,7 @@ import static org.assertj.core.api.Assertions.assertThat;
class MockWebServiceClientAutoConfigurationTests {
private final WebApplicationContextRunner contextRunner = new WebApplicationContextRunner()
.withConfiguration(AutoConfigurations.of(MockWebServiceClientAutoConfiguration.class));
.withConfiguration(AutoConfigurations.of(MockWebServiceClientAutoConfiguration.class));
@Test
void shouldRegisterMockWebServiceClient() {
@@ -45,7 +45,7 @@ class MockWebServiceClientAutoConfigurationTests {
FilteredClassLoader classLoader = new FilteredClassLoader(MockWebServiceClient.class);
this.contextRunner.withClassLoader(classLoader)
.run((context) -> assertThat(context).doesNotHaveBean(MockWebServiceClient.class));
.run((context) -> assertThat(context).doesNotHaveBean(MockWebServiceClient.class));
}
}

View File

@@ -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.
@@ -38,9 +38,8 @@ class WebServiceServerIntegrationTests {
@Test
void payloadRootMethod() {
this.mock
.sendRequest(
RequestCreators.withPayload(new StringSource("<request><message>Hello</message></request>")))
.andExpect(ResponseMatchers.payload(new StringSource("<response><code>42</code></response>")));
.sendRequest(RequestCreators.withPayload(new StringSource("<request><message>Hello</message></request>")))
.andExpect(ResponseMatchers.payload(new StringSource("<response><code>42</code></response>")));
}
}