@Test public void override_java_home() throws Exception { generateValidFileSystem(); File javaHome = temp.newFolder(); when(fs.javaHome()).thenReturn(javaHome); ServerCommandLineFactory underTest = new ServerCommandLineFactory(fs); CommandLine commandLine = underTest.create(server); assertThat(new File(commandLine.getExecutable())).isEqualTo(new File(javaHome, "bin/java")); }
public CommandLine create(Server server) { CommandLine command = createJavaCommandLine(); command.addArgument("-Xmx32m"); command.addArgument("-server"); command.addArgument("-Djava.awt.headless=true"); command.addArgument("-Dsonar.enableStopCommand=true"); command.addArgument("-Djava.net.preferIPv4Stack=true"); IOFileFilter appJarFilter = FileFilterUtils.and(FileFilterUtils.prefixFileFilter("sonar-application-"), FileFilterUtils.suffixFileFilter("jar")); File libDir = new File(server.getHome(), "lib"); Collection<File> files = FileUtils.listFiles(libDir, appJarFilter, FileFilterUtils.trueFileFilter()); if (files.size() != 1) { throw new IllegalStateException("No or too many sonar-application-*.jar files found in: " + libDir.getAbsolutePath()); } command.addArgument("-jar"); command.addArgument("lib/" + files.iterator().next().getName()); return command; }
ServerCommandLineFactory { public CommandLine create(Server server) { CommandLine command = createJavaCommandLine(); command.addArgument("-Xmx32m"); command.addArgument("-server"); command.addArgument("-Djava.awt.headless=true"); command.addArgument("-Dsonar.enableStopCommand=true"); command.addArgument("-Djava.net.preferIPv4Stack=true"); IOFileFilter appJarFilter = FileFilterUtils.and(FileFilterUtils.prefixFileFilter("sonar-application-"), FileFilterUtils.suffixFileFilter("jar")); File libDir = new File(server.getHome(), "lib"); Collection<File> files = FileUtils.listFiles(libDir, appJarFilter, FileFilterUtils.trueFileFilter()); if (files.size() != 1) { throw new IllegalStateException("No or too many sonar-application-*.jar files found in: " + libDir.getAbsolutePath()); } command.addArgument("-jar"); command.addArgument("lib/" + files.iterator().next().getName()); return command; } }
ServerCommandLineFactory { public CommandLine create(Server server) { CommandLine command = createJavaCommandLine(); command.addArgument("-Xmx32m"); command.addArgument("-server"); command.addArgument("-Djava.awt.headless=true"); command.addArgument("-Dsonar.enableStopCommand=true"); command.addArgument("-Djava.net.preferIPv4Stack=true"); IOFileFilter appJarFilter = FileFilterUtils.and(FileFilterUtils.prefixFileFilter("sonar-application-"), FileFilterUtils.suffixFileFilter("jar")); File libDir = new File(server.getHome(), "lib"); Collection<File> files = FileUtils.listFiles(libDir, appJarFilter, FileFilterUtils.trueFileFilter()); if (files.size() != 1) { throw new IllegalStateException("No or too many sonar-application-*.jar files found in: " + libDir.getAbsolutePath()); } command.addArgument("-jar"); command.addArgument("lib/" + files.iterator().next().getName()); return command; } ServerCommandLineFactory(FileSystem fs); }
ServerCommandLineFactory { public CommandLine create(Server server) { CommandLine command = createJavaCommandLine(); command.addArgument("-Xmx32m"); command.addArgument("-server"); command.addArgument("-Djava.awt.headless=true"); command.addArgument("-Dsonar.enableStopCommand=true"); command.addArgument("-Djava.net.preferIPv4Stack=true"); IOFileFilter appJarFilter = FileFilterUtils.and(FileFilterUtils.prefixFileFilter("sonar-application-"), FileFilterUtils.suffixFileFilter("jar")); File libDir = new File(server.getHome(), "lib"); Collection<File> files = FileUtils.listFiles(libDir, appJarFilter, FileFilterUtils.trueFileFilter()); if (files.size() != 1) { throw new IllegalStateException("No or too many sonar-application-*.jar files found in: " + libDir.getAbsolutePath()); } command.addArgument("-jar"); command.addArgument("lib/" + files.iterator().next().getName()); return command; } ServerCommandLineFactory(FileSystem fs); CommandLine create(Server server); }
ServerCommandLineFactory { public CommandLine create(Server server) { CommandLine command = createJavaCommandLine(); command.addArgument("-Xmx32m"); command.addArgument("-server"); command.addArgument("-Djava.awt.headless=true"); command.addArgument("-Dsonar.enableStopCommand=true"); command.addArgument("-Djava.net.preferIPv4Stack=true"); IOFileFilter appJarFilter = FileFilterUtils.and(FileFilterUtils.prefixFileFilter("sonar-application-"), FileFilterUtils.suffixFileFilter("jar")); File libDir = new File(server.getHome(), "lib"); Collection<File> files = FileUtils.listFiles(libDir, appJarFilter, FileFilterUtils.trueFileFilter()); if (files.size() != 1) { throw new IllegalStateException("No or too many sonar-application-*.jar files found in: " + libDir.getAbsolutePath()); } command.addArgument("-jar"); command.addArgument("lib/" + files.iterator().next().getName()); return command; } ServerCommandLineFactory(FileSystem fs); CommandLine create(Server server);  }