Upgrade to H2 2.1.210

H2 2.x contains several important changes such as moving the primary key
generation mechanism to a sequence-based identifier. This commit fixes
a number of tests that were failing.

Closes gh-29651

Co-authored-by: Andy Wilkinson <wilkinsona@vmware.com>
pull/29745/head
Stephane Nicoll 3 years ago
parent 5f7657508f
commit 8c8c9c5f28

@ -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());
}

@ -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);

@ -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);

@ -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");
});
}

@ -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;
}
}

@ -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>

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

@ -399,7 +399,7 @@ bom {
]
}
}
library("H2", "1.4.200") {
library("H2", "2.1.210") {
group("com.h2database") {
modules = [
"h2"

@ -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);

@ -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

@ -1 +1 @@
INSERT INTO USER(ID, USERNAME, VIN) values (123, 'sframework', '01234567890123456');
INSERT INTO DRIVER(id, username, vin) values (123, 'sframework', '01234567890123456');

Loading…
Cancel
Save