Skip to content

Commit 4721172

Browse files
committed
Add some integration tests for the CLI’s quiet mode
See gh-6918
1 parent 0a9bcd9 commit 4721172

File tree

2 files changed

+76
-0
lines changed

2 files changed

+76
-0
lines changed
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
package org.test
2+
3+
@Component
4+
class Example implements CommandLineRunner {
5+
6+
void run(String... args) {
7+
print "Ssshh"
8+
}
9+
10+
}
Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
/*
2+
* Copyright 2012-2016 the original author or authors.
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
17+
package org.springframework.boot.cli;
18+
19+
import java.util.Properties;
20+
21+
import org.junit.After;
22+
import org.junit.Before;
23+
import org.junit.Rule;
24+
import org.junit.Test;
25+
26+
import org.springframework.boot.cli.command.run.RunCommand;
27+
28+
import static org.assertj.core.api.Assertions.assertThat;
29+
30+
/**
31+
* Integration tests for {@link RunCommand}.
32+
*
33+
* @author Andy Wilkinson
34+
*/
35+
public class RunCommandIntegrationTests {
36+
37+
@Rule
38+
public CliTester cli = new CliTester("src/it/resources/run-command/");
39+
40+
private Properties systemProperties = new Properties();
41+
42+
@Before
43+
public void captureSystemProperties() {
44+
this.systemProperties.putAll(System.getProperties());
45+
}
46+
47+
@After
48+
public void restoreSystemProperties() {
49+
System.setProperties(this.systemProperties);
50+
}
51+
52+
@Test
53+
public void bannerAndLoggingIsOutputByDefault() throws Exception {
54+
String output = this.cli.run("quiet.groovy");
55+
assertThat(output).contains(" :: Spring Boot ::");
56+
assertThat(output).contains("Starting application");
57+
assertThat(output).contains("Ssshh");
58+
}
59+
60+
@Test
61+
public void quietModeSuppressesAllCliOutput() throws Exception {
62+
String output = this.cli.run("quiet.groovy", "-q");
63+
assertThat(output).isEqualTo("Ssshh");
64+
}
65+
66+
}

0 commit comments

Comments
 (0)