Use a connection data pool when running tests
It cuts 40 seconds or around from the tests running time.
This commit is contained in:
parent
bf1f10f4d7
commit
3713198a93
5 changed files with 37 additions and 6 deletions
|
|
@ -32,6 +32,11 @@
|
||||||
<groupId>junit</groupId>
|
<groupId>junit</groupId>
|
||||||
<artifactId>junit</artifactId>
|
<artifactId>junit</artifactId>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
<!-- datasource for testing -->
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.jolbox</groupId>
|
||||||
|
<artifactId>bonecp</artifactId>
|
||||||
|
</dependency>
|
||||||
<!-- Spring -->
|
<!-- Spring -->
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.springframework</groupId>
|
<groupId>org.springframework</groupId>
|
||||||
|
|
|
||||||
|
|
@ -7,10 +7,17 @@
|
||||||
http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-2.5.xsd
|
http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-2.5.xsd
|
||||||
http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-2.5.xsd">
|
http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-2.5.xsd">
|
||||||
|
|
||||||
|
<bean id="dataSourceReal"
|
||||||
|
class="com.jolbox.bonecp.BoneCPDataSource" destroy-method="close"
|
||||||
|
p:driverClass="${jdbcDriver.className}" p:jdbcUrl="${testDataSource.url}"
|
||||||
|
p:username="${testDataSource.user}" p:password="${testDataSource.password}"
|
||||||
|
p:maxConnectionsPerPartition="10"
|
||||||
|
p:minConnectionsPerPartition="4"
|
||||||
|
p:partitionCount="3"/>
|
||||||
|
|
||||||
<bean id="dataSource"
|
<bean id="dataSource"
|
||||||
class="org.springframework.jdbc.datasource.DriverManagerDataSource"
|
class="org.springframework.jdbc.datasource.LazyConnectionDataSourceProxy"
|
||||||
p:driverClassName="${jdbcDriver.className}" p:url="${testDataSource.url}"
|
p:targetDataSource-ref="dataSourceReal" />
|
||||||
p:username="${testDataSource.user}" p:password="${testDataSource.password}" />
|
|
||||||
|
|
||||||
<!-- Hibernate Session Factory. -->
|
<!-- Hibernate Session Factory. -->
|
||||||
<bean id="sessionFactory"
|
<bean id="sessionFactory"
|
||||||
|
|
|
||||||
|
|
@ -427,6 +427,11 @@
|
||||||
<groupId>junit</groupId>
|
<groupId>junit</groupId>
|
||||||
<artifactId>junit</artifactId>
|
<artifactId>junit</artifactId>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
<!-- datasource for testing -->
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.jolbox</groupId>
|
||||||
|
<artifactId>bonecp</artifactId>
|
||||||
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.hibernate</groupId>
|
<groupId>org.hibernate</groupId>
|
||||||
<artifactId>hibernate-validator</artifactId>
|
<artifactId>hibernate-validator</artifactId>
|
||||||
|
|
|
||||||
|
|
@ -7,10 +7,17 @@
|
||||||
http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-2.5.xsd
|
http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-2.5.xsd
|
||||||
http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-2.5.xsd">
|
http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-2.5.xsd">
|
||||||
|
|
||||||
|
<bean id="dataSourceReal"
|
||||||
|
class="com.jolbox.bonecp.BoneCPDataSource" destroy-method="close"
|
||||||
|
p:driverClass="${jdbcDriver.className}" p:jdbcUrl="${testDataSource.url}"
|
||||||
|
p:username="${testDataSource.user}" p:password="${testDataSource.password}"
|
||||||
|
p:maxConnectionsPerPartition="10"
|
||||||
|
p:minConnectionsPerPartition="4"
|
||||||
|
p:partitionCount="3"/>
|
||||||
|
|
||||||
<bean id="dataSource"
|
<bean id="dataSource"
|
||||||
class="org.springframework.jdbc.datasource.DriverManagerDataSource"
|
class="org.springframework.jdbc.datasource.LazyConnectionDataSourceProxy"
|
||||||
p:driverClassName="${jdbcDriver.className}" p:url="${testDataSource.url}"
|
p:targetDataSource-ref="dataSourceReal" />
|
||||||
p:username="${testDataSource.user}" p:password="${testDataSource.password}" />
|
|
||||||
|
|
||||||
|
|
||||||
<!-- Hibernate Session Factory. -->
|
<!-- Hibernate Session Factory. -->
|
||||||
|
|
|
||||||
7
pom.xml
7
pom.xml
|
|
@ -263,6 +263,13 @@
|
||||||
<version>4.4</version>
|
<version>4.4</version>
|
||||||
<scope>test</scope>
|
<scope>test</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
<!-- datasource for testing -->
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.jolbox</groupId>
|
||||||
|
<artifactId>bonecp</artifactId>
|
||||||
|
<version>0.7.1.RELEASE</version>
|
||||||
|
<scope>test</scope>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
<!-- Easy mock -->
|
<!-- Easy mock -->
|
||||||
<dependency>
|
<dependency>
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue