Wrap native Exceptions in LettuceConnectionFactory
DATAREDIS-191 - Wrap native Exceptions in RedisConnectionFailureExceptions - Support switching from shared to non-shared connection by resetting shared connection in afterPropertiesSet
This commit is contained in:
@@ -23,6 +23,7 @@ import static org.junit.Assert.assertNotSame;
|
||||
import org.junit.After;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.springframework.data.redis.RedisConnectionFailureException;
|
||||
import org.springframework.data.redis.RedisSystemException;
|
||||
import org.springframework.data.redis.SettingsUtils;
|
||||
import org.springframework.data.redis.connection.DefaultStringRedisConnection;
|
||||
@@ -169,4 +170,44 @@ public class LettuceConnectionFactoryTests {
|
||||
factory.initConnection();
|
||||
assertNotSame(nativeConn, factory.getConnection().getNativeConnection());
|
||||
}
|
||||
|
||||
@Test(expected=RedisConnectionFailureException.class)
|
||||
public void testInitConnectionException() {
|
||||
factory.setHostName("fakeHost");
|
||||
factory.afterPropertiesSet();
|
||||
}
|
||||
|
||||
@Test(expected=RedisConnectionFailureException.class)
|
||||
public void testGetConnectionNotSharedException() {
|
||||
factory.setShareNativeConnection(false);
|
||||
factory.setHostName("fakeHost");
|
||||
factory.afterPropertiesSet();
|
||||
factory.getConnection();
|
||||
}
|
||||
|
||||
@Test(expected=RedisConnectionFailureException.class)
|
||||
public void testGetConnectionSharedException() {
|
||||
factory.setShareNativeConnection(false);
|
||||
factory.setHostName("fakeHost");
|
||||
factory.afterPropertiesSet();
|
||||
factory.setShareNativeConnection(true);
|
||||
factory.getConnection();
|
||||
}
|
||||
|
||||
@Test(expected=RedisConnectionFailureException.class)
|
||||
public void testGetNativeConnectionNotSharedException() {
|
||||
factory.setShareNativeConnection(false);
|
||||
factory.setHostName("fakeHost");
|
||||
factory.afterPropertiesSet();
|
||||
factory.getNativeConnection();
|
||||
}
|
||||
|
||||
@Test(expected=RedisConnectionFailureException.class)
|
||||
public void testGetNativeConnectionSharedException() {
|
||||
factory.setShareNativeConnection(false);
|
||||
factory.setHostName("fakeHost");
|
||||
factory.afterPropertiesSet();
|
||||
factory.setShareNativeConnection(true);
|
||||
factory.getNativeConnection();
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user