use of org.apache.zeppelin.dep.Dependency in project zeppelin by apache.
the class InterpreterFactoryTest method testInterpreterSettingPropertyClass.
@Test
public void testInterpreterSettingPropertyClass() throws IOException, RepositoryException {
// check if default interpreter reference's property type is map
Map<String, InterpreterSetting> interpreterSettingRefs = interpreterSettingManager.getAvailableInterpreterSettings();
InterpreterSetting intpSetting = interpreterSettingRefs.get("mock1");
Map<String, InterpreterProperty> intpProperties = (Map<String, InterpreterProperty>) intpSetting.getProperties();
assertTrue(intpProperties instanceof Map);
// check if interpreter instance is saved as Properties in conf/interpreter.json file
Properties properties = new Properties();
properties.put("key1", "value1");
properties.put("key2", "value2");
interpreterSettingManager.createNewSetting("newMock", "mock1", new LinkedList<Dependency>(), new InterpreterOption(false), properties);
String confFilePath = conf.getInterpreterSettingPath();
byte[] encoded = Files.readAllBytes(Paths.get(confFilePath));
String json = new String(encoded, "UTF-8");
Gson gson = new Gson();
InterpreterInfoSaving infoSaving = gson.fromJson(json, InterpreterInfoSaving.class);
Map<String, InterpreterSetting> interpreterSettings = infoSaving.interpreterSettings;
for (String key : interpreterSettings.keySet()) {
InterpreterSetting setting = interpreterSettings.get(key);
if (setting.getName().equals("newMock")) {
assertEquals(setting.getProperties().toString(), properties.toString());
}
}
}
use of org.apache.zeppelin.dep.Dependency in project zeppelin by apache.
the class InterpreterFactoryTest method testSaveLoad.
@Test
public void testSaveLoad() throws IOException, RepositoryException {
// interpreter settings
int numInterpreters = interpreterSettingManager.get().size();
// check if file saved
assertTrue(new File(conf.getInterpreterSettingPath()).exists());
interpreterSettingManager.createNewSetting("new-mock1", "mock1", new LinkedList<Dependency>(), new InterpreterOption(false), new Properties());
assertEquals(numInterpreters + 1, interpreterSettingManager.get().size());
interpreterSettingManager = new InterpreterSettingManager(conf, depResolver, new InterpreterOption(true));
/*
Current situation, if InterpreterSettinfRef doesn't have the key of InterpreterSetting, it would be ignored.
Thus even though interpreter.json have several interpreterSetting in that file, it would be ignored and would not be initialized from loadFromFile.
In this case, only "mock11" would be referenced from file under interpreter/mock, and "mock11" group would be initialized.
*/
// TODO(jl): Decide how to handle the know referenced interpreterSetting.
assertEquals(1, interpreterSettingManager.get().size());
}
Aggregations