use of org.springframework.boot.loader.tools.JavaExecutable in project spring-boot by spring-projects.
the class JarCommandIT method jarCreationWithGrabResolver.
@Test
public void jarCreationWithGrabResolver() throws Exception {
File jar = new File("target/test-app.jar");
Invocation invocation = this.cli.invoke("run", jar.getAbsolutePath(), "bad.groovy");
invocation.await();
assertThat(invocation.getErrorOutput(), equalTo(""));
invocation = this.cli.invoke("jar", jar.getAbsolutePath(), "bad.groovy");
invocation.await();
assertEquals(invocation.getErrorOutput(), 0, invocation.getErrorOutput().length());
assertTrue(jar.exists());
Process process = new JavaExecutable().processBuilder("-jar", jar.getAbsolutePath()).start();
invocation = new Invocation(process);
invocation.await();
assertThat(invocation.getErrorOutput(), equalTo(""));
}
use of org.springframework.boot.loader.tools.JavaExecutable in project spring-boot by spring-projects.
the class JarCommandIT method jarCreation.
@Test
public void jarCreation() throws Exception {
File jar = new File("target/test-app.jar");
Invocation invocation = this.cli.invoke("jar", jar.getAbsolutePath(), "jar.groovy");
invocation.await();
assertEquals(invocation.getErrorOutput(), 0, invocation.getErrorOutput().length());
assertTrue(jar.exists());
Process process = new JavaExecutable().processBuilder("-jar", jar.getAbsolutePath()).start();
invocation = new Invocation(process);
invocation.await();
assertThat(invocation.getErrorOutput(), equalTo(""));
assertThat(invocation.getStandardOutput(), containsString("Hello World!"));
assertThat(invocation.getStandardOutput(), containsString("/BOOT-INF/classes!/public/public.txt"));
assertThat(invocation.getStandardOutput(), containsString("/BOOT-INF/classes!/resources/resource.txt"));
assertThat(invocation.getStandardOutput(), containsString("/BOOT-INF/classes!/static/static.txt"));
assertThat(invocation.getStandardOutput(), containsString("/BOOT-INF/classes!/templates/template.txt"));
assertThat(invocation.getStandardOutput(), containsString("/BOOT-INF/classes!/root.properties"));
assertThat(invocation.getStandardOutput(), containsString("Goodbye Mama"));
}
use of org.springframework.boot.loader.tools.JavaExecutable in project spring-boot by spring-projects.
the class JarCommandIT method jarCreationWithIncludes.
@Test
public void jarCreationWithIncludes() throws Exception {
File jar = new File("target/test-app.jar");
Invocation invocation = this.cli.invoke("jar", jar.getAbsolutePath(), "--include", "-public/**,-resources/**", "jar.groovy");
invocation.await();
assertEquals(invocation.getErrorOutput(), 0, invocation.getErrorOutput().length());
assertTrue(jar.exists());
Process process = new JavaExecutable().processBuilder("-jar", jar.getAbsolutePath()).start();
invocation = new Invocation(process);
invocation.await();
assertThat(invocation.getErrorOutput(), equalTo(""));
assertThat(invocation.getStandardOutput(), containsString("Hello World!"));
assertThat(invocation.getStandardOutput(), not(containsString("/public/public.txt")));
assertThat(invocation.getStandardOutput(), not(containsString("/resources/resource.txt")));
assertThat(invocation.getStandardOutput(), containsString("/static/static.txt"));
assertThat(invocation.getStandardOutput(), containsString("/templates/template.txt"));
assertThat(invocation.getStandardOutput(), containsString("Goodbye Mama"));
}
use of org.springframework.boot.loader.tools.JavaExecutable in project spring-boot by spring-projects.
the class SampleAntApplicationIT method runJar.
@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");
}
use of org.springframework.boot.loader.tools.JavaExecutable in project spring-boot by spring-projects.
the class StartMojo method runProcess.
private RunProcess runProcess(File workingDirectory, List<String> args) throws MojoExecutionException {
try {
RunProcess runProcess = new RunProcess(workingDirectory, new JavaExecutable().toString());
runProcess.run(false, args.toArray(new String[args.size()]));
return runProcess;
} catch (Exception ex) {
throw new MojoExecutionException("Could not exec java", ex);
}
}
Aggregations