*/
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;
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"));
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
private CeServer underTest = null;
private Thread waitingThread = null;
+ private MinimumViableSystem minimumViableSystem = mock(MinimumViableSystem.class, Mockito.RETURNS_MOCKS);
@After
public void tearDown() throws Exception {
// 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;
}