]> source.dussan.org Git - sonarqube.git/commitdiff
Fix CeServerTest on MS Windows
authorSimon Brandhof <simon.brandhof@sonarsource.com>
Mon, 21 Mar 2016 17:17:01 +0000 (18:17 +0100)
committerSimon Brandhof <simon.brandhof@sonarsource.com>
Mon, 21 Mar 2016 17:17:01 +0000 (18:17 +0100)
server/sonar-ce/src/main/java/org/sonar/ce/app/CeServer.java
server/sonar-ce/src/test/java/org/sonar/ce/app/CeServerTest.java

index 35aa35e56e516c55c02101992a2ae183b63a00c7..279081366e907056d25deb8effdb5f0b69d61b4c 100644 (file)
@@ -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"));
index f19ece9973707fa91137b50be76a71ea7fea8424..62e5382cfb15f20690a535265a0874bb7cce7d6a 100644 (file)
@@ -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;
   }