Merge branch '2.7.x'

This commit is contained in:
Stephane Nicoll
2022-02-05 14:02:00 +01:00
17 changed files with 104 additions and 62 deletions

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2012-2021 the original author or authors.
* Copyright 2012-2022 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,8 @@
package org.springframework.boot.autoconfigure.flyway;
import java.util.UUID;
import org.flywaydb.core.Flyway;
import org.flywaydb.core.api.Location;
import org.flywaydb.core.api.MigrationVersion;
@@ -23,7 +25,7 @@ import org.flywaydb.core.api.migration.JavaMigration;
import org.junit.jupiter.api.Test;
import org.springframework.boot.autoconfigure.AutoConfigurations;
import org.springframework.boot.autoconfigure.jdbc.EmbeddedDataSourceConfiguration;
import org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration;
import org.springframework.boot.test.context.runner.ApplicationContextRunner;
import org.springframework.boot.testsupport.classpath.ClassPathOverrides;
import org.springframework.context.annotation.Bean;
@@ -41,11 +43,11 @@ class Flyway5xAutoConfigurationTests {
private final ApplicationContextRunner contextRunner = new ApplicationContextRunner()
.withConfiguration(AutoConfigurations.of(FlywayAutoConfiguration.class))
.withPropertyValues("spring.datasource.generate-unique-name=true");
.withPropertyValues("spring.datasource.url:jdbc:hsqldb:mem:" + UUID.randomUUID());
@Test
void defaultFlyway() {
this.contextRunner.withUserConfiguration(EmbeddedDataSourceConfiguration.class).run((context) -> {
this.contextRunner.withUserConfiguration(DataSourceAutoConfiguration.class).run((context) -> {
assertThat(context).hasSingleBean(Flyway.class);
Flyway flyway = context.getBean(Flyway.class);
assertThat(flyway.getConfiguration().getLocations())
@@ -56,7 +58,7 @@ class Flyway5xAutoConfigurationTests {
@Test
void flywayJavaMigrationsAreIgnored() {
this.contextRunner
.withUserConfiguration(EmbeddedDataSourceConfiguration.class, FlywayJavaMigrationsConfiguration.class)
.withUserConfiguration(DataSourceAutoConfiguration.class, FlywayJavaMigrationsConfiguration.class)
.run((context) -> assertThat(context).hasNotFailed());
}

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2012-2020 the original author or authors.
* Copyright 2012-2022 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,8 @@
package org.springframework.boot.autoconfigure.flyway;
import java.util.UUID;
import org.flywaydb.core.Flyway;
import org.flywaydb.core.api.Location;
import org.flywaydb.core.api.callback.Callback;
@@ -25,7 +27,7 @@ import org.junit.jupiter.api.Test;
import org.mockito.InOrder;
import org.springframework.boot.autoconfigure.AutoConfigurations;
import org.springframework.boot.autoconfigure.jdbc.EmbeddedDataSourceConfiguration;
import org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration;
import org.springframework.boot.test.context.runner.ApplicationContextRunner;
import org.springframework.boot.testsupport.classpath.ClassPathOverrides;
import org.springframework.context.annotation.Bean;
@@ -48,11 +50,11 @@ class Flyway6xAutoConfigurationTests {
private final ApplicationContextRunner contextRunner = new ApplicationContextRunner()
.withConfiguration(AutoConfigurations.of(FlywayAutoConfiguration.class))
.withPropertyValues("spring.datasource.generate-unique-name=true");
.withPropertyValues("spring.datasource.url:jdbc:hsqldb:mem:" + UUID.randomUUID());
@Test
void defaultFlyway() {
this.contextRunner.withUserConfiguration(EmbeddedDataSourceConfiguration.class).run((context) -> {
this.contextRunner.withUserConfiguration(DataSourceAutoConfiguration.class).run((context) -> {
assertThat(context).hasSingleBean(Flyway.class);
Flyway flyway = context.getBean(Flyway.class);
assertThat(flyway.getConfiguration().getLocations())
@@ -62,7 +64,7 @@ class Flyway6xAutoConfigurationTests {
@Test
void callbacksAreConfiguredAndOrdered() {
this.contextRunner.withUserConfiguration(EmbeddedDataSourceConfiguration.class, CallbackConfiguration.class)
this.contextRunner.withUserConfiguration(DataSourceAutoConfiguration.class, CallbackConfiguration.class)
.run((context) -> {
assertThat(context).hasSingleBean(Flyway.class);
Flyway flyway = context.getBean(Flyway.class);

View File

@@ -16,6 +16,8 @@
package org.springframework.boot.autoconfigure.flyway;
import java.util.UUID;
import org.flywaydb.core.Flyway;
import org.flywaydb.core.api.Location;
import org.flywaydb.core.api.callback.Callback;
@@ -24,7 +26,7 @@ import org.flywaydb.core.api.callback.Event;
import org.junit.jupiter.api.Test;
import org.springframework.boot.autoconfigure.AutoConfigurations;
import org.springframework.boot.autoconfigure.jdbc.EmbeddedDataSourceConfiguration;
import org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration;
import org.springframework.boot.test.context.runner.ApplicationContextRunner;
import org.springframework.boot.testsupport.classpath.ClassPathOverrides;
import org.springframework.context.annotation.Bean;
@@ -47,11 +49,11 @@ class Flyway7xAutoConfigurationTests {
private final ApplicationContextRunner contextRunner = new ApplicationContextRunner()
.withConfiguration(AutoConfigurations.of(FlywayAutoConfiguration.class))
.withPropertyValues("spring.datasource.generate-unique-name=true");
.withPropertyValues("spring.datasource.url:jdbc:hsqldb:mem:" + UUID.randomUUID());
@Test
void defaultFlyway() {
this.contextRunner.withUserConfiguration(EmbeddedDataSourceConfiguration.class).run((context) -> {
this.contextRunner.withUserConfiguration(DataSourceAutoConfiguration.class).run((context) -> {
assertThat(context).hasSingleBean(Flyway.class);
Flyway flyway = context.getBean(Flyway.class);
assertThat(flyway.getConfiguration().getLocations())
@@ -61,7 +63,7 @@ class Flyway7xAutoConfigurationTests {
@Test
void callbacksAreConfigured() {
this.contextRunner.withUserConfiguration(EmbeddedDataSourceConfiguration.class, CallbackConfiguration.class)
this.contextRunner.withUserConfiguration(DataSourceAutoConfiguration.class, CallbackConfiguration.class)
.run((context) -> {
assertThat(context).hasSingleBean(Flyway.class);
Flyway flyway = context.getBean(Flyway.class);

View File

@@ -288,7 +288,7 @@ class HibernateJpaAutoConfigurationTests extends AbstractJpaAutoConfigurationTes
EntityManager em = context.getBean(EntityManagerFactory.class).createEntityManager();
NonAnnotatedEntity found = em.find(NonAnnotatedEntity.class, 2000L);
assertThat(found).isNotNull();
assertThat(found.getValue()).isEqualTo("Test");
assertThat(found.getItem()).isEqualTo("Test");
});
}

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2012-2019 the original author or authors.
* Copyright 2012-2022 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.
@@ -25,13 +25,13 @@ public class NonAnnotatedEntity {
private Long id;
private String value;
private String item;
protected NonAnnotatedEntity() {
}
public NonAnnotatedEntity(String value) {
this.value = value;
public NonAnnotatedEntity(String item) {
this.item = item;
}
public Long getId() {
@@ -42,12 +42,12 @@ public class NonAnnotatedEntity {
this.id = id;
}
public String getValue() {
return this.value;
public String getItem() {
return this.item;
}
public void setValue(String value) {
this.value = value;
public void setItem(String value) {
this.item = value;
}
}

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2012-2021 the original author or authors.
* Copyright 2012-2022 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.
@@ -93,7 +93,7 @@ class R2dbcAutoConfigurationTests {
assertThat(context).hasSingleBean(ConnectionFactory.class).hasSingleBean(ConnectionPool.class)
.hasSingleBean(R2dbcProperties.class);
ConnectionPool connectionPool = context.getBean(ConnectionPool.class);
assertThat(connectionPool).hasFieldOrPropertyWithValue("maxAcquireTime", Duration.ZERO);
assertThat(connectionPool).hasFieldOrPropertyWithValue("maxAcquireTime", Duration.ofNanos(-1));
});
}
@@ -156,8 +156,9 @@ class R2dbcAutoConfigurationTests {
assertThat(context).hasSingleBean(ConnectionFactory.class).doesNotHaveBean(ConnectionPool.class);
ConnectionFactory connectionFactory = context.getBean(ConnectionFactory.class);
assertThat(connectionFactory).asInstanceOf(type(OptionsCapableConnectionFactory.class))
.extracting(OptionsCapableConnectionFactory::getOptions).satisfies((options) -> assertThat(
options.getRequiredValue(Option.<Boolean>valueOf("customized"))).isTrue());
.extracting(OptionsCapableConnectionFactory::getOptions)
.satisfies((options) -> assertThat(options.getRequiredValue(Option.valueOf("customized")))
.isEqualTo(Boolean.TRUE));
});
}
@@ -169,8 +170,9 @@ class R2dbcAutoConfigurationTests {
ConnectionFactory pool = context.getBean(ConnectionFactory.class);
ConnectionFactory connectionFactory = ((ConnectionPool) pool).unwrap();
assertThat(connectionFactory).asInstanceOf(type(OptionsCapableConnectionFactory.class))
.extracting(OptionsCapableConnectionFactory::getOptions).satisfies((options) -> assertThat(
options.getRequiredValue(Option.<Boolean>valueOf("customized"))).isTrue());
.extracting(OptionsCapableConnectionFactory::getOptions)
.satisfies((options) -> assertThat(options.getRequiredValue(Option.valueOf("customized")))
.isEqualTo(Boolean.TRUE));
});
}

View File

@@ -10,8 +10,8 @@
<column name="id"/>
<generated-value strategy="IDENTITY"/>
</id>
<basic name="value">
<column name="value"/>
<basic name="item">
<column name="item"/>
</basic>
</attributes>
</entity>

View File

@@ -1 +1 @@
INSERT INTO NON_ANNOTATED (ID, VALUE) values (2000, 'Test');
INSERT INTO NON_ANNOTATED (id, item) values (2000, 'Test');