Repository: zeppelin
Updated Branches:
  refs/heads/master d88a002d1 -> 7af861682


http://git-wip-us.apache.org/repos/asf/zeppelin/blob/7af86168/zeppelin-zengine/src/test/java/org/apache/zeppelin/interpreter/remote/RemoteAngularObjectTest.java
----------------------------------------------------------------------
diff --git 
a/zeppelin-zengine/src/test/java/org/apache/zeppelin/interpreter/remote/RemoteAngularObjectTest.java
 
b/zeppelin-zengine/src/test/java/org/apache/zeppelin/interpreter/remote/RemoteAngularObjectTest.java
index 658fda3..1029696 100644
--- 
a/zeppelin-zengine/src/test/java/org/apache/zeppelin/interpreter/remote/RemoteAngularObjectTest.java
+++ 
b/zeppelin-zengine/src/test/java/org/apache/zeppelin/interpreter/remote/RemoteAngularObjectTest.java
@@ -20,29 +20,21 @@ package org.apache.zeppelin.interpreter.remote;
 import org.apache.zeppelin.display.AngularObject;
 import org.apache.zeppelin.display.AngularObjectRegistry;
 import org.apache.zeppelin.display.AngularObjectRegistryListener;
-import org.apache.zeppelin.display.GUI;
-import org.apache.zeppelin.interpreter.*;
-import org.apache.zeppelin.interpreter.remote.mock.MockInterpreterAngular;
+import org.apache.zeppelin.interpreter.AbstractInterpreterTest;
+import org.apache.zeppelin.interpreter.InterpreterContext;
+import org.apache.zeppelin.interpreter.InterpreterException;
+import org.apache.zeppelin.interpreter.InterpreterResult;
+import org.apache.zeppelin.interpreter.InterpreterSetting;
 import org.apache.zeppelin.resource.LocalResourcePool;
-import org.apache.zeppelin.user.AuthenticationInfo;
-import org.junit.After;
 import org.junit.Before;
 import org.junit.Test;
 
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.LinkedList;
-import java.util.List;
 import java.util.concurrent.atomic.AtomicInteger;
 
 import static org.junit.Assert.assertEquals;
-import static org.mockito.Mockito.mock;
 
-public class RemoteAngularObjectTest implements AngularObjectRegistryListener {
-  private static final String INTERPRETER_SCRIPT =
-      System.getProperty("os.name").startsWith("Windows") ?
-          "../bin/interpreter.cmd" :
-          "../bin/interpreter.sh";
+public class RemoteAngularObjectTest extends AbstractInterpreterTest
+    implements AngularObjectRegistryListener {
 
   private RemoteInterpreter intp;
   private InterpreterContext context;
@@ -55,51 +47,27 @@ public class RemoteAngularObjectTest implements 
AngularObjectRegistryListener {
 
   @Before
   public void setUp() throws Exception {
+    super.setUp();
+
     onAdd = new AtomicInteger(0);
     onUpdate = new AtomicInteger(0);
     onRemove = new AtomicInteger(0);
 
-    InterpreterOption interpreterOption = new InterpreterOption();
-    InterpreterInfo interpreterInfo1 = new 
InterpreterInfo(MockInterpreterAngular.class.getName(), "mock", true, new 
HashMap<String, Object>());
-    List<InterpreterInfo> interpreterInfos = new ArrayList<>();
-    interpreterInfos.add(interpreterInfo1);
-    InterpreterRunner runner = new InterpreterRunner(INTERPRETER_SCRIPT, 
INTERPRETER_SCRIPT);
-    interpreterSetting = new InterpreterSetting.Builder()
-        .setId("test")
-        .setName("test")
-        .setGroup("test")
-        .setInterpreterInfos(interpreterInfos)
-        .setOption(interpreterOption)
-        .setRunner(runner)
-        .setInterpreterDir("../interpeters/test")
-        .create();
-
-    intp = (RemoteInterpreter) 
interpreterSetting.getDefaultInterpreter("user1", "note1");
+    interpreterSetting = 
interpreterSettingManager.getInterpreterSettingByName("test");
+    intp = (RemoteInterpreter) interpreterSetting.getInterpreter("user1", 
"note1", "mock_ao");
     localRegistry = (RemoteAngularObjectRegistry) 
intp.getInterpreterGroup().getAngularObjectRegistry();
 
-    context = new InterpreterContext(
-        "note",
-        "id",
-        null,
-        "title",
-        "text",
-        new AuthenticationInfo(),
-        new HashMap<String, Object>(),
-        new GUI(),
-        new GUI(),
-        new AngularObjectRegistry(intp.getInterpreterGroup().getId(), null),
-        new LocalResourcePool("pool1"),
-        new LinkedList<InterpreterContextRunner>(), null);
+    context = InterpreterContext.builder()
+        .setNoteId("note")
+        .setParagraphId("id")
+        .setAngularObjectRegistry(new 
AngularObjectRegistry(intp.getInterpreterGroup().getId(), null))
+        .setResourcePool(new LocalResourcePool("pool1"))
+        .build();
 
     intp.open();
 
   }
 
-  @After
-  public void tearDown() throws Exception {
-    interpreterSetting.close();
-  }
-
   @Test
   public void testAngularObjectInterpreterSideCRUD() throws 
InterruptedException, InterpreterException {
     InterpreterResult ret = intp.interpret("get", context);

http://git-wip-us.apache.org/repos/asf/zeppelin/blob/7af86168/zeppelin-zengine/src/test/java/org/apache/zeppelin/interpreter/remote/RemoteInterpreterEventPollerTest.java
----------------------------------------------------------------------
diff --git 
a/zeppelin-zengine/src/test/java/org/apache/zeppelin/interpreter/remote/RemoteInterpreterEventPollerTest.java
 
b/zeppelin-zengine/src/test/java/org/apache/zeppelin/interpreter/remote/RemoteInterpreterEventPollerTest.java
deleted file mode 100644
index 49aa7aa..0000000
--- 
a/zeppelin-zengine/src/test/java/org/apache/zeppelin/interpreter/remote/RemoteInterpreterEventPollerTest.java
+++ /dev/null
@@ -1,55 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements.  See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License.  You may obtain a copy of the License at
- *
- *    http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.zeppelin.interpreter.remote;
-
-import org.apache.zeppelin.interpreter.thrift.RemoteInterpreterEvent;
-import org.apache.zeppelin.interpreter.thrift.RemoteInterpreterService;
-import org.junit.Test;
-
-import static 
org.apache.zeppelin.interpreter.thrift.RemoteInterpreterEventType.NO_OP;
-import static org.junit.Assert.assertEquals;
-import static org.mockito.Mockito.mock;
-import static org.mockito.Mockito.when;
-
-public class RemoteInterpreterEventPollerTest {
-
-       @Test
-       public void shouldClearUnreadEventsOnShutdown() throws Exception {
-               RemoteInterpreterProcess interpreterProc = 
getMockEventsInterpreterProcess();
-               RemoteInterpreterEventPoller eventPoller = new 
RemoteInterpreterEventPoller(null, null);
-
-               eventPoller.setInterpreterProcess(interpreterProc);
-               eventPoller.shutdown();
-               eventPoller.start();
-               eventPoller.join();
-
-               assertEquals(NO_OP, 
interpreterProc.getClient().getEvent().getType());
-       }
-
-       private RemoteInterpreterProcess getMockEventsInterpreterProcess() 
throws Exception {
-               RemoteInterpreterEvent fakeEvent = new RemoteInterpreterEvent();
-               RemoteInterpreterEvent noMoreEvents = new 
RemoteInterpreterEvent(NO_OP, "");
-               RemoteInterpreterService.Client client = 
mock(RemoteInterpreterService.Client.class);
-               RemoteInterpreterProcess intProc = 
mock(RemoteInterpreterProcess.class);
-
-               when(client.getEvent()).thenReturn(fakeEvent, fakeEvent, 
noMoreEvents);
-               when(intProc.getClient()).thenReturn(client);
-
-               return intProc;
-       }
-}

http://git-wip-us.apache.org/repos/asf/zeppelin/blob/7af86168/zeppelin-zengine/src/test/java/org/apache/zeppelin/interpreter/remote/RemoteInterpreterOutputTestStream.java
----------------------------------------------------------------------
diff --git 
a/zeppelin-zengine/src/test/java/org/apache/zeppelin/interpreter/remote/RemoteInterpreterOutputTestStream.java
 
b/zeppelin-zengine/src/test/java/org/apache/zeppelin/interpreter/remote/RemoteInterpreterOutputTestStream.java
index fa2aa42..aa6ccf0 100644
--- 
a/zeppelin-zengine/src/test/java/org/apache/zeppelin/interpreter/remote/RemoteInterpreterOutputTestStream.java
+++ 
b/zeppelin-zengine/src/test/java/org/apache/zeppelin/interpreter/remote/RemoteInterpreterOutputTestStream.java
@@ -17,48 +17,35 @@
 
 package org.apache.zeppelin.interpreter.remote;
 
-import org.apache.zeppelin.display.GUI;
-import org.apache.zeppelin.interpreter.*;
-import org.apache.zeppelin.interpreter.remote.mock.MockInterpreterOutputStream;
-import org.apache.zeppelin.user.AuthenticationInfo;
+import org.apache.zeppelin.interpreter.AbstractInterpreterTest;
+import org.apache.zeppelin.interpreter.InterpreterContext;
+import org.apache.zeppelin.interpreter.InterpreterException;
+import org.apache.zeppelin.interpreter.InterpreterResult;
+import org.apache.zeppelin.interpreter.InterpreterSetting;
 import org.junit.After;
 import org.junit.Before;
 import org.junit.Test;
 
-import java.util.*;
+import java.io.IOException;
+import java.util.List;
+import java.util.Map;
 
 import static org.junit.Assert.assertEquals;
-import static org.mockito.Mockito.mock;
 
 
 /**
  * Test for remote interpreter output stream
  */
-public class RemoteInterpreterOutputTestStream implements 
RemoteInterpreterProcessListener {
-  private static final String INTERPRETER_SCRIPT =
-          System.getProperty("os.name").startsWith("Windows") ?
-                  "../bin/interpreter.cmd" :
-                  "../bin/interpreter.sh";
+public class RemoteInterpreterOutputTestStream extends AbstractInterpreterTest
+    implements RemoteInterpreterProcessListener {
+
 
   private InterpreterSetting interpreterSetting;
 
   @Before
   public void setUp() throws Exception {
-    InterpreterOption interpreterOption = new InterpreterOption();
-
-    InterpreterInfo interpreterInfo1 = new 
InterpreterInfo(MockInterpreterOutputStream.class.getName(), "mock", true, new 
HashMap<String, Object>());
-    List<InterpreterInfo> interpreterInfos = new ArrayList<>();
-    interpreterInfos.add(interpreterInfo1);
-    InterpreterRunner runner = new InterpreterRunner(INTERPRETER_SCRIPT, 
INTERPRETER_SCRIPT);
-    interpreterSetting = new InterpreterSetting.Builder()
-        .setId("test")
-        .setName("test")
-        .setGroup("test")
-        .setInterpreterInfos(interpreterInfos)
-        .setOption(interpreterOption)
-        .setRunner(runner)
-        .setInterpreterDir("../interpeters/test")
-        .create();
+    super.setUp();
+    interpreterSetting = interpreterSettingManager.get("test");
   }
 
   @After
@@ -67,24 +54,15 @@ public class RemoteInterpreterOutputTestStream implements 
RemoteInterpreterProce
   }
 
   private InterpreterContext createInterpreterContext() {
-    return new InterpreterContext(
-        "noteId",
-        "id",
-        null,
-        "title",
-        "text",
-        new AuthenticationInfo(),
-        new HashMap<String, Object>(),
-        new GUI(),
-        new GUI(),
-        null,
-        null,
-        new LinkedList<InterpreterContextRunner>(), null);
+    return InterpreterContext.builder()
+        .setNoteId("noteId")
+        .setParagraphId("id")
+        .build();
   }
 
   @Test
   public void testInterpreterResultOnly() throws InterpreterException {
-    RemoteInterpreter intp = (RemoteInterpreter) 
interpreterSetting.getDefaultInterpreter("user1", "note1");
+    RemoteInterpreter intp = (RemoteInterpreter) 
interpreterSetting.getInterpreter("user1", "note1", "mock_stream");
     InterpreterResult ret = intp.interpret("SUCCESS::staticresult", 
createInterpreterContext());
     assertEquals(InterpreterResult.Code.SUCCESS, ret.code());
     assertEquals("staticresult", ret.message().get(0).getData());
@@ -100,7 +78,7 @@ public class RemoteInterpreterOutputTestStream implements 
RemoteInterpreterProce
 
   @Test
   public void testInterpreterOutputStreamOnly() throws InterpreterException {
-    RemoteInterpreter intp = (RemoteInterpreter) 
interpreterSetting.getDefaultInterpreter("user1", "note1");
+    RemoteInterpreter intp = (RemoteInterpreter) 
interpreterSetting.getInterpreter("user1", "note1", "mock_stream");
     InterpreterResult ret = intp.interpret("SUCCESS:streamresult:", 
createInterpreterContext());
     assertEquals(InterpreterResult.Code.SUCCESS, ret.code());
     assertEquals("streamresult", ret.message().get(0).getData());
@@ -112,7 +90,7 @@ public class RemoteInterpreterOutputTestStream implements 
RemoteInterpreterProce
 
   @Test
   public void testInterpreterResultOutputStreamMixed() throws 
InterpreterException {
-    RemoteInterpreter intp = (RemoteInterpreter) 
interpreterSetting.getDefaultInterpreter("user1", "note1");
+    RemoteInterpreter intp = (RemoteInterpreter) 
interpreterSetting.getInterpreter("user1", "note1", "mock_stream");
     InterpreterResult ret = intp.interpret("SUCCESS:stream:static", 
createInterpreterContext());
     assertEquals(InterpreterResult.Code.SUCCESS, ret.code());
     assertEquals("stream", ret.message().get(0).getData());
@@ -121,7 +99,7 @@ public class RemoteInterpreterOutputTestStream implements 
RemoteInterpreterProce
 
   @Test
   public void testOutputType() throws InterpreterException {
-    RemoteInterpreter intp = (RemoteInterpreter) 
interpreterSetting.getDefaultInterpreter("user1", "note1");
+    RemoteInterpreter intp = (RemoteInterpreter) 
interpreterSetting.getInterpreter("user1", "note1", "mock_stream");
 
     InterpreterResult ret = intp.interpret("SUCCESS:%html hello:", 
createInterpreterContext());
     assertEquals(InterpreterResult.Type.HTML, ret.message().get(0).getType());
@@ -159,14 +137,7 @@ public class RemoteInterpreterOutputTestStream implements 
RemoteInterpreterProce
   }
 
   @Override
-  public void onGetParagraphRunners(String noteId, String paragraphId, 
RemoteWorksEventListener callback) {
-    if (callback != null) {
-      callback.onFinished(new LinkedList<>());
-    }
-  }
-
-  @Override
-  public void onRemoteRunParagraph(String noteId, String ParagraphID) throws 
Exception {
+  public void runParagraphs(String noteId, List<Integer> paragraphIndices, 
List<String> paragraphIds, String curParagraphId) throws IOException {
 
   }
 

http://git-wip-us.apache.org/repos/asf/zeppelin/blob/7af86168/zeppelin-zengine/src/test/java/org/apache/zeppelin/interpreter/remote/RemoteInterpreterTest.java
----------------------------------------------------------------------
diff --git 
a/zeppelin-zengine/src/test/java/org/apache/zeppelin/interpreter/remote/RemoteInterpreterTest.java
 
b/zeppelin-zengine/src/test/java/org/apache/zeppelin/interpreter/remote/RemoteInterpreterTest.java
index 04b7a5b..5b059ef 100644
--- 
a/zeppelin-zengine/src/test/java/org/apache/zeppelin/interpreter/remote/RemoteInterpreterTest.java
+++ 
b/zeppelin-zengine/src/test/java/org/apache/zeppelin/interpreter/remote/RemoteInterpreterTest.java
@@ -40,46 +40,14 @@ import java.util.Map;
 
 import static org.junit.Assert.*;
 
-public class RemoteInterpreterTest {
-
-
-  private static final String INTERPRETER_SCRIPT =
-      System.getProperty("os.name").startsWith("Windows") ?
-          "../bin/interpreter.cmd" :
-          "../bin/interpreter.sh";
+public class RemoteInterpreterTest extends AbstractInterpreterTest {
 
   private InterpreterSetting interpreterSetting;
 
   @Before
   public void setUp() throws Exception {
-    InterpreterOption interpreterOption = new InterpreterOption();
-
-    InterpreterInfo interpreterInfo1 = new 
InterpreterInfo(EchoInterpreter.class.getName(), "echo", true, new 
HashMap<String, Object>());
-    InterpreterInfo interpreterInfo2 = new 
InterpreterInfo(DoubleEchoInterpreter.class.getName(), "double_echo", false, 
new HashMap<String, Object>());
-    InterpreterInfo interpreterInfo3 = new 
InterpreterInfo(SleepInterpreter.class.getName(), "sleep", false, new 
HashMap<String, Object>());
-    InterpreterInfo interpreterInfo4 = new 
InterpreterInfo(GetEnvPropertyInterpreter.class.getName(), "get", false, new 
HashMap<String, Object>());
-    InterpreterInfo interpreterInfo5 = new 
InterpreterInfo(GetAngularObjectSizeInterpreter.class.getName(), 
"angular_obj",false, new HashMap<String, Object>());
-    List<InterpreterInfo> interpreterInfos = new ArrayList<>();
-    interpreterInfos.add(interpreterInfo1);
-    interpreterInfos.add(interpreterInfo2);
-    interpreterInfos.add(interpreterInfo3);
-    interpreterInfos.add(interpreterInfo4);
-    interpreterInfos.add(interpreterInfo5);
-    InterpreterRunner runner = new InterpreterRunner(INTERPRETER_SCRIPT, 
INTERPRETER_SCRIPT);
-    interpreterSetting = new InterpreterSetting.Builder()
-        .setId("test")
-        .setName("test")
-        .setGroup("test")
-        .setInterpreterInfos(interpreterInfos)
-        .setOption(interpreterOption)
-        .setRunner(runner)
-        .setInterpreterDir("../interpeters/test")
-        .create();
-  }
-
-  @After
-  public void tearDown() throws Exception {
-    interpreterSetting.close();
+    super.setUp();
+    interpreterSetting = 
interpreterSettingManager.getInterpreterSettingByName("test");
   }
 
   @Test
@@ -95,9 +63,7 @@ public class RemoteInterpreterTest {
 
     assertEquals(remoteInterpreter1.getScheduler(), 
remoteInterpreter2.getScheduler());
 
-    InterpreterContext context1 = new InterpreterContext("noteId", 
"paragraphId", "repl",
-        "title", "text", AuthenticationInfo.ANONYMOUS, new HashMap<String, 
Object>(), new GUI(), new GUI(),
-        null, null, new ArrayList<InterpreterContextRunner>(), null);
+    InterpreterContext context1 = createDummyInterpreterContext();
     assertEquals("hello", remoteInterpreter1.interpret("hello", 
context1).message().get(0).getData());
     assertEquals(Interpreter.FormType.NATIVE, interpreter1.getFormType());
     assertEquals(0, remoteInterpreter1.getProgress(context1));
@@ -140,9 +106,7 @@ public class RemoteInterpreterTest {
 
     assertNotEquals(interpreter1.getScheduler(), interpreter2.getScheduler());
 
-    InterpreterContext context1 = new InterpreterContext("noteId", 
"paragraphId", "repl",
-        "title", "text", AuthenticationInfo.ANONYMOUS, new HashMap<String, 
Object>(), new GUI(), new GUI(),
-        null, null, new ArrayList<InterpreterContextRunner>(), null);
+    InterpreterContext context1 = createDummyInterpreterContext();
     assertEquals("hello", remoteInterpreter1.interpret("hello", 
context1).message().get(0).getData());
     assertEquals("hello", remoteInterpreter2.interpret("hello", 
context1).message().get(0).getData());
     assertEquals(Interpreter.FormType.NATIVE, interpreter1.getFormType());
@@ -188,9 +152,7 @@ public class RemoteInterpreterTest {
 
     assertNotEquals(interpreter1.getScheduler(), interpreter2.getScheduler());
 
-    InterpreterContext context1 = new InterpreterContext("noteId", 
"paragraphId", "repl",
-        "title", "text", AuthenticationInfo.ANONYMOUS, new HashMap<String, 
Object>(), new GUI(), new GUI(),
-        null, null, new ArrayList<InterpreterContextRunner>(), null);
+    InterpreterContext context1 = createDummyInterpreterContext();
     assertEquals("hello", remoteInterpreter1.interpret("hello", 
context1).message().get(0).getData());
     assertEquals("hello", remoteInterpreter2.interpret("hello", 
context1).message().get(0).getData());
     assertEquals(Interpreter.FormType.NATIVE, interpreter1.getFormType());
@@ -229,9 +191,7 @@ public class RemoteInterpreterTest {
     interpreterSetting.getOption().setPerUser(InterpreterOption.SHARED);
     interpreterSetting.setProperty("zeppelin.SleepInterpreter.precode", "fail 
test");
     Interpreter interpreter1 = interpreterSetting.getInterpreter("user1", 
"note1", "sleep");
-    InterpreterContext context1 = new InterpreterContext("noteId", 
"paragraphId", "repl",
-        "title", "text", AuthenticationInfo.ANONYMOUS, new HashMap<String, 
Object>(), new GUI(), new GUI(),
-        null, null, new ArrayList<InterpreterContextRunner>(), null);
+    InterpreterContext context1 = createDummyInterpreterContext();;
     assertEquals(Code.ERROR, interpreter1.interpret("10", context1).code());
   }
 
@@ -240,9 +200,7 @@ public class RemoteInterpreterTest {
     interpreterSetting.getOption().setPerUser(InterpreterOption.SHARED);
     interpreterSetting.setProperty("zeppelin.SleepInterpreter.precode", "1");
     Interpreter interpreter1 = interpreterSetting.getInterpreter("user1", 
"note1", "sleep");
-    InterpreterContext context1 = new InterpreterContext("noteId", 
"paragraphId", "repl",
-        "title", "text", AuthenticationInfo.ANONYMOUS, new HashMap<String, 
Object>(), new GUI(), new GUI(),
-        null, null, new ArrayList<InterpreterContextRunner>(), null);
+    InterpreterContext context1 = createDummyInterpreterContext();
     assertEquals(Code.SUCCESS, interpreter1.interpret("10", context1).code());
   }
 
@@ -255,9 +213,7 @@ public class RemoteInterpreterTest {
     assertTrue(interpreter1 instanceof RemoteInterpreter);
     RemoteInterpreter remoteInterpreter1 = (RemoteInterpreter) interpreter1;
 
-    InterpreterContext context1 = new InterpreterContext("noteId", 
"paragraphId", "repl",
-        "title", "text", AuthenticationInfo.ANONYMOUS, new HashMap<String, 
Object>(), new GUI(), new GUI(),
-        null, null, new ArrayList<InterpreterContextRunner>(), null);
+    InterpreterContext context1 = createDummyInterpreterContext();;
     assertEquals(Code.ERROR, remoteInterpreter1.interpret("hello", 
context1).code());
   }
 
@@ -267,9 +223,7 @@ public class RemoteInterpreterTest {
     // by default SleepInterpreter would use FIFOScheduler
 
     final Interpreter interpreter1 = 
interpreterSetting.getInterpreter("user1", "note1", "sleep");
-    final InterpreterContext context1 = new InterpreterContext("noteId", 
"paragraphId", "repl",
-        "title", "text", AuthenticationInfo.ANONYMOUS, new HashMap<String, 
Object>(), new GUI(), new GUI(),
-        null, null, new ArrayList<InterpreterContextRunner>(), null);
+    final InterpreterContext context1 = createDummyInterpreterContext();
     // run this dummy interpret method first to launch the 
RemoteInterpreterProcess to avoid the
     // time overhead of launching the process.
     interpreter1.interpret("1", context1);
@@ -310,9 +264,7 @@ public class RemoteInterpreterTest {
     interpreterSetting.setProperty("zeppelin.SleepInterpreter.parallel", 
"true");
 
     final Interpreter interpreter1 = 
interpreterSetting.getInterpreter("user1", "note1", "sleep");
-    final InterpreterContext context1 = new InterpreterContext("noteId", 
"paragraphId", "repl",
-        "title", "text", AuthenticationInfo.ANONYMOUS, new HashMap<String, 
Object>(), new GUI(), new GUI(),
-        null, null, new ArrayList<InterpreterContextRunner>(), null);
+    final InterpreterContext context1 = createDummyInterpreterContext();
 
     // run this dummy interpret method first to launch the 
RemoteInterpreterProcess to avoid the
     // time overhead of launching the process.
@@ -383,10 +335,7 @@ public class RemoteInterpreterTest {
     Interpreter interpreter = interpreterSetting.getInterpreter("user1", 
"note1", "angular_obj");
     interpreter.getInterpreterGroup().setAngularObjectRegistry(registry);
 
-    final InterpreterContext context = new InterpreterContext("noteId", 
"paragraphId", "repl",
-        "title", "text", AuthenticationInfo.ANONYMOUS, new HashMap<String, 
Object>(), new GUI(), new GUI(),
-        null, null, new ArrayList<InterpreterContextRunner>(), null);
-
+    final InterpreterContext context = createDummyInterpreterContext();
     InterpreterResult result = interpreter.interpret("dummy", context);
     assertEquals(Code.SUCCESS, result.code());
     assertEquals("2", result.message().get(0).getData());
@@ -410,15 +359,13 @@ public class RemoteInterpreterTest {
     interpreterSetting.setProperty("property_1", "value_1");
 
     final Interpreter interpreter1 = 
interpreterSetting.getInterpreter("user1", "note1", "get");
-    final InterpreterContext context1 = new InterpreterContext("noteId", 
"paragraphId", "repl",
-        "title", "text", AuthenticationInfo.ANONYMOUS, new HashMap<String, 
Object>(), new GUI(), new GUI(),
-        null, null, new ArrayList<InterpreterContextRunner>(), null);
+    final InterpreterContext context1 = createDummyInterpreterContext();
 
     assertEquals("VALUE_1", interpreter1.interpret("getEnv ENV_1", 
context1).message().get(0).getData());
     assertEquals("null", interpreter1.interpret("getEnv ENV_2", 
context1).message().get(0).getData());
 
     assertEquals("value_1", interpreter1.interpret("getProperty property_1", 
context1).message().get(0).getData());
-    assertEquals("null", interpreter1.interpret("getProperty property_2", 
context1).message().get(0).getData());
+    assertEquals("null", interpreter1.interpret("getProperty 
not_existed_property", context1).message().get(0).getData());
   }
 
   @Test
@@ -436,9 +383,7 @@ public class RemoteInterpreterTest {
     gui.textbox("textbox_id");
     Map<String, Input> expected = new LinkedHashMap<>(gui.getForms());
     Interpreter interpreter = 
interpreterSetting.getDefaultInterpreter("user1", "note1");
-    InterpreterContext context = new InterpreterContext("noteId", 
"paragraphId", "repl", null,
-        null, AuthenticationInfo.ANONYMOUS, new HashMap<String, Object>(), 
gui, new GUI(),
-        null, null, new ArrayList<InterpreterContextRunner>(), null);
+    InterpreterContext context = createDummyInterpreterContext();
 
     interpreter.interpret("text", context);
     assertArrayEquals(expected.values().toArray(), 
gui.getForms().values().toArray());

http://git-wip-us.apache.org/repos/asf/zeppelin/blob/7af86168/zeppelin-zengine/src/test/java/org/apache/zeppelin/resource/DistributedResourcePoolTest.java
----------------------------------------------------------------------
diff --git 
a/zeppelin-zengine/src/test/java/org/apache/zeppelin/resource/DistributedResourcePoolTest.java
 
b/zeppelin-zengine/src/test/java/org/apache/zeppelin/resource/DistributedResourcePoolTest.java
index 6f7c197..925515e 100644
--- 
a/zeppelin-zengine/src/test/java/org/apache/zeppelin/resource/DistributedResourcePoolTest.java
+++ 
b/zeppelin-zengine/src/test/java/org/apache/zeppelin/resource/DistributedResourcePoolTest.java
@@ -17,21 +17,18 @@
 package org.apache.zeppelin.resource;
 
 import com.google.gson.Gson;
-import org.apache.zeppelin.display.GUI;
-import org.apache.zeppelin.interpreter.*;
+import org.apache.zeppelin.interpreter.AbstractInterpreterTest;
+import org.apache.zeppelin.interpreter.InterpreterContext;
+import org.apache.zeppelin.interpreter.InterpreterException;
+import org.apache.zeppelin.interpreter.InterpreterResult;
+import org.apache.zeppelin.interpreter.InterpreterSetting;
 import org.apache.zeppelin.interpreter.remote.RemoteInterpreter;
-import org.apache.zeppelin.interpreter.remote.RemoteInterpreterEventPoller;
-import org.apache.zeppelin.user.AuthenticationInfo;
 import org.junit.After;
 import org.junit.Before;
 import org.junit.Test;
 
-import java.util.HashMap;
-import java.util.LinkedList;
-
 import static org.junit.Assert.assertEquals;
 import static org.junit.Assert.assertTrue;
-import static org.mockito.Mockito.mock;
 
 /**
  * Unittest for DistributedResourcePool
@@ -41,8 +38,6 @@ public class DistributedResourcePoolTest extends 
AbstractInterpreterTest {
   private RemoteInterpreter intp1;
   private RemoteInterpreter intp2;
   private InterpreterContext context;
-  private RemoteInterpreterEventPoller eventPoller1;
-  private RemoteInterpreterEventPoller eventPoller2;
 
 
   @Before
@@ -52,26 +47,13 @@ public class DistributedResourcePoolTest extends 
AbstractInterpreterTest {
     intp1 = (RemoteInterpreter) interpreterSetting.getInterpreter("user1", 
"note1", "mock_resource_pool");
     intp2 = (RemoteInterpreter) interpreterSetting.getInterpreter("user2", 
"note1", "mock_resource_pool");
 
-    context = new InterpreterContext(
-        "note",
-        "id",
-        null,
-        "title",
-        "text",
-        new AuthenticationInfo(),
-        new HashMap<String, Object>(),
-        new GUI(),
-        new GUI(),
-        null,
-        null,
-        new LinkedList<InterpreterContextRunner>(),
-        null);
+    context = InterpreterContext.builder()
+        .setNoteId("note")
+        .setParagraphId("id")
+        .build();
 
     intp1.open();
     intp2.open();
-
-    eventPoller1 = 
intp1.getInterpreterGroup().getRemoteInterpreterProcess().getRemoteInterpreterEventPoller();
-    eventPoller2 = 
intp1.getInterpreterGroup().getRemoteInterpreterProcess().getRemoteInterpreterEventPoller();
   }
 
   @After

http://git-wip-us.apache.org/repos/asf/zeppelin/blob/7af86168/zeppelin-zengine/src/test/java/org/apache/zeppelin/scheduler/RemoteSchedulerTest.java
----------------------------------------------------------------------
diff --git 
a/zeppelin-zengine/src/test/java/org/apache/zeppelin/scheduler/RemoteSchedulerTest.java
 
b/zeppelin-zengine/src/test/java/org/apache/zeppelin/scheduler/RemoteSchedulerTest.java
index 1253789..4542b0e 100644
--- 
a/zeppelin-zengine/src/test/java/org/apache/zeppelin/scheduler/RemoteSchedulerTest.java
+++ 
b/zeppelin-zengine/src/test/java/org/apache/zeppelin/scheduler/RemoteSchedulerTest.java
@@ -17,28 +17,20 @@
 
 package org.apache.zeppelin.scheduler;
 
-import org.apache.zeppelin.display.GUI;
+import org.apache.zeppelin.interpreter.AbstractInterpreterTest;
 import org.apache.zeppelin.interpreter.InterpreterContext;
-import org.apache.zeppelin.interpreter.InterpreterContextRunner;
 import org.apache.zeppelin.interpreter.InterpreterException;
-import org.apache.zeppelin.interpreter.InterpreterInfo;
-import org.apache.zeppelin.interpreter.InterpreterOption;
 import org.apache.zeppelin.interpreter.InterpreterResult;
-import org.apache.zeppelin.interpreter.InterpreterRunner;
 import org.apache.zeppelin.interpreter.InterpreterSetting;
 import org.apache.zeppelin.interpreter.remote.RemoteInterpreter;
 import org.apache.zeppelin.interpreter.remote.RemoteInterpreterProcessListener;
-import org.apache.zeppelin.interpreter.remote.mock.MockInterpreterA;
 import org.apache.zeppelin.resource.LocalResourcePool;
 import org.apache.zeppelin.scheduler.Job.Status;
-import org.apache.zeppelin.user.AuthenticationInfo;
 import org.junit.After;
 import org.junit.Before;
 import org.junit.Test;
 
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.LinkedList;
+import java.io.IOException;
 import java.util.List;
 import java.util.Map;
 
@@ -47,12 +39,8 @@ import static org.junit.Assert.assertNotNull;
 import static org.junit.Assert.assertNull;
 import static org.junit.Assert.assertTrue;
 
-public class RemoteSchedulerTest implements RemoteInterpreterProcessListener {
-
-  private static final String INTERPRETER_SCRIPT =
-      System.getProperty("os.name").startsWith("Windows") ?
-          "../bin/interpreter.cmd" :
-          "../bin/interpreter.sh";
+public class RemoteSchedulerTest extends AbstractInterpreterTest
+    implements RemoteInterpreterProcessListener {
 
   private InterpreterSetting interpreterSetting;
   private SchedulerFactory schedulerSvc;
@@ -61,22 +49,9 @@ public class RemoteSchedulerTest implements 
RemoteInterpreterProcessListener {
 
   @Before
   public void setUp() throws Exception {
+    super.setUp();
     schedulerSvc = new SchedulerFactory();
-
-    InterpreterOption interpreterOption = new InterpreterOption();
-    InterpreterInfo interpreterInfo1 = new 
InterpreterInfo(MockInterpreterA.class.getName(), "mock", true, new 
HashMap<String, Object>());
-    List<InterpreterInfo> interpreterInfos = new ArrayList<>();
-    interpreterInfos.add(interpreterInfo1);
-    InterpreterRunner runner = new InterpreterRunner(INTERPRETER_SCRIPT, 
INTERPRETER_SCRIPT);
-    interpreterSetting = new InterpreterSetting.Builder()
-        .setId("test")
-        .setName("test")
-        .setGroup("test")
-        .setInterpreterInfos(interpreterInfos)
-        .setOption(interpreterOption)
-        .setRunner(runner)
-        .setInterpreterDir("../interpeters/test")
-        .create();
+    interpreterSetting = 
interpreterSettingManager.getInterpreterSettingByName("test");
   }
 
   @After
@@ -86,7 +61,7 @@ public class RemoteSchedulerTest implements 
RemoteInterpreterProcessListener {
 
   @Test
   public void test() throws Exception {
-    final RemoteInterpreter intpA = (RemoteInterpreter) 
interpreterSetting.getDefaultInterpreter("user1", "note1");
+    final RemoteInterpreter intpA = (RemoteInterpreter) 
interpreterSetting.getInterpreter("user1", "note1", "mock");
 
     intpA.open();
 
@@ -112,19 +87,11 @@ public class RemoteSchedulerTest implements 
RemoteInterpreterProcessListener {
 
       @Override
       protected Object jobRun() throws Throwable {
-        intpA.interpret("1000", new InterpreterContext(
-            "note",
-            "jobId",
-            null,
-            "title",
-            "text",
-            new AuthenticationInfo(),
-            new HashMap<String, Object>(),
-            new GUI(),
-            new GUI(),
-            null,
-            new LocalResourcePool("pool1"),
-            new LinkedList<InterpreterContextRunner>(), null));
+        intpA.interpret("1000", InterpreterContext.builder()
+                .setNoteId("noteId")
+                .setParagraphId("jobId")
+                .setResourcePool(new LocalResourcePool("pool1"))
+                .build());
         return "1000";
       }
 
@@ -142,6 +109,7 @@ public class RemoteSchedulerTest implements 
RemoteInterpreterProcessListener {
 
     int cycles = 0;
     while (!job.isRunning() && cycles < MAX_WAIT_CYCLES) {
+      LOGGER.info("Status:" + job.getStatus());
       Thread.sleep(TICK_WAIT);
       cycles++;
     }
@@ -167,26 +135,18 @@ public class RemoteSchedulerTest implements 
RemoteInterpreterProcessListener {
 
   @Test
   public void testAbortOnPending() throws Exception {
-    final RemoteInterpreter intpA = (RemoteInterpreter) 
interpreterSetting.getDefaultInterpreter("user1", "note1");
+    final RemoteInterpreter intpA = (RemoteInterpreter) 
interpreterSetting.getInterpreter("user1", "note1", "mock");
     intpA.open();
 
     Scheduler scheduler = intpA.getScheduler();
 
     Job job1 = new Job("jobId1", "jobName1", null, 200) {
       Object results;
-      InterpreterContext context = new InterpreterContext(
-          "note",
-          "jobId1",
-          null,
-          "title",
-          "text",
-          new AuthenticationInfo(),
-          new HashMap<String, Object>(),
-          new GUI(),
-          new GUI(),
-          null,
-          new LocalResourcePool("pool1"),
-          new LinkedList<InterpreterContextRunner>(), null);
+      InterpreterContext context = InterpreterContext.builder()
+          .setNoteId("noteId")
+          .setParagraphId("jobId1")
+          .setResourcePool(new LocalResourcePool("pool1"))
+          .build();
 
       @Override
       public Object getReturn() {
@@ -229,19 +189,11 @@ public class RemoteSchedulerTest implements 
RemoteInterpreterProcessListener {
 
     Job job2 = new Job("jobId2", "jobName2", null, 200) {
       public Object results;
-      InterpreterContext context = new InterpreterContext(
-          "note",
-          "jobId2",
-          null,
-          "title",
-          "text",
-          new AuthenticationInfo(),
-          new HashMap<String, Object>(),
-          new GUI(),
-          new GUI(),
-          null,
-          new LocalResourcePool("pool1"),
-          new LinkedList<InterpreterContextRunner>(), null);
+      InterpreterContext context = InterpreterContext.builder()
+          .setNoteId("noteId")
+          .setParagraphId("jobId2")
+          .setResourcePool(new LocalResourcePool("pool1"))
+          .build();
 
       @Override
       public Object getReturn() {
@@ -335,18 +287,13 @@ public class RemoteSchedulerTest implements 
RemoteInterpreterProcessListener {
   }
 
   @Override
-  public void onGetParagraphRunners(String noteId, String paragraphId, 
RemoteWorksEventListener callback) {
-    if (callback != null) {
-      callback.onFinished(new LinkedList<>());
-    }
-  }
+  public void runParagraphs(String noteId, List<Integer> paragraphIndices, 
List<String> paragraphIds, String curParagraphId) throws IOException {
 
-  @Override
-  public void onRemoteRunParagraph(String noteId, String PsaragraphID) throws 
Exception {
   }
 
   @Override
   public void onParaInfosReceived(String noteId, String paragraphId,
                                   String interpreterSettingId, Map<String, 
String> metaInfos) {
   }
+
 }

http://git-wip-us.apache.org/repos/asf/zeppelin/blob/7af86168/zeppelin-zengine/src/test/resources/interpreter/test/interpreter-setting.json
----------------------------------------------------------------------
diff --git 
a/zeppelin-zengine/src/test/resources/interpreter/test/interpreter-setting.json 
b/zeppelin-zengine/src/test/resources/interpreter/test/interpreter-setting.json
index 99e980b..8a4f69c 100644
--- 
a/zeppelin-zengine/src/test/resources/interpreter/test/interpreter-setting.json
+++ 
b/zeppelin-zengine/src/test/resources/interpreter/test/interpreter-setting.json
@@ -60,5 +60,75 @@
       "language": "java",
       "editOnDblClick": false
     }
+  },
+
+  {
+    "group": "test",
+    "name": "get",
+    "defaultInterpreter": false,
+    "className": 
"org.apache.zeppelin.interpreter.remote.mock.GetEnvPropertyInterpreter",
+    "properties": {
+
+    },
+    "editor": {
+      "language": "java",
+      "editOnDblClick": false
+    }
+  },
+
+  {
+    "group": "test",
+    "name": "angular_obj",
+    "defaultInterpreter": false,
+    "className": 
"org.apache.zeppelin.interpreter.remote.mock.GetAngularObjectSizeInterpreter",
+    "properties": {
+
+    },
+    "editor": {
+      "language": "java",
+      "editOnDblClick": false
+    }
+  },
+
+  {
+    "group": "test",
+    "name": "mock",
+    "defaultInterpreter": false,
+    "className": 
"org.apache.zeppelin.interpreter.remote.mock.MockInterpreterA",
+    "properties": {
+
+    },
+    "editor": {
+      "language": "java",
+      "editOnDblClick": false
+    }
+  },
+
+  {
+    "group": "test",
+    "name": "mock_ao",
+    "defaultInterpreter": false,
+    "className": 
"org.apache.zeppelin.interpreter.remote.mock.MockInterpreterAngular",
+    "properties": {
+
+    },
+    "editor": {
+      "language": "java",
+      "editOnDblClick": false
+    }
+  },
+
+  {
+    "group": "test",
+    "name": "mock_stream",
+    "defaultInterpreter": false,
+    "className": 
"org.apache.zeppelin.interpreter.remote.mock.MockInterpreterOutputStream",
+    "properties": {
+
+    },
+    "editor": {
+      "language": "java",
+      "editOnDblClick": false
+    }
   }
 ]

Reply via email to