Java 类org.springframework.boot.loader.tools.JavaExecutable 实例源码

项目:https-github.com-g0t4-jenkins2-course-spring-boot    文件:SampleAntApplicationIT.java   
@Test
public void runJar() throws Exception {
    File target = new File("target");
    File[] jarFiles = target.listFiles(new FileFilter() {

        @Override
        public boolean accept(File file) {
            return file.getName().endsWith(".jar");
        }

    });
    assertThat(jarFiles).hasSize(1);
    Process process = new JavaExecutable().processBuilder("-jar", jarFiles[0].getName()).directory(target).start();
    process.waitFor(5, TimeUnit.MINUTES);
    assertThat(process.exitValue()).isEqualTo(0);
    String output = FileCopyUtils.copyToString(new InputStreamReader(process.getInputStream()));
    assertThat(output).contains("Spring Boot Ant Example");
}
项目:https-github.com-g0t4-jenkins2-course-spring-boot    文件:RunMojo.java   
@Override
protected void runWithForkedJvm(List<String> args) throws MojoExecutionException {
    try {
        RunProcess runProcess = new RunProcess(new JavaExecutable().toString());
        Runtime.getRuntime()
                .addShutdownHook(new Thread(new RunProcessKiller(runProcess)));
        int exitCode = runProcess.run(true, args.toArray(new String[args.size()]));

        if (exitCode != 0) {
            throw new MojoExecutionException(
                    "Application finished with non-zero exit code: " + exitCode);
        }
    }
    catch (Exception ex) {
        throw new MojoExecutionException("Could not exec java", ex);
    }
}
项目:spring-boot-concourse    文件:SampleAntApplicationIT.java   
@Test
public void runJar() throws Exception {
    File target = new File("target");
    File[] jarFiles = target.listFiles(new FileFilter() {

        @Override
        public boolean accept(File file) {
            return file.getName().endsWith(".jar");
        }

    });
    assertThat(jarFiles).hasSize(1);
    Process process = new JavaExecutable().processBuilder("-jar", jarFiles[0].getName()).directory(target).start();
    process.waitFor(5, TimeUnit.MINUTES);
    assertThat(process.exitValue()).isEqualTo(0);
    String output = FileCopyUtils.copyToString(new InputStreamReader(process.getInputStream()));
    assertThat(output).contains("Spring Boot Ant Example");
}
项目:contestparser    文件:SampleAntApplicationIT.java   
@Test
public void runJar() throws Exception {
    File target = new File("target");
    File[] jarFiles = target.listFiles(new FileFilter() {

        @Override
        public boolean accept(File file) {
            return file.getName().endsWith(".jar");
        }

    });
    assertThat("Number of jars", jarFiles.length, equalTo(1));
    Process process = new JavaExecutable().processBuilder("-jar", jarFiles[0].getName()).directory(target).start();
    process.waitFor(5, TimeUnit.MINUTES);
    assertThat(process.exitValue(), equalTo(0));
    String output = FileCopyUtils.copyToString(new InputStreamReader(process.getInputStream()));
    assertThat(output, containsString("Spring Boot Ant Example"));
}
项目:spring-boot-concourse    文件:RunMojo.java   
@Override
protected void runWithForkedJvm(List<String> args) throws MojoExecutionException {
    try {
        RunProcess runProcess = new RunProcess(new JavaExecutable().toString());
        Runtime.getRuntime()
                .addShutdownHook(new Thread(new RunProcessKiller(runProcess)));
        runProcess.run(true, args.toArray(new String[args.size()]));
    }
    catch (Exception ex) {
        throw new MojoExecutionException("Could not exec java", ex);
    }
}
项目:contestparser    文件:RunMojo.java   
@Override
protected void runWithForkedJvm(List<String> args) throws MojoExecutionException {
    try {
        new RunProcess(new JavaExecutable().toString()).run(true,
                args.toArray(new String[args.size()]));
    }
    catch (Exception ex) {
        throw new MojoExecutionException("Could not exec java", ex);
    }
}
项目:https-github.com-g0t4-jenkins2-course-spring-boot    文件:ForkProcessCommand.java   
ForkProcessCommand(Command command) {
    super(new JavaExecutable().toString());
    this.command = command;
}
项目:spring-boot-concourse    文件:ForkProcessCommand.java   
ForkProcessCommand(Command command) {
    super(new JavaExecutable().toString());
    this.command = command;
}
项目:contestparser    文件:ForkProcessCommand.java   
ForkProcessCommand(Command command) {
    super(new JavaExecutable().toString());
    this.command = command;
}