Skip to content

Commit 5244509

Browse files
lor6pivovarit
authored andcommitted
Non transient exception (eugenp#570)
* non transient data access exception examples * change to derby db * change to in memory derby db * delete failed test * fix invalidresource test * fix cleanupfailure test
1 parent a7694db commit 5244509

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

spring-exceptions/src/test/java/org/baeldung/ex/nontransientdataaccessexception/CleanupFailureExceptionTest.java

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,15 +8,19 @@
88
import org.junit.runner.RunWith;
99
import org.springframework.beans.factory.annotation.Autowired;
1010
import org.springframework.dao.CleanupFailureDataAccessException;
11-
import org.springframework.dao.NonTransientDataAccessException;
1211
import org.springframework.test.context.ContextConfiguration;
1312
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
1413
import org.springframework.test.context.support.AnnotationConfigContextLoader;
1514

15+
import java.util.logging.Level;
16+
import java.util.logging.Logger;
17+
1618
@RunWith(SpringJUnit4ClassRunner.class)
1719
@ContextConfiguration(classes = { Cause1NonTransientConfig.class }, loader = AnnotationConfigContextLoader.class)
1820
public class CleanupFailureExceptionTest {
1921

22+
private static final Logger LOG = Logger.getLogger(CleanupFailureExceptionTest.class.getName());
23+
2024
@Autowired
2125
private SessionFactory sessionFactory;
2226

@@ -31,8 +35,8 @@ public void whenCleanupAfterSaving_thenCleanupException() {
3135
} finally {
3236
try {
3337
sessionFactory.close();
34-
} catch (final NonTransientDataAccessException exc) {
35-
throw new CleanupFailureDataAccessException("Closing connection failed", exc.getCause());
38+
} catch (final CleanupFailureDataAccessException exc) {
39+
LOG.log(Level.SEVERE, exc.getMessage());
3640
}
3741
}
3842
}

0 commit comments

Comments
 (0)