diff --git a/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/flyway/Flyway5xAutoConfigurationTests.java b/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/flyway/Flyway5xAutoConfigurationTests.java index 4dbff8c68c1..d2fc87842a2 100644 --- a/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/flyway/Flyway5xAutoConfigurationTests.java +++ b/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/flyway/Flyway5xAutoConfigurationTests.java @@ -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()); } diff --git a/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/flyway/Flyway6xAutoConfigurationTests.java b/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/flyway/Flyway6xAutoConfigurationTests.java index fd169165fd8..bb5faa2e85d 100644 --- a/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/flyway/Flyway6xAutoConfigurationTests.java +++ b/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/flyway/Flyway6xAutoConfigurationTests.java @@ -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); diff --git a/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/flyway/Flyway7xAutoConfigurationTests.java b/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/flyway/Flyway7xAutoConfigurationTests.java index f37c7fb6a97..777b7e38a62 100644 --- a/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/flyway/Flyway7xAutoConfigurationTests.java +++ b/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/flyway/Flyway7xAutoConfigurationTests.java @@ -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); diff --git a/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/orm/jpa/HibernateJpaAutoConfigurationTests.java b/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/orm/jpa/HibernateJpaAutoConfigurationTests.java index b526445c783..6b271f10bd3 100644 --- a/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/orm/jpa/HibernateJpaAutoConfigurationTests.java +++ b/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/orm/jpa/HibernateJpaAutoConfigurationTests.java @@ -318,7 +318,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"); }); } diff --git a/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/orm/jpa/mapping/NonAnnotatedEntity.java b/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/orm/jpa/mapping/NonAnnotatedEntity.java index 7ed418d43c2..b9f41c89358 100644 --- a/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/orm/jpa/mapping/NonAnnotatedEntity.java +++ b/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/orm/jpa/mapping/NonAnnotatedEntity.java @@ -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; } } diff --git a/spring-boot-project/spring-boot-autoconfigure/src/test/resources/META-INF/mappings/non-annotated.xml b/spring-boot-project/spring-boot-autoconfigure/src/test/resources/META-INF/mappings/non-annotated.xml index db6bee33194..3b33b0dff38 100644 --- a/spring-boot-project/spring-boot-autoconfigure/src/test/resources/META-INF/mappings/non-annotated.xml +++ b/spring-boot-project/spring-boot-autoconfigure/src/test/resources/META-INF/mappings/non-annotated.xml @@ -10,8 +10,8 @@ - - + + diff --git a/spring-boot-project/spring-boot-autoconfigure/src/test/resources/db/non-annotated-data.sql b/spring-boot-project/spring-boot-autoconfigure/src/test/resources/db/non-annotated-data.sql index 709bc377bcc..b741d23ccf8 100644 --- a/spring-boot-project/spring-boot-autoconfigure/src/test/resources/db/non-annotated-data.sql +++ b/spring-boot-project/spring-boot-autoconfigure/src/test/resources/db/non-annotated-data.sql @@ -1 +1 @@ -INSERT INTO NON_ANNOTATED (ID, VALUE) values (2000, 'Test'); +INSERT INTO NON_ANNOTATED (id, item) values (2000, 'Test'); diff --git a/spring-boot-project/spring-boot-dependencies/build.gradle b/spring-boot-project/spring-boot-dependencies/build.gradle index da203b42c25..8499fd22c82 100644 --- a/spring-boot-project/spring-boot-dependencies/build.gradle +++ b/spring-boot-project/spring-boot-dependencies/build.gradle @@ -399,7 +399,7 @@ bom { ] } } - library("H2", "1.4.200") { + library("H2", "2.1.210") { group("com.h2database") { modules = [ "h2" diff --git a/spring-boot-project/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/orm/jpa/DataJpaTestIntegrationTests.java b/spring-boot-project/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/orm/jpa/DataJpaTestIntegrationTests.java index 723dd514edd..3f1d9e26319 100644 --- a/spring-boot-project/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/orm/jpa/DataJpaTestIntegrationTests.java +++ b/spring-boot-project/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/orm/jpa/DataJpaTestIntegrationTests.java @@ -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. @@ -27,7 +27,6 @@ import org.springframework.boot.autoconfigure.liquibase.LiquibaseAutoConfigurati import org.springframework.context.ApplicationContext; import org.springframework.data.repository.config.BootstrapMode; import org.springframework.jdbc.core.JdbcTemplate; -import org.springframework.test.context.TestPropertySource; import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.api.Assertions.assertThatExceptionOfType; @@ -41,7 +40,6 @@ import static org.springframework.boot.test.autoconfigure.AutoConfigurationImpor * @author Scott Frederick */ @DataJpaTest -@TestPropertySource(properties = "spring.jpa.hibernate.use-new-id-generator-mappings=false") class DataJpaTestIntegrationTests { @Autowired @@ -71,6 +69,7 @@ class DataJpaTestIntegrationTests { @Test void testEntityManagerPersistAndGetId() { Long id = this.entities.persistAndGetId(new ExampleEntity("spring", "123"), Long.class); + this.entities.flush(); assertThat(id).isNotNull(); String reference = this.jdbcTemplate.queryForObject("SELECT REFERENCE FROM EXAMPLE_ENTITY WHERE ID = ?", String.class, id); diff --git a/spring-boot-tests/spring-boot-smoke-tests/spring-boot-smoke-test-test/src/main/java/smoketest/test/domain/User.java b/spring-boot-tests/spring-boot-smoke-tests/spring-boot-smoke-test-test/src/main/java/smoketest/test/domain/User.java index 05fef4cc700..c81eee54678 100644 --- a/spring-boot-tests/spring-boot-smoke-tests/spring-boot-smoke-test-test/src/main/java/smoketest/test/domain/User.java +++ b/spring-boot-tests/spring-boot-smoke-tests/spring-boot-smoke-test-test/src/main/java/smoketest/test/domain/User.java @@ -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. @@ -20,6 +20,7 @@ import javax.persistence.Column; import javax.persistence.Entity; import javax.persistence.GeneratedValue; import javax.persistence.Id; +import javax.persistence.Table; import org.springframework.util.Assert; @@ -29,6 +30,7 @@ import org.springframework.util.Assert; * @author Phillip Webb */ @Entity +@Table(name = "DRIVER") public class User { @Id diff --git a/spring-boot-tests/spring-boot-smoke-tests/spring-boot-smoke-test-test/src/test/resources/data.sql b/spring-boot-tests/spring-boot-smoke-tests/spring-boot-smoke-test-test/src/test/resources/data.sql index 70ecc99a379..7ea61039b1f 100644 --- a/spring-boot-tests/spring-boot-smoke-tests/spring-boot-smoke-test-test/src/test/resources/data.sql +++ b/spring-boot-tests/spring-boot-smoke-tests/spring-boot-smoke-test-test/src/test/resources/data.sql @@ -1 +1 @@ -INSERT INTO USER(ID, USERNAME, VIN) values (123, 'sframework', '01234567890123456'); +INSERT INTO DRIVER(id, username, vin) values (123, 'sframework', '01234567890123456');