diff options
author | Sébastien Lesaint <sebastien.lesaint@sonarsource.com> | 2017-02-23 10:20:28 +0100 |
---|---|---|
committer | Sébastien Lesaint <sebastien.lesaint@sonarsource.com> | 2017-02-24 21:14:06 +0100 |
commit | e19a54c19d956d2157ad5b2fca7d5af6ea5b72b4 (patch) | |
tree | bd99e1f8d5cc2df41e745a8a84a0d57bd72d9020 /sonar-application/src | |
parent | 1277b589387648eaa7a7aecfac7151c7c5d5a9be (diff) | |
download | sonarqube-e19a54c19d956d2157ad5b2fca7d5af6ea5b72b4.tar.gz sonarqube-e19a54c19d956d2157ad5b2fca7d5af6ea5b72b4.zip |
SONAR-7937 Monitor reloads JavaCommand to execute on restart
Diffstat (limited to 'sonar-application/src')
-rw-r--r-- | sonar-application/src/main/java/org/sonar/application/App.java | 2 | ||||
-rw-r--r-- | sonar-application/src/test/java/org/sonar/application/AppTest.java | 13 |
2 files changed, 8 insertions, 7 deletions
diff --git a/sonar-application/src/main/java/org/sonar/application/App.java b/sonar-application/src/main/java/org/sonar/application/App.java index a2e96cbd3ab..7271d593ad8 100644 --- a/sonar-application/src/main/java/org/sonar/application/App.java +++ b/sonar-application/src/main/java/org/sonar/application/App.java @@ -76,7 +76,7 @@ public class App implements Stoppable { } public void start(Props props) throws InterruptedException { - monitor.start(createCommands(props)); + monitor.start(() -> createCommands(props)); monitor.awaitTermination(); } diff --git a/sonar-application/src/test/java/org/sonar/application/AppTest.java b/sonar-application/src/test/java/org/sonar/application/AppTest.java index 12869dc3e08..e335cbd9c9d 100644 --- a/sonar-application/src/test/java/org/sonar/application/AppTest.java +++ b/sonar-application/src/test/java/org/sonar/application/AppTest.java @@ -23,6 +23,7 @@ import java.io.File; import java.io.IOException; import java.util.List; import java.util.Properties; +import java.util.function.Supplier; import org.apache.commons.io.FilenameUtils; import org.junit.Rule; import org.junit.Test; @@ -58,9 +59,9 @@ public class AppTest { Monitor monitor = mock(Monitor.class); App app = new App(monitor); app.start(props); - ArgumentCaptor<List<JavaCommand>> argument = newJavaCommandArgumentCaptor(); + ArgumentCaptor<Supplier<List<JavaCommand>>> argument = newJavaCommandArgumentCaptor(); verify(monitor).start(argument.capture()); - assertThat(argument.getValue()).extracting("processId").containsExactly(ProcessId.ELASTICSEARCH, ProcessId.WEB_SERVER, ProcessId.COMPUTE_ENGINE); + assertThat(argument.getValue().get()).extracting("processId").containsExactly(ProcessId.ELASTICSEARCH, ProcessId.WEB_SERVER, ProcessId.COMPUTE_ENGINE); app.stopAsync(); verify(monitor).stop(); @@ -176,13 +177,13 @@ public class AppTest { Monitor monitor = mock(Monitor.class); App app = new App(monitor); app.start(props); - ArgumentCaptor<List<JavaCommand>> argument = newJavaCommandArgumentCaptor(); + ArgumentCaptor<Supplier<List<JavaCommand>>> argument = newJavaCommandArgumentCaptor(); verify(monitor).start(argument.capture()); - return argument.getValue(); + return argument.getValue().get(); } - private ArgumentCaptor<List<JavaCommand>> newJavaCommandArgumentCaptor() { - Class<List<JavaCommand>> listClass = (Class<List<JavaCommand>>) (Class) List.class; + private ArgumentCaptor<Supplier<List<JavaCommand>>> newJavaCommandArgumentCaptor() { + Class<Supplier<List<JavaCommand>>> listClass = (Class<Supplier<List<JavaCommand>>>) (Class) List.class; return ArgumentCaptor.forClass(listClass); } } |