Consistently use generated name in embedded databases
... to avoid database name conflicts when test classes are executed in a different order. See gh-29122
This commit is contained in:
parent
0adec6d15a
commit
9cac5eeeab
|
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
* Copyright 2002-2019 the original author or authors.
|
* Copyright 2002-2023 the original author or authors.
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
|
|
@ -82,8 +82,8 @@ class DataSourceOnlySqlScriptsTests {
|
||||||
|
|
||||||
@Bean
|
@Bean
|
||||||
DataSource dataSource() {
|
DataSource dataSource() {
|
||||||
return new EmbeddedDatabaseBuilder()//
|
return new EmbeddedDatabaseBuilder()
|
||||||
.setName("empty-sql-scripts-without-tx-mgr-test-db")//
|
.generateUniqueName(true)
|
||||||
.build();
|
.build();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
* Copyright 2002-2022 the original author or authors.
|
* Copyright 2002-2023 the original author or authors.
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
|
|
@ -46,9 +46,9 @@ public class EmptyDatabaseConfig {
|
||||||
|
|
||||||
@Bean
|
@Bean
|
||||||
DataSource dataSource() {
|
DataSource dataSource() {
|
||||||
return new EmbeddedDatabaseBuilder()//
|
return new EmbeddedDatabaseBuilder()
|
||||||
.setName("empty-sql-scripts-test-db")//
|
.generateUniqueName(true)
|
||||||
.build();
|
.build();
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
* Copyright 2002-2019 the original author or authors.
|
* Copyright 2002-2023 the original author or authors.
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
|
|
@ -97,20 +97,20 @@ class InferredDataSourceTransactionalSqlScriptsTests {
|
||||||
|
|
||||||
@Bean
|
@Bean
|
||||||
DataSource dataSource1() {
|
DataSource dataSource1() {
|
||||||
return new EmbeddedDatabaseBuilder()//
|
return new EmbeddedDatabaseBuilder()
|
||||||
.setName("database1")//
|
.generateUniqueName(true)
|
||||||
.addScript("classpath:/org/springframework/test/context/jdbc/schema.sql")//
|
.addScript("classpath:/org/springframework/test/context/jdbc/schema.sql")
|
||||||
.addScript("classpath:/org/springframework/test/context/jdbc/data.sql")//
|
.addScript("classpath:/org/springframework/test/context/jdbc/data.sql")
|
||||||
.build();
|
.build();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Bean
|
@Bean
|
||||||
DataSource dataSource2() {
|
DataSource dataSource2() {
|
||||||
return new EmbeddedDatabaseBuilder()//
|
return new EmbeddedDatabaseBuilder()
|
||||||
.setName("database2")//
|
.generateUniqueName(true)
|
||||||
.addScript("classpath:/org/springframework/test/context/jdbc/schema.sql")//
|
.addScript("classpath:/org/springframework/test/context/jdbc/schema.sql")
|
||||||
.addScript("classpath:/org/springframework/test/context/jdbc/data.sql")//
|
.addScript("classpath:/org/springframework/test/context/jdbc/data.sql")
|
||||||
.build();
|
.build();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -81,7 +81,7 @@ class InfrastructureProxyTransactionalSqlScriptsTests extends AbstractTransactio
|
||||||
@Bean
|
@Bean
|
||||||
DataSource dataSource() {
|
DataSource dataSource() {
|
||||||
return new EmbeddedDatabaseBuilder()//
|
return new EmbeddedDatabaseBuilder()//
|
||||||
.setName("empty-sql-scripts-test-db")//
|
.generateUniqueName(true)
|
||||||
.build();
|
.build();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
* Copyright 2002-2019 the original author or authors.
|
* Copyright 2002-2023 the original author or authors.
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
|
|
@ -93,20 +93,20 @@ class MultipleDataSourcesAndTransactionManagersSqlScriptsTests {
|
||||||
|
|
||||||
@Bean
|
@Bean
|
||||||
DataSource dataSource1() {
|
DataSource dataSource1() {
|
||||||
return new EmbeddedDatabaseBuilder()//
|
return new EmbeddedDatabaseBuilder()
|
||||||
.setName("database1")//
|
.generateUniqueName(true)
|
||||||
.addScript("classpath:/org/springframework/test/context/jdbc/schema.sql")//
|
.addScript("classpath:/org/springframework/test/context/jdbc/schema.sql")
|
||||||
.addScript("classpath:/org/springframework/test/context/jdbc/data.sql")//
|
.addScript("classpath:/org/springframework/test/context/jdbc/data.sql")
|
||||||
.build();
|
.build();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Bean
|
@Bean
|
||||||
DataSource dataSource2() {
|
DataSource dataSource2() {
|
||||||
return new EmbeddedDatabaseBuilder()//
|
return new EmbeddedDatabaseBuilder()
|
||||||
.setName("database2")//
|
.generateUniqueName(true)
|
||||||
.addScript("classpath:/org/springframework/test/context/jdbc/schema.sql")//
|
.addScript("classpath:/org/springframework/test/context/jdbc/schema.sql")
|
||||||
.addScript("classpath:/org/springframework/test/context/jdbc/data.sql")//
|
.addScript("classpath:/org/springframework/test/context/jdbc/data.sql")
|
||||||
.build();
|
.build();
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
* Copyright 2002-2019 the original author or authors.
|
* Copyright 2002-2023 the original author or authors.
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
|
|
@ -94,20 +94,20 @@ class MultipleDataSourcesAndTransactionManagersTransactionalSqlScriptsTests {
|
||||||
|
|
||||||
@Bean
|
@Bean
|
||||||
DataSource dataSource1() {
|
DataSource dataSource1() {
|
||||||
return new EmbeddedDatabaseBuilder()//
|
return new EmbeddedDatabaseBuilder()
|
||||||
.setName("database1")//
|
.generateUniqueName(true)
|
||||||
.addScript("classpath:/org/springframework/test/context/jdbc/schema.sql")//
|
.addScript("classpath:/org/springframework/test/context/jdbc/schema.sql")
|
||||||
.addScript("classpath:/org/springframework/test/context/jdbc/data.sql")//
|
.addScript("classpath:/org/springframework/test/context/jdbc/data.sql")
|
||||||
.build();
|
.build();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Bean
|
@Bean
|
||||||
DataSource dataSource2() {
|
DataSource dataSource2() {
|
||||||
return new EmbeddedDatabaseBuilder()//
|
return new EmbeddedDatabaseBuilder()
|
||||||
.setName("database2")//
|
.generateUniqueName(true)
|
||||||
.addScript("classpath:/org/springframework/test/context/jdbc/schema.sql")//
|
.addScript("classpath:/org/springframework/test/context/jdbc/schema.sql")
|
||||||
.addScript("classpath:/org/springframework/test/context/jdbc/data.sql")//
|
.addScript("classpath:/org/springframework/test/context/jdbc/data.sql")
|
||||||
.build();
|
.build();
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
* Copyright 2002-2019 the original author or authors.
|
* Copyright 2002-2023 the original author or authors.
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
|
|
@ -42,10 +42,10 @@ public class PopulatedSchemaDatabaseConfig {
|
||||||
|
|
||||||
@Bean
|
@Bean
|
||||||
DataSource dataSource() {
|
DataSource dataSource() {
|
||||||
return new EmbeddedDatabaseBuilder()//
|
return new EmbeddedDatabaseBuilder()
|
||||||
.generateUniqueName(true)
|
.generateUniqueName(true)
|
||||||
.addScript("classpath:/org/springframework/test/context/jdbc/schema.sql") //
|
.addScript("classpath:/org/springframework/test/context/jdbc/schema.sql")
|
||||||
.build();
|
.build();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Bean
|
@Bean
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
* Copyright 2002-2015 the original author or authors.
|
* Copyright 2002-2023 the original author or authors.
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
|
|
@ -41,10 +41,10 @@ public class EmbeddedPersonDatabaseTestsConfig {
|
||||||
|
|
||||||
@Bean
|
@Bean
|
||||||
public DataSource dataSource() {
|
public DataSource dataSource() {
|
||||||
return new EmbeddedDatabaseBuilder()//
|
return new EmbeddedDatabaseBuilder()
|
||||||
.generateUniqueName(true)//
|
.generateUniqueName(true)
|
||||||
.addScript("classpath:/org/springframework/test/jdbc/schema.sql") //
|
.addScript("classpath:/org/springframework/test/jdbc/schema.sql")
|
||||||
.build();
|
.build();
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
* Copyright 2002-2022 the original author or authors.
|
* Copyright 2002-2023 the original author or authors.
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
|
|
@ -286,10 +286,10 @@ public class ProgrammaticTxMgmtSpringRuleTests {
|
||||||
|
|
||||||
@Bean
|
@Bean
|
||||||
DataSource dataSource() {
|
DataSource dataSource() {
|
||||||
return new EmbeddedDatabaseBuilder()//
|
return new EmbeddedDatabaseBuilder()
|
||||||
.generateUniqueName(true)//
|
.generateUniqueName(true)
|
||||||
.addScript("classpath:/org/springframework/test/context/jdbc/schema.sql") //
|
.addScript("classpath:/org/springframework/test/context/jdbc/schema.sql")
|
||||||
.build();
|
.build();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
* Copyright 2002-2019 the original author or authors.
|
* Copyright 2002-2023 the original author or authors.
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
|
|
@ -183,10 +183,11 @@ public class AnnotationConfigTransactionalTestNGSpringContextTests
|
||||||
|
|
||||||
@Bean
|
@Bean
|
||||||
DataSource dataSource() {
|
DataSource dataSource() {
|
||||||
return new EmbeddedDatabaseBuilder()//
|
return new EmbeddedDatabaseBuilder()
|
||||||
.addScript("classpath:/org/springframework/test/jdbc/schema.sql")//
|
.generateUniqueName(true)
|
||||||
.addScript("classpath:/org/springframework/test/jdbc/data.sql")//
|
.addScript("classpath:/org/springframework/test/jdbc/schema.sql")
|
||||||
.build();
|
.addScript("classpath:/org/springframework/test/jdbc/data.sql")
|
||||||
|
.build();
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
* Copyright 2002-2022 the original author or authors.
|
* Copyright 2002-2023 the original author or authors.
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
|
|
@ -257,10 +257,10 @@ public class ProgrammaticTxMgmtTestNGTests extends AbstractTransactionalTestNGSp
|
||||||
|
|
||||||
@Bean
|
@Bean
|
||||||
public DataSource dataSource() {
|
public DataSource dataSource() {
|
||||||
return new EmbeddedDatabaseBuilder()//
|
return new EmbeddedDatabaseBuilder()
|
||||||
.setName("programmatic-tx-mgmt-test-db")//
|
.generateUniqueName(true)
|
||||||
.addScript("classpath:/org/springframework/test/context/jdbc/schema.sql") //
|
.addScript("classpath:/org/springframework/test/context/jdbc/schema.sql")
|
||||||
.build();
|
.build();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
* Copyright 2002-2022 the original author or authors.
|
* Copyright 2002-2023 the original author or authors.
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
|
|
@ -277,10 +277,10 @@ class ProgrammaticTxMgmtTests {
|
||||||
|
|
||||||
@Bean
|
@Bean
|
||||||
DataSource dataSource() {
|
DataSource dataSource() {
|
||||||
return new EmbeddedDatabaseBuilder()//
|
return new EmbeddedDatabaseBuilder()
|
||||||
.generateUniqueName(true)//
|
.generateUniqueName(true)
|
||||||
.addScript("classpath:/org/springframework/test/context/jdbc/schema.sql") //
|
.addScript("classpath:/org/springframework/test/context/jdbc/schema.sql")
|
||||||
.build();
|
.build();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue