File tree Expand file tree Collapse file tree
src/test/java/com/baeldung/connectionpool
spring-5/src/test/java/com/baeldung/connectionpool Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1919 <groupId >org.springframework.boot</groupId >
2020 <artifactId >spring-boot-starter-web</artifactId >
2121 </dependency >
22+ <dependency >
23+ <groupId >org.springframework.boot</groupId >
24+ <artifactId >spring-boot-starter-data-jpa</artifactId >
25+ <exclusions >
26+ <exclusion >
27+ <groupId >org.apache.tomcat</groupId >
28+ <artifactId >tomcat-jdbc</artifactId >
29+ </exclusion >
30+ </exclusions >
31+ </dependency >
32+ <dependency >
33+ <groupId >com.h2database</groupId >
34+ <artifactId >h2</artifactId >
35+ <version >${h2database.version} </version >
36+ <scope >test</scope >
37+ </dependency >
38+ <dependency >
39+ <groupId >com.zaxxer</groupId >
40+ <artifactId >HikariCP</artifactId >
41+ <version >${hikaricp.version} </version >
42+ </dependency >
2243 <dependency >
2344 <groupId >org.springframework.boot</groupId >
2445 <artifactId >spring-boot-starter-test</artifactId >
5879 <flips-web .version>1.0.1</flips-web .version>
5980 <lombok .version>1.16.18</lombok .version>
6081 <java .version>1.8</java .version>
82+ <h2database .version>1.4.197</h2database .version>
6183 </properties >
6284
6385</project >
Original file line number Diff line number Diff line change 1+ package com .baeldung .connectionpool ;
2+
3+ import org .springframework .boot .SpringApplication ;
4+ import org .springframework .boot .autoconfigure .SpringBootApplication ;
5+
6+ @ SpringBootApplication
7+ public class ApplicationWithHikariConnectionPool {
8+
9+ public static void main (String [] args ) {
10+ SpringApplication .run (ApplicationWithHikariConnectionPool .class , args );
11+ }
12+ }
Original file line number Diff line number Diff line change 1+ package com .baeldung .connectionpool ;
2+
3+ import static org .junit .Assert .*;
4+
5+ import javax .sql .DataSource ;
6+
7+ import org .junit .Test ;
8+ import org .junit .runner .RunWith ;
9+ import org .springframework .beans .factory .annotation .Autowired ;
10+ import org .springframework .boot .test .context .SpringBootTest ;
11+ import org .springframework .test .context .junit4 .SpringRunner ;
12+
13+ @ RunWith (SpringRunner .class )
14+ @ SpringBootTest (
15+ // instead of setting this property, we can exclude the dependency to org.apache.tomcat:tomcat-jdbc in pom.xml
16+ properties = "spring.datasource.type=com.zaxxer.hikari.HikariDataSource" )
17+ public class HikariIntegrationTest {
18+
19+ @ Autowired
20+ private DataSource dataSource ;
21+
22+ @ Test
23+ public void hikariConnectionPoolIsConfigured () {
24+ assertEquals ("com.zaxxer.hikari.HikariDataSource" , dataSource .getClass ()
25+ .getName ());
26+ }
27+
28+ }
Original file line number Diff line number Diff line change 1+ package com .baeldung .connectionpool ;
2+
3+ import org .springframework .boot .SpringApplication ;
4+ import org .springframework .boot .autoconfigure .SpringBootApplication ;
5+
6+ @ SpringBootApplication
7+ public class ApplicationWithHikariConnectionPool {
8+
9+ public static void main (String [] args ) {
10+ SpringApplication .run (ApplicationWithHikariConnectionPool .class , args );
11+ }
12+ }
Original file line number Diff line number Diff line change 1+ package com .baeldung .connectionpool ;
2+
3+ import static org .junit .Assert .*;
4+
5+ import javax .sql .DataSource ;
6+
7+ import org .junit .Test ;
8+ import org .junit .runner .RunWith ;
9+ import org .springframework .beans .factory .annotation .Autowired ;
10+ import org .springframework .boot .test .context .SpringBootTest ;
11+ import org .springframework .test .context .junit4 .SpringRunner ;
12+
13+ @ RunWith (SpringRunner .class )
14+ @ SpringBootTest
15+ public class HikariIntegrationTest {
16+
17+ @ Autowired
18+ private DataSource dataSource ;
19+
20+ @ Test
21+ public void hikariConnectionPoolIsConfigured () {
22+ assertEquals ("com.zaxxer.hikari.HikariDataSource" , dataSource .getClass ()
23+ .getName ());
24+ }
25+
26+ }
You can’t perform that action at this time.
0 commit comments