|
8 | 8 |
|
9 | 9 | import java.io.IOException; |
10 | 10 | import java.io.Reader; |
11 | | -import java.nio.charset.Charset; |
12 | 11 | import java.nio.file.Path; |
13 | 12 | import java.nio.file.Paths; |
14 | 13 | import java.util.ArrayList; |
|
19 | 18 | import java.util.stream.Stream; |
20 | 19 |
|
21 | 20 | import static _test.io.text.TextParserAssertions.assertTextParserCompliance; |
| 21 | +import static java.nio.charset.Charset.defaultCharset; |
22 | 22 | import static java.nio.charset.StandardCharsets.UTF_8; |
| 23 | +import static java.util.Arrays.asList; |
23 | 24 | import static java.util.Collections.singleton; |
24 | 25 | import static java.util.Collections.singletonList; |
25 | 26 | import static java.util.stream.Collectors.*; |
@@ -139,21 +140,61 @@ public void testAsParserWithListener() { |
139 | 140 |
|
140 | 141 | @SuppressWarnings("DataFlowIssue") |
141 | 142 | @Test |
142 | | - public void testParseProcess() throws IOException { |
| 143 | + public void testParseProcessOfProcess() throws IOException { |
143 | 144 | TextParser<Path> x = onParsingReader(TextParserTest::toPath); |
144 | 145 |
|
145 | 146 | assertThatNullPointerException() |
146 | | - .isThrownBy(() -> x.parseProcess(null, UTF_8)) |
| 147 | + .isThrownBy(() -> x.parseProcess((Process) null, UTF_8)) |
147 | 148 | .withMessageContaining("process"); |
148 | 149 |
|
149 | 150 | switch (OS.NAME) { |
150 | 151 | case WINDOWS: |
151 | | - assertThat(x.parseProcess(new ProcessBuilder("where", "where").start(), Charset.defaultCharset())).exists(); |
| 152 | + assertThat(x.parseProcess(new ProcessBuilder("where", "where").start(), defaultCharset())).exists(); |
152 | 153 | break; |
153 | 154 | case LINUX: |
154 | 155 | case MACOS: |
155 | 156 | case SOLARIS: |
156 | | - assertThat(x.parseProcess(new ProcessBuilder("which", "which").start(), Charset.defaultCharset())).exists(); |
| 157 | + assertThat(x.parseProcess(new ProcessBuilder("which", "which").start(), defaultCharset())).exists(); |
| 158 | + break; |
| 159 | + } |
| 160 | + } |
| 161 | + @SuppressWarnings("DataFlowIssue") |
| 162 | + @Test |
| 163 | + public void testParseProcessOfProcessBuilder() throws IOException { |
| 164 | + TextParser<Path> x = onParsingReader(TextParserTest::toPath); |
| 165 | + |
| 166 | + assertThatNullPointerException() |
| 167 | + .isThrownBy(() -> x.parseProcess((ProcessBuilder) null, UTF_8)) |
| 168 | + .withMessageContaining("processBuilder"); |
| 169 | + |
| 170 | + switch (OS.NAME) { |
| 171 | + case WINDOWS: |
| 172 | + assertThat(x.parseProcess(new ProcessBuilder("where", "where"), defaultCharset())).exists(); |
| 173 | + break; |
| 174 | + case LINUX: |
| 175 | + case MACOS: |
| 176 | + case SOLARIS: |
| 177 | + assertThat(x.parseProcess(new ProcessBuilder("which", "which"), defaultCharset())).exists(); |
| 178 | + break; |
| 179 | + } |
| 180 | + } |
| 181 | + @SuppressWarnings("DataFlowIssue") |
| 182 | + @Test |
| 183 | + public void testParseProcessOfCommand() throws IOException { |
| 184 | + TextParser<Path> x = onParsingReader(TextParserTest::toPath); |
| 185 | + |
| 186 | + assertThatNullPointerException() |
| 187 | + .isThrownBy(() -> x.parseProcess((List<String>) null, UTF_8)) |
| 188 | + .withMessageContaining("command"); |
| 189 | + |
| 190 | + switch (OS.NAME) { |
| 191 | + case WINDOWS: |
| 192 | + assertThat(x.parseProcess(asList("where", "where"), defaultCharset())).exists(); |
| 193 | + break; |
| 194 | + case LINUX: |
| 195 | + case MACOS: |
| 196 | + case SOLARIS: |
| 197 | + assertThat(x.parseProcess(asList("which", "which"), defaultCharset())).exists(); |
157 | 198 | break; |
158 | 199 | } |
159 | 200 | } |
|
0 commit comments