From 95e0d6c0f7acfe1c612478e8a1d5e71660dab397 Mon Sep 17 00:00:00 2001 From: Vedran Pavic Date: Tue, 7 Jun 2022 14:37:12 +0200 Subject: [PATCH 1/2] Update smoke tests to avoid conflicts with NAME environment variable This commit updates several smoke tests in order to avoid conflicts with NAME environment variable that is present in WSL and causes project build to fail. Previous attempt to fix this in 7da42d71 was incomplete. See gh-31267 --- .../main/java/smoketest/aop/service/HelloWorldService.java | 4 ++-- .../src/main/resources/application.properties | 2 +- .../test/java/smoketest/aop/SampleAopApplicationTests.java | 4 ++-- .../java/smoketest/jetty/service/HelloWorldService.java | 4 ++-- .../spring-boot-smoke-test-profile/application.yml | 2 +- .../java/smoketest/profile/SampleProfileApplication.java | 2 +- .../main/java/smoketest/profile/service/GenericService.java | 6 +++--- .../java/smoketest/profile/service/GoodbyeWorldService.java | 4 ++-- .../java/smoketest/profile/service/HelloWorldService.java | 4 ++-- .../src/main/resources/application.yml | 4 ++-- .../smoketest/profile/SampleProfileApplicationTests.java | 2 +- .../main/java/smoketest/simple/SampleSimpleApplication.java | 4 ++-- .../java/smoketest/simple/service/HelloWorldService.java | 6 +++--- .../src/main/resources/application.properties | 2 +- .../java/smoketest/simple/SampleSimpleApplicationTests.java | 4 ++-- .../java/smoketest/testng/service/HelloWorldService.java | 4 ++-- .../java/smoketest/tomcat/service/HelloWorldService.java | 4 ++-- .../main/java/smoketest/xml/service/HelloWorldService.java | 4 ++-- 18 files changed, 33 insertions(+), 33 deletions(-) diff --git a/spring-boot-tests/spring-boot-smoke-tests/spring-boot-smoke-test-aop/src/main/java/smoketest/aop/service/HelloWorldService.java b/spring-boot-tests/spring-boot-smoke-tests/spring-boot-smoke-test-aop/src/main/java/smoketest/aop/service/HelloWorldService.java index b061ebca2f1..b3e05a05e08 100644 --- a/spring-boot-tests/spring-boot-smoke-tests/spring-boot-smoke-test-aop/src/main/java/smoketest/aop/service/HelloWorldService.java +++ b/spring-boot-tests/spring-boot-smoke-tests/spring-boot-smoke-test-aop/src/main/java/smoketest/aop/service/HelloWorldService.java @@ -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() { diff --git a/spring-boot-tests/spring-boot-smoke-tests/spring-boot-smoke-test-aop/src/main/resources/application.properties b/spring-boot-tests/spring-boot-smoke-tests/spring-boot-smoke-test-aop/src/main/resources/application.properties index b04cdc39b58..f8f9c0ac797 100644 --- a/spring-boot-tests/spring-boot-smoke-tests/spring-boot-smoke-test-aop/src/main/resources/application.properties +++ b/spring-boot-tests/spring-boot-smoke-tests/spring-boot-smoke-test-aop/src/main/resources/application.properties @@ -1 +1 @@ -name: Phil +test.name: Phil diff --git a/spring-boot-tests/spring-boot-smoke-tests/spring-boot-smoke-test-aop/src/test/java/smoketest/aop/SampleAopApplicationTests.java b/spring-boot-tests/spring-boot-smoke-tests/spring-boot-smoke-test-aop/src/test/java/smoketest/aop/SampleAopApplicationTests.java index 3d216259a86..5cf677c5741 100644 --- a/spring-boot-tests/spring-boot-smoke-tests/spring-boot-smoke-test-aop/src/test/java/smoketest/aop/SampleAopApplicationTests.java +++ b/spring-boot-tests/spring-boot-smoke-tests/spring-boot-smoke-test-aop/src/test/java/smoketest/aop/SampleAopApplicationTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2021 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. @@ -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"); } diff --git a/spring-boot-tests/spring-boot-smoke-tests/spring-boot-smoke-test-jetty/src/main/java/smoketest/jetty/service/HelloWorldService.java b/spring-boot-tests/spring-boot-smoke-tests/spring-boot-smoke-test-jetty/src/main/java/smoketest/jetty/service/HelloWorldService.java index d74455b18fd..d2564ad58b9 100644 --- a/spring-boot-tests/spring-boot-smoke-tests/spring-boot-smoke-test-jetty/src/main/java/smoketest/jetty/service/HelloWorldService.java +++ b/spring-boot-tests/spring-boot-smoke-tests/spring-boot-smoke-test-jetty/src/main/java/smoketest/jetty/service/HelloWorldService.java @@ -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() { diff --git a/spring-boot-tests/spring-boot-smoke-tests/spring-boot-smoke-test-profile/application.yml b/spring-boot-tests/spring-boot-smoke-tests/spring-boot-smoke-test-profile/application.yml index 8689513d3b1..f524f375bda 100644 --- a/spring-boot-tests/spring-boot-smoke-tests/spring-boot-smoke-test-profile/application.yml +++ b/spring-boot-tests/spring-boot-smoke-tests/spring-boot-smoke-test-profile/application.yml @@ -1 +1 @@ -hello: Bonjour +test.hello: Bonjour diff --git a/spring-boot-tests/spring-boot-smoke-tests/spring-boot-smoke-test-profile/src/main/java/smoketest/profile/SampleProfileApplication.java b/spring-boot-tests/spring-boot-smoke-tests/spring-boot-smoke-test-profile/src/main/java/smoketest/profile/SampleProfileApplication.java index c64eb7e7a98..2df5781f41b 100644 --- a/spring-boot-tests/spring-boot-smoke-tests/spring-boot-smoke-test-profile/src/main/java/smoketest/profile/SampleProfileApplication.java +++ b/spring-boot-tests/spring-boot-smoke-tests/spring-boot-smoke-test-profile/src/main/java/smoketest/profile/SampleProfileApplication.java @@ -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; diff --git a/spring-boot-tests/spring-boot-smoke-tests/spring-boot-smoke-test-profile/src/main/java/smoketest/profile/service/GenericService.java b/spring-boot-tests/spring-boot-smoke-tests/spring-boot-smoke-test-profile/src/main/java/smoketest/profile/service/GenericService.java index f4a8d358da7..f83df4a51b4 100644 --- a/spring-boot-tests/spring-boot-smoke-tests/spring-boot-smoke-test-profile/src/main/java/smoketest/profile/service/GenericService.java +++ b/spring-boot-tests/spring-boot-smoke-tests/spring-boot-smoke-test-profile/src/main/java/smoketest/profile/service/GenericService.java @@ -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. @@ -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; - @Value("${name:World}") + @Value("${test.name:World}") private String name; @Override diff --git a/spring-boot-tests/spring-boot-smoke-tests/spring-boot-smoke-test-profile/src/main/java/smoketest/profile/service/GoodbyeWorldService.java b/spring-boot-tests/spring-boot-smoke-tests/spring-boot-smoke-test-profile/src/main/java/smoketest/profile/service/GoodbyeWorldService.java index a18cc59594f..6ef189d2c1d 100644 --- a/spring-boot-tests/spring-boot-smoke-tests/spring-boot-smoke-test-profile/src/main/java/smoketest/profile/service/GoodbyeWorldService.java +++ b/spring-boot-tests/spring-boot-smoke-tests/spring-boot-smoke-test-profile/src/main/java/smoketest/profile/service/GoodbyeWorldService.java @@ -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. @@ -24,7 +24,7 @@ import org.springframework.stereotype.Component; @Profile("goodbye") public class GoodbyeWorldService implements MessageService { - @Value("${name:World}") + @Value("${test.name:World}") private String name; @Override diff --git a/spring-boot-tests/spring-boot-smoke-tests/spring-boot-smoke-test-profile/src/main/java/smoketest/profile/service/HelloWorldService.java b/spring-boot-tests/spring-boot-smoke-tests/spring-boot-smoke-test-profile/src/main/java/smoketest/profile/service/HelloWorldService.java index 33aa6b3c187..a343ea61ae6 100644 --- a/spring-boot-tests/spring-boot-smoke-tests/spring-boot-smoke-test-profile/src/main/java/smoketest/profile/service/HelloWorldService.java +++ b/spring-boot-tests/spring-boot-smoke-tests/spring-boot-smoke-test-profile/src/main/java/smoketest/profile/service/HelloWorldService.java @@ -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. @@ -24,7 +24,7 @@ import org.springframework.stereotype.Component; @Profile({ "hello", "default" }) public class HelloWorldService implements MessageService { - @Value("${name:World}") + @Value("${test.name:World}") private String name; @Override diff --git a/spring-boot-tests/spring-boot-smoke-tests/spring-boot-smoke-test-profile/src/main/resources/application.yml b/spring-boot-tests/spring-boot-smoke-tests/spring-boot-smoke-test-profile/src/main/resources/application.yml index ed01e5c852c..b6ffc61aa82 100644 --- a/spring-boot-tests/spring-boot-smoke-tests/spring-boot-smoke-test-profile/src/main/resources/application.yml +++ b/spring-boot-tests/spring-boot-smoke-tests/spring-boot-smoke-test-profile/src/main/resources/application.yml @@ -1,6 +1,6 @@ -name: Phil +test.name: Phil --- spring.config.activate.on-profile: goodbye | dev -name: Everyone +test.name: Everyone diff --git a/spring-boot-tests/spring-boot-smoke-tests/spring-boot-smoke-test-profile/src/test/java/smoketest/profile/SampleProfileApplicationTests.java b/spring-boot-tests/spring-boot-smoke-tests/spring-boot-smoke-test-profile/src/test/java/smoketest/profile/SampleProfileApplicationTests.java index d4dd213b0c3..af351536188 100644 --- a/spring-boot-tests/spring-boot-smoke-tests/spring-boot-smoke-test-profile/src/test/java/smoketest/profile/SampleProfileApplicationTests.java +++ b/spring-boot-tests/spring-boot-smoke-tests/spring-boot-smoke-test-profile/src/test/java/smoketest/profile/SampleProfileApplicationTests.java @@ -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(); diff --git a/spring-boot-tests/spring-boot-smoke-tests/spring-boot-smoke-test-simple/src/main/java/smoketest/simple/SampleSimpleApplication.java b/spring-boot-tests/spring-boot-smoke-tests/spring-boot-smoke-test-simple/src/main/java/smoketest/simple/SampleSimpleApplication.java index 2f9f0cb2756..27b19d59ac8 100644 --- a/spring-boot-tests/spring-boot-smoke-tests/spring-boot-smoke-test-simple/src/main/java/smoketest/simple/SampleSimpleApplication.java +++ b/spring-boot-tests/spring-boot-smoke-tests/spring-boot-smoke-test-simple/src/main/java/smoketest/simple/SampleSimpleApplication.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2020 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. @@ -30,7 +30,7 @@ public class SampleSimpleApplication 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 HelloWorldService helloWorldService; diff --git a/spring-boot-tests/spring-boot-smoke-tests/spring-boot-smoke-test-simple/src/main/java/smoketest/simple/service/HelloWorldService.java b/spring-boot-tests/spring-boot-smoke-tests/spring-boot-smoke-test-simple/src/main/java/smoketest/simple/service/HelloWorldService.java index f89c1f55647..1540265e4f7 100644 --- a/spring-boot-tests/spring-boot-smoke-tests/spring-boot-smoke-test-simple/src/main/java/smoketest/simple/service/HelloWorldService.java +++ b/spring-boot-tests/spring-boot-smoke-tests/spring-boot-smoke-test-simple/src/main/java/smoketest/simple/service/HelloWorldService.java @@ -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. @@ -24,10 +24,10 @@ import org.springframework.stereotype.Component; @Component public class HelloWorldService { - @Value("${name:World}") + @Value("${test.name:World}") private String name; - @Value("${duration:10s}") + @Value("${test.duration:10s}") private Duration duration; public String getHelloMessage() { diff --git a/spring-boot-tests/spring-boot-smoke-tests/spring-boot-smoke-test-simple/src/main/resources/application.properties b/spring-boot-tests/spring-boot-smoke-tests/spring-boot-smoke-test-simple/src/main/resources/application.properties index 080603f9e54..43dac287187 100644 --- a/spring-boot-tests/spring-boot-smoke-tests/spring-boot-smoke-test-simple/src/main/resources/application.properties +++ b/spring-boot-tests/spring-boot-smoke-tests/spring-boot-smoke-test-simple/src/main/resources/application.properties @@ -1,4 +1,4 @@ -name=Phil +test.name=Phil sample.name=Andy spring.banner.image.bitdepth=8 diff --git a/spring-boot-tests/spring-boot-smoke-tests/spring-boot-smoke-test-simple/src/test/java/smoketest/simple/SampleSimpleApplicationTests.java b/spring-boot-tests/spring-boot-smoke-tests/spring-boot-smoke-test-simple/src/test/java/smoketest/simple/SampleSimpleApplicationTests.java index 8cdf90067db..ad085d13337 100644 --- a/spring-boot-tests/spring-boot-smoke-tests/spring-boot-smoke-test-simple/src/test/java/smoketest/simple/SampleSimpleApplicationTests.java +++ b/spring-boot-tests/spring-boot-smoke-tests/spring-boot-smoke-test-simple/src/test/java/smoketest/simple/SampleSimpleApplicationTests.java @@ -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. @@ -60,7 +60,7 @@ class SampleSimpleApplicationTests { @Test void testCommandLineOverrides(CapturedOutput output) { - 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"); } diff --git a/spring-boot-tests/spring-boot-smoke-tests/spring-boot-smoke-test-testng/src/main/java/smoketest/testng/service/HelloWorldService.java b/spring-boot-tests/spring-boot-smoke-tests/spring-boot-smoke-test-testng/src/main/java/smoketest/testng/service/HelloWorldService.java index 5749cc1792b..79d96f92517 100644 --- a/spring-boot-tests/spring-boot-smoke-tests/spring-boot-smoke-test-testng/src/main/java/smoketest/testng/service/HelloWorldService.java +++ b/spring-boot-tests/spring-boot-smoke-tests/spring-boot-smoke-test-testng/src/main/java/smoketest/testng/service/HelloWorldService.java @@ -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() { diff --git a/spring-boot-tests/spring-boot-smoke-tests/spring-boot-smoke-test-tomcat/src/main/java/smoketest/tomcat/service/HelloWorldService.java b/spring-boot-tests/spring-boot-smoke-tests/spring-boot-smoke-test-tomcat/src/main/java/smoketest/tomcat/service/HelloWorldService.java index b49003bdec0..ba74eb7dad2 100644 --- a/spring-boot-tests/spring-boot-smoke-tests/spring-boot-smoke-test-tomcat/src/main/java/smoketest/tomcat/service/HelloWorldService.java +++ b/spring-boot-tests/spring-boot-smoke-tests/spring-boot-smoke-test-tomcat/src/main/java/smoketest/tomcat/service/HelloWorldService.java @@ -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() { diff --git a/spring-boot-tests/spring-boot-smoke-tests/spring-boot-smoke-test-xml/src/main/java/smoketest/xml/service/HelloWorldService.java b/spring-boot-tests/spring-boot-smoke-tests/spring-boot-smoke-test-xml/src/main/java/smoketest/xml/service/HelloWorldService.java index 675d864a488..57ab83873b8 100644 --- a/spring-boot-tests/spring-boot-smoke-tests/spring-boot-smoke-test-xml/src/main/java/smoketest/xml/service/HelloWorldService.java +++ b/spring-boot-tests/spring-boot-smoke-tests/spring-boot-smoke-test-xml/src/main/java/smoketest/xml/service/HelloWorldService.java @@ -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() { From 0834dc5b01a9a2c29599cd550587e6780e3518c5 Mon Sep 17 00:00:00 2001 From: Andy Wilkinson Date: Wed, 8 Jun 2022 12:08:40 +0100 Subject: [PATCH 2/2] Polish "Update smoke tests to avoid conflicts with NAME environment variable" See gh-31267 --- .../java/smoketest/jetty10/service/HelloWorldService.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/spring-boot-tests/spring-boot-smoke-tests/spring-boot-smoke-test-jetty10/src/main/java/smoketest/jetty10/service/HelloWorldService.java b/spring-boot-tests/spring-boot-smoke-tests/spring-boot-smoke-test-jetty10/src/main/java/smoketest/jetty10/service/HelloWorldService.java index 732de935ba6..ffd94c184c3 100644 --- a/spring-boot-tests/spring-boot-smoke-tests/spring-boot-smoke-test-jetty10/src/main/java/smoketest/jetty10/service/HelloWorldService.java +++ b/spring-boot-tests/spring-boot-smoke-tests/spring-boot-smoke-test-jetty10/src/main/java/smoketest/jetty10/service/HelloWorldService.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2021 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() {