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

@@ -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
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

View File

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

View File

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

View File

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