Upgrade to HSQLDB 2.3.1

Replace `hsqldb:hsqldb:1.8.0.10` with `org.hsqldb:hsqldb:2.3.1` and
fix breaking tests.

Issue: SPR-10947
This commit is contained in:
Phillip Webb 2013-11-21 15:48:17 -08:00
parent 87e443b429
commit d9c4470461
10 changed files with 46 additions and 36 deletions

View File

@ -15,7 +15,7 @@ configure(allprojects) { project ->
ext.aspectjVersion = "1.8.0.M1" ext.aspectjVersion = "1.8.0.M1"
ext.groovyVersion = "1.8.9" ext.groovyVersion = "1.8.9"
ext.hsqldbVersion = "1.8.0.10" ext.hsqldbVersion = "2.3.1"
ext.junitVersion = "4.11" ext.junitVersion = "4.11"
ext.slf4jVersion = "1.6.1" ext.slf4jVersion = "1.6.1"
ext.jettyVersion = "9.1.0.v20131115" ext.jettyVersion = "9.1.0.v20131115"
@ -495,7 +495,7 @@ project("spring-jdbc") {
optional(project(":spring-context")) // for JndiDataSourceLookup optional(project(":spring-context")) // for JndiDataSourceLookup
compile(project(":spring-tx")) compile(project(":spring-tx"))
optional("c3p0:c3p0:0.9.1.2") optional("c3p0:c3p0:0.9.1.2")
optional("hsqldb:hsqldb:${hsqldbVersion}") optional("org.hsqldb:hsqldb:${hsqldbVersion}")
optional("com.h2database:h2:1.0.71") optional("com.h2database:h2:1.0.71")
optional("org.apache.derby:derby:10.5.3.0_1") optional("org.apache.derby:derby:10.5.3.0_1")
optional("org.apache.derby:derbyclient:10.5.3.0_1") optional("org.apache.derby:derbyclient:10.5.3.0_1")
@ -528,7 +528,7 @@ project("spring-context-support") {
testCompile("org.apache.poi:poi:3.9") testCompile("org.apache.poi:poi:3.9")
testCompile("commons-beanutils:commons-beanutils:1.8.0") // for Velocity/JasperReports testCompile("commons-beanutils:commons-beanutils:1.8.0") // for Velocity/JasperReports
testCompile("commons-digester:commons-digester:1.8.1") // for Velocity/JasperReports testCompile("commons-digester:commons-digester:1.8.1") // for Velocity/JasperReports
testCompile("hsqldb:hsqldb:${hsqldbVersion}") testCompile("org.hsqldb:hsqldb:${hsqldbVersion}")
} }
// pick up **/*.types files in src/main // pick up **/*.types files in src/main
@ -622,7 +622,7 @@ project("spring-orm") {
provided("javax.servlet:javax.servlet-api:3.0.1") provided("javax.servlet:javax.servlet-api:3.0.1")
testCompile("org.slf4j:slf4j-jcl:${slf4jVersion}") testCompile("org.slf4j:slf4j-jcl:${slf4jVersion}")
testCompile("commons-dbcp:commons-dbcp:1.2.2") testCompile("commons-dbcp:commons-dbcp:1.2.2")
testCompile("hsqldb:hsqldb:${hsqldbVersion}") testCompile("org.hsqldb:hsqldb:${hsqldbVersion}")
compile(project(":spring-core")) compile(project(":spring-core"))
compile(project(":spring-beans")) compile(project(":spring-beans"))
optional(project(":spring-aop")) optional(project(":spring-aop"))
@ -790,7 +790,7 @@ project("spring-test") {
testCompile(project(":spring-webmvc-tiles3")) testCompile(project(":spring-webmvc-tiles3"))
testCompile("org.hibernate:hibernate-core:3.6.9.Final") testCompile("org.hibernate:hibernate-core:3.6.9.Final")
testCompile "org.slf4j:slf4j-jcl:${slf4jVersion}" testCompile "org.slf4j:slf4j-jcl:${slf4jVersion}"
testCompile("hsqldb:hsqldb:${hsqldbVersion}") testCompile("org.hsqldb:hsqldb:${hsqldbVersion}")
testCompile("org.hibernate:hibernate-validator:4.3.0.Final") testCompile("org.hibernate:hibernate-validator:4.3.0.Final")
testCompile("org.codehaus.jackson:jackson-mapper-asl:1.9.12") testCompile("org.codehaus.jackson:jackson-mapper-asl:1.9.12")
testCompile("com.fasterxml.jackson.core:jackson-databind:2.2.2") testCompile("com.fasterxml.jackson.core:jackson-databind:2.2.2")
@ -918,7 +918,7 @@ configure(rootProject) {
testCompile("javax.inject:javax.inject:1") testCompile("javax.inject:javax.inject:1")
testCompile("javax.resource:connector-api:1.5") testCompile("javax.resource:connector-api:1.5")
testCompile("org.aspectj:aspectjweaver:${aspectjVersion}") testCompile("org.aspectj:aspectjweaver:${aspectjVersion}")
testCompile("hsqldb:hsqldb:${hsqldbVersion}") testCompile("org.hsqldb:hsqldb:${hsqldbVersion}")
} }
task api(type: Javadoc) { task api(type: Javadoc) {

View File

@ -28,6 +28,8 @@ import org.springframework.jdbc.datasource.embedded.EmbeddedDatabase;
import org.springframework.jdbc.datasource.embedded.EmbeddedDatabaseBuilder; import org.springframework.jdbc.datasource.embedded.EmbeddedDatabaseBuilder;
import org.springframework.transaction.support.TransactionSynchronizationManager; import org.springframework.transaction.support.TransactionSynchronizationManager;
import static org.hamcrest.Matchers.*;
import static org.junit.Assert.*; import static org.junit.Assert.*;
import static org.mockito.BDDMockito.*; import static org.mockito.BDDMockito.*;
@ -59,8 +61,9 @@ public class DatabasePopulatorTests {
private void assertUsersDatabaseCreated(String... lastNames) { private void assertUsersDatabaseCreated(String... lastNames) {
for (String lastName : lastNames) { for (String lastName : lastNames) {
assertEquals("Did not find user with last name [" + lastName + "].", 1, assertThat("Did not find user with last name [" + lastName + "].",
jdbcTemplate.queryForInt("select count(0) from users where last_name = ?", lastName)); jdbcTemplate.queryForObject("select count(0) from users where last_name = ?", Integer.class, lastName),
equalTo(1));
} }
} }
@ -131,8 +134,8 @@ public class DatabasePopulatorTests {
connection.close(); connection.close();
} }
assertEquals(1, jdbcTemplate.queryForInt("select COUNT(NAME) from T_TEST where NAME='Keith'")); assertThat(jdbcTemplate.queryForObject("select COUNT(NAME) from T_TEST where NAME='Keith'", Integer.class), equalTo(1));
assertEquals(1, jdbcTemplate.queryForInt("select COUNT(NAME) from T_TEST where NAME='Dave'")); assertThat(jdbcTemplate.queryForObject("select COUNT(NAME) from T_TEST where NAME='Dave'", Integer.class), equalTo(1));
} }
@Test @Test
@ -148,8 +151,8 @@ public class DatabasePopulatorTests {
connection.close(); connection.close();
} }
assertEquals(1, jdbcTemplate.queryForInt("select COUNT(NAME) from T_TEST where NAME='Keith'")); assertThat(jdbcTemplate.queryForObject("select COUNT(NAME) from T_TEST where NAME='Keith'", Integer.class), equalTo(1));
assertEquals(1, jdbcTemplate.queryForInt("select COUNT(NAME) from T_TEST where NAME='Dave'")); assertThat(jdbcTemplate.queryForObject("select COUNT(NAME) from T_TEST where NAME='Dave'", Integer.class), equalTo(1));
} }
@Test @Test
@ -165,8 +168,8 @@ public class DatabasePopulatorTests {
connection.close(); connection.close();
} }
assertEquals(1, jdbcTemplate.queryForInt("select COUNT(NAME) from T_TEST where NAME='Keith'")); assertThat(jdbcTemplate.queryForObject("select COUNT(NAME) from T_TEST where NAME='Keith'", Integer.class), equalTo(1));
assertEquals(1, jdbcTemplate.queryForInt("select COUNT(NAME) from T_TEST where NAME='Dave'")); assertThat(jdbcTemplate.queryForObject("select COUNT(NAME) from T_TEST where NAME='Dave'", Integer.class), equalTo(1));
} }
@Test @Test
@ -181,8 +184,8 @@ public class DatabasePopulatorTests {
connection.close(); connection.close();
} }
assertEquals(1, jdbcTemplate.queryForInt("select COUNT(NAME) from T_TEST where NAME='Keith'")); assertThat(jdbcTemplate.queryForObject("select COUNT(NAME) from T_TEST where NAME='Keith'", Integer.class), equalTo(1));
assertEquals(1, jdbcTemplate.queryForInt("select COUNT(NAME) from T_TEST where NAME='Dave'")); assertThat(jdbcTemplate.queryForObject("select COUNT(NAME) from T_TEST where NAME='Dave'", Integer.class), equalTo(1));
} }
@Test @Test
@ -198,8 +201,8 @@ public class DatabasePopulatorTests {
connection.close(); connection.close();
} }
assertEquals(1, jdbcTemplate.queryForInt("select COUNT(NAME) from T_TEST where NAME='Keith'")); assertThat(jdbcTemplate.queryForObject("select COUNT(NAME) from T_TEST where NAME='Keith'", Integer.class), equalTo(1));
assertEquals(1, jdbcTemplate.queryForInt("select COUNT(NAME) from T_TEST where NAME='Dave'")); assertThat(jdbcTemplate.queryForObject("select COUNT(NAME) from T_TEST where NAME='Dave'", Integer.class), equalTo(1));
} }
@Test @Test
@ -244,8 +247,8 @@ public class DatabasePopulatorTests {
connection.close(); connection.close();
} }
assertEquals(1, jdbcTemplate.queryForInt("select COUNT(NAME) from T_TEST where NAME='Keith'")); assertThat(jdbcTemplate.queryForObject("select COUNT(NAME) from T_TEST where NAME='Keith'", Integer.class), equalTo(1));
assertEquals(1, jdbcTemplate.queryForInt("select COUNT(NAME) from T_TEST where NAME='Dave'")); assertThat(jdbcTemplate.queryForObject("select COUNT(NAME) from T_TEST where NAME='Dave'", Integer.class), equalTo(1));
} }
/** /**

View File

@ -1,7 +1,7 @@
DROP TABLE users IF EXISTS; DROP TABLE users IF EXISTS;
CREATE TABLE users ( CREATE TABLE users (
id INTEGER NOT NULL IDENTITY PRIMARY KEY, id INTEGER NOT NULL IDENTITY,
first_name VARCHAR(50) NOT NULL, first_name VARCHAR(50) NOT NULL,
last_name VARCHAR(50) NOT NULL last_name VARCHAR(50) NOT NULL
); );

View File

@ -16,6 +16,9 @@
package org.springframework.orm.jpa; package org.springframework.orm.jpa;
import javax.persistence.EntityManager;
import javax.persistence.Query;
import org.springframework.test.jpa.AbstractJpaTests; import org.springframework.test.jpa.AbstractJpaTests;
import org.springframework.transaction.support.TransactionSynchronizationManager; import org.springframework.transaction.support.TransactionSynchronizationManager;
@ -81,6 +84,10 @@ public abstract class AbstractEntityManagerFactoryIntegrationTests extends Abstr
assertFalse(TransactionSynchronizationManager.isActualTransactionActive()); assertFalse(TransactionSynchronizationManager.isActualTransactionActive());
} }
protected int countRowsInTable(EntityManager em, String tableName) {
Query query = em.createNativeQuery("SELECT COUNT(0) FROM " + tableName);
return ((Number) query.getSingleResult()).intValue();
};
public enum Provider { public enum Provider {
ECLIPSELINK, HIBERNATE, OPENJPA ECLIPSELINK, HIBERNATE, OPENJPA

View File

@ -93,7 +93,7 @@ public class ApplicationManagedEntityManagerIntegrationTests extends AbstractEnt
em.persist(p); em.persist(p);
em.flush(); em.flush();
assertEquals("1 row must have been inserted", 1, countRowsInTable("person")); assertEquals("1 row must have been inserted", 1, countRowsInTable(em, "person"));
} }
public void testStateClean() { public void testStateClean() {
@ -122,14 +122,14 @@ public class ApplicationManagedEntityManagerIntegrationTests extends AbstractEnt
setComplete(); setComplete();
endTransaction(); // Should rollback endTransaction(); // Should rollback
assertEquals("Tx must have committed back", assertEquals("Tx must have committed back",
1, countRowsInTable("person")); 1, countRowsInTable(em, "person"));
// Now clean up the database // Now clean up the database
startNewTransaction(); startNewTransaction();
em.joinTransaction(); em.joinTransaction();
deleteAllPeopleUsingEntityManager(em); deleteAllPeopleUsingEntityManager(em);
assertEquals("People have been killed", assertEquals("People have been killed",
0, countRowsInTable("person")); 0, countRowsInTable(em, "person"));
setComplete(); setComplete();
} }
@ -143,7 +143,7 @@ public class ApplicationManagedEntityManagerIntegrationTests extends AbstractEnt
doInstantiateAndSave(em); doInstantiateAndSave(em);
endTransaction(); // Should rollback endTransaction(); // Should rollback
assertEquals("Tx must have been rolled back", assertEquals("Tx must have been rolled back",
0, countRowsInTable("person")); 0, countRowsInTable(em, "person"));
} }
public void testCommitOccurs() { public void testCommitOccurs() {
@ -154,7 +154,7 @@ public class ApplicationManagedEntityManagerIntegrationTests extends AbstractEnt
setComplete(); setComplete();
endTransaction(); // Should rollback endTransaction(); // Should rollback
assertEquals("Tx must have committed back", assertEquals("Tx must have committed back",
1, countRowsInTable("person")); 1, countRowsInTable(em, "person"));
// Now clean up the database // Now clean up the database
deleteFromTables(new String[] { "person" }); deleteFromTables(new String[] { "person" });

View File

@ -105,7 +105,7 @@ public class ContainerManagedEntityManagerIntegrationTests extends AbstractEntit
public void doInstantiateAndSave(EntityManager em) { public void doInstantiateAndSave(EntityManager em) {
assertEquals("Should be no people from previous transactions", assertEquals("Should be no people from previous transactions",
0, countRowsInTable("person")); 0, countRowsInTable(em, "person"));
Person p = new Person(); Person p = new Person();
p.setFirstName("Tony"); p.setFirstName("Tony");
@ -113,7 +113,7 @@ public class ContainerManagedEntityManagerIntegrationTests extends AbstractEntit
em.persist(p); em.persist(p);
em.flush(); em.flush();
assertEquals("1 row must have been inserted", 1, countRowsInTable("person")); assertEquals("1 row must have been inserted", 1, countRowsInTable(em, "person"));
} }
public void testReuseInNewTransaction() { public void testReuseInNewTransaction() {
@ -132,7 +132,7 @@ public class ContainerManagedEntityManagerIntegrationTests extends AbstractEntit
setComplete(); setComplete();
endTransaction(); // Should rollback endTransaction(); // Should rollback
assertEquals("Tx must have committed back", assertEquals("Tx must have committed back",
1, countRowsInTable("person")); 1, countRowsInTable(em, "person"));
// Now clean up the database // Now clean up the database
deleteFromTables(new String[] { "person" }); deleteFromTables(new String[] { "person" });
@ -143,7 +143,7 @@ public class ContainerManagedEntityManagerIntegrationTests extends AbstractEntit
doInstantiateAndSave(em); doInstantiateAndSave(em);
endTransaction(); // Should rollback endTransaction(); // Should rollback
assertEquals("Tx must have been rolled back", assertEquals("Tx must have been rolled back",
0, countRowsInTable("person")); 0, countRowsInTable(em, "person"));
} }
public void testCommitOccurs() { public void testCommitOccurs() {
@ -152,7 +152,7 @@ public class ContainerManagedEntityManagerIntegrationTests extends AbstractEntit
setComplete(); setComplete();
endTransaction(); // Should rollback endTransaction(); // Should rollback
assertEquals("Tx must have committed back", assertEquals("Tx must have committed back",
1, countRowsInTable("person")); 1, countRowsInTable(em, "person"));
// Now clean up the database // Now clean up the database
deleteFromTables(new String[] { "person" }); deleteFromTables(new String[] { "person" });

View File

@ -134,7 +134,7 @@ public abstract class AbstractTransactionalDataSourceSpringContextTests
* @return the number of rows in the table * @return the number of rows in the table
*/ */
protected int countRowsInTable(String tableName) { protected int countRowsInTable(String tableName) {
return this.jdbcTemplate.queryForInt("SELECT COUNT(0) FROM " + tableName); return this.jdbcTemplate.queryForObject("SELECT COUNT(0) FROM " + tableName, Integer.class);
} }

View File

@ -109,7 +109,7 @@ public class HibernateSessionFlushingTests extends AbstractTransactionalJUnit4Sp
// finally flushed (i.e., in production code) // finally flushed (i.e., in production code)
} }
@Test(expected = GenericJDBCException.class) @Test(expected = ConstraintViolationException.class)
public void updateSamWithNullDriversLicenseWithSessionFlush() { public void updateSamWithNullDriversLicenseWithSessionFlush() {
updateSamWithNullDriversLicense(); updateSamWithNullDriversLicense();
// Manual flush is required to avoid false positive in test // Manual flush is required to avoid false positive in test

View File

@ -2,7 +2,7 @@ DROP TABLE drivers_license IF EXISTS;
DROP TABLE person IF EXISTS; DROP TABLE person IF EXISTS;
CREATE TABLE person ( CREATE TABLE person (
id INTEGER NOT NULL IDENTITY PRIMARY KEY, id INTEGER NOT NULL IDENTITY,
name VARCHAR(50) NOT NULL, name VARCHAR(50) NOT NULL,
drivers_license_id INTEGER NOT NULL drivers_license_id INTEGER NOT NULL
); );
@ -10,7 +10,7 @@ CREATE UNIQUE INDEX person_name ON person(name);
CREATE UNIQUE INDEX person_drivers_license_id ON person(drivers_license_id); CREATE UNIQUE INDEX person_drivers_license_id ON person(drivers_license_id);
CREATE TABLE drivers_license ( CREATE TABLE drivers_license (
id INTEGER NOT NULL IDENTITY PRIMARY KEY, id INTEGER NOT NULL IDENTITY,
license_number INTEGER NOT NULL license_number INTEGER NOT NULL
); );
CREATE UNIQUE INDEX drivers_license_license_number ON drivers_license(license_number); CREATE UNIQUE INDEX drivers_license_license_number ON drivers_license(license_number);

View File

@ -1,3 +1,3 @@
CREATE TABLE enigma ( CREATE TABLE enigma (
id INTEGER NOT NULL IDENTITY PRIMARY KEY id INTEGER NOT NULL IDENTITY
); );