diff --git a/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/jdbc/DataSourceInitializerTests.java b/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/jdbc/DataSourceInitializerTests.java index 46261a89e3..93040a8a01 100644 --- a/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/jdbc/DataSourceInitializerTests.java +++ b/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/jdbc/DataSourceInitializerTests.java @@ -56,7 +56,8 @@ public class DataSourceInitializerTests { EmbeddedDatabaseConnection.override = null; EnvironmentTestUtils.addEnvironment(this.context, "spring.datasource.initialize:false", - "spring.datasource.url:jdbc:hsqldb:mem:testdb-" + new Random().nextInt()); + "spring.datasource.url:jdbc:hsqldb:mem:testdb-" + new Random().nextInt() + + ";shutdown=true"); } @After diff --git a/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/orm/jpa/AbstractJpaAutoConfigurationTests.java b/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/orm/jpa/AbstractJpaAutoConfigurationTests.java index 3d9ae030a2..49b29eebbc 100644 --- a/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/orm/jpa/AbstractJpaAutoConfigurationTests.java +++ b/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/orm/jpa/AbstractJpaAutoConfigurationTests.java @@ -19,12 +19,14 @@ package org.springframework.boot.autoconfigure.orm.jpa; import java.lang.reflect.Field; import java.util.HashMap; import java.util.Map; +import java.util.Random; import javax.persistence.EntityManagerFactory; import javax.sql.DataSource; import org.hibernate.engine.transaction.jta.platform.internal.NoJtaPlatform; import org.junit.After; +import org.junit.Before; import org.junit.Rule; import org.junit.Test; import org.junit.rules.ExpectedException; @@ -71,6 +73,13 @@ public abstract class AbstractJpaAutoConfigurationTests { protected AnnotationConfigApplicationContext context = new AnnotationConfigApplicationContext(); + @Before + public void setup() { + EnvironmentTestUtils.addEnvironment(this.context, + "spring.datasource.url:jdbc:hsqldb:mem:testdb-" + new Random().nextInt() + + ";shutdown=true"); + } + @After public void close() { this.context.close(); diff --git a/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/security/SecurityAutoConfigurationTests.java b/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/security/SecurityAutoConfigurationTests.java index 66a89918ee..0b9e0c53b1 100644 --- a/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/security/SecurityAutoConfigurationTests.java +++ b/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/security/SecurityAutoConfigurationTests.java @@ -297,7 +297,7 @@ public class SecurityAutoConfigurationTests { this.context = new AnnotationConfigWebApplicationContext(); this.context.setServletContext(new MockServletContext()); EnvironmentTestUtils.addEnvironment(this.context, - "spring.datasource.url:jdbc:hsqldb:mem:testsecdb"); + "spring.datasource.url:jdbc:hsqldb:mem:testsecdb;shutdown=true"); this.context.register(EntityConfiguration.class, PropertyPlaceholderAutoConfiguration.class, DataSourceAutoConfiguration.class, HibernateJpaAutoConfiguration.class, diff --git a/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/security/jpa/JpaUserDetailsTests.java b/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/security/jpa/JpaUserDetailsTests.java index e7b6c90365..69fc819e93 100644 --- a/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/security/jpa/JpaUserDetailsTests.java +++ b/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/security/jpa/JpaUserDetailsTests.java @@ -29,6 +29,7 @@ import org.springframework.boot.test.SpringApplicationConfiguration; import org.springframework.context.annotation.ComponentScan; import org.springframework.context.annotation.Import; import org.springframework.test.annotation.DirtiesContext; +import org.springframework.test.context.TestPropertySource; import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; /** @@ -42,6 +43,7 @@ import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; @RunWith(SpringJUnit4ClassRunner.class) @SpringApplicationConfiguration(JpaUserDetailsTests.Main.class) @DirtiesContext +@TestPropertySource(properties = "spring.datasource.url:jdbc:hsqldb:mem:testdb;shutdown=true") public class JpaUserDetailsTests { @Test