From 027e49c58ae47274eb14c0591663f6d8ad82095a Mon Sep 17 00:00:00 2001 From: Sam Brannen Date: Tue, 19 Jun 2012 20:48:07 +0200 Subject: [PATCH] Document default scripts for embedded databases The reference manual currently documents the wrong file name for the default data SQL script used by EmbeddedDatabaseBuilder. In addition, the testing chapter of the reference manual does not link to the testing section of the JDBC chapter. - Updated the "Testing data access logic with an embedded database" section of the reference manual appropriately. - Added a new paragraph to the "JDBC Testing Support" section of the testing chapter which cross references the "Testing data access logic with an embedded database" section. Issue: SPR-9467 --- .../embedded/EmbeddedDatabaseBuilder.java | 17 +++++++++-------- .../embedded/EmbeddedDatabaseFactory.java | 4 ---- src/reference/docbook/jdbc.xml | 8 +++++--- src/reference/docbook/testing.xml | 6 ++++++ 4 files changed, 20 insertions(+), 15 deletions(-) diff --git a/spring-jdbc/src/main/java/org/springframework/jdbc/datasource/embedded/EmbeddedDatabaseBuilder.java b/spring-jdbc/src/main/java/org/springframework/jdbc/datasource/embedded/EmbeddedDatabaseBuilder.java index a4ad58b3959..6c1ea235dcc 100644 --- a/spring-jdbc/src/main/java/org/springframework/jdbc/datasource/embedded/EmbeddedDatabaseBuilder.java +++ b/spring-jdbc/src/main/java/org/springframework/jdbc/datasource/embedded/EmbeddedDatabaseBuilder.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2009 the original author or authors. + * Copyright 2002-2012 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. @@ -33,6 +33,7 @@ import org.springframework.jdbc.datasource.init.ResourceDatabasePopulator; * @author Keith Donald * @author Juergen Hoeller * @author Dave Syer + * @author Sam Brannen * @since 3.0 */ public class EmbeddedDatabaseBuilder { @@ -62,8 +63,8 @@ public class EmbeddedDatabaseBuilder { } /** - * Sets the name of the embedded database - * Defaults to 'testdb' if not called. + * Set the name of the embedded database. + *

Defaults to "testdb" if not called. * @param databaseName the database name * @return this, to facilitate method chaining */ @@ -73,8 +74,8 @@ public class EmbeddedDatabaseBuilder { } /** - * Sets the type of embedded database. - * Defaults to HSQL if not called. + * Set the type of embedded database. + *

Defaults to HSQL if not called. * @param databaseType the database type * @return this, to facilitate method chaining */ @@ -84,7 +85,7 @@ public class EmbeddedDatabaseBuilder { } /** - * Adds a SQL script to execute to populate the database. + * Add a SQL script to execute to populate the database. * @param sqlResource the sql resource location * @return this, to facilitate method chaining */ @@ -95,8 +96,8 @@ public class EmbeddedDatabaseBuilder { /** * Add default scripts to execute to populate the database. - * The default scripts are schema.sql to create the db schema and - * data.sql to populate the db with data. + *

The default scripts are schema.sql to create the db + * schema and data.sql to populate the db with data. * @return this, to facilitate method chaining */ public EmbeddedDatabaseBuilder addDefaultScripts() { diff --git a/spring-jdbc/src/main/java/org/springframework/jdbc/datasource/embedded/EmbeddedDatabaseFactory.java b/spring-jdbc/src/main/java/org/springframework/jdbc/datasource/embedded/EmbeddedDatabaseFactory.java index f740e88c1b0..9c368c7700f 100644 --- a/spring-jdbc/src/main/java/org/springframework/jdbc/datasource/embedded/EmbeddedDatabaseFactory.java +++ b/spring-jdbc/src/main/java/org/springframework/jdbc/datasource/embedded/EmbeddedDatabaseFactory.java @@ -204,10 +204,6 @@ public class EmbeddedDatabaseFactory { return this.dataSource.isWrapperFor(iface); } - public Logger getParentLogger() { - return Logger.getLogger(Logger.GLOBAL_LOGGER_NAME); - } - public void shutdown() { shutdownDatabase(); } diff --git a/src/reference/docbook/jdbc.xml b/src/reference/docbook/jdbc.xml index 8d4132daa0a..a982cece000 100644 --- a/src/reference/docbook/jdbc.xml +++ b/src/reference/docbook/jdbc.xml @@ -2902,11 +2902,13 @@ SqlTypeValue value = new AbstractSqlTypeValue() { public class DataAccessUnitTestTemplate { + private EmbeddedDatabase db; @Before public void setUp() { - // creates a HSQL in-memory db populated from default scripts classpath:schema.sql and classpath:test-data.sql + // creates an HSQL in-memory database populated from default scripts + // classpath:schema.sql and classpath:data.sql db = new EmbeddedDatabaseBuilder().addDefaultScripts().build(); } @@ -2920,8 +2922,8 @@ public class DataAccessUnitTestTemplate { public void tearDown() { db.shutdown(); } -} - + +} diff --git a/src/reference/docbook/testing.xml b/src/reference/docbook/testing.xml index 1e0602e08e1..1af3b663f4b 100644 --- a/src/reference/docbook/testing.xml +++ b/src/reference/docbook/testing.xml @@ -416,6 +416,12 @@ AbstractTransactionalTestNGSpringContextTests provide convenience methods which delegate to SimpleJdbcTestUtils internally. + + The spring-jdbc module provides support for + configuring and launching an embedded database which can be used in + integration tests that interact with a database. For details, see and .