2828@ Test
2929public class ProcessUtilTest {
3030
31- private final String process ;
31+ private final String program ;
32+ private final String path ;
3233
3334 public ProcessUtilTest () {
34- this .process = Objects .requireNonNull (ProcessUtilTest .class .getResource ("/process.py" )).getPath ();
35+ this .program = "python" ;
36+ this .path = Objects .requireNonNull (ProcessUtilTest .class .getResource ("/process.py" )).getPath ();
3537 }
3638
3739 @ BeforeTest
3840 public void setUp () {
3941 try {
40- if (ProcessUtil .invokeProcess (new String [] {"python" , "--version" }) != 0 ) {
42+ if (ProcessUtil .invokeProcess (new String [] {program , "--version" }) != 0 ) {
4143 throw new SkipException ("python not supported" );
4244 }
4345 } catch (IOException | InterruptedException e ) {
@@ -47,35 +49,35 @@ public void setUp() {
4749
4850 @ Test
4951 public void testReturnValue () throws IOException , InterruptedException {
50- Assert .assertEquals (ProcessUtil .invokeProcess (new String [] {process , "abc" }), 0 );
51- Assert .assertEquals (ProcessUtil .invokeProcess (new String [] {process , "abc" , "def" }), 1 );
52+ Assert .assertEquals (ProcessUtil .invokeProcess (new String [] {program , path , "abc" }), 0 );
53+ Assert .assertEquals (ProcessUtil .invokeProcess (new String [] {program , path , "abc" , "def" }), 1 );
5254
53- Assert .assertEquals (ProcessUtil .invokeProcess (new String [] {process }, new StringReader ("abc" )), 0 );
54- Assert .assertEquals (ProcessUtil .invokeProcess (new String [] {process }, new StringReader ("abc def" )), 1 );
55+ Assert .assertEquals (ProcessUtil .invokeProcess (new String [] {program , path }, new StringReader ("abc" )), 0 );
56+ Assert .assertEquals (ProcessUtil .invokeProcess (new String [] {program , path }, new StringReader ("abc def" )), 1 );
5557 }
5658
5759 @ Test
5860 public void testProcessOutput () throws IOException , InterruptedException {
5961 StringJoiner stdOutJoiner = new StringJoiner ("\n " );
6062 StringJoiner stdErrBuilder = new StringJoiner ("\n " );
6163
62- Assert .assertEquals (ProcessUtil .invokeProcess (new String [] {process , "abc" },
64+ Assert .assertEquals (ProcessUtil .invokeProcess (new String [] {program , path , "abc" },
6365 stdOutJoiner ::add ,
6466 stdErrBuilder ::add ), 0 );
6567 Assert .assertEquals (stdOutJoiner .toString (), "294" );
6668 Assert .assertEquals (stdErrBuilder .toString (), "abc" );
6769
6870 stdOutJoiner = new StringJoiner ("\n " );
6971 stdErrBuilder = new StringJoiner ("\n " );
70- Assert .assertEquals (ProcessUtil .invokeProcess (new String [] {process , "abc" , "def" },
72+ Assert .assertEquals (ProcessUtil .invokeProcess (new String [] {program , path , "abc" , "def" },
7173 stdOutJoiner ::add ,
7274 stdErrBuilder ::add ), 1 );
7375 Assert .assertEquals (stdOutJoiner .toString (), "294\n 303" );
7476 Assert .assertEquals (stdErrBuilder .toString (), "abc\n def" );
7577
7678 stdOutJoiner = new StringJoiner ("\n " );
7779 stdErrBuilder = new StringJoiner ("\n " );
78- Assert .assertEquals (ProcessUtil .invokeProcess (new String [] {process },
80+ Assert .assertEquals (ProcessUtil .invokeProcess (new String [] {program , path },
7981 new StringReader ("abc" ),
8082 stdOutJoiner ::add ,
8183 stdErrBuilder ::add ), 0 );
@@ -84,7 +86,7 @@ public void testProcessOutput() throws IOException, InterruptedException {
8486
8587 stdOutJoiner = new StringJoiner ("\n " );
8688 stdErrBuilder = new StringJoiner ("\n " );
87- Assert .assertEquals (ProcessUtil .invokeProcess (new String [] {process },
89+ Assert .assertEquals (ProcessUtil .invokeProcess (new String [] {program , path },
8890 new StringReader ("abc def" ),
8991 stdOutJoiner ::add ,
9092 stdErrBuilder ::add ), 1 );
0 commit comments