Browse Source

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
pull/100/head
Sam Brannen 12 years ago
parent
commit
027e49c58a
  1. 17
      spring-jdbc/src/main/java/org/springframework/jdbc/datasource/embedded/EmbeddedDatabaseBuilder.java
  2. 4
      spring-jdbc/src/main/java/org/springframework/jdbc/datasource/embedded/EmbeddedDatabaseFactory.java
  3. 8
      src/reference/docbook/jdbc.xml
  4. 6
      src/reference/docbook/testing.xml

17
spring-jdbc/src/main/java/org/springframework/jdbc/datasource/embedded/EmbeddedDatabaseBuilder.java

@ -1,5 +1,5 @@ @@ -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; @@ -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 { @@ -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 { @@ -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 { @@ -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 { @@ -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() {

4
spring-jdbc/src/main/java/org/springframework/jdbc/datasource/embedded/EmbeddedDatabaseFactory.java

@ -204,10 +204,6 @@ public class EmbeddedDatabaseFactory { @@ -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();
}

8
src/reference/docbook/jdbc.xml

@ -2902,11 +2902,13 @@ SqlTypeValue value = new AbstractSqlTypeValue() { @@ -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 { @@ -2920,8 +2922,8 @@ public class DataAccessUnitTestTemplate {
public void tearDown() {
db.shutdown();
}
}
</programlisting>
}</programlisting>
</section>
</section>

6
src/reference/docbook/testing.xml

@ -416,6 +416,12 @@ @@ -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">

Loading…
Cancel
Save