Interpreter { @ZeppelinApi public Properties getProperty() { Properties p = new Properties(); p.putAll(property); RegisteredInterpreter registeredInterpreter = Interpreter.findRegisteredInterpreterByClassName( getClassName()); if (null != registeredInterpreter) { Map<String, InterpreterProperty> defaultProperties = registeredInterpreter.getProperties(); for (String k : defaultProperties.keySet()) { if (!p.containsKey(k)) { String value = defaultProperties.get(k).getValue(); if (value != null) { p.put(k, defaultProperties.get(k).getValue()); } } } } return p; } @ZeppelinApi  Interpreter(Properties property); @ZeppelinApi abstract void open(); @ZeppelinApi abstract void close(); @ZeppelinApi abstract InterpreterResult interpret(String st, InterpreterContext context); @ZeppelinApi abstract void cancel(InterpreterContext context); @ZeppelinApi abstract FormType getFormType(); @ZeppelinApi abstract int getProgress(InterpreterContext context); @ZeppelinApi List<InterpreterCompletion> completion(String buf, int cursor); @ZeppelinApi Scheduler getScheduler(); @ZeppelinApi void destroy(); void setProperty(Properties property); @ZeppelinApi Properties getProperty(); @ZeppelinApi String getProperty(String key); String getClassName(); void setInterpreterGroup(InterpreterGroup interpreterGroup); @ZeppelinApi InterpreterGroup getInterpreterGroup(); URL[] getClassloaderUrls(); void setClassloaderUrls(URL[] classloaderUrls); @ZeppelinApi Interpreter getInterpreterInTheSameSessionByClassName(String className); static void register(String name, String className); static void register(String name, String group, String className); @Deprecated static void register(String name, String group, String className,
                              Map<String, InterpreterProperty> properties); static void register(RegisteredInterpreter registeredInterpreter); static RegisteredInterpreter findRegisteredInterpreterByClassName(String className); static Logger logger; static Map<String, RegisteredInterpreter> registeredInterpreters; }
@Test public void testDefaultProperty() { Properties p = new Properties(); MockInterpreterA intp = new MockInterpreterA(p); assertEquals(1, intp.getProperty().size()); assertEquals("v1", intp.getProperty().get("p1")); assertEquals("v1", intp.getProperty("p1")); }
@Test public void testOverridedProperty() { Properties p = new Properties(); p.put("p1", "v2"); MockInterpreterA intp = new MockInterpreterA(p); assertEquals(1, intp.getProperty().size()); assertEquals("v2", intp.getProperty().get("p1")); assertEquals("v2", intp.getProperty("p1")); }
@Test public void testAdditionalProperty() { Properties p = new Properties(); p.put("p2", "v2"); MockInterpreterA intp = new MockInterpreterA(p); assertEquals(2, intp.getProperty().size()); assertEquals("v1", intp.getProperty().get("p1")); assertEquals("v1", intp.getProperty("p1")); assertEquals("v2", intp.getProperty().get("p2")); assertEquals("v2", intp.getProperty("p2")); }