Search in sources :

Example 16 with Interpreter

use of org.apache.zeppelin.interpreter.Interpreter in project zeppelin by apache.

the class NoteInterpreterLoaderTest method testNoteInterpreterCloseForAll.

@Test
public void testNoteInterpreterCloseForAll() throws IOException {
    interpreterSettingManager.setInterpreters("user", "FitstNote", interpreterSettingManager.getDefaultInterpreterSettingList());
    interpreterSettingManager.getInterpreterSettings("FitstNote").get(0).getOption().setPerNote(InterpreterOption.SCOPED);
    interpreterSettingManager.setInterpreters("user", "yourFirstNote", interpreterSettingManager.getDefaultInterpreterSettingList());
    interpreterSettingManager.getInterpreterSettings("yourFirstNote").get(0).getOption().setPerNote(InterpreterOption.ISOLATED);
    // interpreters are not created before accessing it
    assertNull(interpreterSettingManager.getInterpreterSettings("FitstNote").get(0).getInterpreterGroup("user", "FitstNote").get("FitstNote"));
    assertNull(interpreterSettingManager.getInterpreterSettings("yourFirstNote").get(0).getInterpreterGroup("user", "yourFirstNote").get("yourFirstNote"));
    Interpreter firstNoteIntp = factory.getInterpreter("user", "FitstNote", "group1.mock1");
    Interpreter yourFirstNoteIntp = factory.getInterpreter("user", "yourFirstNote", "group1.mock1");
    firstNoteIntp.open();
    yourFirstNoteIntp.open();
    assertTrue(((LazyOpenInterpreter) firstNoteIntp).isOpen());
    assertTrue(((LazyOpenInterpreter) yourFirstNoteIntp).isOpen());
    interpreterSettingManager.closeNote("user", "FitstNote");
    assertFalse(((LazyOpenInterpreter) firstNoteIntp).isOpen());
    assertTrue(((LazyOpenInterpreter) yourFirstNoteIntp).isOpen());
    //reopen
    firstNoteIntp.open();
    assertTrue(((LazyOpenInterpreter) firstNoteIntp).isOpen());
    assertTrue(((LazyOpenInterpreter) yourFirstNoteIntp).isOpen());
    // invalid check
    interpreterSettingManager.closeNote("invalid", "Note");
    assertTrue(((LazyOpenInterpreter) firstNoteIntp).isOpen());
    assertTrue(((LazyOpenInterpreter) yourFirstNoteIntp).isOpen());
    // invalid contains value check
    interpreterSettingManager.closeNote("u", "Note");
    assertTrue(((LazyOpenInterpreter) firstNoteIntp).isOpen());
    assertTrue(((LazyOpenInterpreter) yourFirstNoteIntp).isOpen());
}
Also used : Interpreter(org.apache.zeppelin.interpreter.Interpreter) LazyOpenInterpreter(org.apache.zeppelin.interpreter.LazyOpenInterpreter) Test(org.junit.Test)

Aggregations

Interpreter (org.apache.zeppelin.interpreter.Interpreter)16 InterpreterGroup (org.apache.zeppelin.interpreter.InterpreterGroup)6 WrappedInterpreter (org.apache.zeppelin.interpreter.WrappedInterpreter)6 Properties (java.util.Properties)5 LazyOpenInterpreter (org.apache.zeppelin.interpreter.LazyOpenInterpreter)5 InterpreterResult (org.apache.zeppelin.interpreter.InterpreterResult)4 CassandraInterpreter (org.apache.zeppelin.cassandra.CassandraInterpreter)3 AngularObjectRegistry (org.apache.zeppelin.display.AngularObjectRegistry)3 InterpreterContext (org.apache.zeppelin.interpreter.InterpreterContext)3 AuthenticationInfo (org.apache.zeppelin.user.AuthenticationInfo)3 Before (org.junit.Before)3 HashMap (java.util.HashMap)2 LinkedList (java.util.LinkedList)2 GUI (org.apache.zeppelin.display.GUI)2 InterpreterOutput (org.apache.zeppelin.interpreter.InterpreterOutput)2 InterpreterResultMessage (org.apache.zeppelin.interpreter.InterpreterResultMessage)2 LocalResourcePool (org.apache.zeppelin.resource.LocalResourcePool)2 ResourcePool (org.apache.zeppelin.resource.ResourcePool)2 Test (org.junit.Test)2 ArrayList (java.util.ArrayList)1