本文整理汇总了Java中org.springframework.boot.autoconfigure.context.PropertyPlaceholderAutoConfiguration类的典型用法代码示例。如果您正苦于以下问题:Java PropertyPlaceholderAutoConfiguration类的具体用法?Java PropertyPlaceholderAutoConfiguration怎么用?Java PropertyPlaceholderAutoConfiguration使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
PropertyPlaceholderAutoConfiguration类属于org.springframework.boot.autoconfigure.context包,在下文中一共展示了PropertyPlaceholderAutoConfiguration类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: init
import org.springframework.boot.autoconfigure.context.PropertyPlaceholderAutoConfiguration; //导入依赖的package包/类
@Before
public void init() {
dbUrl = "h2:mem:testdb-" + new Random().nextInt();
EnvironmentTestUtils.addEnvironment(context,
"spring.datasource.initialize:false",
"spring.datasource.url:jdbc:" + dbUrl);
context.setClassLoader(new HidePackagesClassLoader("com.vladmihalcea.flexypool", "net.ttddyy.dsproxy"));
context.register(DataSourceAutoConfiguration.class,
DataSourceDecoratorAutoConfiguration.class,
TraceAutoConfiguration.class,
SleuthLogAutoConfiguration.class,
SleuthListenerAutoConfiguration.class,
SavingSpanReporterConfiguration.class,
PropertyPlaceholderAutoConfiguration.class);
context.refresh();
dataSource = context.getBean(DataSource.class);
spanReporter = context.getBean(CollectingSpanReporter.class);
}
开发者ID:gavlyukovskiy,项目名称:spring-boot-data-source-decorator,代码行数:20,代码来源:TracingJdbcEventListenerTests.java
示例2: init
import org.springframework.boot.autoconfigure.context.PropertyPlaceholderAutoConfiguration; //导入依赖的package包/类
@Before
public void init() {
dbUrl = "h2:mem:testdb-" + new Random().nextInt();
EnvironmentTestUtils.addEnvironment(context,
"spring.datasource.initialize:false",
"spring.datasource.url:jdbc:" + dbUrl);
context.setClassLoader(new HidePackagesClassLoader("com.vladmihalcea.flexypool", "com.p6spy"));
context.register(DataSourceAutoConfiguration.class,
DataSourceDecoratorAutoConfiguration.class,
SavingSpanReporterConfiguration.class,
TraceAutoConfiguration.class,
SleuthLogAutoConfiguration.class,
SleuthListenerAutoConfiguration.class,
PropertyPlaceholderAutoConfiguration.class);
context.refresh();
dataSource = context.getBean(DataSource.class);
spanReporter = context.getBean(CollectingSpanReporter.class);
}
开发者ID:gavlyukovskiy,项目名称:spring-boot-data-source-decorator,代码行数:20,代码来源:TracingQueryExecutionListenerTests.java
示例3: testAddsDatasourceProxyListener
import org.springframework.boot.autoconfigure.context.PropertyPlaceholderAutoConfiguration; //导入依赖的package包/类
@Test
public void testAddsDatasourceProxyListener() {
context.setClassLoader(new HidePackagesClassLoader("com.vladmihalcea.flexypool", "com.p6spy"));
context.register(DataSourceAutoConfiguration.class,
DataSourceDecoratorAutoConfiguration.class,
TraceAutoConfiguration.class,
SleuthLogAutoConfiguration.class,
SleuthListenerAutoConfiguration.class,
PropertyPlaceholderAutoConfiguration.class);
context.refresh();
DataSource dataSource = context.getBean(DataSource.class);
ProxyDataSource proxyDataSource = (ProxyDataSource) ((DecoratedDataSource) dataSource).getDecoratedDataSource();
ChainListener chainListener = proxyDataSource.getProxyConfig().getQueryListener();
assertThat(chainListener.getListeners()).extracting("class").contains(TracingQueryExecutionListener.class);
}
开发者ID:gavlyukovskiy,项目名称:spring-boot-data-source-decorator,代码行数:17,代码来源:SleuthListenerAutoConfigurationTests.java
示例4: testDecoratedHikariSpecificPropertiesIsSet
import org.springframework.boot.autoconfigure.context.PropertyPlaceholderAutoConfiguration; //导入依赖的package包/类
@Test
public void testDecoratedHikariSpecificPropertiesIsSet() throws Exception {
EnvironmentTestUtils.addEnvironment(context,
"spring.datasource.type:" + HikariDataSource.class.getName(),
"spring.datasource.hikari.catalog:test_catalog");
context.register(DataSourceAutoConfiguration.class,
DataSourceDecoratorAutoConfiguration.class,
PropertyPlaceholderAutoConfiguration.class);
context.refresh();
DataSource dataSource = context.getBean(DataSource.class);
assertThat(dataSource).isNotNull();
assertThat(dataSource).isInstanceOf(DecoratedDataSource.class);
DataSource realDataSource = ((DecoratedDataSource) dataSource).getRealDataSource();
assertThat(realDataSource).isInstanceOf(HikariDataSource.class);
assertThat(((HikariDataSource) realDataSource).getCatalog()).isEqualTo("test_catalog");
}
开发者ID:gavlyukovskiy,项目名称:spring-boot-data-source-decorator,代码行数:17,代码来源:DataSourceDecoratorAutoConfigurationTests.java
示例5: testCustomDataSourceDecoratorApplied
import org.springframework.boot.autoconfigure.context.PropertyPlaceholderAutoConfiguration; //导入依赖的package包/类
@Test
public void testCustomDataSourceDecoratorApplied() throws Exception {
System.setProperty(PropertyLoader.PROPERTIES_FILE_PATH, "db/decorator/flexy-pool.properties");
context.register(TestDataSourceDecoratorConfiguration.class,
DataSourceAutoConfiguration.class,
DataSourceDecoratorAutoConfiguration.class,
PropertyPlaceholderAutoConfiguration.class);
context.refresh();
DataSource dataSource = context.getBean(DataSource.class);
assertThat(dataSource).isNotNull();
DataSource customDataSource = ((DecoratedDataSource) dataSource).getDecoratedDataSource();
assertThat(customDataSource).isInstanceOf(CustomDataSourceProxy.class);
DataSource realDataSource = ((DecoratedDataSource) dataSource).getRealDataSource();
assertThat(realDataSource).isInstanceOf(org.apache.tomcat.jdbc.pool.DataSource.class);
assertThatDataSourceDecoratingChain(dataSource).containsExactly(CustomDataSourceProxy.class, P6DataSource.class, ProxyDataSource.class, FlexyPoolDataSource.class);
}
开发者ID:gavlyukovskiy,项目名称:spring-boot-data-source-decorator,代码行数:21,代码来源:DataSourceDecoratorAutoConfigurationTests.java
示例6: testDecoratingCanBeDisabledForSpecificBeans
import org.springframework.boot.autoconfigure.context.PropertyPlaceholderAutoConfiguration; //导入依赖的package包/类
@Test
public void testDecoratingCanBeDisabledForSpecificBeans() throws Exception {
EnvironmentTestUtils.addEnvironment(context,
"decorator.datasource.exclude-beans:secondDataSource");
context.register(TestMultiDataSourceConfiguration.class,
DataSourceAutoConfiguration.class,
DataSourceDecoratorAutoConfiguration.class,
PropertyPlaceholderAutoConfiguration.class);
context.refresh();
DataSource dataSource = context.getBean("dataSource", DataSource.class);
assertThat(dataSource).isInstanceOf(DecoratedDataSource.class);
DataSource secondDataSource = context.getBean("secondDataSource", DataSource.class);
assertThat(secondDataSource).isInstanceOf(BasicDataSource.class);
}
开发者ID:gavlyukovskiy,项目名称:spring-boot-data-source-decorator,代码行数:17,代码来源:DataSourceDecoratorAutoConfigurationTests.java
示例7: testDecoratingHikariDataSourceWithDefaultStrategies
import org.springframework.boot.autoconfigure.context.PropertyPlaceholderAutoConfiguration; //导入依赖的package包/类
@Test
public void testDecoratingHikariDataSourceWithDefaultStrategies() throws Exception {
EnvironmentTestUtils.addEnvironment(context,
"spring.datasource.type:" + HikariDataSource.class.getName());
context.register(DataSourceAutoConfiguration.class,
DataSourceDecoratorAutoConfiguration.class,
PropertyPlaceholderAutoConfiguration.class);
context.refresh();
DataSource dataSource = context.getBean(DataSource.class);
assertDataSourceOfType(dataSource, HikariDataSource.class);
FlexyPoolDataSource<HikariDataSource> flexyPoolDataSource = assertDataSourceOfType(dataSource, HikariDataSource.class);
IncrementPoolOnTimeoutConnectionAcquiringStrategy strategy1 =
findStrategy(flexyPoolDataSource, IncrementPoolOnTimeoutConnectionAcquiringStrategy.class);
assertThat(strategy1).isNotNull();
assertThat(strategy1).hasFieldOrPropertyWithValue("maxOverflowPoolSize", 15);
assertThat(strategy1).hasFieldOrPropertyWithValue("timeoutMillis", 500);
RetryConnectionAcquiringStrategy strategy2 =
findStrategy(flexyPoolDataSource, RetryConnectionAcquiringStrategy.class);
assertThat(strategy2).isNotNull();
assertThat(strategy2).hasFieldOrPropertyWithValue("retryAttempts", 2);
}
开发者ID:gavlyukovskiy,项目名称:spring-boot-data-source-decorator,代码行数:24,代码来源:FlexyPoolConfigurationTests.java
示例8: testDecoratingHikariDataSourceWithCustomPropertyStrategies
import org.springframework.boot.autoconfigure.context.PropertyPlaceholderAutoConfiguration; //导入依赖的package包/类
@Test
public void testDecoratingHikariDataSourceWithCustomPropertyStrategies() throws Exception {
EnvironmentTestUtils.addEnvironment(context,
"spring.datasource.type:" + HikariDataSource.class.getName(),
"decorator.datasource.flexy-pool.acquiring-strategy.increment-pool.max-overflow-pool-size:15",
"decorator.datasource.flexy-pool.acquiring-strategy.increment-pool.timeout-millis:500",
"decorator.datasource.flexy-pool.acquiring-strategy.retry.attempts:5");
context.register(DataSourceAutoConfiguration.class,
DataSourceDecoratorAutoConfiguration.class,
PropertyPlaceholderAutoConfiguration.class,
HikariConfiguration.class);
context.refresh();
DataSource dataSource = context.getBean(DataSource.class);
FlexyPoolDataSource<HikariDataSource> flexyPoolDataSource = assertDataSourceOfType(dataSource, HikariDataSource.class);
IncrementPoolOnTimeoutConnectionAcquiringStrategy strategy1 =
findStrategy(flexyPoolDataSource, IncrementPoolOnTimeoutConnectionAcquiringStrategy.class);
assertThat(strategy1).isNotNull();
assertThat(strategy1).hasFieldOrPropertyWithValue("maxOverflowPoolSize", 35);
assertThat(strategy1).hasFieldOrPropertyWithValue("timeoutMillis", 10000);
RetryConnectionAcquiringStrategy strategy2 =
findStrategy(flexyPoolDataSource, RetryConnectionAcquiringStrategy.class);
assertThat(strategy2).isNotNull();
assertThat(strategy2).hasFieldOrPropertyWithValue("retryAttempts", 5);
}
开发者ID:gavlyukovskiy,项目名称:spring-boot-data-source-decorator,代码行数:27,代码来源:FlexyPoolConfigurationTests.java
示例9: providesCollectorComponent_whenBootstrapServersSet
import org.springframework.boot.autoconfigure.context.PropertyPlaceholderAutoConfiguration; //导入依赖的package包/类
@Test
public void providesCollectorComponent_whenBootstrapServersSet() {
addEnvironment(context,
"zipkin.sparkstreaming.stream.kafka.bootstrap-servers:" + KAFKA_BOOTSTRAP
);
context.register(
PropertyPlaceholderAutoConfiguration.class,
ZipkinKafkaStreamFactoryAutoConfiguration.class
);
context.refresh();
ZipkinKafkaStreamFactoryProperties props =
context.getBean(ZipkinKafkaStreamFactoryProperties.class);
assertThat(props.getBootstrapServers())
.containsExactly(KAFKA_BOOTSTRAP);
}
开发者ID:openzipkin,项目名称:zipkin-sparkstreaming,代码行数:17,代码来源:ZipkinKafkaStreamFactoryAutoConfigurationTest.java
示例10: providesCollectorComponent_whenKafkaZookeeperSet
import org.springframework.boot.autoconfigure.context.PropertyPlaceholderAutoConfiguration; //导入依赖的package包/类
@Test
public void providesCollectorComponent_whenKafkaZookeeperSet() {
addEnvironment(context,
"zipkin.sparkstreaming.stream.kafka.zookeeper.connect:" + KAFKA_ZOOKEEPER
);
context.register(
PropertyPlaceholderAutoConfiguration.class,
ZipkinKafkaStreamFactoryAutoConfiguration.class
);
context.refresh();
ZipkinKafkaStreamFactoryProperties props =
context.getBean(ZipkinKafkaStreamFactoryProperties.class);
assertThat(props.getZookeeper().getConnect())
.isEqualTo(KAFKA_ZOOKEEPER);
}
开发者ID:openzipkin,项目名称:zipkin-sparkstreaming,代码行数:17,代码来源:ZipkinKafkaStreamFactoryAutoConfigurationTest.java
示例11: provideCollectorComponent_setsZipkinSqsCollectorProperties
import org.springframework.boot.autoconfigure.context.PropertyPlaceholderAutoConfiguration; //导入依赖的package包/类
@Test
public void provideCollectorComponent_setsZipkinSqsCollectorProperties() {
context = new AnnotationConfigApplicationContext();
addEnvironment(context, "zipkin.collector.sqs.queue-url:" + sqsRule.queueUrl());
addEnvironment(context, "zipkin.collector.sqs.wait-time-seconds:1");
addEnvironment(context, "zipkin.collector.sqs.parallelism:3");
addEnvironment(context, "zipkin.collector.sqs.aws-access-key-id: x");
addEnvironment(context, "zipkin.collector.sqs.aws-secret-access-key: x");
context.register(PropertyPlaceholderAutoConfiguration.class, Region.class,
ZipkinSQSCollectorAutoConfiguration.class, ZipkinSQSCredentialsAutoConfiguration.class, InMemoryConfiguration.class);
context.refresh();
ZipkinSQSCollectorProperties properties = context.getBean(ZipkinSQSCollectorProperties.class);
assertThat(properties.getQueueUrl()).isEqualTo(sqsRule.queueUrl());
assertThat(properties.getWaitTimeSeconds()).isEqualTo(1);
assertThat(properties.getParallelism()).isEqualTo(3);
}
示例12: provideSecurityTokenService_whenAwsStsRoleArnIsSet
import org.springframework.boot.autoconfigure.context.PropertyPlaceholderAutoConfiguration; //导入依赖的package包/类
@Test
public void provideSecurityTokenService_whenAwsStsRoleArnIsSet() {
context = new AnnotationConfigApplicationContext();
addEnvironment(context, "zipkin.collector.sqs.queue-url:" + sqsRule.queueUrl());
addEnvironment(context, "zipkin.collector.sqs.wait-time-seconds:1");
addEnvironment(context, "zipkin.collector.sqs.aws-access-key-id: x");
addEnvironment(context, "zipkin.collector.sqs.aws-secret-access-key: x");
addEnvironment(context, "zipkin.collector.sqs.aws-sts-role-arn: test");
context.register(PropertyPlaceholderAutoConfiguration.class, Region.class,
ZipkinSQSCollectorAutoConfiguration.class, ZipkinSQSCredentialsAutoConfiguration.class, InMemoryConfiguration.class);
context.refresh();
assertThat(context.getBean(SQSCollector.class)).isNotNull();
assertThat(context.getBean(AWSSecurityTokenService.class)).isNotNull();
assertThat(context.getBean(AWSCredentialsProvider.class)).isInstanceOf(STSAssumeRoleSessionCredentialsProvider.class);
}
示例13: testWithConfigurationVariablesAndPropertiesOtherKey
import org.springframework.boot.autoconfigure.context.PropertyPlaceholderAutoConfiguration; //导入依赖的package包/类
@Test
public void testWithConfigurationVariablesAndPropertiesOtherKey() {
TestPropertyValues.of(
"mybatis.configuration.variables.key1:value1",
"mybatis.configuration-properties.key2:value2")
.applyTo(this.context);
this.context.register(EmbeddedDataSourceConfiguration.class,
MybatisAutoConfiguration.class,
PropertyPlaceholderAutoConfiguration.class);
this.context.refresh();
Properties variables = this.context.getBean(SqlSessionFactory.class).getConfiguration().getVariables();
assertThat(variables).hasSize(2);
assertThat(variables.getProperty("key1")).isEqualTo("value1");
assertThat(variables.getProperty("key2")).isEqualTo("value2");
}
示例14: defaultsToV2Endpoint
import org.springframework.boot.autoconfigure.context.PropertyPlaceholderAutoConfiguration; //导入依赖的package包/类
@Test
public void defaultsToV2Endpoint() throws Exception {
context = new AnnotationConfigApplicationContext();
addEnvironment(context, "spring.zipkin.base-url:" + server.url("/"));
context.register(
PropertyPlaceholderAutoConfiguration.class,
TraceMetricsAutoConfiguration.class,
ZipkinAutoConfiguration.class);
context.refresh();
SpanReporter spanReporter = context.getBean(SpanReporter.class);
spanReporter.report(span);
Awaitility.await().untilAsserted(() -> then(server.getRequestCount()).isGreaterThan(0));
RecordedRequest request = server.takeRequest();
then(request.getPath()).isEqualTo("/api/v2/spans");
then(request.getBody().readUtf8()).contains("localEndpoint");
}
示例15: encoderDirectsEndpoint
import org.springframework.boot.autoconfigure.context.PropertyPlaceholderAutoConfiguration; //导入依赖的package包/类
@Test
public void encoderDirectsEndpoint() throws Exception {
context = new AnnotationConfigApplicationContext();
addEnvironment(
context, "spring.zipkin.base-url:" + server.url("/"), "spring.zipkin.encoder:JSON_V1");
context.register(
PropertyPlaceholderAutoConfiguration.class,
TraceMetricsAutoConfiguration.class,
ZipkinAutoConfiguration.class);
context.refresh();
SpanReporter spanReporter = context.getBean(SpanReporter.class);
spanReporter.report(span);
Awaitility.await().untilAsserted(() -> then(server.getRequestCount()).isGreaterThan(0));
RecordedRequest request = server.takeRequest();
then(request.getPath()).isEqualTo("/api/v1/spans");
then(request.getBody().readUtf8()).contains("binaryAnnotations");
}