From db5ab1d14c67c187030eadd1042fd151fac5c42b Mon Sep 17 00:00:00 2001 From: Andy Wilkinson Date: Thu, 13 Dec 2018 13:39:19 +0000 Subject: [PATCH] Do not rely on test runner using static main method in RestarterTests Closes gh-15461 --- .../boot/devtools/restart/RestarterTests.java | 21 ++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) diff --git a/spring-boot-project/spring-boot-devtools/src/test/java/org/springframework/boot/devtools/restart/RestarterTests.java b/spring-boot-project/spring-boot-devtools/src/test/java/org/springframework/boot/devtools/restart/RestarterTests.java index a8b9eb518bf..e5ce01b2aab 100644 --- a/spring-boot-project/spring-boot-devtools/src/test/java/org/springframework/boot/devtools/restart/RestarterTests.java +++ b/spring-boot-project/spring-boot-devtools/src/test/java/org/springframework/boot/devtools/restart/RestarterTests.java @@ -62,7 +62,7 @@ public class RestarterTests { @Before public void setup() { - Restarter.setInstance(new TestableRestarter()); + RestarterInitializer.setRestarterInstance(); } @After @@ -176,6 +176,13 @@ public class RestarterTests { assertThat(Restarter.getInstance().getInitialUrls()).isEqualTo(urls); } + @FunctionalInterface + private interface WithMainAction { + + void perform() throws Exception; + + } + @Component @EnableScheduling public static class SampleApplication { @@ -272,4 +279,16 @@ public class RestarterTests { } + static class RestarterInitializer { + + static void setRestarterInstance() { + main(new String[0]); + } + + static void main(String[] args) { + Restarter.setInstance(new TestableRestarter()); + } + + } + }