Fix CLI script
This commit is contained in:
@@ -38,6 +38,8 @@ public class TomcatEmbeddedServletContainer implements EmbeddedServletContainer
|
||||
|
||||
private final Log logger = LogFactory.getLog(TomcatEmbeddedServletContainer.class);
|
||||
|
||||
private static int containerCounter = 0;
|
||||
|
||||
private final Tomcat tomcat;
|
||||
|
||||
/**
|
||||
@@ -55,7 +57,7 @@ public class TomcatEmbeddedServletContainer implements EmbeddedServletContainer
|
||||
this.tomcat.start();
|
||||
// Unlike Jetty, all Tomcat threads are daemon threads. We create a
|
||||
// blocking non-daemon to stop immediate shutdown
|
||||
Thread awaitThread = new Thread() {
|
||||
Thread awaitThread = new Thread("container-" + (containerCounter++)) {
|
||||
@Override
|
||||
public void run() {
|
||||
TomcatEmbeddedServletContainer.this.tomcat.getServer().await();
|
||||
|
||||
@@ -39,6 +39,7 @@ import static org.junit.Assert.assertTrue;
|
||||
@Configuration
|
||||
public class SimpleMainTests {
|
||||
|
||||
private static final String SPRING_STARTUP = "root of context hierarchy";
|
||||
private PrintStream savedOutput;
|
||||
private ByteArrayOutputStream output;
|
||||
|
||||
@@ -58,33 +59,33 @@ public class SimpleMainTests {
|
||||
@Test(expected = IllegalArgumentException.class)
|
||||
public void emptyApplicationContext() throws Exception {
|
||||
SpringApplication.main(getArgs());
|
||||
assertTrue(getOutput().contains("Pre-instantiating singletons"));
|
||||
assertTrue(getOutput().contains(SPRING_STARTUP));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void basePackageScan() throws Exception {
|
||||
SpringApplication.main(getArgs(ClassUtils.getPackageName(getClass())
|
||||
+ ".sampleconfig"));
|
||||
assertTrue(getOutput().contains("Pre-instantiating singletons"));
|
||||
assertTrue(getOutput().contains(SPRING_STARTUP));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void configClassContext() throws Exception {
|
||||
SpringApplication.main(getArgs(getClass().getName()));
|
||||
assertTrue(getOutput().contains("Pre-instantiating singletons"));
|
||||
assertTrue(getOutput().contains(SPRING_STARTUP));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void xmlContext() throws Exception {
|
||||
SpringApplication.main(getArgs("org/springframework/bootstrap/sample-beans.xml"));
|
||||
assertTrue(getOutput().contains("Pre-instantiating singletons"));
|
||||
assertTrue(getOutput().contains(SPRING_STARTUP));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void mixedContext() throws Exception {
|
||||
SpringApplication.main(getArgs(getClass().getName(),
|
||||
"org/springframework/bootstrap/sample-beans.xml"));
|
||||
assertTrue(getOutput().contains("Pre-instantiating singletons"));
|
||||
assertTrue(getOutput().contains(SPRING_STARTUP));
|
||||
}
|
||||
|
||||
private String[] getArgs(String... args) {
|
||||
|
||||
@@ -71,6 +71,7 @@ public class LoggingApplicationContextInitializerTests {
|
||||
System.clearProperty("LOG_PATH");
|
||||
System.clearProperty("PID");
|
||||
System.setOut(this.savedOutput);
|
||||
System.out.println(getOutput());
|
||||
}
|
||||
|
||||
private String getOutput() {
|
||||
|
||||
Reference in New Issue
Block a user