Lazily instantiate shared Lettuce connection

Allow app context to start if Redis is down

DATAREDIS-209
This commit is contained in:
Jennifer Hickey
2013-08-16 14:20:30 -07:00
parent 500a94d83d
commit f9cdad751c
2 changed files with 8 additions and 18 deletions

View File

@@ -174,18 +174,21 @@ public class LettuceConnectionFactoryTests {
assertNotSame(nativeConn, factory.getConnection().getNativeConnection());
}
@Test(expected=RedisConnectionFailureException.class)
public void testInitConnectionException() {
public void testGetConnectionException() {
factory.setHostName("fakeHost");
factory.afterPropertiesSet();
try {
factory.getConnection();
fail("Expected connection failure exception");
} catch(RedisConnectionFailureException e) {
}
}
@Test(expected=RedisConnectionFailureException.class)
public void testGetConnectionSharedException() {
@Test
public void testGetConnectionNotSharedBadHostname() {
factory.setShareNativeConnection(false);
factory.setHostName("fakeHost");
factory.afterPropertiesSet();
factory.setShareNativeConnection(true);
factory.getConnection();
}
@@ -197,15 +200,6 @@ public class LettuceConnectionFactoryTests {
assertNull(factory.getSharedConnection());
}
@Test(expected=RedisConnectionFailureException.class)
public void testGetSharedConnectionSharedException() {
factory.setShareNativeConnection(false);
factory.setHostName("fakeHost");
factory.afterPropertiesSet();
factory.setShareNativeConnection(true);
factory.getSharedConnection();
}
@Test
public void testCreateFactoryWithPool() {
DefaultLettucePool pool = new DefaultLettucePool(SettingsUtils.getHost(),