Modify connection tests to reuse connection factories
- Use Spring integration test support to instantiate ConnectionFactory once per instance of test class (instead of per method) - Minimizes number of connection factories and thus connections in pooled scenarios
This commit is contained in:
@@ -0,0 +1,24 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<beans xmlns="http://www.springframework.org/schema/beans"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:p="http://www.springframework.org/schema/p"
|
||||
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
|
||||
|
||||
|
||||
<!-- We can't pool connections for this test because Jedis leaves OutputSteam
|
||||
in compromised state on NullPointerException (which happens if a null key
|
||||
or value is used) but doesn't remove them from the pool or reconnect them
|
||||
on next attempted use -->
|
||||
<bean id="jedisConnectionFactory "
|
||||
class="org.springframework.data.redis.connection.jedis.JedisConnectionFactory"
|
||||
p:usePool="false">
|
||||
<property name="hostName">
|
||||
<bean class="org.springframework.data.redis.SettingsUtils"
|
||||
factory-method="getHost" />
|
||||
</property>
|
||||
<property name="port">
|
||||
<bean class="org.springframework.data.redis.SettingsUtils"
|
||||
factory-method="getPort" />
|
||||
</property>
|
||||
</bean>
|
||||
|
||||
</beans>
|
||||
@@ -0,0 +1,22 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<beans xmlns="http://www.springframework.org/schema/beans"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:p="http://www.springframework.org/schema/p"
|
||||
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
|
||||
|
||||
<!-- We can't pool connections for this test because JRedis closes connections
|
||||
on Exception but doesn't remove them from the pool or reconnect them on next
|
||||
attempted use -->
|
||||
<bean id="jredisConnectionFactory "
|
||||
class="org.springframework.data.redis.connection.jredis.JredisConnectionFactory"
|
||||
p:usePool="false">
|
||||
<property name="hostName">
|
||||
<bean class="org.springframework.data.redis.SettingsUtils"
|
||||
factory-method="getHost" />
|
||||
</property>
|
||||
<property name="port">
|
||||
<bean class="org.springframework.data.redis.SettingsUtils"
|
||||
factory-method="getPort" />
|
||||
</property>
|
||||
</bean>
|
||||
|
||||
</beans>
|
||||
@@ -0,0 +1,16 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<beans xmlns="http://www.springframework.org/schema/beans"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:p="http://www.springframework.org/schema/p"
|
||||
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
|
||||
|
||||
<bean id="lettuceConnectionFactory "
|
||||
class="org.springframework.data.redis.connection.lettuce.LettuceConnectionFactory">
|
||||
<property name="hostName">
|
||||
<bean class="org.springframework.data.redis.SettingsUtils" factory-method="getHost" />
|
||||
</property>
|
||||
<property name="port">
|
||||
<bean class="org.springframework.data.redis.SettingsUtils" factory-method="getPort" />
|
||||
</property>
|
||||
</bean>
|
||||
|
||||
</beans>
|
||||
@@ -0,0 +1,18 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<beans xmlns="http://www.springframework.org/schema/beans"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:p="http://www.springframework.org/schema/p"
|
||||
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
|
||||
|
||||
<bean id="rjcConnectionFactory "
|
||||
class="org.springframework.data.redis.connection.rjc.RjcConnectionFactory">
|
||||
<property name="hostName">
|
||||
<bean class="org.springframework.data.redis.SettingsUtils"
|
||||
factory-method="getHost" />
|
||||
</property>
|
||||
<property name="port">
|
||||
<bean class="org.springframework.data.redis.SettingsUtils"
|
||||
factory-method="getPort" />
|
||||
</property>
|
||||
</bean>
|
||||
|
||||
</beans>
|
||||
@@ -0,0 +1,18 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<beans xmlns="http://www.springframework.org/schema/beans"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:p="http://www.springframework.org/schema/p"
|
||||
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
|
||||
|
||||
<bean id="srpConnectionFactory "
|
||||
class="org.springframework.data.redis.connection.srp.SrpConnectionFactory">
|
||||
<property name="hostName">
|
||||
<bean class="org.springframework.data.redis.SettingsUtils"
|
||||
factory-method="getHost" />
|
||||
</property>
|
||||
<property name="port">
|
||||
<bean class="org.springframework.data.redis.SettingsUtils"
|
||||
factory-method="getPort" />
|
||||
</property>
|
||||
</bean>
|
||||
|
||||
</beans>
|
||||
Reference in New Issue
Block a user