|
|
@ -15,15 +15,23 @@
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
package org.springframework.bootstrap.cli;
|
|
|
|
package org.springframework.bootstrap.cli;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
import java.io.ByteArrayOutputStream;
|
|
|
|
|
|
|
|
import java.io.PrintStream;
|
|
|
|
|
|
|
|
import java.net.URL;
|
|
|
|
import java.util.concurrent.Callable;
|
|
|
|
import java.util.concurrent.Callable;
|
|
|
|
import java.util.concurrent.Executors;
|
|
|
|
import java.util.concurrent.Executors;
|
|
|
|
import java.util.concurrent.Future;
|
|
|
|
import java.util.concurrent.Future;
|
|
|
|
import java.util.concurrent.TimeUnit;
|
|
|
|
import java.util.concurrent.TimeUnit;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
import org.apache.ivy.util.FileUtil;
|
|
|
|
import org.junit.After;
|
|
|
|
import org.junit.After;
|
|
|
|
|
|
|
|
import org.junit.Before;
|
|
|
|
import org.junit.BeforeClass;
|
|
|
|
import org.junit.BeforeClass;
|
|
|
|
import org.junit.Test;
|
|
|
|
import org.junit.Test;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
import static org.junit.Assert.assertEquals;
|
|
|
|
|
|
|
|
import static org.junit.Assert.assertTrue;
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
/**
|
|
|
|
* @author Dave Syer
|
|
|
|
* @author Dave Syer
|
|
|
|
*
|
|
|
|
*
|
|
|
@ -32,6 +40,25 @@ public class SampleIntegrationTests {
|
|
|
|
|
|
|
|
|
|
|
|
private RunCommand command;
|
|
|
|
private RunCommand command;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private PrintStream savedOutput;
|
|
|
|
|
|
|
|
private ByteArrayOutputStream output;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Before
|
|
|
|
|
|
|
|
public void init() {
|
|
|
|
|
|
|
|
this.savedOutput = System.out;
|
|
|
|
|
|
|
|
this.output = new ByteArrayOutputStream();
|
|
|
|
|
|
|
|
System.setOut(new PrintStream(this.output));
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@After
|
|
|
|
|
|
|
|
public void clear() {
|
|
|
|
|
|
|
|
System.setOut(this.savedOutput);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private String getOutput() {
|
|
|
|
|
|
|
|
return this.output.toString();
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
private void start(final String sample) throws Exception {
|
|
|
|
private void start(final String sample) throws Exception {
|
|
|
|
Future<RunCommand> future = Executors.newSingleThreadExecutor().submit(
|
|
|
|
Future<RunCommand> future = Executors.newSingleThreadExecutor().submit(
|
|
|
|
new Callable<RunCommand>() {
|
|
|
|
new Callable<RunCommand>() {
|
|
|
@ -61,26 +88,39 @@ public class SampleIntegrationTests {
|
|
|
|
@Test
|
|
|
|
@Test
|
|
|
|
public void appSample() throws Exception {
|
|
|
|
public void appSample() throws Exception {
|
|
|
|
start("samples/app.groovy");
|
|
|
|
start("samples/app.groovy");
|
|
|
|
|
|
|
|
String output = getOutput();
|
|
|
|
|
|
|
|
assertTrue("Wrong output: " + output, output.contains("Hello World"));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@Test
|
|
|
|
@Test
|
|
|
|
public void jobSample() throws Exception {
|
|
|
|
public void jobSample() throws Exception {
|
|
|
|
start("samples/job.groovy");
|
|
|
|
start("samples/job.groovy");
|
|
|
|
|
|
|
|
String output = getOutput();
|
|
|
|
|
|
|
|
assertTrue("Wrong output: " + output,
|
|
|
|
|
|
|
|
output.contains("completed with the following parameters"));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@Test
|
|
|
|
@Test
|
|
|
|
public void webSample() throws Exception {
|
|
|
|
public void webSample() throws Exception {
|
|
|
|
start("samples/web.groovy");
|
|
|
|
start("samples/web.groovy");
|
|
|
|
|
|
|
|
String result = FileUtil.readEntirely(new URL("http://localhost:8080")
|
|
|
|
|
|
|
|
.openStream());
|
|
|
|
|
|
|
|
assertEquals("World!", result);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@Test
|
|
|
|
@Test
|
|
|
|
public void serviceSample() throws Exception {
|
|
|
|
public void serviceSample() throws Exception {
|
|
|
|
start("samples/service.groovy");
|
|
|
|
start("samples/service.groovy");
|
|
|
|
|
|
|
|
String result = FileUtil.readEntirely(new URL("http://localhost:8080")
|
|
|
|
|
|
|
|
.openStream());
|
|
|
|
|
|
|
|
assertEquals("{\"message\":\"Hello World!\"}", result);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@Test
|
|
|
|
@Test
|
|
|
|
public void integrationSample() throws Exception {
|
|
|
|
public void integrationSample() throws Exception {
|
|
|
|
start("samples/integration.groovy");
|
|
|
|
start("samples/integration.groovy");
|
|
|
|
|
|
|
|
String output = getOutput();
|
|
|
|
|
|
|
|
assertTrue("Wrong output: " + output, output.contains("Hello, World"));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|