本文整理匯總了Java中org.springframework.mock.env.MockEnvironment.setProperty方法的典型用法代碼示例。如果您正苦於以下問題:Java MockEnvironment.setProperty方法的具體用法?Java MockEnvironment.setProperty怎麽用?Java MockEnvironment.setProperty使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類org.springframework.mock.env.MockEnvironment
的用法示例。
在下文中一共展示了MockEnvironment.setProperty方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: initialize
import org.springframework.mock.env.MockEnvironment; //導入方法依賴的package包/類
@Override
public void initialize(ConfigurableApplicationContext applicationContext) {
MockEnvironment environment = new MockEnvironment();
environment.setProperty("admin.api.url", "/admin");
environment.setProperty("admin.i18n.path", "/admin/i18n");
environment.setProperty("admin.debug", "true");
applicationContext.setEnvironment(environment);
}
示例2: testEndpointMBeanExporterWithProperties
import org.springframework.mock.env.MockEnvironment; //導入方法依賴的package包/類
@Test
public void testEndpointMBeanExporterWithProperties() throws IntrospectionException,
InstanceNotFoundException, MalformedObjectNameException, ReflectionException {
MockEnvironment environment = new MockEnvironment();
environment.setProperty("endpoints.jmx.domain", "test-domain");
environment.setProperty("endpoints.jmx.unique_names", "true");
environment.setProperty("endpoints.jmx.static_names", "key1=value1, key2=value2");
this.context = new AnnotationConfigApplicationContext();
this.context.setEnvironment(environment);
this.context.register(JmxAutoConfiguration.class, EndpointAutoConfiguration.class,
EndpointMBeanExportAutoConfiguration.class);
this.context.refresh();
this.context.getBean(EndpointMBeanExporter.class);
MBeanExporter mbeanExporter = this.context.getBean(EndpointMBeanExporter.class);
assertThat(mbeanExporter.getServer().getMBeanInfo(ObjectNameManager.getInstance(
getObjectName("test-domain", "healthEndpoint", this.context).toString()
+ ",key1=value1,key2=value2"))).isNotNull();
}
開發者ID:vikrammane23,項目名稱:https-github.com-g0t4-jenkins2-course-spring-boot,代碼行數:20,代碼來源:EndpointMBeanExportAutoConfigurationTests.java
示例3: testPlaceholderBased
import org.springframework.mock.env.MockEnvironment; //導入方法依賴的package包/類
@Test
public void testPlaceholderBased() throws Exception {
MockEnvironment env = new MockEnvironment();
env.setProperty("serverName", "server");
AnnotationConfigApplicationContext ctx = new AnnotationConfigApplicationContext();
ctx.setEnvironment(env);
ctx.register(PlaceholderBasedConfiguration.class);
ctx.refresh();
try {
MBeanServer server = (MBeanServer) ctx.getBean("server");
ObjectName oname = ObjectNameManager.getInstance("bean:name=testBean4");
assertNotNull(server.getObjectInstance(oname));
String name = (String) server.getAttribute(oname, "Name");
assertEquals("Invalid name returned", "TEST", name);
}
finally {
ctx.close();
}
}
示例4: setEnvironmentWithSpringApplicationNameShouldSetComponentName
import org.springframework.mock.env.MockEnvironment; //導入方法依賴的package包/類
@Test
public void setEnvironmentWithSpringApplicationNameShouldSetComponentName() {
CereebroProperties c = new CereebroProperties();
MockEnvironment env = new MockEnvironment();
env.setProperty("spring.application.name", "cyclop");
c.setEnvironment(env);
Assert.assertEquals("cyclop", c.getApplication().getComponent().getName());
}
示例5: testFilePatternProperty
import org.springframework.mock.env.MockEnvironment; //導入方法依賴的package包/類
@Test
public void testFilePatternProperty() throws Exception {
MockEnvironment environment = new MockEnvironment();
environment.setProperty("logging.pattern.file", "%logger %msg");
LoggingInitializationContext loggingInitializationContext = new LoggingInitializationContext(
environment);
File file = new File(tmpDir(), "logback-test.log");
LogFile logFile = getLogFile(file.getPath(), null);
this.loggingSystem.initialize(loggingInitializationContext, null, logFile);
this.logger.info("Hello world");
String output = this.output.toString().trim();
assertThat(getLineWithText(output, "Hello world")).contains("INFO");
assertThat(getLineWithText(file, "Hello world")).doesNotContain("INFO");
}
示例6: testEnabledMBeanExport
import org.springframework.mock.env.MockEnvironment; //導入方法依賴的package包/類
@Test
public void testEnabledMBeanExport() {
MockEnvironment env = new MockEnvironment();
env.setProperty("spring.jmx.enabled", "true");
this.context = new AnnotationConfigApplicationContext();
this.context.setEnvironment(env);
this.context.register(JmxAutoConfiguration.class);
this.context.refresh();
assertThat(this.context.getBean(MBeanExporter.class)).isNotNull();
}
示例7: createFromInitialReportSkipsTextAnalysisWhenServiceUrlIsMissing
import org.springframework.mock.env.MockEnvironment; //導入方法依賴的package包/類
@Test
public void createFromInitialReportSkipsTextAnalysisWhenServiceUrlIsMissing() {
final MockEnvironment mockEnvironment = (MockEnvironment) environment;
mockEnvironment.setProperty(ConfigParam.TEXT_ANALYSIS_SERVICE_URL.toString(), "");
final OccurrenceReport result = reportFactory.createFromInitialReport(initialReport());
assertNotNull(result);
assertNotNull(result.getInitialReport());
assertEquals(TEXT, result.getInitialReport().getDescription());
}
示例8: testEndpointMBeanExporterIsNotInstalled
import org.springframework.mock.env.MockEnvironment; //導入方法依賴的package包/類
@Test(expected = NoSuchBeanDefinitionException.class)
public void testEndpointMBeanExporterIsNotInstalled() {
MockEnvironment environment = new MockEnvironment();
environment.setProperty("endpoints.jmx.enabled", "false");
this.context = new AnnotationConfigApplicationContext();
this.context.setEnvironment(environment);
this.context.register(JmxAutoConfiguration.class, EndpointAutoConfiguration.class,
EndpointMBeanExportAutoConfiguration.class);
this.context.refresh();
this.context.getBean(EndpointMBeanExporter.class);
}
開發者ID:vikrammane23,項目名稱:https-github.com-g0t4-jenkins2-course-spring-boot,代碼行數:12,代碼來源:EndpointMBeanExportAutoConfigurationTests.java
示例9: testDisabledMBeanExport
import org.springframework.mock.env.MockEnvironment; //導入方法依賴的package包/類
@Test(expected = NoSuchBeanDefinitionException.class)
public void testDisabledMBeanExport() {
MockEnvironment env = new MockEnvironment();
env.setProperty("spring.jmx.enabled", "false");
this.context = new AnnotationConfigApplicationContext();
this.context.setEnvironment(env);
this.context.register(TestConfiguration.class, JmxAutoConfiguration.class);
this.context.refresh();
this.context.getBean(MBeanExporter.class);
}
開發者ID:vikrammane23,項目名稱:https-github.com-g0t4-jenkins2-course-spring-boot,代碼行數:11,代碼來源:JmxAutoConfigurationTests.java
示例10: trusted_destination_config_with_single_ip
import org.springframework.mock.env.MockEnvironment; //導入方法依賴的package包/類
@Test
public void trusted_destination_config_with_single_ip() {
MockEnvironment env = new MockEnvironment();
this.context = new AnnotationConfigApplicationContext();
env.setProperty("broker.filter.trusted.destination.hosts", "192.168.0.1");
this.context.setEnvironment(env);
this.context.register(SpecificationConfig.DefaultSpecificationConfig.class, SpecificationConfig.AllowedDestinationSpecificationConfig.class);
this.context.refresh();
final TrustedDestination trustedDestination = this.context.getBean(TrustedDestination.class);
Assertions.assertThat(trustedDestination).isEqualTo(ImmutableTrustedDestination.builder()
.hosts(ImmutableIPAddress.of("192.168.0.1"))
.build());
}
示例11: getPageWhenUrlIsRelativeAndHasPortWillUseLocalhostPort
import org.springframework.mock.env.MockEnvironment; //導入方法依賴的package包/類
@Test
public void getPageWhenUrlIsRelativeAndHasPortWillUseLocalhostPort()
throws Exception {
MockEnvironment environment = new MockEnvironment();
environment.setProperty("local.server.port", "8181");
WebClient client = new LocalHostWebClient(environment);
WebConnection connection = mockConnection();
client.setWebConnection(connection);
client.getPage("/test");
verify(connection).getResponse(this.requestCaptor.capture());
assertThat(this.requestCaptor.getValue().getUrl())
.isEqualTo(new URL("http://localhost:8181/test"));
}
開發者ID:vikrammane23,項目名稱:https-github.com-g0t4-jenkins2-course-spring-boot,代碼行數:14,代碼來源:LocalHostWebClientTests.java
示例12: testConsolePatternProperty
import org.springframework.mock.env.MockEnvironment; //導入方法依賴的package包/類
@Test
public void testConsolePatternProperty() {
MockEnvironment environment = new MockEnvironment();
environment.setProperty("logging.pattern.console", "%logger %msg");
LoggingInitializationContext loggingInitializationContext = new LoggingInitializationContext(
environment);
this.loggingSystem.initialize(loggingInitializationContext, null, null);
this.logger.info("Hello world");
String output = this.output.toString().trim();
assertThat(getLineWithText(output, "Hello world")).doesNotContain("INFO");
}
示例13: testInitializersSeeBoundProperties
import org.springframework.mock.env.MockEnvironment; //導入方法依賴的package包/類
@Test
public void testInitializersSeeBoundProperties() {
MockEnvironment env = new MockEnvironment();
env.setProperty("bar", "foo");
this.context = new AnnotationConfigApplicationContext();
this.context.setEnvironment(env);
this.context.register(TestConfigurationWithInitializer.class);
this.context.refresh();
}
開發者ID:philwebb,項目名稱:spring-boot-concourse,代碼行數:10,代碼來源:ConfigurationPropertiesBindingPostProcessorTests.java
示例14: testLevelPatternProperty
import org.springframework.mock.env.MockEnvironment; //導入方法依賴的package包/類
@Test
public void testLevelPatternProperty() {
MockEnvironment environment = new MockEnvironment();
environment.setProperty("logging.pattern.level", "X%clr(%p)X");
LoggingInitializationContext loggingInitializationContext = new LoggingInitializationContext(
environment);
this.loggingSystem.initialize(loggingInitializationContext, null, null);
this.logger.info("Hello world");
String output = this.output.toString().trim();
assertThat(getLineWithText(output, "Hello world")).contains("XINFOX");
}
開發者ID:vikrammane23,項目名稱:https-github.com-g0t4-jenkins2-course-spring-boot,代碼行數:12,代碼來源:LogbackLoggingSystemTests.java
示例15: testSuccessfulValidationWithJSR303
import org.springframework.mock.env.MockEnvironment; //導入方法依賴的package包/類
@Test
public void testSuccessfulValidationWithJSR303() {
MockEnvironment env = new MockEnvironment();
env.setProperty("test.foo", "123456");
env.setProperty("test.bar", "654321");
this.context = new AnnotationConfigApplicationContext();
this.context.setEnvironment(env);
this.context.register(TestConfigurationWithJSR303.class);
this.context.refresh();
}
開發者ID:philwebb,項目名稱:spring-boot-concourse,代碼行數:11,代碼來源:ConfigurationPropertiesBindingPostProcessorTests.java