Update tests to shut down in-memory databases proactively

pull/3906/merge
Andy Wilkinson 9 years ago
parent ddbbd37718
commit 72122ec965

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

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

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

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

Loading…
Cancel
Save