Skip to content

Commit ef66708

Browse files
committed
Fixed BadSqlGrammarException usage in transaction test suite
Issue: SPR-10902
1 parent 30b3e24 commit ef66708

File tree

2 files changed

+11
-14
lines changed

2 files changed

+11
-14
lines changed

spring-test/src/test/java/org/springframework/test/context/junit4/AbstractTransactionalSpringRunnerTests.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2012 the original author or authors.
2+
* Copyright 2002-2013 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.
@@ -16,7 +16,7 @@
1616

1717
package org.springframework.test.context.junit4;
1818

19-
import org.springframework.jdbc.BadSqlGrammarException;
19+
import org.springframework.dao.DataAccessException;
2020
import org.springframework.jdbc.core.simple.SimpleJdbcTemplate;
2121
import org.springframework.test.annotation.NotTransactional;
2222
import org.springframework.test.context.ContextConfiguration;
@@ -54,7 +54,7 @@ protected static void createPersonTable(SimpleJdbcTemplate simpleJdbcTemplate) {
5454
try {
5555
simpleJdbcTemplate.update("CREATE TABLE person (name VARCHAR(20) NOT NULL, PRIMARY KEY(name))");
5656
}
57-
catch (BadSqlGrammarException bsge) {
57+
catch (DataAccessException dae) {
5858
// ignore
5959
}
6060
}

spring-test/src/test/java/org/springframework/test/context/junit4/ConcreteTransactionalJUnit4SpringContextTests.java

Lines changed: 8 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -16,31 +16,28 @@
1616

1717
package org.springframework.test.context.junit4;
1818

19-
import static org.junit.Assert.assertEquals;
20-
import static org.junit.Assert.assertNotNull;
21-
import static org.junit.Assert.assertNull;
22-
import static org.junit.Assert.assertTrue;
23-
import static org.springframework.test.transaction.TransactionTestUtils.assertInTransaction;
24-
import static org.springframework.test.transaction.TransactionTestUtils.inTransaction;
25-
2619
import javax.annotation.Resource;
2720
import javax.sql.DataSource;
2821

2922
import org.junit.After;
3023
import org.junit.Before;
3124
import org.junit.Test;
32-
import org.springframework.tests.sample.beans.Employee;
33-
import org.springframework.tests.sample.beans.Pet;
25+
3426
import org.springframework.beans.factory.BeanNameAware;
3527
import org.springframework.beans.factory.InitializingBean;
3628
import org.springframework.beans.factory.annotation.Autowired;
37-
import org.springframework.jdbc.BadSqlGrammarException;
29+
import org.springframework.dao.DataAccessException;
3830
import org.springframework.jdbc.core.simple.SimpleJdbcTemplate;
3931
import org.springframework.test.annotation.NotTransactional;
4032
import org.springframework.test.context.ContextConfiguration;
4133
import org.springframework.test.context.transaction.AfterTransaction;
4234
import org.springframework.test.context.transaction.BeforeTransaction;
4335
import org.springframework.test.jdbc.SimpleJdbcTestUtils;
36+
import org.springframework.tests.sample.beans.Employee;
37+
import org.springframework.tests.sample.beans.Pet;
38+
39+
import static org.junit.Assert.*;
40+
import static org.springframework.test.transaction.TransactionTestUtils.*;
4441

4542
/**
4643
* Combined integration test for {@link AbstractJUnit4SpringContextTests} and
@@ -87,7 +84,7 @@ protected static void createPersonTable(final SimpleJdbcTemplate simpleJdbcTempl
8784
try {
8885
simpleJdbcTemplate.update("CREATE TABLE person (name VARCHAR(20) NOT NULL, PRIMARY KEY(name))");
8986
}
90-
catch (final BadSqlGrammarException bsge) {
87+
catch (DataAccessException dae) {
9188
/* ignore */
9289
}
9390
}

0 commit comments

Comments
 (0)