当前位置: 首页>>代码示例>>Java>>正文


Java EnvironmentTestUtils.addEnvironment方法代码示例

本文整理汇总了Java中org.springframework.boot.test.EnvironmentTestUtils.addEnvironment方法的典型用法代码示例。如果您正苦于以下问题:Java EnvironmentTestUtils.addEnvironment方法的具体用法?Java EnvironmentTestUtils.addEnvironment怎么用?Java EnvironmentTestUtils.addEnvironment使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.springframework.boot.test.EnvironmentTestUtils的用法示例。


在下文中一共展示了EnvironmentTestUtils.addEnvironment方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: testOkHttpClientAutoConfiguredWithCustomProperties

import org.springframework.boot.test.EnvironmentTestUtils; //导入方法依赖的package包/类
@Test
public void testOkHttpClientAutoConfiguredWithCustomProperties() {
    context = new AnnotationConfigApplicationContext();
    context.register(OkHttpAutoConfiguration.class);
    EnvironmentTestUtils.addEnvironment(context, "spring.okhttp.connection-timeout:500");
    EnvironmentTestUtils.addEnvironment(context, "spring.okhttp.read-timeout:600");
    EnvironmentTestUtils.addEnvironment(context, "spring.okhttp.write-timeout:700");
    context.refresh();

    OkHttpClient okHttpClient = context.getBean(OkHttpClient.class);

    assertThat(okHttpClient).isNotNull();
    assertThat(okHttpClient.connectTimeoutMillis()).isEqualTo(500);
    assertThat(okHttpClient.readTimeoutMillis()).isEqualTo(600);
    assertThat(okHttpClient.writeTimeoutMillis()).isEqualTo(700);
}
 
开发者ID:troinine,项目名称:spring-boot-square-oss-support,代码行数:17,代码来源:OkHttpAutoConfigurationTest.java

示例2: testDataSourcePropertiesOverridden

import org.springframework.boot.test.EnvironmentTestUtils; //导入方法依赖的package包/类
@Test
public void testDataSourcePropertiesOverridden() throws Exception {
	this.context.register(CommonsDataSourceConfiguration.class);
	EnvironmentTestUtils.addEnvironment(this.context,
			PREFIX + "url:jdbc:foo//bar/spam");
	EnvironmentTestUtils.addEnvironment(this.context, PREFIX + "testWhileIdle:true");
	EnvironmentTestUtils.addEnvironment(this.context, PREFIX + "testOnBorrow:true");
	EnvironmentTestUtils.addEnvironment(this.context, PREFIX + "testOnReturn:true");
	EnvironmentTestUtils.addEnvironment(this.context,
			PREFIX + "timeBetweenEvictionRunsMillis:10000");
	EnvironmentTestUtils.addEnvironment(this.context,
			PREFIX + "minEvictableIdleTimeMillis:12345");
	EnvironmentTestUtils.addEnvironment(this.context, PREFIX + "maxWait:1234");
	this.context.refresh();
	BasicDataSource ds = this.context.getBean(BasicDataSource.class);
	assertEquals("jdbc:foo//bar/spam", ds.getUrl());
	assertTrue(ds.getTestWhileIdle());
	assertTrue(ds.getTestOnBorrow());
	assertTrue(ds.getTestOnReturn());
	assertEquals(10000, ds.getTimeBetweenEvictionRunsMillis());
	assertEquals(12345, ds.getMinEvictableIdleTimeMillis());
	assertEquals(1234, ds.getMaxWait());
}
 
开发者ID:Nephilim84,项目名称:contestparser,代码行数:24,代码来源:CommonsDataSourceConfigurationTests.java

示例3: negativeOuterPositiveInnerBean

import org.springframework.boot.test.EnvironmentTestUtils; //导入方法依赖的package包/类
@Test
public void negativeOuterPositiveInnerBean() throws Exception {
	AnnotationConfigApplicationContext context = new AnnotationConfigApplicationContext();
	EnvironmentTestUtils.addEnvironment(context, "test.present=true");
	context.register(NegativeOuterConfig.class);
	context.refresh();
	ConditionEvaluationReport report = ConditionEvaluationReport
			.get(context.getBeanFactory());
	Map<String, ConditionAndOutcomes> sourceOutcomes = report
			.getConditionAndOutcomesBySource();
	assertThat(context.containsBean("negativeOuterPositiveInnerBean"),
			equalTo(false));
	String negativeConfig = NegativeOuterConfig.class.getName();
	assertThat(sourceOutcomes.get(negativeConfig).isFullMatch(), equalTo(false));
	String positiveConfig = NegativeOuterConfig.PositiveInnerConfig.class.getName();
	assertThat(sourceOutcomes.get(positiveConfig).isFullMatch(), equalTo(false));
}
 
开发者ID:Nephilim84,项目名称:contestparser,代码行数:18,代码来源:ConditionEvaluationReportTests.java

示例4: testKeySanitizationWithCustomKeysByEnvironment

import org.springframework.boot.test.EnvironmentTestUtils; //导入方法依赖的package包/类
@SuppressWarnings("unchecked")
@Test
public void testKeySanitizationWithCustomKeysByEnvironment() throws Exception {
	this.context = new AnnotationConfigApplicationContext();
	EnvironmentTestUtils.addEnvironment(this.context,
			"endpoints.env.keys-to-sanitize: key");
	this.context.register(Config.class);
	this.context.refresh();
	System.setProperty("dbPassword", "123456");
	System.setProperty("apiKey", "123456");
	EnvironmentEndpoint report = getEndpointBean();
	Map<String, Object> env = report.invoke();
	assertEquals("123456",
			((Map<String, Object>) env.get("systemProperties")).get("dbPassword"));
	assertEquals("******",
			((Map<String, Object>) env.get("systemProperties")).get("apiKey"));
}
 
开发者ID:Nephilim84,项目名称:contestparser,代码行数:18,代码来源:EnvironmentEndpointTests.java

示例5: load

import org.springframework.boot.test.EnvironmentTestUtils; //导入方法依赖的package包/类
private AnnotationConfigApplicationContext load(Class<?> config, String... env) {
	AnnotationConfigApplicationContext context = new AnnotationConfigApplicationContext();
	EnvironmentTestUtils.addEnvironment(context, env);
	context.register(config);
	context.refresh();
	return context;
}
 
开发者ID:spring-cloud,项目名称:spring-cloud-dashboard,代码行数:8,代码来源:OnSecurityEnabledAndOAuth2DisabledTests.java

示例6: load

import org.springframework.boot.test.EnvironmentTestUtils; //导入方法依赖的package包/类
private void load(Class<?> config, String... environment) {
    AnnotationConfigApplicationContext applicationContext = new AnnotationConfigApplicationContext();
    EnvironmentTestUtils.addEnvironment(applicationContext, environment);
    applicationContext.register(config);
    applicationContext.register(S3AutoConfiguration.class);
    applicationContext.refresh();
    this.context = applicationContext;
}
 
开发者ID:kbastani,项目名称:spring-boot-starter-amazon-s3,代码行数:9,代码来源:S3AutoConfigurationTest.java

示例7: fsUriCanBeCustomized

import org.springframework.boot.test.EnvironmentTestUtils; //导入方法依赖的package包/类
@Test
public void fsUriCanBeCustomized() {
	AnnotationConfigApplicationContext context = new AnnotationConfigApplicationContext();
	EnvironmentTestUtils.addEnvironment(context, "hdfs.fsUri:hdfs://localhost:8020");
	context.register(Conf.class);
	context.refresh();
	HdfsSinkProperties properties = context.getBean(HdfsSinkProperties.class);
	assertThat(properties.getFsUri(), equalTo("hdfs://localhost:8020"));
}
 
开发者ID:spring-cloud,项目名称:spring-cloud-stream-app-starters,代码行数:10,代码来源:HdfsSinkPropertiesTests.java

示例8: tmpFileSuffixCanBeCustomized

import org.springframework.boot.test.EnvironmentTestUtils; //导入方法依赖的package包/类
@Test
public void tmpFileSuffixCanBeCustomized() {
	AnnotationConfigApplicationContext context = new AnnotationConfigApplicationContext();
	EnvironmentTestUtils.addEnvironment(context, "sftp.tmpFileSuffix:.foo");
	context.register(Conf.class);
	context.refresh();
	SftpSinkProperties properties = context.getBean(SftpSinkProperties.class);
	assertThat(properties.getTmpFileSuffix(), equalTo(".foo"));
}
 
开发者ID:spring-cloud,项目名称:spring-cloud-stream-app-starters,代码行数:10,代码来源:SftpSinkPropertiesTests.java

示例9: fail_to_set_service_with_no_name

import org.springframework.boot.test.EnvironmentTestUtils; //导入方法依赖的package包/类
@Test
public void fail_to_set_service_with_no_name() {
    this.context.register(TestConfiguration.class);
    EnvironmentTestUtils.addEnvironment(this.context,
            "services.tripadvisor.name:",
            "services.tripadvisor.description:a_description",
            "services.tripadvisor.plans.default.name:default");
    this.thrown.expect(BeanCreationException.class);
    this.thrown.expectMessage(ServiceProperties.NO_NAME_ERROR);
    this.context.refresh();
}
 
开发者ID:orange-cloudfoundry,项目名称:static-creds-broker,代码行数:12,代码来源:ServicePropertiesTest.java

示例10: writerCacheSizeCanBeCustomized

import org.springframework.boot.test.EnvironmentTestUtils; //导入方法依赖的package包/类
@Test
public void writerCacheSizeCanBeCustomized() {
	AnnotationConfigApplicationContext context = new AnnotationConfigApplicationContext();
	EnvironmentTestUtils.addEnvironment(context, "hdfs.dataset.writerCacheSize:20");
	context.register(Conf.class);
	context.refresh();
	HdfsDatasetSinkProperties properties = context.getBean(HdfsDatasetSinkProperties.class);
	assertThat(properties.getWriterCacheSize(), equalTo(20));
}
 
开发者ID:spring-cloud,项目名称:spring-cloud-stream-app-starters,代码行数:10,代码来源:DatasetSinkPropertiesTests.java

示例11: codecCanBeCustomized

import org.springframework.boot.test.EnvironmentTestUtils; //导入方法依赖的package包/类
@Test
public void codecCanBeCustomized() {
	AnnotationConfigApplicationContext context = new AnnotationConfigApplicationContext();
	EnvironmentTestUtils.addEnvironment(context, "hdfs.codec:snappy");
	context.register(Conf.class);
	context.refresh();
	HdfsSinkProperties properties = context.getBean(HdfsSinkProperties.class);
	assertThat(properties.getCodec(), equalTo(Codecs.SNAPPY.getAbbreviation()));
}
 
开发者ID:spring-cloud,项目名称:spring-cloud-stream-app-starters,代码行数:10,代码来源:HdfsSinkPropertiesTests.java

示例12: localDirCanBeCustomized

import org.springframework.boot.test.EnvironmentTestUtils; //导入方法依赖的package包/类
@Test
public void localDirCanBeCustomized() {
	AnnotationConfigApplicationContext context = new AnnotationConfigApplicationContext();
	EnvironmentTestUtils.addEnvironment(context, "ftp.localDir:local");
	context.register(Conf.class);
	context.refresh();
	FtpSourceProperties properties = context.getBean(FtpSourceProperties.class);
	assertThat(properties.getLocalDir(), equalTo(new File("local")));
}
 
开发者ID:spring-cloud,项目名称:spring-cloud-stream-app-starters,代码行数:10,代码来源:FtpSourcePropertiesTests.java

示例13: partitionPathCanBeCustomized

import org.springframework.boot.test.EnvironmentTestUtils; //导入方法依赖的package包/类
@Test
public void partitionPathCanBeCustomized() {
	AnnotationConfigApplicationContext context = new AnnotationConfigApplicationContext();
	EnvironmentTestUtils.addEnvironment(context, "hdfs.dataset.partitionPath:year('timestamp')");
	context.register(Conf.class);
	context.refresh();
	HdfsDatasetSinkProperties properties = context.getBean(HdfsDatasetSinkProperties.class);
	assertThat(properties.getPartitionPath(), equalTo("year('timestamp')"));
}
 
开发者ID:spring-cloud,项目名称:spring-cloud-stream-app-starters,代码行数:10,代码来源:DatasetSinkPropertiesTests.java

示例14: remoteFileSeparatorCanBeCustomized

import org.springframework.boot.test.EnvironmentTestUtils; //导入方法依赖的package包/类
@Test
public void remoteFileSeparatorCanBeCustomized() {
	AnnotationConfigApplicationContext context = new AnnotationConfigApplicationContext();
	EnvironmentTestUtils.addEnvironment(context, "ftp.remoteFileSeparator:\\");
	context.register(Conf.class);
	context.refresh();
	FtpSinkProperties properties = context.getBean(FtpSinkProperties.class);
	assertThat(properties.getRemoteFileSeparator(), equalTo("\\"));
}
 
开发者ID:spring-cloud,项目名称:spring-cloud-stream-app-starters,代码行数:10,代码来源:FtpSinkPropertiesTests.java

示例15: updateCanBeCustomized

import org.springframework.boot.test.EnvironmentTestUtils; //导入方法依赖的package包/类
@Test
public void updateCanBeCustomized() {
	EnvironmentTestUtils.addEnvironment(this.context, "jdbc.query:select foo from bar where baz < 1");
	String update = "update bar set baz=1 where foo in (:foo)";
	EnvironmentTestUtils.addEnvironment(this.context, "jdbc.update:" + update);
	this.context.register(Conf.class);
	this.context.refresh();
	JdbcSourceProperties properties = this.context.getBean(JdbcSourceProperties.class);
	assertThat(properties.getUpdate(), equalTo(update));
}
 
开发者ID:spring-cloud,项目名称:spring-cloud-stream-app-starters,代码行数:11,代码来源:JdbcSourcePropertiesTests.java


注:本文中的org.springframework.boot.test.EnvironmentTestUtils.addEnvironment方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。