* gh-31267: Polish "Update smoke tests to avoid conflicts with NAME environment variable" Update smoke tests to avoid conflicts with NAME environment variable Closes gh-31267
@ -1,5 +1,5 @@
/*
* Copyright 2012-2019 the original author or authors.
* Copyright 2012-2022 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@ -22,7 +22,7 @@ import org.springframework.stereotype.Component;
@Component
public class HelloWorldService {
@Value("${name:World}")
@Value("${test.name:World}")
private String name;
public String getHelloMessage() {
@ -1 +1 @@
name: Phil
test.name: Phil
* Copyright 2012-2021 the original author or authors.
@ -60,7 +60,7 @@ class SampleAopApplicationTests {
@Test
void testCommandLineOverrides(CapturedOutput output) {
SampleAopApplication.main(new String[] { "--name=Gordon" });
SampleAopApplication.main(new String[] { "--test.name=Gordon" });
assertThat(output).contains("Hello Gordon");
}
hello: Bonjour
test.hello: Bonjour
@ -30,7 +30,7 @@ public class SampleProfileApplication implements CommandLineRunner {
// Simple example shows how a command line spring application can execute an
// injected bean service. Also demonstrates how you can use @Value to inject
// command line args ('--name=whatever') or application properties
// command line args ('--test.name=whatever') or application properties
@Autowired
private MessageService helloWorldService;
@ -24,10 +24,10 @@ import org.springframework.stereotype.Component;
@Profile({ "generic" })
public class GenericService implements MessageService {
@Value("${hello:Hello}")
@Value("${test.hello:Hello}")
private String hello;
@Override
@ -24,7 +24,7 @@ import org.springframework.stereotype.Component;
@Profile("goodbye")
public class GoodbyeWorldService implements MessageService {
@Profile({ "hello", "default" })
public class HelloWorldService implements MessageService {
@ -1,6 +1,6 @@
---
spring.config.activate.on-profile: goodbye | dev
name: Everyone
test.name: Everyone
@ -65,7 +65,7 @@ class SampleProfileApplicationTests {
* This is a profile that requires a new environment property, and one which is
* only overridden in the current working directory. That file also only contains
* partial overrides, and the default application.yml should still supply the
* "name" property.
* "test.name" property.
*/
System.setProperty("spring.profiles.active", "generic");
SampleProfileApplication.main();
* Copyright 2012-2020 the original author or authors.
@ -30,7 +30,7 @@ public class SampleSimpleApplication implements CommandLineRunner {
private HelloWorldService helloWorldService;
@Value("${duration:10s}")
@Value("${test.duration:10s}")
private Duration duration;
@ -1,4 +1,4 @@
name=Phil
test.name=Phil
sample.name=Andy
spring.banner.image.bitdepth=8
@ -60,7 +60,7 @@ class SampleSimpleApplicationTests {
SampleSimpleApplication.main(new String[] { "--name=Gordon", "--duration=1m" });
SampleSimpleApplication.main(new String[] { "--test.name=Gordon", "--test.duration=1m" });
assertThat(output).contains("Hello Gordon for 60 seconds");