DATAREDIS-676 - Polishing.

Set disposal state in LettuceClusterConnection only once. Close resources after tests. Typos, formatting.

Original pull request: #266.
This commit is contained in:
Mark Paluch
2017-08-21 10:07:36 +02:00
parent 4e903113c7
commit cdb2624f62
2 changed files with 11 additions and 7 deletions

View File

@@ -31,6 +31,7 @@ import org.junit.Before;
import org.junit.Test;
import org.springframework.data.redis.ConnectionFactoryTracker;
import org.springframework.data.redis.connection.RedisClusterConfiguration;
import org.springframework.data.redis.connection.RedisClusterConnection;
import org.springframework.data.redis.connection.RedisSentinelConfiguration;
import org.springframework.test.util.ReflectionTestUtils;
@@ -38,7 +39,6 @@ import com.lambdaworks.redis.AbstractRedisClient;
import com.lambdaworks.redis.RedisClient;
import com.lambdaworks.redis.RedisURI;
import com.lambdaworks.redis.cluster.RedisClusterClient;
import org.springframework.test.util.ReflectionTestUtils;
/**
@@ -279,13 +279,18 @@ public class LettuceConnectionFactoryUnitTests {
}
}
@Test // DATAREDIS-676
@Test // DATAREDIS-676
public void timeoutShouldBePassedOnToClusterConnection() {
LettuceConnectionFactory connectionFactory = new LettuceConnectionFactory(clusterConfig);
connectionFactory.setShutdownTimeout(0);
connectionFactory.setTimeout(2000);
connectionFactory.afterPropertiesSet();
ConnectionFactoryTracker.add(connectionFactory);
assertThat((Long) ReflectionTestUtils.getField(connectionFactory.getClusterConnection(), "timeout"), is(equalTo(2000L)));
RedisClusterConnection clusterConnection = connectionFactory.getClusterConnection();
assertThat((Long) ReflectionTestUtils.getField(clusterConnection, "timeout"), is(equalTo(2000L)));
clusterConnection.close();
}
}