Java Code Examples for org.springframework.boot.test.util.EnvironmentTestUtils#addEnvironment()
The following examples show how to use
org.springframework.boot.test.util.EnvironmentTestUtils#addEnvironment() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: SpringBeanResolutionTest.java From ogham with Apache License 2.0 | 5 votes |
@Before public void setUp() { context = new AnnotationConfigApplicationContext(); EnvironmentTestUtils.addEnvironment(context, "mail.smtp.host="+ServerSetupTest.SMTP.getBindAddress(), "mail.smtp.port="+ServerSetupTest.SMTP.getPort(), "ogham.sms.smpp.host=127.0.0.1", "ogham.sms.smpp.port="+smppServer.getPort(), "spring.freemarker.suffix="); context.register(TestConfig.class, ThymeleafAutoConfiguration.class, FreeMarkerAutoConfiguration.class, OghamSpringBoot1AutoConfiguration.class); context.refresh(); messagingService = context.getBean(MessagingService.class); }
Example 2
Source File: RocketMqAutoConfigurationTest.java From spring-boot-rocketmq-starter with Apache License 2.0 | 5 votes |
private void load(boolean refresh, String... environment) { AnnotationConfigApplicationContext ctx = new AnnotationConfigApplicationContext(); ctx.register(RocketMqAutoConfiguration.class); EnvironmentTestUtils.addEnvironment(ctx, environment); if (refresh) { ctx.refresh(); } this.context = ctx; }
Example 3
Source File: FooConfigurationTest.java From spring-test-examples with Apache License 2.0 | 5 votes |
@Test public void testFooCreatePropertyTrue() { EnvironmentTestUtils.addEnvironment(context, "foo.create=true"); context.register(FooConfiguration.class); context.refresh(); assertNotNull(context.getBean(Foo.class)); }
Example 4
Source File: MQConsumerAutoConfigurationTest.java From rocketmq-spring-boot-starter with Apache License 2.0 | 5 votes |
private void prepareApplicationContextMissingParent() { this.context = new AnnotationConfigApplicationContext(); EnvironmentTestUtils.addEnvironment(this.context, "spring.rocketmq.name-server-address:127.0.0.1:9876"); this.context.register(TestConsumerMissingParent.class); this.context.register(MQConsumerAutoConfiguration.class); this.context.refresh(); }
Example 5
Source File: MQConsumerAutoConfigurationTest.java From rocketmq-spring-boot-starter with Apache License 2.0 | 5 votes |
private void prepareApplicationContextCMError() { this.context = new AnnotationConfigApplicationContext(); EnvironmentTestUtils.addEnvironment(this.context, "spring.rocketmq.name-server-address:127.0.0.1:9876"); this.context.register(TestConsumerErrorCM.class); this.context.register(MQConsumerAutoConfiguration.class); this.context.refresh(); }
Example 6
Source File: MQConsumerAutoConfigurationTest.java From rocketmq-spring-boot-starter with Apache License 2.0 | 5 votes |
private void prepareApplicationContextCMOrderly() { this.context = new AnnotationConfigApplicationContext(); EnvironmentTestUtils.addEnvironment(this.context, "spring.rocketmq.name-server-address:127.0.0.1:9876"); this.context.register(TestConsumerOrderly.class); this.context.register(MQConsumerAutoConfiguration.class); this.context.refresh(); }
Example 7
Source File: MQConsumerAutoConfigurationTest.java From rocketmq-spring-boot-starter with Apache License 2.0 | 5 votes |
private void prepareApplicationContext() { this.context = new AnnotationConfigApplicationContext(); EnvironmentTestUtils.addEnvironment(this.context, "spring.rocketmq.name-server-address:127.0.0.1:9876"); this.context.register(TestConsumer.class); this.context.register(MQConsumerAutoConfiguration.class); this.context.refresh(); }
Example 8
Source File: OghamSpringBoot1SendGridAutoConfigurationTests.java From ogham with Apache License 2.0 | 5 votes |
@Before public void setUp() { context = new AnnotationConfigApplicationContext(); EnvironmentTestUtils.addEnvironment(context, "mail.smtp.host="+ServerSetupTest.SMTP.getBindAddress(), "mail.smtp.port="+ServerSetupTest.SMTP.getPort(), "ogham.sms.smpp.host=127.0.0.1", "ogham.sms.smpp.port="+smppServer.getPort(), "spring.sendgrid.api-key=spring", "ogham.freemarker.default-encoding="+StandardCharsets.US_ASCII.name(), "spring.freemarker.charset="+StandardCharsets.UTF_16BE.name()); }
Example 9
Source File: AmazonConfigurationTest.java From service-block-samples with Apache License 2.0 | 5 votes |
private void load(Class<?> config, String... environment) { AnnotationConfigApplicationContext applicationContext = new AnnotationConfigApplicationContext(); EnvironmentTestUtils.addEnvironment(applicationContext, environment); applicationContext.register(config); applicationContext.register(AmazonAutoConfiguration.class); applicationContext.refresh(); this.context = applicationContext; }
Example 10
Source File: TensorflowProcessorPropertiesTest.java From tensorflow-spring-cloud-stream-app-starters with Apache License 2.0 | 5 votes |
@Test public void saveOutputInHeaderCanBeCustomized() { EnvironmentTestUtils.addEnvironment(context, "tensorflow.saveOutputInHeader:false"); context.register(Conf.class); context.refresh(); TensorflowProcessorProperties properties = context.getBean(TensorflowProcessorProperties.class); assertFalse(properties.isSaveOutputInHeader()); }
Example 11
Source File: TensorflowProcessorPropertiesTest.java From tensorflow-spring-cloud-stream-app-starters with Apache License 2.0 | 5 votes |
@Test public void outputIndexCanBeCustomized() { EnvironmentTestUtils.addEnvironment(context, "tensorflow.outputIndex:666"); context.register(Conf.class); context.refresh(); TensorflowProcessorProperties properties = context.getBean(TensorflowProcessorProperties.class); assertThat(properties.getOutputIndex(), equalTo(666)); }
Example 12
Source File: GitHubConfigTest.java From service-block-samples with Apache License 2.0 | 5 votes |
private void load(Class<?> config, String... environment) { AnnotationConfigApplicationContext applicationContext = new AnnotationConfigApplicationContext(); EnvironmentTestUtils.addEnvironment(applicationContext, environment); applicationContext.register(config); applicationContext.register(GitHubAutoConfiguration.class); applicationContext.refresh(); this.context = applicationContext; }
Example 13
Source File: OghamSpringBoot1JavaMailAutoConfigurationTests.java From ogham with Apache License 2.0 | 5 votes |
@Test public void oghamPropertiesWithSpringPropsShouldUseOghamPropertiesPrecedence() throws Exception { EnvironmentTestUtils.addEnvironment(context, "ogham.email.javamail.host=ogham", "spring.mail.host=spring"); context.register(ManuallyEnableSpringPropertiesConfig.class, OghamSpringBoot1AutoConfiguration.class); context.refresh(); MessagingService messagingService = context.getBean(MessagingService.class); OghamInternalAssertions.assertThat(messagingService) .javaMail() .host(equalTo("ogham")); }
Example 14
Source File: LabelImageProcessorPropertiesTest.java From tensorflow-spring-cloud-stream-app-starters with Apache License 2.0 | 5 votes |
@Test public void alternativesLengthCanBeCustomized() { AnnotationConfigApplicationContext context = new AnnotationConfigApplicationContext(); EnvironmentTestUtils.addEnvironment(context, "inception.labelsLocation:/remote"); EnvironmentTestUtils.addEnvironment(context, "inception.alternativesLength:5"); context.register(Conf.class); context.refresh(); LabelImageProcessorProperties properties = context.getBean(LabelImageProcessorProperties.class); assertThat(properties.getAlternativesLength(), equalTo(5)); }
Example 15
Source File: OghamSpringBoot1SendGridAutoConfigurationTests.java From ogham with Apache License 2.0 | 5 votes |
@Test public void useCustomSendGridBean() throws Exception { EnvironmentTestUtils.addEnvironment(context, "ogham.email.sendgrid.api-key=ogham"); context.register(CustomSendGridConfig.class, SendGridAutoConfiguration.class, OghamSpringBoot1AutoConfiguration.class); context.refresh(); MessagingService messagingService = context.getBean(MessagingService.class); checkEmail(messagingService); checkSms(messagingService); OghamInternalAssertions.assertThat(messagingService) .sendGrid() .apiKey(nullValue(String.class)) .client(allOf(isA(CustomSendGrid.class), isSpringBeanInstance(context, SendGrid.class))); }
Example 16
Source File: OghamSpringBoot1JavaMailAutoConfigurationTests.java From ogham with Apache License 2.0 | 5 votes |
@Test public void oghamWithJavaMailAutoConfigShouldUseSpringProperties() throws Exception { EnvironmentTestUtils.addEnvironment(context, "spring.mail.host=spring"); context.register(MailSenderAutoConfiguration.class, OghamSpringBoot1AutoConfiguration.class); context.refresh(); MessagingService messagingService = context.getBean(MessagingService.class); OghamInternalAssertions.assertThat(messagingService) .javaMail() .host(equalTo("spring")); }
Example 17
Source File: SpringletsWebJacksonAutoConfigurationTest.java From springlets with Apache License 2.0 | 2 votes |
/** * Process the {@link SpringletsWebJacksonAutoConfiguration} class by the * {@link ApplicationContext}. After the processing the {@link BindingResultModule} * must be in the ApplicationContext. * * @see EnvironmentTestUtils#addEnvironment(String, org.springframework.core.env.ConfigurableEnvironment, String...) */ private void registerAndRefreshContext(String... env) { EnvironmentTestUtils.addEnvironment(this.context, env); this.context.register(SpringletsWebJacksonAutoConfiguration.class); this.context.refresh(); }
Example 18
Source File: SpringletsImageFileConverterAutoConfigurationTest.java From springlets with Apache License 2.0 | 2 votes |
/** * Process the {@link SpringletsWebMvcAutoConfiguration} class by the * {@link ApplicationContext}. After the processing the {@link SpringletsImageFileConverter} * must be in the ApplicationContext. * * Additionally add (high priority) values to the {@link Environment} owned by the * {@link ApplicationContext}. * * @param env Strings following the pattern "property-name:property-value" * @see EnvironmentTestUtils#addEnvironment(String, org.springframework.core.env.ConfigurableEnvironment, String...) */ private void registerAndRefreshContext(String... env) { EnvironmentTestUtils.addEnvironment(this.context, env); this.context.register(SpringletsWebMvcAutoConfiguration.class); this.context.refresh(); }
Example 19
Source File: SpringletsStringTrimmerAdviceAutoConfigurationTest.java From springlets with Apache License 2.0 | 2 votes |
/** * Process the {@link SpringletsWebMvcAutoConfiguration} class by the * {@link ApplicationContext}. After the processing the {@link StringTrimmerAdvice} * must be in the ApplicationContext. * * Additionally add (high priority) values to the {@link Environment} owned by the * {@link ApplicationContext}. * * @param env Strings following the pattern "property-name:property-value" * @see EnvironmentTestUtils#addEnvironment(ConfigurableEnvironment, String...) */ private void registerAndRefreshContext(String... env) { EnvironmentTestUtils.addEnvironment(this.context, env); this.context.register(SpringletsWebMvcAutoConfiguration.class); this.context.refresh(); }
Example 20
Source File: SpringletsJsonpAdviceAutoConfigurationTest.java From springlets with Apache License 2.0 | 2 votes |
/** * Process the {@link SpringletsWebMvcAutoConfiguration} class by the * {@link ApplicationContext}. After the processing the {@link JsonpAdvice} * must be in the ApplicationContext. * * Additionally add (high priority) values to the {@link Environment} owned by the * {@link ApplicationContext}. * * @param env Strings following the pattern "property-name:property-value" * @see EnvironmentTestUtils#addEnvironment(String, org.springframework.core.env.ConfigurableEnvironment, String...) */ private void registerAndRefreshContext(String... env) { EnvironmentTestUtils.addEnvironment(this.context, env); this.context.register(SpringletsWebMvcAutoConfiguration.class); this.context.refresh(); }