Guest User

Untitled

a guest
Mar 23rd, 2018
121
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.62 KB | None | 0 0
  1. @RunWith(SpringRunner.class)
  2. @JdbcTest
  3. @AutoConfigureTestDatabase(replace= AutoConfigureTestDatabase.Replace.NONE)
  4. @Sql( ... schema creation, sample data, etc )
  5. @ContextConfiguration(classes = ... dao and service classes used in the test)
  6.  
  7. // <editor-fold name='connection leaking fix'
  8. @Autowired
  9. private DataSource dataSource;
  10. private static HikariDataSource hikariDataSource;
  11.  
  12. @Before
  13. public void saveDataSource() {
  14. this.hikariDataSource = (HikariDataSource)dataSource;
  15. }
  16.  
  17. @AfterClass
  18. public static void releaseDataSource() {
  19. if (hikariDataSource != null) {
  20. hikariDataSource.close();
  21. }
  22. }
  23. // </editor-fold>
Add Comment
Please, Sign In to add comment