Skip to content

Commit 027e49c

Browse files
committed
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
1 parent 5eae22a commit 027e49c

File tree

4 files changed

+20
-15
lines changed

4 files changed

+20
-15
lines changed

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

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2009 the original author or authors.
2+
* Copyright 2002-2012 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -33,6 +33,7 @@
3333
* @author Keith Donald
3434
* @author Juergen Hoeller
3535
* @author Dave Syer
36+
* @author Sam Brannen
3637
* @since 3.0
3738
*/
3839
public class EmbeddedDatabaseBuilder {
@@ -62,8 +63,8 @@ public EmbeddedDatabaseBuilder(ResourceLoader resourceLoader) {
6263
}
6364

6465
/**
65-
* Sets the name of the embedded database
66-
* Defaults to 'testdb' if not called.
66+
* Set the name of the embedded database.
67+
* <p>Defaults to "testdb" if not called.
6768
* @param databaseName the database name
6869
* @return this, to facilitate method chaining
6970
*/
@@ -73,8 +74,8 @@ public EmbeddedDatabaseBuilder setName(String databaseName) {
7374
}
7475

7576
/**
76-
* Sets the type of embedded database.
77-
* Defaults to HSQL if not called.
77+
* Set the type of embedded database.
78+
* <p>Defaults to HSQL if not called.
7879
* @param databaseType the database type
7980
* @return this, to facilitate method chaining
8081
*/
@@ -84,7 +85,7 @@ public EmbeddedDatabaseBuilder setType(EmbeddedDatabaseType databaseType) {
8485
}
8586

8687
/**
87-
* Adds a SQL script to execute to populate the database.
88+
* Add a SQL script to execute to populate the database.
8889
* @param sqlResource the sql resource location
8990
* @return this, to facilitate method chaining
9091
*/
@@ -95,8 +96,8 @@ public EmbeddedDatabaseBuilder addScript(String sqlResource) {
9596

9697
/**
9798
* Add default scripts to execute to populate the database.
98-
* The default scripts are <code>schema.sql</code> to create the db schema and
99-
* <code>data.sql</code> to populate the db with data.
99+
* <p>The default scripts are <code>schema.sql</code> to create the db
100+
* schema and <code>data.sql</code> to populate the db with data.
100101
* @return this, to facilitate method chaining
101102
*/
102103
public EmbeddedDatabaseBuilder addDefaultScripts() {

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

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -204,10 +204,6 @@ public boolean isWrapperFor(Class<?> iface) throws SQLException {
204204
return this.dataSource.isWrapperFor(iface);
205205
}
206206

207-
public Logger getParentLogger() {
208-
return Logger.getLogger(Logger.GLOBAL_LOGGER_NAME);
209-
}
210-
211207
public void shutdown() {
212208
shutdownDatabase();
213209
}

src/reference/docbook/jdbc.xml

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2902,11 +2902,13 @@ SqlTypeValue value = new AbstractSqlTypeValue() {
29022902

29032903
<programlisting language="java">
29042904
public class DataAccessUnitTestTemplate {
2905+
29052906
private EmbeddedDatabase db;
29062907

29072908
@Before
29082909
public void setUp() {
2909-
// creates a HSQL in-memory db populated from default scripts classpath:schema.sql and classpath:test-data.sql
2910+
// creates an HSQL in-memory database populated from default scripts
2911+
// classpath:schema.sql and classpath:data.sql
29102912
db = new EmbeddedDatabaseBuilder().addDefaultScripts().build();
29112913
}
29122914

@@ -2920,8 +2922,8 @@ public class DataAccessUnitTestTemplate {
29202922
public void tearDown() {
29212923
db.shutdown();
29222924
}
2923-
}
2924-
</programlisting>
2925+
2926+
}</programlisting>
29252927
</section>
29262928
</section>
29272929

src/reference/docbook/testing.xml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -416,6 +416,12 @@
416416
<classname>AbstractTransactionalTestNGSpringContextTests</classname>
417417
</link> provide convenience methods which delegate to
418418
<classname>SimpleJdbcTestUtils</classname> internally.</emphasis></para>
419+
420+
<para>The <literal>spring-jdbc</literal> module provides support for
421+
configuring and launching an embedded database which can be used in
422+
integration tests that interact with a database. For details, see <xref
423+
linkend="jdbc-embedded-database-support" /> and <xref
424+
linkend="jdbc-embedded-database-dao-testing" />.</para>
419425
</section>
420426

421427
<section id="integration-testing-annotations">

0 commit comments

Comments
 (0)