+ improve connection cleanup in some tests
This commit is contained in:
@@ -19,19 +19,17 @@ package org.springframework.data.keyvalue.redis.connection;
|
||||
import static org.junit.Assert.*;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.LinkedHashSet;
|
||||
import java.util.List;
|
||||
import java.util.Properties;
|
||||
import java.util.Set;
|
||||
import java.util.UUID;
|
||||
|
||||
import org.junit.After;
|
||||
import org.junit.AfterClass;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.springframework.beans.factory.DisposableBean;
|
||||
import org.springframework.dao.DataAccessException;
|
||||
import org.springframework.data.keyvalue.redis.Address;
|
||||
import org.springframework.data.keyvalue.redis.ConnectionFactoryTracker;
|
||||
import org.springframework.data.keyvalue.redis.Person;
|
||||
import org.springframework.data.keyvalue.redis.core.StringRedisTemplate;
|
||||
import org.springframework.data.keyvalue.redis.serializer.JdkSerializationRedisSerializer;
|
||||
@@ -49,26 +47,17 @@ public abstract class AbstractConnectionIntegrationTests {
|
||||
|
||||
protected abstract RedisConnectionFactory getConnectionFactory();
|
||||
|
||||
private static Set<RedisConnectionFactory> connFactories = new LinkedHashSet<RedisConnectionFactory>();
|
||||
|
||||
@Before
|
||||
public void setUp() {
|
||||
connection = new DefaultStringRedisConnection(getConnectionFactory().getConnection());
|
||||
connFactories.add(getConnectionFactory());
|
||||
ConnectionFactoryTracker.add(getConnectionFactory());
|
||||
|
||||
}
|
||||
|
||||
@AfterClass
|
||||
public static void cleanUp() {
|
||||
if (connFactories != null) {
|
||||
for (RedisConnectionFactory connectionFactory : connFactories) {
|
||||
try {
|
||||
((DisposableBean) connectionFactory).destroy();
|
||||
} catch (Exception ex) {
|
||||
System.err.println("Cannot clean factory " + connectionFactory + ex);
|
||||
}
|
||||
}
|
||||
}
|
||||
ConnectionFactoryTracker.cleanUp();
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -44,6 +44,7 @@ public class RedisAtomicTests {
|
||||
intCounter = new RedisAtomicInteger(getClass().getSimpleName() + ":int", factory);
|
||||
longCounter = new RedisAtomicLong(getClass().getSimpleName() + ":long", factory);
|
||||
this.factory = factory;
|
||||
ConnectionFactoryTracker.add(factory);
|
||||
}
|
||||
|
||||
@After
|
||||
|
||||
Reference in New Issue
Block a user