Java 类org.springframework.boot.autoconfigure.data.mongo.MongoDataAutoConfiguration 实例源码

项目:https-github.com-g0t4-jenkins2-course-spring-boot    文件:EmbeddedMongoAutoConfigurationTests.java   
private void assertVersionConfiguration(String configuredVersion,
        String expectedVersion) {
    this.context = new AnnotationConfigApplicationContext();
    int mongoPort = SocketUtils.findAvailableTcpPort();
    EnvironmentTestUtils.addEnvironment(this.context,
            "spring.data.mongodb.port=" + mongoPort);
    if (configuredVersion != null) {
        EnvironmentTestUtils.addEnvironment(this.context,
                "spring.mongodb.embedded.version=" + configuredVersion);
    }
    this.context.register(MongoAutoConfiguration.class,
            MongoDataAutoConfiguration.class, EmbeddedMongoAutoConfiguration.class);
    this.context.refresh();
    MongoTemplate mongo = this.context.getBean(MongoTemplate.class);
    CommandResult buildInfo = mongo.executeCommand("{ buildInfo: 1 }");

    assertThat(buildInfo.getString("version")).isEqualTo(expectedVersion);
}
项目:spring-boot-concourse    文件:EmbeddedMongoAutoConfigurationTests.java   
private void assertVersionConfiguration(String configuredVersion,
        String expectedVersion) {
    this.context = new AnnotationConfigApplicationContext();
    int mongoPort = SocketUtils.findAvailableTcpPort();
    EnvironmentTestUtils.addEnvironment(this.context,
            "spring.data.mongodb.port=" + mongoPort);
    if (configuredVersion != null) {
        EnvironmentTestUtils.addEnvironment(this.context,
                "spring.mongodb.embedded.version=" + configuredVersion);
    }
    this.context.register(MongoAutoConfiguration.class,
            MongoDataAutoConfiguration.class, EmbeddedMongoAutoConfiguration.class);
    this.context.refresh();
    MongoTemplate mongo = this.context.getBean(MongoTemplate.class);
    CommandResult buildInfo = mongo.executeCommand("{ buildInfo: 1 }");

    assertThat(buildInfo.getString("version")).isEqualTo(expectedVersion);
}
项目:contestparser    文件:EmbeddedMongoAutoConfigurationTests.java   
private void assertVersionConfiguration(String configuredVersion,
        String expectedVersion) {
    this.context = new AnnotationConfigApplicationContext();
    int mongoPort = SocketUtils.findAvailableTcpPort();
    EnvironmentTestUtils.addEnvironment(this.context,
            "spring.data.mongodb.port=" + mongoPort);
    if (configuredVersion != null) {
        EnvironmentTestUtils.addEnvironment(this.context,
                "spring.mongodb.embedded.version=" + configuredVersion);
    }
    this.context.register(MongoAutoConfiguration.class,
            MongoDataAutoConfiguration.class, EmbeddedMongoAutoConfiguration.class);
    this.context.refresh();
    MongoTemplate mongo = this.context.getBean(MongoTemplate.class);
    CommandResult buildInfo = mongo.executeCommand("{ buildInfo: 1 }");

    assertThat(buildInfo.getString("version"), equalTo(expectedVersion));
}
项目:https-github.com-g0t4-jenkins2-course-spring-boot    文件:HealthIndicatorAutoConfigurationTests.java   
@Test
public void mongoHealthIndicator() {
    this.context.register(MongoAutoConfiguration.class,
            ManagementServerProperties.class, MongoDataAutoConfiguration.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(MongoHealthIndicator.class);
}
项目:https-github.com-g0t4-jenkins2-course-spring-boot    文件:HealthIndicatorAutoConfigurationTests.java   
@Test
public void notMongoHealthIndicator() {
    this.context.register(MongoAutoConfiguration.class,
            ManagementServerProperties.class, MongoDataAutoConfiguration.class,
            HealthIndicatorAutoConfiguration.class);
    EnvironmentTestUtils.addEnvironment(this.context,
            "management.health.mongo.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    文件:MongoHealthIndicatorTests.java   
@Test
public void indicatorExists() {
    this.context = new AnnotationConfigApplicationContext(
            PropertyPlaceholderAutoConfiguration.class, MongoAutoConfiguration.class,
            MongoDataAutoConfiguration.class, EndpointAutoConfiguration.class,
            HealthIndicatorAutoConfiguration.class);
    assertThat(this.context.getBeanNamesForType(MongoTemplate.class).length)
            .isEqualTo(1);
    MongoHealthIndicator healthIndicator = this.context
            .getBean(MongoHealthIndicator.class);
    assertThat(healthIndicator).isNotNull();
}
项目:https-github.com-g0t4-jenkins2-course-spring-boot    文件:SessionAutoConfigurationTests.java   
@Test
public void mongoSessionStore() {
    load(Arrays.asList(EmbeddedMongoAutoConfiguration.class,
            MongoAutoConfiguration.class, MongoDataAutoConfiguration.class),
            "spring.session.store-type=mongo", "spring.data.mongodb.port=0");
    validateSessionRepository(MongoOperationsSessionRepository.class);
}
项目:https-github.com-g0t4-jenkins2-course-spring-boot    文件:SessionAutoConfigurationTests.java   
@Test
public void mongoSessionStoreWithCustomizations() {
    load(Arrays.asList(EmbeddedMongoAutoConfiguration.class,
            MongoAutoConfiguration.class, MongoDataAutoConfiguration.class),
            "spring.session.store-type=mongo", "spring.data.mongodb.port=0",
            "spring.session.mongo.collection-name=foobar");
    MongoOperationsSessionRepository repository = validateSessionRepository(
            MongoOperationsSessionRepository.class);
    assertThat(new DirectFieldAccessor(repository).getPropertyValue("collectionName"))
            .isEqualTo("foobar");
}
项目:spring-boot-concourse    文件:HealthIndicatorAutoConfigurationTests.java   
@Test
public void mongoHealthIndicator() {
    this.context.register(MongoAutoConfiguration.class,
            ManagementServerProperties.class, MongoDataAutoConfiguration.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(MongoHealthIndicator.class);
}
项目:spring-boot-concourse    文件:HealthIndicatorAutoConfigurationTests.java   
@Test
public void notMongoHealthIndicator() {
    this.context.register(MongoAutoConfiguration.class,
            ManagementServerProperties.class, MongoDataAutoConfiguration.class,
            HealthIndicatorAutoConfiguration.class);
    EnvironmentTestUtils.addEnvironment(this.context,
            "management.health.mongo.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    文件:MongoHealthIndicatorTests.java   
@Test
public void indicatorExists() {
    this.context = new AnnotationConfigApplicationContext(
            PropertyPlaceholderAutoConfiguration.class, MongoAutoConfiguration.class,
            MongoDataAutoConfiguration.class, EndpointAutoConfiguration.class,
            HealthIndicatorAutoConfiguration.class);
    assertThat(this.context.getBeanNamesForType(MongoTemplate.class).length)
            .isEqualTo(1);
    MongoHealthIndicator healthIndicator = this.context
            .getBean(MongoHealthIndicator.class);
    assertThat(healthIndicator).isNotNull();
}
项目:spring-boot-concourse    文件:SessionAutoConfigurationTests.java   
@Test
public void mongoSessionStore() {
    load(Arrays.asList(EmbeddedMongoAutoConfiguration.class,
            MongoAutoConfiguration.class, MongoDataAutoConfiguration.class),
            "spring.session.store-type=mongo", "spring.data.mongodb.port=0");
    validateSessionRepository(MongoOperationsSessionRepository.class);
}
项目:spring-boot-concourse    文件:SessionAutoConfigurationTests.java   
@Test
public void mongoSessionStoreWithCustomizations() {
    load(Arrays.asList(EmbeddedMongoAutoConfiguration.class,
            MongoAutoConfiguration.class, MongoDataAutoConfiguration.class),
            "spring.session.store-type=mongo", "spring.data.mongodb.port=0",
            "spring.session.mongo.collection-name=foobar");
    MongoOperationsSessionRepository repository = validateSessionRepository(
            MongoOperationsSessionRepository.class);
    assertThat(new DirectFieldAccessor(repository).getPropertyValue("collectionName"))
            .isEqualTo("foobar");
}
项目:contestparser    文件:HealthIndicatorAutoConfigurationTests.java   
@Test
public void mongoHealthIndicator() {
    this.context.register(MongoAutoConfiguration.class,
            ManagementServerProperties.class, MongoDataAutoConfiguration.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(MongoHealthIndicator.class,
            beans.values().iterator().next().getClass());
}
项目:contestparser    文件:HealthIndicatorAutoConfigurationTests.java   
@Test
public void notMongoHealthIndicator() {
    this.context.register(MongoAutoConfiguration.class,
            ManagementServerProperties.class, MongoDataAutoConfiguration.class,
            HealthIndicatorAutoConfiguration.class);
    EnvironmentTestUtils.addEnvironment(this.context,
            "management.health.mongo.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    文件:MongoHealthIndicatorTests.java   
@Test
public void indicatorExists() {
    this.context = new AnnotationConfigApplicationContext(
            PropertyPlaceholderAutoConfiguration.class, MongoAutoConfiguration.class,
            MongoDataAutoConfiguration.class, EndpointAutoConfiguration.class,
            HealthIndicatorAutoConfiguration.class);
    assertEquals(1, this.context.getBeanNamesForType(MongoTemplate.class).length);
    MongoHealthIndicator healthIndicator = this.context
            .getBean(MongoHealthIndicator.class);
    assertNotNull(healthIndicator);
}