2222
2323import java .util .Properties ;
2424
25- import org .apache .commons .exec .ExecuteException ;
2625import org .apache .zeppelin .interpreter .InterpreterContext ;
2726import org .apache .zeppelin .interpreter .InterpreterResult ;
2827import org .apache .zeppelin .interpreter .InterpreterResult .Code ;
3332public class ShellInterpreterTest {
3433
3534 private ShellInterpreter shell ;
35+ private InterpreterContext context ;
36+ private InterpreterResult result ;
3637
3738 @ Before
3839 public void setUp () throws Exception {
3940 Properties p = new Properties ();
4041 p .setProperty ("shell.command.timeout.millisecs" , "60000" );
4142 shell = new ShellInterpreter (p );
4243
44+ context = new InterpreterContext ("" , "1" , null , "" , "" , null , null , null , null , null , null , null );
4345 shell .open ();
4446 }
4547
@@ -49,8 +51,6 @@ public void tearDown() throws Exception {
4951
5052 @ Test
5153 public void test () {
52- InterpreterContext context = new InterpreterContext ("" , "1" , null , "" , "" , null , null , null , null , null , null , null );
53- InterpreterResult result ;
5454 if (System .getProperty ("os.name" ).startsWith ("Windows" )) {
5555 result = shell .interpret ("dir" , context );
5656 } else {
@@ -65,29 +65,23 @@ public void test() {
6565
6666 @ Test
6767 public void testInvalidCommand (){
68- InterpreterContext context = new InterpreterContext ("" , "1" , null , "" , "" , null , null , null , null , null , null , null );
69- InterpreterResult result ;
7068 if (System .getProperty ("os.name" ).startsWith ("Windows" )) {
7169 result = shell .interpret ("invalid_command\n dir" , context );
7270 } else {
7371 result = shell .interpret ("invalid_command\n ls" , context );
7472 }
75- assertEquals (InterpreterResult . Code .SUCCESS , result .code ());
76- assertTrue (result . message (). get ( 0 ). getData (). contains ( "invalid_command" ));
73+ assertEquals (Code .SUCCESS , result .code ());
74+ assertTrue (shell . executors . isEmpty ( ));
7775 }
7876
7977 @ Test
8078 public void testShellTimeout () {
81- InterpreterContext context = new InterpreterContext ("" , "1" , null , "" , "" , null , null , null , null , null , null , null );
82- InterpreterResult result ;
83-
8479 if (System .getProperty ("os.name" ).startsWith ("Windows" )) {
8580 result = shell .interpret ("timeout 61" , context );
8681 } else {
8782 result = shell .interpret ("sleep 61" , context );
8883 }
8984
90- assertEquals (InterpreterResult .Code .SUCCESS , result .code ());
9185 assertEquals (Code .INCOMPLETE , result .code ());
9286 assertTrue (result .message ().get (0 ).getData ().contains ("Paragraph received a SIGTERM" ));
9387 }
0 commit comments