WebServer(Props props) { new MinimumViableSystem() .checkWritableTempDir() .checkRequiredJavaOptions(ImmutableMap.of("file.encoding", "UTF-8")); this.sharedDir = getSharedDir(props); this.tomcat = new EmbeddedTomcat(props); }
/** * Verify that temp directory is writable */ public MinimumViableSystem checkWritableTempDir() { checkWritableDir(System.getProperty("java.io.tmpdir")); return this; }
@VisibleForTesting protected CeServer(ComputeEngine computeEngine, MinimumViableSystem mvs) { this.computeEngine = computeEngine; mvs .checkWritableTempDir() .checkRequiredJavaOptions(ImmutableMap.of("file.encoding", "UTF-8")); }
/** * Entry point for all checks */ public void check() { checkJavaVersion(); checkJavaOptions(); checkWritableTempDir(); }
/** * Can't be started as is. Needs to be bootstrapped by sonar-application */ public static void main(String[] args) { ProcessEntryPoint entryPoint = ProcessEntryPoint.createForArguments(args); Props props = entryPoint.getProps(); new CeProcessLogging().configure(props); CeServer server = new CeServer( new ComputeEngineImpl(props, new ComputeEngineContainerImpl()), new MinimumViableSystem()); entryPoint.launch(server); }
@Test public void checkRequiredJavaOptions() { String key = "MinimumViableEnvironmentTest.test.prop"; try { System.setProperty(key, "false"); underTest.checkRequiredJavaOptions(ImmutableMap.of(key, "true")); fail(); } catch (MessageException e) { assertThat(e).hasMessage("JVM option '" + key + "' must be set to 'true'. Got 'false'"); } System.setProperty(key, "true"); // do not fail underTest.checkRequiredJavaOptions(ImmutableMap.of(key, "true")); }
public SearchServer(Props props) { this.settings = new SearchSettings(props); new MinimumViableSystem().check(); }
@VisibleForTesting protected CeServer(ComputeEngine computeEngine, MinimumViableSystem mvs) { this.computeEngine = computeEngine; mvs .checkWritableTempDir() .checkRequiredJavaOptions(ImmutableMap.of("file.encoding", "UTF-8")); }
/** * Can't be started as is. Needs to be bootstrapped by sonar-application */ public static void main(String[] args) { ProcessEntryPoint entryPoint = ProcessEntryPoint.createForArguments(args); Props props = entryPoint.getProps(); new CeProcessLogging().configure(props); CeServer server = new CeServer( new ComputeEngineImpl(props, new ComputeEngineContainerImpl()), new MinimumViableSystem()); entryPoint.launch(server); }
WebServer(Props props) { new MinimumViableSystem() .checkWritableTempDir() .checkRequiredJavaOptions(ImmutableMap.of("file.encoding", "UTF-8")); this.sharedDir = getSharedDir(props); this.tomcat = new EmbeddedTomcat(props); }
@Test public void checkWritableTempDir() throws Exception { File dir = temp.newFolder(); underTest.checkWritableDir(dir.getAbsolutePath()); dir.delete(); try { underTest.checkWritableDir(dir.getAbsolutePath()); fail(); } catch (IllegalStateException e) { assertThat(e).hasMessage("Temp directory is not writable: " + dir.getAbsolutePath()); } } }
/** * Verify that temp directory is writable */ private void checkWritableTempDir() { checkWritableDir(System.getProperty("java.io.tmpdir")); }