Java 类org.springframework.boot.autoconfigure.PropertyPlaceholderAutoConfiguration 实例源码

项目:zipkin-collector-eventhub    文件:EventHubCollectorAutoConfigurationTest.java   
@Test
public void provideCollectorComponent_canSetStorageContainerName() {

    String storageContainerName = "pashmak";

    context = new AnnotationConfigApplicationContext();
    addEnvironment(context, "zipkin.collector.eventhub.storageConnectionString:" + dummyEventHubConnectionString);
    addEnvironment(context, "zipkin.collector.eventhub.eventHubConnectionString:" + dummyStorageConnectionString );
    addEnvironment(context, "zipkin.collector.eventhub.storageContainerName:" + storageContainerName);
    context.register(PropertyPlaceholderAutoConfiguration.class,
            EventHubCollectorAutoConfiguration.class,
            InMemoryConfiguration.class);
    context.refresh();

    EventHubCollector collector = context.getBean(EventHubCollector.class);
    assertNotNull(collector);
    assertEquals(storageContainerName, collector.getStorageContainerName());
}
项目:zipkin-collector-eventhub    文件:EventHubCollectorAutoConfigurationTest.java   
@Test
public void provideCollectorComponent_canSetConsumerGroupName() {

    String consumerGroupName = "pashmak";

    context = new AnnotationConfigApplicationContext();
    addEnvironment(context, "zipkin.collector.eventhub.storageConnectionString:" + dummyEventHubConnectionString);
    addEnvironment(context, "zipkin.collector.eventhub.eventHubConnectionString:" + dummyStorageConnectionString );
    addEnvironment(context, "zipkin.collector.eventhub.consumerGroupName:" + consumerGroupName);
    context.register(PropertyPlaceholderAutoConfiguration.class,
            EventHubCollectorAutoConfiguration.class,
            InMemoryConfiguration.class);
    context.refresh();

    EventHubCollector collector = context.getBean(EventHubCollector.class);
    assertNotNull(collector);
    assertEquals(consumerGroupName, collector.getConsumerGroupName());
}
项目:zipkin-collector-eventhub    文件:EventHubCollectorAutoConfigurationTest.java   
@Test
public void provideCollectorComponent_canSetEventHubName() {

    String eventHubName = "pashmak";

    context = new AnnotationConfigApplicationContext();
    addEnvironment(context, "zipkin.collector.eventhub.storageConnectionString:" + dummyEventHubConnectionString);
    addEnvironment(context, "zipkin.collector.eventhub.eventHubConnectionString:" + dummyStorageConnectionString );
    addEnvironment(context, "zipkin.collector.eventhub.eventHubName:" + eventHubName);
    context.register(PropertyPlaceholderAutoConfiguration.class,
            EventHubCollectorAutoConfiguration.class,
            InMemoryConfiguration.class);
    context.refresh();

    EventHubCollector collector = context.getBean(EventHubCollector.class);
    assertNotNull(collector);
    assertEquals(eventHubName, collector.getEventHubName());
}
项目:zipkin-collector-eventhub    文件:EventHubCollectorAutoConfigurationTest.java   
@Test
public void provideCollectorComponent_canSetProcessorHostName() {

    String processorHostName = "pashmak";

    context = new AnnotationConfigApplicationContext();
    addEnvironment(context, "zipkin.collector.eventhub.storageConnectionString:" + dummyEventHubConnectionString);
    addEnvironment(context, "zipkin.collector.eventhub.eventHubConnectionString:" + dummyStorageConnectionString );
    addEnvironment(context, "zipkin.collector.eventhub.processorHostName:" + processorHostName);
    context.register(PropertyPlaceholderAutoConfiguration.class,
            EventHubCollectorAutoConfiguration.class,
            InMemoryConfiguration.class);
    context.refresh();

    EventHubCollector collector = context.getBean(EventHubCollector.class);
    assertNotNull(collector);
    assertEquals(processorHostName, collector.getProcessorHostName());
}
项目:zipkin-collector-eventhub    文件:EventHubCollectorAutoConfigurationTest.java   
@Test
public void provideCollectorComponent_canSetStorageBlobPrefix() {

    String storageBlobPrefix = "pashmak";

    context = new AnnotationConfigApplicationContext();
    addEnvironment(context, "zipkin.collector.eventhub.storageConnectionString:" + dummyEventHubConnectionString);
    addEnvironment(context, "zipkin.collector.eventhub.eventHubConnectionString:" + dummyStorageConnectionString );
    addEnvironment(context, "zipkin.collector.eventhub.storageBlobPrefix:" + storageBlobPrefix);
    context.register(PropertyPlaceholderAutoConfiguration.class,
            EventHubCollectorAutoConfiguration.class,
            InMemoryConfiguration.class);
    context.refresh();

    EventHubCollector collector = context.getBean(EventHubCollector.class);
    assertNotNull(collector);
    assertEquals(storageBlobPrefix, collector.getStorageBlobPrefix());
}
项目:zipkin-collector-eventhub    文件:EventHubCollectorAutoConfigurationTest.java   
@Test
public void provideCollectorComponent_canSetCheckpointBatchSize() {

    int checkpointBatchSize = 1000;

    context = new AnnotationConfigApplicationContext();
    addEnvironment(context, "zipkin.collector.eventhub.storageConnectionString:" + dummyEventHubConnectionString);
    addEnvironment(context, "zipkin.collector.eventhub.eventHubConnectionString:" + dummyStorageConnectionString );
    addEnvironment(context, "zipkin.collector.eventhub.checkpoint-batch-size:" + checkpointBatchSize);
    context.register(PropertyPlaceholderAutoConfiguration.class,
            EventHubCollectorAutoConfiguration.class,
            InMemoryConfiguration.class);
    context.refresh();

    EventHubCollector collector = context.getBean(EventHubCollector.class);
    assertNotNull(collector);
    assertEquals(checkpointBatchSize, collector.getCheckpointBatchSize());
}
项目:zipkin-azure    文件:ZipkinEventHubCollectorAutoConfigurationTest.java   
@Test
public void providesCollectorComponent_whenConnectionStringsSet() {
  addEnvironment(context,
      "zipkin.collector.eventhub.connection-string:" + CONNECTION_STRING);
  addEnvironment(context,
      "zipkin.collector.eventhub.storage.connection-string:"
          + STORAGE_CONNECTION_STRING);
  context.register(
      PropertyPlaceholderAutoConfiguration.class,
      ZipkinEventHubCollectorAutoConfiguration.class,
      TestConfiguration.class
  );
  context.refresh();

  ZipkinEventHubCollectorProperties props = context.getBean(ZipkinEventHubCollectorProperties.class);
  assertThat(props.getConnectionString())
      .isEqualTo(CONNECTION_STRING);
  assertThat(props.getStorage().getConnectionString())
      .isEqualTo(STORAGE_CONNECTION_STRING);
}
项目:spring-boot-concourse    文件:DeviceDelegatingViewResolverAutoConfigurationTests.java   
@Test
public void defaultPropertyValues() throws Exception {
    this.context = new AnnotationConfigEmbeddedWebApplicationContext();
    EnvironmentTestUtils.addEnvironment(this.context,
            "spring.mobile.devicedelegatingviewresolver.enabled:true");
    this.context.register(Config.class, WebMvcAutoConfiguration.class,
            HttpMessageConvertersAutoConfiguration.class,
            PropertyPlaceholderAutoConfiguration.class,
            DeviceDelegatingViewResolverConfiguration.class);
    this.context.refresh();
    LiteDeviceDelegatingViewResolver liteDeviceDelegatingViewResolver = this.context
            .getBean("deviceDelegatingViewResolver",
                    LiteDeviceDelegatingViewResolver.class);

    DirectFieldAccessor accessor = new DirectFieldAccessor(
            liteDeviceDelegatingViewResolver);
    assertThat(accessor.getPropertyValue("enableFallback")).isEqualTo(Boolean.FALSE);
    assertThat(accessor.getPropertyValue("normalPrefix")).isEqualTo("");
    assertThat(accessor.getPropertyValue("mobilePrefix")).isEqualTo("mobile/");
    assertThat(accessor.getPropertyValue("tabletPrefix")).isEqualTo("tablet/");
    assertThat(accessor.getPropertyValue("normalSuffix")).isEqualTo("");
    assertThat(accessor.getPropertyValue("mobileSuffix")).isEqualTo("");
    assertThat(accessor.getPropertyValue("tabletSuffix")).isEqualTo("");
}
项目:spring-boot-concourse    文件:MetricExportAutoConfigurationTests.java   
@Test
public void provideAdditionalWriter() {
    this.context = new AnnotationConfigApplicationContext(WriterConfig.class,
            MetricRepositoryAutoConfiguration.class,
            MetricExportAutoConfiguration.class,
            PropertyPlaceholderAutoConfiguration.class);
    GaugeService gaugeService = this.context.getBean(GaugeService.class);
    assertThat(gaugeService).isNotNull();
    gaugeService.submit("foo", 2.7);
    MetricExporters exporters = this.context.getBean(MetricExporters.class);
    MetricCopyExporter exporter = (MetricCopyExporter) exporters.getExporters()
            .get("writer");
    exporter.setIgnoreTimestamps(true);
    exporter.export();
    MetricWriter writer = this.context.getBean("writer", MetricWriter.class);
    Mockito.verify(writer, Mockito.atLeastOnce()).set(Matchers.any(Metric.class));
}
项目:spring-boot-concourse    文件:DataSourceInitializerTests.java   
@Test
public void testDataSourceInitializedWithMultipleScripts() throws Exception {
    EnvironmentTestUtils.addEnvironment(this.context,
            "spring.datasource.initialize:true",
            "spring.datasource.schema:"
                    + ClassUtils.addResourcePathToPackagePath(getClass(),
                            "schema.sql")
                    + ","
                    + ClassUtils.addResourcePathToPackagePath(getClass(),
                            "another.sql"),
            "spring.datasource.data:" + ClassUtils
                    .addResourcePathToPackagePath(getClass(), "data.sql"));
    this.context.register(DataSourceAutoConfiguration.class,
            PropertyPlaceholderAutoConfiguration.class);
    this.context.refresh();
    DataSource dataSource = this.context.getBean(DataSource.class);
    assertThat(dataSource instanceof org.apache.tomcat.jdbc.pool.DataSource).isTrue();
    assertThat(dataSource).isNotNull();
    JdbcOperations template = new JdbcTemplate(dataSource);
    assertThat(template.queryForObject("SELECT COUNT(*) from FOO", Integer.class))
            .isEqualTo(1);
    assertThat(template.queryForObject("SELECT COUNT(*) from SPAM", Integer.class))
            .isEqualTo(0);
}
项目:https-github.com-g0t4-jenkins2-course-spring-boot    文件:ThymeleafAutoConfigurationTests.java   
@Test
public void createLayoutFromConfigClass() throws Exception {
    AnnotationConfigWebApplicationContext context = new AnnotationConfigWebApplicationContext();
    context.register(ThymeleafAutoConfiguration.class,
            PropertyPlaceholderAutoConfiguration.class);
    MockServletContext servletContext = new MockServletContext();
    context.setServletContext(servletContext);
    context.refresh();
    ThymeleafView view = (ThymeleafView) context.getBean(ThymeleafViewResolver.class)
            .resolveViewName("view", Locale.UK);
    MockHttpServletResponse response = new MockHttpServletResponse();
    MockHttpServletRequest request = new MockHttpServletRequest();
    request.setAttribute(RequestContext.WEB_APPLICATION_CONTEXT_ATTRIBUTE, context);
    view.render(Collections.singletonMap("foo", "bar"), request, response);
    String result = response.getContentAsString();
    assertThat(result).contains("<title>Content</title>");
    assertThat(result).contains("<span>bar</span>");
    context.close();
}
项目:spring-boot-concourse    文件:DataSourceInitializerTests.java   
@Test
public void testInitializationDisabled() throws Exception {
    this.context.register(DataSourceAutoConfiguration.class,
            PropertyPlaceholderAutoConfiguration.class);
    this.context.refresh();

    DataSource dataSource = this.context.getBean(DataSource.class);

    this.context.publishEvent(new DataSourceInitializedEvent(dataSource));

    assertThat(dataSource instanceof org.apache.tomcat.jdbc.pool.DataSource).isTrue();
    assertThat(dataSource).isNotNull();
    JdbcOperations template = new JdbcTemplate(dataSource);

    try {
        template.queryForObject("SELECT COUNT(*) from BAR", Integer.class);
        fail("Query should have failed as BAR table does not exist");
    }
    catch (BadSqlGrammarException ex) {
        SQLException sqlException = ex.getSQLException();
        int expectedCode = -5501; // user lacks privilege or object not found
        assertThat(sqlException.getErrorCode()).isEqualTo(expectedCode);
    }
}
项目:spring-boot-concourse    文件:EmbeddedMongoAutoConfigurationTests.java   
@Test
public void portIsAvailableInParentContext() {
    ConfigurableApplicationContext parent = new AnnotationConfigApplicationContext();
    parent.refresh();
    try {
        this.context = new AnnotationConfigApplicationContext();
        this.context.setParent(parent);
        EnvironmentTestUtils.addEnvironment(this.context,
                "spring.data.mongodb.port=0");
        this.context.register(EmbeddedMongoAutoConfiguration.class,
                MongoClientConfiguration.class,
                PropertyPlaceholderAutoConfiguration.class);
        this.context.refresh();
        assertThat(parent.getEnvironment().getProperty("local.mongo.port"))
                .isNotNull();
    }
    finally {
        parent.close();
    }
}
项目:https-github.com-g0t4-jenkins2-course-spring-boot    文件:DataSourceInitializerTests.java   
@Test
public void testInitializationDisabled() throws Exception {
    this.context.register(DataSourceAutoConfiguration.class,
            PropertyPlaceholderAutoConfiguration.class);
    this.context.refresh();
    DataSource dataSource = this.context.getBean(DataSource.class);
    this.context.publishEvent(new DataSourceInitializedEvent(dataSource));
    assertThat(dataSource instanceof org.apache.tomcat.jdbc.pool.DataSource).isTrue();
    assertThat(dataSource).isNotNull();
    JdbcOperations template = new JdbcTemplate(dataSource);
    try {
        template.queryForObject("SELECT COUNT(*) from BAR", Integer.class);
        fail("Query should have failed as BAR table does not exist");
    }
    catch (BadSqlGrammarException ex) {
        SQLException sqlException = ex.getSQLException();
        int expectedCode = -5501; // user lacks privilege or object not found
        assertThat(sqlException.getErrorCode()).isEqualTo(expectedCode);
    }
}
项目:https-github.com-g0t4-jenkins2-course-spring-boot    文件:ElasticsearchAutoConfigurationTests.java   
@Test
public void createNodeClientWithOverrides() {
    this.context = new AnnotationConfigApplicationContext();
    EnvironmentTestUtils.addEnvironment(this.context,
            "spring.data.elasticsearch.properties.foo.bar:baz",
            "spring.data.elasticsearch.properties.path.home:target",
            "spring.data.elasticsearch.properties.node.local:false",
            "spring.data.elasticsearch.properties.node.data:true",
            "spring.data.elasticsearch.properties.http.enabled:true");
    this.context.register(PropertyPlaceholderAutoConfiguration.class,
            ElasticsearchAutoConfiguration.class);
    this.context.refresh();
    assertThat(this.context.getBeanNamesForType(Client.class).length).isEqualTo(1);
    NodeClient client = (NodeClient) this.context.getBean(Client.class);
    assertThat(client.settings().get("foo.bar")).isEqualTo("baz");
    assertThat(client.settings().get("node.local")).isEqualTo("false");
    assertThat(client.settings().get("node.data")).isEqualTo("true");
    assertThat(client.settings().get("http.enabled")).isEqualTo("true");
}
项目:spring-boot-concourse    文件:SecurityAutoConfigurationTests.java   
@Test
public void testJpaCoexistsHappily() throws Exception {
    this.context = new AnnotationConfigWebApplicationContext();
    this.context.setServletContext(new MockServletContext());
    EnvironmentTestUtils.addEnvironment(this.context,
            "spring.datasource.url:jdbc:hsqldb:mem:testsecdb");
    EnvironmentTestUtils.addEnvironment(this.context,
            "spring.datasource.initialize:false");
    this.context.register(EntityConfiguration.class,
            PropertyPlaceholderAutoConfiguration.class,
            DataSourceAutoConfiguration.class, HibernateJpaAutoConfiguration.class,
            SecurityAutoConfiguration.class, ServerPropertiesAutoConfiguration.class);
    // This can fail if security @Conditionals force early instantiation of the
    // HibernateJpaAutoConfiguration (e.g. the EntityManagerFactory is not found)
    this.context.refresh();
    assertThat(this.context.getBean(JpaTransactionManager.class)).isNotNull();
}
项目:spring-boot-concourse    文件:ThymeleafAutoConfigurationTests.java   
@Test
public void renderNonWebAppTemplate() throws Exception {
    AnnotationConfigApplicationContext context = new AnnotationConfigApplicationContext(
            ThymeleafAutoConfiguration.class,
            PropertyPlaceholderAutoConfiguration.class);
    assertThat(context.getBeanNamesForType(ViewResolver.class).length).isEqualTo(0);
    try {
        TemplateEngine engine = context.getBean(TemplateEngine.class);
        Context attrs = new Context(Locale.UK,
                Collections.singletonMap("greeting", "Hello World"));
        String result = engine.process("message", attrs);
        assertThat(result).contains("Hello World");
    }
    finally {
        context.close();
    }
}
项目:https-github.com-g0t4-jenkins2-course-spring-boot    文件:ThymeleafAutoConfigurationTests.java   
@Test
public void renderNonWebAppTemplate() throws Exception {
    AnnotationConfigApplicationContext context = new AnnotationConfigApplicationContext(
            ThymeleafAutoConfiguration.class,
            PropertyPlaceholderAutoConfiguration.class);
    assertThat(context.getBeanNamesForType(ViewResolver.class).length).isEqualTo(0);
    try {
        TemplateEngine engine = context.getBean(TemplateEngine.class);
        Context attrs = new Context(Locale.UK,
                Collections.singletonMap("greeting", "Hello World"));
        String result = engine.process("message", attrs);
        assertThat(result).contains("Hello World");
    }
    finally {
        context.close();
    }
}
项目:https-github.com-g0t4-jenkins2-course-spring-boot    文件:BatchAutoConfigurationTests.java   
@Test
public void testRenamePrefix() throws Exception {
    this.context = new AnnotationConfigApplicationContext();
    EnvironmentTestUtils.addEnvironment(this.context,
            "spring.datasource.name:batchtest",
            "spring.batch.schema:classpath:batch/custom-schema-hsql.sql",
            "spring.batch.tablePrefix:PREFIX_");
    this.context.register(TestConfiguration.class,
            EmbeddedDataSourceConfiguration.class,
            HibernateJpaAutoConfiguration.class, BatchAutoConfiguration.class,
            PropertyPlaceholderAutoConfiguration.class);
    this.context.refresh();
    assertThat(this.context.getBean(JobLauncher.class)).isNotNull();
    assertThat(new JdbcTemplate(this.context.getBean(DataSource.class))
            .queryForList("select * from PREFIX_JOB_EXECUTION")).isEmpty();
    JobExplorer jobExplorer = this.context.getBean(JobExplorer.class);
    assertThat(jobExplorer.findRunningJobExecutions("test")).isEmpty();
    JobRepository jobRepository = this.context.getBean(JobRepository.class);
    assertThat(jobRepository.getLastJobExecution("test", new JobParameters()))
            .isNull();
}
项目:https-github.com-g0t4-jenkins2-course-spring-boot    文件:EmbeddedMongoAutoConfigurationTests.java   
@Test
public void portIsAvailableInParentContext() {
    ConfigurableApplicationContext parent = new AnnotationConfigApplicationContext();
    parent.refresh();
    try {
        this.context = new AnnotationConfigApplicationContext();
        this.context.setParent(parent);
        EnvironmentTestUtils.addEnvironment(this.context,
                "spring.data.mongodb.port=0");
        this.context.register(EmbeddedMongoAutoConfiguration.class,
                MongoClientConfiguration.class,
                PropertyPlaceholderAutoConfiguration.class);
        this.context.refresh();
        assertThat(parent.getEnvironment().getProperty("local.mongo.port"))
                .isNotNull();
    }
    finally {
        parent.close();
    }
}
项目:spring-boot-concourse    文件:DataSourceInitializerTests.java   
@Test
public void testDataSourceInitializedWithExplicitScript() throws Exception {
    this.context.register(DataSourceAutoConfiguration.class,
            PropertyPlaceholderAutoConfiguration.class);
    EnvironmentTestUtils.addEnvironment(this.context,
            "spring.datasource.initialize:true",
            "spring.datasource.schema:" + ClassUtils
                    .addResourcePathToPackagePath(getClass(), "schema.sql"),
            "spring.datasource.data:" + ClassUtils
                    .addResourcePathToPackagePath(getClass(), "data.sql"));
    this.context.refresh();
    DataSource dataSource = this.context.getBean(DataSource.class);
    assertThat(dataSource instanceof org.apache.tomcat.jdbc.pool.DataSource).isTrue();
    assertThat(dataSource).isNotNull();
    JdbcOperations template = new JdbcTemplate(dataSource);
    assertThat(template.queryForObject("SELECT COUNT(*) from FOO", Integer.class))
            .isEqualTo(1);
}
项目:https-github.com-g0t4-jenkins2-course-spring-boot    文件:DataSourceInitializerTests.java   
@Test
public void testDataSourceInitializedWithSchemaCredentials() {
    this.context.register(DataSourceAutoConfiguration.class,
            PropertyPlaceholderAutoConfiguration.class);
    EnvironmentTestUtils.addEnvironment(this.context,
            "spring.datasource.initialize:true",
            "spring.datasource.sqlScriptEncoding:UTF-8",
            "spring.datasource.schema:" + ClassUtils
                    .addResourcePathToPackagePath(getClass(), "encoding-schema.sql"),
            "spring.datasource.data:" + ClassUtils
                    .addResourcePathToPackagePath(getClass(), "encoding-data.sql"),
            "spring.datasource.schema-username:admin",
            "spring.datasource.schema-password:admin");
    try {
        this.context.refresh();
        fail("User does not exist");
    }
    catch (Exception ex) {
        assertThat(ex).isInstanceOf(UnsatisfiedDependencyException.class);
    }
}
项目:https-github.com-g0t4-jenkins2-course-spring-boot    文件:SecurityAutoConfigurationTests.java   
@Test
public void testOverrideAuthenticationManagerWithBuilderAndInjectIntoSecurityFilter()
        throws Exception {
    this.context = new AnnotationConfigWebApplicationContext();
    this.context.setServletContext(new MockServletContext());
    this.context.register(AuthenticationManagerCustomizer.class,
            SecurityCustomizer.class, SecurityAutoConfiguration.class,
            ServerPropertiesAutoConfiguration.class,
            PropertyPlaceholderAutoConfiguration.class);
    this.context.refresh();
    UsernamePasswordAuthenticationToken user = new UsernamePasswordAuthenticationToken(
            "foo", "bar",
            AuthorityUtils.commaSeparatedStringToAuthorityList("ROLE_USER"));
    assertThat(this.context.getBean(AuthenticationManager.class).authenticate(user))
            .isNotNull();
    pingAuthenticationListener();
}
项目:https-github.com-g0t4-jenkins2-course-spring-boot    文件:SecurityAutoConfigurationTests.java   
@Test
public void testJpaCoexistsHappily() throws Exception {
    this.context = new AnnotationConfigWebApplicationContext();
    this.context.setServletContext(new MockServletContext());
    EnvironmentTestUtils.addEnvironment(this.context,
            "spring.datasource.url:jdbc:hsqldb:mem:testsecdb");
    EnvironmentTestUtils.addEnvironment(this.context,
            "spring.datasource.initialize:false");
    this.context.register(EntityConfiguration.class,
            PropertyPlaceholderAutoConfiguration.class,
            DataSourceAutoConfiguration.class, HibernateJpaAutoConfiguration.class,
            SecurityAutoConfiguration.class, ServerPropertiesAutoConfiguration.class);
    // This can fail if security @Conditionals force early instantiation of the
    // HibernateJpaAutoConfiguration (e.g. the EntityManagerFactory is not found)
    this.context.refresh();
    assertThat(this.context.getBean(JpaTransactionManager.class)).isNotNull();
}
项目:zipkin-collector-eventhub    文件:EventHubCollectorAutoConfigurationTest.java   
@Test
public void doesntProvideCollectorComponent_whenSqsQueueUrlUnset() {
    context = new AnnotationConfigApplicationContext();
    context.register(PropertyPlaceholderAutoConfiguration.class,
            EventHubCollectorProperties.class,
            EventHubCollectorAutoConfiguration.class,
            InMemoryConfiguration.class);
    context.refresh();

    thrown.expect(NoSuchBeanDefinitionException.class);
    context.getBean(EventHubCollector.class);
}
项目:zipkin-collector-eventhub    文件:EventHubCollectorAutoConfigurationTest.java   
@Test
public void provideCollectorComponent_whenEventHubConnectionStringIsSet() {
    context = new AnnotationConfigApplicationContext();
    addEnvironment(context, "zipkin.collector.eventhub.storageConnectionString:" + dummyStorageConnectionString);
    addEnvironment(context, "zipkin.collector.eventhub.eventHubConnectionString:" + dummyEventHubConnectionString );
    context.register(PropertyPlaceholderAutoConfiguration.class,
            EventHubCollectorAutoConfiguration.class,
            InMemoryConfiguration.class);
    context.refresh();

    EventHubCollector collector = context.getBean(EventHubCollector.class);
    assertNotNull(collector);
    assertEquals(dummyEventHubConnectionString, collector.getEventHubConnectionString());
    assertEquals(dummyStorageConnectionString, collector.getStorageConnectionString());
}
项目:zipkin-azure    文件:ZipkinEventHubCollectorPropertiesTest.java   
@Test
public void canOverrideValueOf() {
  addEnvironment(context, property + ":" + value);

  context.register(
      PropertyPlaceholderAutoConfiguration.class,
      EnableEventHubCollectorProperties.class
  );
  context.refresh();

  assertThat(context.getBean(ZipkinEventHubCollectorProperties.class))
      .extracting(extractor)
      .containsExactly(value);
}
项目:zipkin-azure    文件:ZipkinEventHubCollectorAutoConfigurationTest.java   
@Test
public void doesntProvideCollectorComponent_whenConnectionStringsUnset() {
  context.register(
      PropertyPlaceholderAutoConfiguration.class,
      ZipkinEventHubCollectorAutoConfiguration.class,
      TestConfiguration.class
  );
  context.refresh();

  thrown.expect(NoSuchBeanDefinitionException.class);
  context.getBean(EventHubCollector.class);
}
项目:spring-boot-concourse    文件:EndpointMBeanExportAutoConfigurationTests.java   
@Test
public void testEndpointMBeanExporterIsInstalled() throws Exception {
    this.context = new AnnotationConfigApplicationContext();
    this.context.register(TestConfiguration.class, JmxAutoConfiguration.class,
            EndpointAutoConfiguration.class,
            EndpointMBeanExportAutoConfiguration.class,
            PropertyPlaceholderAutoConfiguration.class);
    this.context.refresh();
    assertThat(this.context.getBean(EndpointMBeanExporter.class)).isNotNull();
    MBeanExporter mbeanExporter = this.context.getBean(EndpointMBeanExporter.class);
    assertThat(mbeanExporter.getServer()
            .queryNames(getObjectName("*", "*,*", this.context), null)).isNotEmpty();
}
项目:https-github.com-g0t4-jenkins2-course-spring-boot    文件:FlywayAutoConfigurationTests.java   
@Test
public void overrideLocationsList() throws Exception {
    EnvironmentTestUtils.addEnvironment(this.context,
            "flyway.locations[0]:classpath:db/changelog",
            "flyway.locations[1]:classpath:db/migration");
    registerAndRefresh(EmbeddedDataSourceConfiguration.class,
            FlywayAutoConfiguration.class,
            PropertyPlaceholderAutoConfiguration.class);
    Flyway flyway = this.context.getBean(Flyway.class);
    assertThat(flyway.getLocations()).containsExactly("classpath:db/changelog",
            "classpath:db/migration");
}
项目:https-github.com-g0t4-jenkins2-course-spring-boot    文件:LiquibaseAutoConfigurationTests.java   
@Test
public void testDefaultSpringLiquibase() throws Exception {
    this.context.register(EmbeddedDataSourceConfiguration.class,
            LiquibaseAutoConfiguration.class,
            PropertyPlaceholderAutoConfiguration.class);
    this.context.refresh();
    SpringLiquibase liquibase = this.context.getBean(SpringLiquibase.class);
    assertThat(liquibase.getChangeLog())
            .isEqualTo("classpath:/db/changelog/db.changelog-master.yaml");
    assertThat(liquibase.getContexts()).isNull();
    assertThat(liquibase.getDefaultSchema()).isNull();
    assertThat(liquibase.isDropFirst()).isFalse();
}
项目:spring-boot-concourse    文件:LiquibaseAutoConfigurationTests.java   
@Test
public void testOverrideContexts() throws Exception {
    EnvironmentTestUtils.addEnvironment(this.context,
            "liquibase.contexts:test, production");
    this.context.register(EmbeddedDataSourceConfiguration.class,
            LiquibaseAutoConfiguration.class,
            PropertyPlaceholderAutoConfiguration.class);
    this.context.refresh();
    SpringLiquibase liquibase = this.context.getBean(SpringLiquibase.class);
    assertThat(liquibase.getContexts()).isEqualTo("test, production");
}
项目:https-github.com-g0t4-jenkins2-course-spring-boot    文件:DataSourceAutoConfigurationTests.java   
@Test
public void testDataSourceHasEmbeddedDefault() throws Exception {
    this.context.register(DataSourceAutoConfiguration.class,
            PropertyPlaceholderAutoConfiguration.class);
    this.context.refresh();
    org.apache.tomcat.jdbc.pool.DataSource dataSource = this.context
            .getBean(org.apache.tomcat.jdbc.pool.DataSource.class);
    assertThat(dataSource.getUrl()).isNotNull();
    assertThat(dataSource.getDriverClassName()).isNotNull();
}
项目:spring-boot-concourse    文件:DeviceDelegatingViewResolverAutoConfigurationTests.java   
@Test(expected = NoSuchBeanDefinitionException.class)
public void deviceDelegatingInternalResourceViewResolverDisabled() throws Exception {
    this.context = new AnnotationConfigEmbeddedWebApplicationContext();
    EnvironmentTestUtils.addEnvironment(this.context,
            "spring.mobile.devicedelegatingviewresolver.enabled:false");
    this.context.register(Config.class, WebMvcAutoConfiguration.class,
            HttpMessageConvertersAutoConfiguration.class,
            PropertyPlaceholderAutoConfiguration.class,
            DeviceDelegatingViewResolverConfiguration.class);
    this.context.refresh();
    assertThat(this.context.getBean(InternalResourceViewResolver.class)).isNotNull();
    try {
        this.context.getBean(ThymeleafViewResolver.class);
    }
    catch (NoSuchBeanDefinitionException ex) {
        // expected. ThymeleafViewResolver shouldn't be defined.
    }
    this.context.getBean("deviceDelegatingViewResolver",
            AbstractDeviceDelegatingViewResolver.class);
}
项目:https-github.com-g0t4-jenkins2-course-spring-boot    文件:SampleWebSocketsApplicationTests.java   
@Test
public void echoEndpoint() throws Exception {
    ConfigurableApplicationContext context = new SpringApplicationBuilder(
            ClientConfiguration.class, PropertyPlaceholderAutoConfiguration.class)
                    .properties("websocket.uri:ws://localhost:" + this.port
                            + "/echo/websocket")
                    .run("--spring.main.web_environment=false");
    long count = context.getBean(ClientConfiguration.class).latch.getCount();
    AtomicReference<String> messagePayloadReference = context
            .getBean(ClientConfiguration.class).messagePayload;
    context.close();
    assertThat(count).isEqualTo(0);
    assertThat(messagePayloadReference.get())
            .isEqualTo("Did you say \"Hello world!\"?");
}
项目:spring-boot-concourse    文件:RedisAutoConfigurationTests.java   
private AnnotationConfigApplicationContext doLoad(String... environment) {
    AnnotationConfigApplicationContext applicationContext = new AnnotationConfigApplicationContext();
    EnvironmentTestUtils.addEnvironment(applicationContext, environment);
    applicationContext.register(RedisAutoConfiguration.class,
            PropertyPlaceholderAutoConfiguration.class);
    applicationContext.refresh();
    return applicationContext;
}
项目:spring-boot-concourse    文件:FlywayAutoConfigurationTests.java   
@Test
public void changeLogDoesNotExist() throws Exception {
    EnvironmentTestUtils.addEnvironment(this.context,
            "flyway.locations:file:no-such-dir");
    this.thrown.expect(BeanCreationException.class);
    registerAndRefresh(EmbeddedDataSourceConfiguration.class,
            FlywayAutoConfiguration.class,
            PropertyPlaceholderAutoConfiguration.class);
}
项目:zipkin    文件:ZipkinKafkaCollectorAutoConfigurationTest.java   
@Test
public void doesntProvidesCollectorComponent_whenKafkaZooKeeperUnset() {
  context = new AnnotationConfigApplicationContext();
  context.register(PropertyPlaceholderAutoConfiguration.class,
      ZipkinKafkaCollectorAutoConfiguration.class, InMemoryConfiguration.class);
  context.refresh();

  thrown.expect(NoSuchBeanDefinitionException.class);
  context.getBean(KafkaCollector.class);
}
项目:spring-boot-concourse    文件:SampleAtmosphereApplicationTests.java   
@Test
public void chatEndpoint() throws Exception {
    ConfigurableApplicationContext context = new SpringApplicationBuilder(
            ClientConfiguration.class, PropertyPlaceholderAutoConfiguration.class)
                    .properties("websocket.uri:ws://localhost:" + this.port
                            + "/chat/websocket")
                    .run("--spring.main.web_environment=false");
    long count = context.getBean(ClientConfiguration.class).latch.getCount();
    AtomicReference<String> messagePayloadReference = context
            .getBean(ClientConfiguration.class).messagePayload;
    context.close();
    assertThat(count).isEqualTo(0L);
    assertThat(messagePayloadReference.get())
            .contains("{\"message\":\"test\",\"author\":\"test\",\"time\":");
}
项目:https-github.com-g0t4-jenkins2-course-spring-boot    文件:ThymeleafAutoConfigurationTests.java   
@Test
public void overrideViewNames() throws Exception {
    EnvironmentTestUtils.addEnvironment(this.context,
            "spring.thymeleaf.viewNames:foo,bar");
    this.context.register(ThymeleafAutoConfiguration.class,
            PropertyPlaceholderAutoConfiguration.class);
    this.context.refresh();
    ThymeleafViewResolver views = this.context.getBean(ThymeleafViewResolver.class);
    assertThat(views.getViewNames()).isEqualTo(new String[] { "foo", "bar" });
}