Suppress warnings in tests in spring-jdbc

This commit is contained in:
Sam Brannen 2015-08-21 23:56:01 +02:00
parent c685fd7c23
commit a43d78ea55
1 changed files with 16 additions and 16 deletions

View File

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