use of org.apache.zeppelin.notebook.NoteManager in project zeppelin by apache.
the class NotebookRepoSyncTest method testOneWaySyncOnReloadedList.
@Test
public void testOneWaySyncOnReloadedList() throws IOException, SchedulerException {
System.setProperty(ConfVars.ZEPPELIN_NOTEBOOK_DIR.getVarName(), mainNotebookDir.getAbsolutePath());
System.setProperty(ConfVars.ZEPPELIN_NOTEBOOK_ONE_WAY_SYNC.getVarName(), "true");
conf = ZeppelinConfiguration.create();
notebookRepoSync = new NotebookRepoSync(conf);
notebook = new Notebook(conf, mock(AuthorizationService.class), notebookRepoSync, new NoteManager(notebookRepoSync, conf), factory, interpreterSettingManager, credentials, null);
// check that both storage repos are empty
assertTrue(notebookRepoSync.getRepoCount() > 1);
assertEquals(0, notebookRepoSync.list(0, null).size());
assertEquals(0, notebookRepoSync.list(1, null).size());
File srcDir = new File("src/test/resources/notebook");
File destDir = secNotebookDir;
/* copy manually new notebook into secondary storage repo and check repos */
try {
FileUtils.copyDirectory(srcDir, destDir);
} catch (IOException e) {
LOG.error(e.toString(), e);
}
assertEquals(0, notebookRepoSync.list(0, null).size());
assertEquals(2, notebookRepoSync.list(1, null).size());
// after reloading the notebook should be wiped from secondary storage
notebook.reloadAllNotes(null);
assertEquals(0, notebookRepoSync.list(0, null).size());
assertEquals(0, notebookRepoSync.list(1, null).size());
destDir = mainNotebookDir;
// copy manually new notebook into primary storage repo and check repos
try {
FileUtils.copyDirectory(srcDir, destDir);
} catch (IOException e) {
LOG.error(e.toString(), e);
}
assertEquals(2, notebookRepoSync.list(0, null).size());
assertEquals(0, notebookRepoSync.list(1, null).size());
// after reloading notebooks repos should be synchronized
notebook.reloadAllNotes(null);
assertEquals(2, notebookRepoSync.list(0, null).size());
assertEquals(2, notebookRepoSync.list(1, null).size());
}
use of org.apache.zeppelin.notebook.NoteManager in project zeppelin by apache.
the class HeliumApplicationFactoryTest method setUp.
@Override
@Before
public void setUp() throws Exception {
super.setUp();
// set AppEventListener properly
for (InterpreterSetting interpreterSetting : interpreterSettingManager.get()) {
interpreterSetting.setAppEventListener(heliumAppFactory);
}
AuthorizationService authorizationService = mock(AuthorizationService.class);
notebookRepo = mock(NotebookRepo.class);
notebook = new Notebook(conf, authorizationService, notebookRepo, new NoteManager(notebookRepo, ZeppelinConfiguration.create()), interpreterFactory, interpreterSettingManager, new Credentials());
heliumAppFactory = new HeliumApplicationFactory(notebook, null);
notebook.addNotebookEventListener(heliumAppFactory);
anonymous = new AuthenticationInfo("anonymous");
}
Aggregations