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
This commit is contained in:
Sam Brannen 2012-06-19 20:48:07 +02:00
parent 5eae22abb8
commit 027e49c58a
4 changed files with 20 additions and 15 deletions

View File

@ -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.
* <p>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.
* <p>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 <code>schema.sql</code> to create the db schema and
* <code>data.sql</code> to populate the db with data.
* <p>The default scripts are <code>schema.sql</code> to create the db
* schema and <code>data.sql</code> to populate the db with data.
* @return this, to facilitate method chaining
*/
public EmbeddedDatabaseBuilder addDefaultScripts() {

View File

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

View File

@ -2902,11 +2902,13 @@ SqlTypeValue value = new AbstractSqlTypeValue() {
<programlisting language="java">
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();
}
}
</programlisting>
}</programlisting>
</section>
</section>

View File

@ -416,6 +416,12 @@
<classname>AbstractTransactionalTestNGSpringContextTests</classname>
</link> provide convenience methods which delegate to
<classname>SimpleJdbcTestUtils</classname> internally.</emphasis></para>
<para>The <literal>spring-jdbc</literal> 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 <xref
linkend="jdbc-embedded-database-support" /> and <xref
linkend="jdbc-embedded-database-dao-testing" />.</para>
</section>
<section id="integration-testing-annotations">