Java 类org.springframework.boot.autoconfigure.data.redis.RedisAutoConfiguration 实例源码

项目:spring-cloud-cluster    文件:RedisLockServiceAutoConfigurationTests.java   
@Test
public void testChangeTimeout() throws Exception {
    EnvironmentTestUtils
            .addEnvironment(
                    this.context,
                    "spring.cloud.cluster.redis.lock.expireAfter:1234");
    context.register(RedisAutoConfiguration.class, RedisLockServiceAutoConfiguration.class);
    context.refresh();

    RedisLockService service = context.getBean(RedisLockService.class);
    RedisLockRegistry redisLockRegistry = TestUtils.readField("redisLockRegistry", service);
    String registryKey = TestUtils.readField("registryKey", redisLockRegistry);
    Long expireAfter = TestUtils.readField("expireAfter", redisLockRegistry);

    assertThat(registryKey, is(RedisLockService.DEFAULT_REGISTRY_KEY));
    assertThat(expireAfter, is(1234l));
}
项目:https-github.com-g0t4-jenkins2-course-spring-boot    文件:HealthIndicatorAutoConfigurationTests.java   
@Test
public void redisHealthIndicator() {
    this.context.register(RedisAutoConfiguration.class,
            ManagementServerProperties.class, HealthIndicatorAutoConfiguration.class);
    EnvironmentTestUtils.addEnvironment(this.context,
            "management.health.diskspace.enabled:false");
    this.context.refresh();
    Map<String, HealthIndicator> beans = this.context
            .getBeansOfType(HealthIndicator.class);
    assertThat(beans).hasSize(1);
    assertThat(beans.values().iterator().next().getClass())
            .isEqualTo(RedisHealthIndicator.class);
}
项目:https-github.com-g0t4-jenkins2-course-spring-boot    文件:HealthIndicatorAutoConfigurationTests.java   
@Test
public void notRedisHealthIndicator() {
    this.context.register(RedisAutoConfiguration.class,
            ManagementServerProperties.class, HealthIndicatorAutoConfiguration.class);
    EnvironmentTestUtils.addEnvironment(this.context,
            "management.health.redis.enabled:false",
            "management.health.diskspace.enabled:false");
    this.context.refresh();
    Map<String, HealthIndicator> beans = this.context
            .getBeansOfType(HealthIndicator.class);
    assertThat(beans).hasSize(1);
    assertThat(beans.values().iterator().next().getClass())
            .isEqualTo(ApplicationHealthIndicator.class);
}
项目:https-github.com-g0t4-jenkins2-course-spring-boot    文件:HealthIndicatorAutoConfigurationTests.java   
@Test
public void combinedHealthIndicator() {
    this.context.register(MongoAutoConfiguration.class, RedisAutoConfiguration.class,
            MongoDataAutoConfiguration.class, SolrAutoConfiguration.class,
            HealthIndicatorAutoConfiguration.class);
    this.context.refresh();
    Map<String, HealthIndicator> beans = this.context
            .getBeansOfType(HealthIndicator.class);
    assertThat(beans).hasSize(4);
}
项目:https-github.com-g0t4-jenkins2-course-spring-boot    文件:RedisHealthIndicatorTests.java   
@Test
public void indicatorExists() {
    this.context = new AnnotationConfigApplicationContext(
            PropertyPlaceholderAutoConfiguration.class, RedisAutoConfiguration.class,
            EndpointAutoConfiguration.class, HealthIndicatorAutoConfiguration.class);
    assertThat(this.context.getBeanNamesForType(RedisConnectionFactory.class))
            .hasSize(1);
    RedisHealthIndicator healthIndicator = this.context
            .getBean(RedisHealthIndicator.class);
    assertThat(healthIndicator).isNotNull();
}
项目:https-github.com-g0t4-jenkins2-course-spring-boot    文件:SessionAutoConfigurationRedisTests.java   
@Test
public void redisSessionStore() {
    load(Collections.<Class<?>>singletonList(RedisAutoConfiguration.class),
            "spring.session.store-type=redis");
    validateSpringSessionUsesRedis();
    this.output.expect(not(containsString("Spring Session store type is mandatory: set 'spring.session.store-type=redis' in your configuration")));
}
项目:https-github.com-g0t4-jenkins2-course-spring-boot    文件:SessionAutoConfigurationRedisTests.java   
@Test
public void redisSessionStoreWithCustomizations() {
    load(Collections.<Class<?>>singletonList(RedisAutoConfiguration.class),
            "spring.session.store-type=redis", "spring.session.redis.namespace=foo",
            "spring.session.redis.flush-mode=immediate");
    RedisOperationsSessionRepository repository = validateSessionRepository(
            RedisOperationsSessionRepository.class);
    assertThat(repository.getSessionCreatedChannelPrefix())
            .isEqualTo("spring:session:foo:event:created:");
    assertThat(new DirectFieldAccessor(repository).getPropertyValue("redisFlushMode"))
            .isEqualTo(RedisFlushMode.IMMEDIATE);
}
项目:spring-boot-concourse    文件:HealthIndicatorAutoConfigurationTests.java   
@Test
public void redisHealthIndicator() {
    this.context.register(RedisAutoConfiguration.class,
            ManagementServerProperties.class, HealthIndicatorAutoConfiguration.class);
    EnvironmentTestUtils.addEnvironment(this.context,
            "management.health.diskspace.enabled:false");
    this.context.refresh();
    Map<String, HealthIndicator> beans = this.context
            .getBeansOfType(HealthIndicator.class);
    assertThat(beans).hasSize(1);
    assertThat(beans.values().iterator().next().getClass())
            .isEqualTo(RedisHealthIndicator.class);
}
项目:spring-boot-concourse    文件:HealthIndicatorAutoConfigurationTests.java   
@Test
public void notRedisHealthIndicator() {
    this.context.register(RedisAutoConfiguration.class,
            ManagementServerProperties.class, HealthIndicatorAutoConfiguration.class);
    EnvironmentTestUtils.addEnvironment(this.context,
            "management.health.redis.enabled:false",
            "management.health.diskspace.enabled:false");
    this.context.refresh();
    Map<String, HealthIndicator> beans = this.context
            .getBeansOfType(HealthIndicator.class);
    assertThat(beans).hasSize(1);
    assertThat(beans.values().iterator().next().getClass())
            .isEqualTo(ApplicationHealthIndicator.class);
}
项目:spring-boot-concourse    文件:HealthIndicatorAutoConfigurationTests.java   
@Test
public void combinedHealthIndicator() {
    this.context.register(MongoAutoConfiguration.class, RedisAutoConfiguration.class,
            MongoDataAutoConfiguration.class, SolrAutoConfiguration.class,
            HealthIndicatorAutoConfiguration.class);
    this.context.refresh();
    Map<String, HealthIndicator> beans = this.context
            .getBeansOfType(HealthIndicator.class);
    assertThat(beans).hasSize(4);
}
项目:spring-boot-concourse    文件:RedisHealthIndicatorTests.java   
@Test
public void indicatorExists() {
    this.context = new AnnotationConfigApplicationContext(
            PropertyPlaceholderAutoConfiguration.class, RedisAutoConfiguration.class,
            EndpointAutoConfiguration.class, HealthIndicatorAutoConfiguration.class);
    assertThat(this.context.getBeanNamesForType(RedisConnectionFactory.class))
            .hasSize(1);
    RedisHealthIndicator healthIndicator = this.context
            .getBean(RedisHealthIndicator.class);
    assertThat(healthIndicator).isNotNull();
}
项目:spring-boot-concourse    文件:SessionAutoConfigurationRedisTests.java   
@Test
public void redisSessionStore() {
    load(Collections.<Class<?>>singletonList(RedisAutoConfiguration.class),
            "spring.session.store-type=redis");
    validateSpringSessionUsesRedis();
    this.output.expect(not(containsString("Spring Session store type is mandatory: set 'spring.session.store-type=redis' in your configuration")));
}
项目:spring-boot-concourse    文件:SessionAutoConfigurationRedisTests.java   
@Test
public void redisSessionStoreWithCustomizations() {
    load(Collections.<Class<?>>singletonList(RedisAutoConfiguration.class),
            "spring.session.store-type=redis", "spring.session.redis.namespace=foo",
            "spring.session.redis.flush-mode=immediate");
    RedisOperationsSessionRepository repository = validateSessionRepository(
            RedisOperationsSessionRepository.class);
    assertThat(repository.getSessionCreatedChannelPrefix())
            .isEqualTo("spring:session:foo:event:created:");
    assertThat(new DirectFieldAccessor(repository).getPropertyValue("redisFlushMode"))
            .isEqualTo(RedisFlushMode.IMMEDIATE);
}
项目:spring-cloud-dataflow    文件:DataFlowServerConfigurationTests.java   
@Before
public void setup() {
    context = new AnnotationConfigApplicationContext();
    context.setId("testDataFlowConfig");
    context.register(DataFlowServerConfigurationTests.TestConfiguration.class, RedisAutoConfiguration.class,
            SecurityAutoConfiguration.class, DataFlowServerAutoConfiguration.class,
            DataFlowControllerAutoConfiguration.class, DataSourceAutoConfiguration.class,
            DataFlowServerConfiguration.class, PropertyPlaceholderAutoConfiguration.class,
            WebClientAutoConfiguration.class, HibernateJpaAutoConfiguration.class, WebConfiguration.class);
    environment = new StandardEnvironment();
    propertySources = environment.getPropertySources();
}
项目:contestparser    文件:HealthIndicatorAutoConfigurationTests.java   
@Test
public void redisHealthIndicator() {
    this.context.register(RedisAutoConfiguration.class,
            ManagementServerProperties.class, HealthIndicatorAutoConfiguration.class);
    EnvironmentTestUtils.addEnvironment(this.context,
            "management.health.diskspace.enabled:false");
    this.context.refresh();
    Map<String, HealthIndicator> beans = this.context
            .getBeansOfType(HealthIndicator.class);
    assertEquals(1, beans.size());
    assertEquals(RedisHealthIndicator.class,
            beans.values().iterator().next().getClass());
}
项目:contestparser    文件:HealthIndicatorAutoConfigurationTests.java   
@Test
public void notRedisHealthIndicator() {
    this.context.register(RedisAutoConfiguration.class,
            ManagementServerProperties.class, HealthIndicatorAutoConfiguration.class);
    EnvironmentTestUtils.addEnvironment(this.context,
            "management.health.redis.enabled:false",
            "management.health.diskspace.enabled:false");
    this.context.refresh();
    Map<String, HealthIndicator> beans = this.context
            .getBeansOfType(HealthIndicator.class);
    assertEquals(1, beans.size());
    assertEquals(ApplicationHealthIndicator.class,
            beans.values().iterator().next().getClass());
}
项目:contestparser    文件:HealthIndicatorAutoConfigurationTests.java   
@Test
public void combinedHealthIndicator() {
    this.context.register(MongoAutoConfiguration.class, RedisAutoConfiguration.class,
            MongoDataAutoConfiguration.class, SolrAutoConfiguration.class,
            HealthIndicatorAutoConfiguration.class);
    this.context.refresh();
    Map<String, HealthIndicator> beans = this.context
            .getBeansOfType(HealthIndicator.class);
    assertEquals(4, beans.size());
}
项目:contestparser    文件:RedisHealthIndicatorTests.java   
@Test
public void indicatorExists() {
    this.context = new AnnotationConfigApplicationContext(
            PropertyPlaceholderAutoConfiguration.class, RedisAutoConfiguration.class,
            EndpointAutoConfiguration.class, HealthIndicatorAutoConfiguration.class);
    assertEquals(1,
            this.context.getBeanNamesForType(RedisConnectionFactory.class).length);
    RedisHealthIndicator healthIndicator = this.context
            .getBean(RedisHealthIndicator.class);
    assertNotNull(healthIndicator);
}
项目:contestparser    文件:SessionAutoConfigurationTests.java   
@Test
public void flat() throws Exception {
    this.context = new AnnotationConfigEmbeddedWebApplicationContext();
    this.context.register(Config.class, ServerPropertiesAutoConfiguration.class,
            RedisAutoConfiguration.class, SessionAutoConfiguration.class,
            PropertyPlaceholderAutoConfiguration.class);
    this.context.refresh();
    ServerProperties server = this.context.getBean(ServerProperties.class);
    assertNotNull(server);
}
项目:contestparser    文件:SessionAutoConfigurationTests.java   
@Test
public void hierarchy() throws Exception {
    AnnotationConfigApplicationContext parent = new AnnotationConfigApplicationContext();
    parent.register(RedisAutoConfiguration.class, SessionAutoConfiguration.class,
            PropertyPlaceholderAutoConfiguration.class);
    parent.refresh();
    this.context = new AnnotationConfigEmbeddedWebApplicationContext();
    this.context.setParent(parent);
    this.context.register(Config.class, ServerPropertiesAutoConfiguration.class,
            PropertyPlaceholderAutoConfiguration.class);
    this.context.refresh();
    ServerProperties server = this.context.getBean(ServerProperties.class);
    assertNotNull(server);
}
项目:spring-cloud-cluster    文件:RedisLockServiceAutoConfigurationTests.java   
@Test
public void testDefaults() {
    EnvironmentTestUtils.addEnvironment(this.context);
    context.register(RedisAutoConfiguration.class, RedisLockServiceAutoConfiguration.class);
    context.refresh();

    assertThat(context.containsBean("redisLockService"), is(true));     
}
项目:spring-cloud-cluster    文件:RedisLockServiceAutoConfigurationTests.java   
@Test
public void testDisabled() throws Exception {
    EnvironmentTestUtils
            .addEnvironment(
                    this.context,
                    "spring.cloud.cluster.redis.lock.enabled:false");
    context.register(RedisAutoConfiguration.class, RedisLockServiceAutoConfiguration.class);
    context.refresh();

    assertThat(context.containsBean("redisLockService"), is(false));
}
项目:spring-cloud-cluster    文件:RedisLockServiceAutoConfigurationTests.java   
@Test
public void testGlobalLeaderDisabled() throws Exception {
    EnvironmentTestUtils
            .addEnvironment(
                    this.context,
                    "spring.cloud.cluster.lock.enabled:false",
                    "spring.cloud.cluster.redis.lock.enabled:true");
    context.register(RedisAutoConfiguration.class, RedisLockServiceAutoConfiguration.class);
    context.refresh();

    assertThat(context.containsBean("redisLockService"), is(false));
}
项目:spring-cloud-cluster    文件:RedisLockServiceAutoConfigurationTests.java   
@Test
public void testChangeRole() throws Exception {
    EnvironmentTestUtils
            .addEnvironment(
                    this.context,
                    "spring.cloud.cluster.lock.role:foo");
    context.register(RedisAutoConfiguration.class, RedisLockServiceAutoConfiguration.class);
    context.refresh();

    RedisLockService service = context.getBean(RedisLockService.class);
    RedisLockRegistry redisLockRegistry = TestUtils.readField("redisLockRegistry", service);
    String registryKey = TestUtils.readField("registryKey", redisLockRegistry);

    assertThat(registryKey, is("foo"));
}
项目:spring-cloud-cluster    文件:RedisIT.java   
@Before
public void setup() {
    context = new AnnotationConfigApplicationContext();
    EnvironmentTestUtils.addEnvironment(context);
    context.register(RedisAutoConfiguration.class);
    context.refresh();
    connectionFactory = context.getBean(RedisConnectionFactory.class);
    redisTemplate = new RedisTemplate<String, String>();
    redisTemplate.setConnectionFactory(connectionFactory);
    redisTemplate.setKeySerializer(new StringRedisSerializer());
    redisTemplate.setValueSerializer(new StringRedisSerializer());
    redisTemplate.afterPropertiesSet();
    cleanLocks();
}
项目:https-github.com-g0t4-jenkins2-course-spring-boot    文件:SessionAutoConfigurationRedisTests.java   
@Test
public void redisSessionStoreIsTheDefault() {
    load(Collections.<Class<?>>singletonList(RedisAutoConfiguration.class));
    validateSpringSessionUsesRedis();
    this.output.expect(containsString("Spring Session store type is mandatory: set 'spring.session.store-type=redis' in your configuration"));
}
项目:spring-boot-concourse    文件:SessionAutoConfigurationRedisTests.java   
@Test
public void redisSessionStoreIsTheDefault() {
    load(Collections.<Class<?>>singletonList(RedisAutoConfiguration.class));
    validateSpringSessionUsesRedis();
    this.output.expect(containsString("Spring Session store type is mandatory: set 'spring.session.store-type=redis' in your configuration"));
}