File tree Expand file tree Collapse file tree 2 files changed +29
-0
lines changed
persistence-modules/spring-boot-mysql/src
test/java/com/baeldung/boot/mysql Expand file tree Collapse file tree 2 files changed +29
-0
lines changed Original file line number Diff line number Diff line change @@ -22,6 +22,7 @@ spring:
2222 url : jdbc:mysql://localhost:3306/test?
2323 username : root
2424 password :
25+ driver-class-name : com.mysql.cj.jdbc.Driver
2526
2627---
2728
Original file line number Diff line number Diff line change 1+ package com .baeldung .boot .mysql ;
2+
3+ import static org .junit .jupiter .api .Assertions .assertNotNull ;
4+
5+ import java .sql .Connection ;
6+
7+ import javax .sql .DataSource ;
8+
9+ import org .junit .jupiter .api .Test ;
10+ import org .springframework .beans .factory .annotation .Autowired ;
11+ import org .springframework .boot .test .context .SpringBootTest ;
12+ import org .springframework .test .context .ActiveProfiles ;
13+
14+ //Please note, this test requires a MySQL server running on localhost:3306 with database "test" already created.
15+ @ SpringBootTest
16+ @ ActiveProfiles ("dev1" )
17+ class LoadDriverLiveTest {
18+
19+ @ Autowired
20+ private DataSource dataSource ;
21+
22+ @ Test
23+ void whenConnectingToDatabase_thenConnectionShouldBeValid () throws Exception {
24+ try (Connection connection = dataSource .getConnection ()) {
25+ assertNotNull (connection );
26+ }
27+ }
28+ }
You can’t perform that action at this time.
0 commit comments