Package org.springframework.data.redis.connection

Examples of org.springframework.data.redis.connection.RedisConnection


    this.redisConnectionFactory = connectionFactory;
  }

  @Override
  protected void doHealthCheck(Health.Builder builder) throws Exception {
    RedisConnection connection = RedisConnectionUtils
        .getConnection(this.redisConnectionFactory);
    try {
      Properties info = connection.info();
      builder.up().withDetail("version", info.getProperty("redis_version"));
    }
    finally {
      RedisConnectionUtils.releaseConnection(connection,
          this.redisConnectionFactory);
View Full Code Here


  @Test
  public void redisIsUp() throws Exception {
    Properties info = new Properties();
    info.put("redis_version", "2.8.9");

    RedisConnection redisConnection = mock(RedisConnection.class);
    RedisConnectionFactory redisConnectionFactory = mock(RedisConnectionFactory.class);
    given(redisConnectionFactory.getConnection()).willReturn(redisConnection);
    given(redisConnection.info()).willReturn(info);
    RedisHealthIndicator healthIndicator = new RedisHealthIndicator(
        redisConnectionFactory);

    Health health = healthIndicator.health();
    assertEquals(Status.UP, health.getStatus());
View Full Code Here

    verify(redisConnection).info();
  }

  @Test
  public void redisIsDown() throws Exception {
    RedisConnection redisConnection = mock(RedisConnection.class);
    RedisConnectionFactory redisConnectionFactory = mock(RedisConnectionFactory.class);
    given(redisConnectionFactory.getConnection()).willReturn(redisConnection);
    given(redisConnection.info()).willThrow(
        new RedisConnectionFailureException("Connection failed"));
    RedisHealthIndicator healthIndicator = new RedisHealthIndicator(
        redisConnectionFactory);

    Health health = healthIndicator.health();
View Full Code Here

    ConnectionFactoryTracker.add(factory);
  }

  @After
  public void stop() {
    RedisConnection connection = factory.getConnection();
    connection.flushDb();
    connection.close();
  }
View Full Code Here

  public RedisTestProfileValueSource() {
    if (redisVersion == null) {
      LettuceConnectionFactory connectionFactory = new LettuceConnectionFactory(SettingsUtils.getHost(),
          SettingsUtils.getPort());
      connectionFactory.afterPropertiesSet();
      RedisConnection connection = connectionFactory.getConnection();
      redisVersion = RedisVersionUtils.getRedisVersion(connection);
      connection.close();
      connectionFactory.destroy();
    }
  }
View Full Code Here

    assumeTrue(RedisTestProfileValueSource.matches("redisVersion", "2.6"));
  }

  @After
  public void stop() {
    RedisConnection connection = factory.getConnection();
    connection.flushDb();
    connection.close();
  }
View Full Code Here

    connectionFactory.setHostName(SettingsUtils.getHost());
    connectionFactory.setPort(SettingsUtils.getPort());
    connectionFactory.setTimeout(100);

    connectionFactory.afterPropertiesSet();
    RedisConnection connection = connectionFactory.getConnection();

    Version version = Version.UNKNOWN;

    try {
      version = RedisVersionUtils.getRedisVersion(connection);
      connection.close();
    } finally {
      connectionFactory.destroy();
    }

    return version;
View Full Code Here

    @SuppressWarnings({ "rawtypes" })
    @Bean
    public RedisTemplate redisTemplate() {

      RedisConnection connectionMock = mock(RedisConnection.class);
      RedisConnectionFactory factoryMock = mock(RedisConnectionFactory.class);

      when(factoryMock.getConnection()).thenReturn(connectionMock);

      RedisTemplate template = new RedisTemplate();
View Full Code Here

    @SuppressWarnings({ "rawtypes" })
    @Bean
    public RedisTemplate redisTemplate() {

      RedisConnection connectionMock = mock(RedisConnection.class);
      RedisConnectionFactory factoryMock = mock(RedisConnectionFactory.class);

      when(factoryMock.getConnection()).thenReturn(connectionMock);

      RedisTemplate template = new RedisTemplate();
View Full Code Here

    if (log.isDebugEnabled()) {
      log.debug("Opening RedisConnection");
    }

    RedisConnection conn = factory.getConnection();

    if (bind) {

      RedisConnection connectionToBind = conn;
      if (enableTransactionSupport && isActualNonReadonlyTransactionActive()) {
        connectionToBind = createConnectionProxy(conn, factory);
      }

      connHolder = new RedisConnectionHolder(connectionToBind);
View Full Code Here

TOP

Related Classes of org.springframework.data.redis.connection.RedisConnection

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.