From ed1cdbc81529107a1779bcee1e2988fa7a865771 Mon Sep 17 00:00:00 2001 From: Simon Brandhof Date: Mon, 21 Mar 2016 18:17:01 +0100 Subject: [PATCH] Fix CeServerTest on MS Windows --- .../sonar-ce/src/main/java/org/sonar/ce/app/CeServer.java | 8 +++++++- .../src/test/java/org/sonar/ce/app/CeServerTest.java | 8 ++++++-- 2 files changed, 13 insertions(+), 3 deletions(-) diff --git a/server/sonar-ce/src/main/java/org/sonar/ce/app/CeServer.java b/server/sonar-ce/src/main/java/org/sonar/ce/app/CeServer.java index 35aa35e56e5..279081366e9 100644 --- a/server/sonar-ce/src/main/java/org/sonar/ce/app/CeServer.java +++ b/server/sonar-ce/src/main/java/org/sonar/ce/app/CeServer.java @@ -19,6 +19,7 @@ */ package org.sonar.ce.app; +import com.google.common.annotations.VisibleForTesting; import com.google.common.collect.ImmutableMap; import java.util.concurrent.atomic.AtomicReference; import javax.annotation.CheckForNull; @@ -62,9 +63,14 @@ public class CeServer implements Monitored { private CeMainThread ceMainThread = null; protected CeServer(WebServerWatcher webServerWatcher, ComputeEngine computeEngine) { + this(webServerWatcher, computeEngine, new MinimumViableSystem()); + } + + @VisibleForTesting + protected CeServer(WebServerWatcher webServerWatcher, ComputeEngine computeEngine, MinimumViableSystem mvs) { this.webServerWatcher = webServerWatcher; this.computeEngine = computeEngine; - new MinimumViableSystem() + mvs .checkJavaVersion() .checkWritableTempDir() .checkRequiredJavaOptions(ImmutableMap.of("file.encoding", "UTF-8")); diff --git a/server/sonar-ce/src/test/java/org/sonar/ce/app/CeServerTest.java b/server/sonar-ce/src/test/java/org/sonar/ce/app/CeServerTest.java index f19ece99737..62e5382cfb1 100644 --- a/server/sonar-ce/src/test/java/org/sonar/ce/app/CeServerTest.java +++ b/server/sonar-ce/src/test/java/org/sonar/ce/app/CeServerTest.java @@ -30,11 +30,14 @@ import org.junit.Test; import org.junit.rules.ExpectedException; import org.junit.rules.TemporaryFolder; import org.junit.rules.Timeout; +import org.mockito.Mockito; import org.sonar.ce.ComputeEngine; +import org.sonar.process.MinimumViableSystem; import static com.google.common.base.Preconditions.checkState; import static java.util.concurrent.TimeUnit.MILLISECONDS; import static org.assertj.core.api.Assertions.assertThat; +import static org.mockito.Mockito.mock; public class CeServerTest { @Rule @@ -46,6 +49,7 @@ public class CeServerTest { private CeServer underTest = null; private Thread waitingThread = null; + private MinimumViableSystem minimumViableSystem = mock(MinimumViableSystem.class, Mockito.RETURNS_MOCKS); @After public void tearDown() throws Exception { @@ -289,13 +293,13 @@ public class CeServerTest { // return instantly simulating WebServer is already operational return true; } - }, computeEngine); + }, computeEngine, minimumViableSystem); return underTest; } private CeServer newCeServer(WebServerWatcher webServerWatcher, ComputeEngine computeEngine) { checkState(this.underTest == null, "Only one CeServer can be created per test method"); - this.underTest = new CeServer(webServerWatcher, computeEngine); + this.underTest = new CeServer(webServerWatcher, computeEngine, minimumViableSystem); return underTest; } -- 2.39.5