Browse Source

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
pull/418/head
Phillip Webb 11 years ago
parent
commit
d9c4470461
  1. 12
      build.gradle
  2. 31
      spring-jdbc/src/test/java/org/springframework/jdbc/datasource/init/DatabasePopulatorTests.java
  3. 2
      spring-jdbc/src/test/resources/org/springframework/jdbc/datasource/init/users-schema.sql
  4. 7
      spring-orm/src/test/java/org/springframework/orm/jpa/AbstractEntityManagerFactoryIntegrationTests.java
  5. 10
      spring-orm/src/test/java/org/springframework/orm/jpa/ApplicationManagedEntityManagerIntegrationTests.java
  6. 10
      spring-orm/src/test/java/org/springframework/orm/jpa/ContainerManagedEntityManagerIntegrationTests.java
  7. 2
      spring-orm/src/test/java/org/springframework/test/AbstractTransactionalDataSourceSpringContextTests.java
  8. 2
      spring-test/src/test/java/org/springframework/test/context/junit4/orm/HibernateSessionFlushingTests.java
  9. 4
      spring-test/src/test/java/org/springframework/test/context/junit4/orm/db-schema.sql
  10. 2
      spring-test/src/test/java/org/springframework/test/context/junit4/spr8849/spr8849-schema.sql

12
build.gradle

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

31
spring-jdbc/src/test/java/org/springframework/jdbc/datasource/init/DatabasePopulatorTests.java

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

2
spring-jdbc/src/test/resources/org/springframework/jdbc/datasource/init/users-schema.sql

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

7
spring-orm/src/test/java/org/springframework/orm/jpa/AbstractEntityManagerFactoryIntegrationTests.java

@ -16,6 +16,9 @@ @@ -16,6 +16,9 @@
package org.springframework.orm.jpa;
import javax.persistence.EntityManager;
import javax.persistence.Query;
import org.springframework.test.jpa.AbstractJpaTests;
import org.springframework.transaction.support.TransactionSynchronizationManager;
@ -81,6 +84,10 @@ public abstract class AbstractEntityManagerFactoryIntegrationTests extends Abstr @@ -81,6 +84,10 @@ public abstract class AbstractEntityManagerFactoryIntegrationTests extends Abstr
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 {
ECLIPSELINK, HIBERNATE, OPENJPA

10
spring-orm/src/test/java/org/springframework/orm/jpa/ApplicationManagedEntityManagerIntegrationTests.java

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

10
spring-orm/src/test/java/org/springframework/orm/jpa/ContainerManagedEntityManagerIntegrationTests.java

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

2
spring-orm/src/test/java/org/springframework/test/AbstractTransactionalDataSourceSpringContextTests.java

@ -134,7 +134,7 @@ public abstract class AbstractTransactionalDataSourceSpringContextTests @@ -134,7 +134,7 @@ public abstract class AbstractTransactionalDataSourceSpringContextTests
* @return the number of rows in the table
*/
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);
}

2
spring-test/src/test/java/org/springframework/test/context/junit4/orm/HibernateSessionFlushingTests.java

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

4
spring-test/src/test/java/org/springframework/test/context/junit4/orm/db-schema.sql

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

2
spring-test/src/test/java/org/springframework/test/context/junit4/spr8849/spr8849-schema.sql

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

Loading…
Cancel
Save