Suppress warnings in tests in spring-jdbc
This commit is contained in:
parent
c685fd7c23
commit
a43d78ea55
|
|
@ -35,27 +35,27 @@ import static org.junit.Assert.*;
|
|||
public class CustomSQLExceptionTranslatorRegistrarTests {
|
||||
|
||||
@Test
|
||||
@SuppressWarnings("resource")
|
||||
public void customErrorCodeTranslation() {
|
||||
try (ClassPathXmlApplicationContext context = new ClassPathXmlApplicationContext(
|
||||
"test-custom-translators-context.xml", CustomSQLExceptionTranslatorRegistrarTests.class)) {
|
||||
new ClassPathXmlApplicationContext("test-custom-translators-context.xml",
|
||||
CustomSQLExceptionTranslatorRegistrarTests.class);
|
||||
|
||||
SQLErrorCodes codes = SQLErrorCodesFactory.getInstance().getErrorCodes("H2");
|
||||
SQLErrorCodeSQLExceptionTranslator sext = new SQLErrorCodeSQLExceptionTranslator();
|
||||
sext.setSqlErrorCodes(codes);
|
||||
SQLErrorCodes codes = SQLErrorCodesFactory.getInstance().getErrorCodes("H2");
|
||||
SQLErrorCodeSQLExceptionTranslator sext = new SQLErrorCodeSQLExceptionTranslator();
|
||||
sext.setSqlErrorCodes(codes);
|
||||
|
||||
DataAccessException exFor4200 = sext.doTranslate("", "", new SQLException("Ouch", "42000", 42000));
|
||||
assertNotNull("Should have been translated", exFor4200);
|
||||
assertTrue("Should have been instance of BadSqlGrammarException",
|
||||
BadSqlGrammarException.class.isAssignableFrom(exFor4200.getClass()));
|
||||
DataAccessException exFor4200 = sext.doTranslate("", "", new SQLException("Ouch", "42000", 42000));
|
||||
assertNotNull("Should have been translated", exFor4200);
|
||||
assertTrue("Should have been instance of BadSqlGrammarException",
|
||||
BadSqlGrammarException.class.isAssignableFrom(exFor4200.getClass()));
|
||||
|
||||
DataAccessException exFor2 = sext.doTranslate("", "", new SQLException("Ouch", "42000", 2));
|
||||
assertNotNull("Should have been translated", exFor2);
|
||||
assertTrue("Should have been instance of TransientDataAccessResourceException",
|
||||
TransientDataAccessResourceException.class.isAssignableFrom(exFor2.getClass()));
|
||||
DataAccessException exFor2 = sext.doTranslate("", "", new SQLException("Ouch", "42000", 2));
|
||||
assertNotNull("Should have been translated", exFor2);
|
||||
assertTrue("Should have been instance of TransientDataAccessResourceException",
|
||||
TransientDataAccessResourceException.class.isAssignableFrom(exFor2.getClass()));
|
||||
|
||||
DataAccessException exFor3 = sext.doTranslate("", "", new SQLException("Ouch", "42000", 3));
|
||||
assertNull("Should not have been translated", exFor3);
|
||||
}
|
||||
DataAccessException exFor3 = sext.doTranslate("", "", new SQLException("Ouch", "42000", 3));
|
||||
assertNull("Should not have been translated", exFor3);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue