List of usage examples for org.springframework.data.redis.connection.lettuce LettuceConnectionFactory getConnection
public RedisConnection getConnection()
From source file:org.springframework.data.redis.connection.lettuce.LettuceConnectionFactoryTests.java
@Test // DATAREDIS-576 public void connectionAppliesClientName() { LettuceClientConfiguration configuration = LettuceClientConfiguration.builder() .clientResources(LettuceTestClientResources.getSharedClientResources()).clientName("clientName") .build();/*from w w w. j a va 2s. c o m*/ LettuceConnectionFactory factory = new LettuceConnectionFactory(new RedisStandaloneConfiguration(), configuration); factory.setShareNativeConnection(false); factory.afterPropertiesSet(); ConnectionFactoryTracker.add(factory); RedisConnection connection = factory.getConnection(); assertThat(connection.getClientName(), is(equalTo("clientName"))); connection.close(); }
From source file:org.springframework.data.redis.connection.lettuce.LettuceConnectionFactoryTests.java
@Test // DATAREDIS-576 public void getClientNameShouldEqualWithFactorySetting() { LettuceConnectionFactory factory = new LettuceConnectionFactory(new RedisStandaloneConfiguration()); factory.setClientResources(LettuceTestClientResources.getSharedClientResources()); factory.setClientName("clientName"); factory.afterPropertiesSet();// w w w .j a v a2 s. co m ConnectionFactoryTracker.add(factory); RedisConnection connection = factory.getConnection(); assertThat(connection.getClientName(), equalTo("clientName")); connection.close(); }
From source file:org.springframework.xd.test.redis.RedisAvailableRule.java
@Override public Statement apply(Statement base, Description description) { LettuceConnectionFactory connectionFactory = null; try {/*from w w w.j a v a 2 s . c o m*/ connectionFactory = new LettuceConnectionFactory(); connectionFactory.afterPropertiesSet(); connectionFactory.getConnection().close(); } catch (Exception e) { logger.error("REDIS IS NOT AVAILABLE", e); fail("REDIS IS NOT AVAILABLE"); } finally { if (connectionFactory != null) { connectionFactory.destroy(); } } return super.apply(base, description); }