mirror of
https://github.com/apache/zeppelin
synced 2026-05-24 09:38:26 +00:00
Modify test
This commit is contained in:
parent
b03cde2679
commit
1f83f15f06
2 changed files with 67 additions and 1 deletions
|
|
@ -29,8 +29,10 @@ import java.io.IOException;
|
|||
import java.util.ArrayList;
|
||||
import java.util.Date;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import org.apache.commons.io.FileUtils;
|
||||
import org.apache.zeppelin.conf.ZeppelinConfiguration;
|
||||
import org.apache.zeppelin.conf.ZeppelinConfiguration.ConfVars;
|
||||
import org.apache.zeppelin.display.AngularObjectRegistry;
|
||||
|
|
@ -117,6 +119,44 @@ public class NotebookTest implements JobListenerFactory{
|
|||
assertEquals("repl2: hello world", p2.getResult().message());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testReloadAllNotes() throws IOException {
|
||||
File srcDir = new File("src/test/resources/2A94M5J1Z");
|
||||
File destDir = new File(notebookDir.getAbsolutePath() + "/2A94M5J1Z");
|
||||
|
||||
// copy the notebook
|
||||
try {
|
||||
FileUtils.copyDirectory(srcDir, destDir);
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
// doesn't have copied notebook in memory before reloading
|
||||
List<Note> notes = notebook.getAllNotes();
|
||||
assertEquals(notes.size(), 0);
|
||||
|
||||
// load copied notebook on memory when reloadAllNotes() is called
|
||||
Note copiedNote = notebookRepo.get("2A94M5J1Z");
|
||||
notebook.reloadAllNotes();
|
||||
notes = notebook.getAllNotes();
|
||||
assertEquals(notes.size(), 1);
|
||||
assertEquals(notes.get(0).id(), copiedNote.id());
|
||||
assertEquals(notes.get(0).getName(), copiedNote.getName());
|
||||
assertEquals(notes.get(0).getParagraphs(), copiedNote.getParagraphs());
|
||||
|
||||
// delete the notebook
|
||||
FileUtils.deleteDirectory(destDir);
|
||||
|
||||
// keep notebook in memory before reloading
|
||||
notes = notebook.getAllNotes();
|
||||
assertEquals(notes.size(), 1);
|
||||
|
||||
// delete notebook from notebook list when reloadAllNotes() is called
|
||||
notebook.reloadAllNotes();
|
||||
notes = notebook.getAllNotes();
|
||||
assertEquals(notes.size(), 0);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testPersist() throws IOException, SchedulerException{
|
||||
Note note = notebook.createNote();
|
||||
|
|
|
|||
|
|
@ -25,6 +25,7 @@ import java.io.File;
|
|||
import java.io.IOException;
|
||||
import java.util.Map;
|
||||
|
||||
import org.apache.commons.io.FileUtils;
|
||||
import org.apache.zeppelin.conf.ZeppelinConfiguration;
|
||||
import org.apache.zeppelin.conf.ZeppelinConfiguration.ConfVars;
|
||||
import org.apache.zeppelin.interpreter.InterpreterFactory;
|
||||
|
|
@ -183,7 +184,32 @@ public class NotebookRepoSyncTest implements JobListenerFactory {
|
|||
assertEquals(p1.getId(), notebookRepoSync.get(1,
|
||||
notebookRepoSync.list(1).get(0).getId()).getLastParagraph().getId());
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void testSyncOnReloadedList() throws IOException {
|
||||
/* check that both storage repos are empty */
|
||||
assertTrue(notebookRepoSync.getRepoCount() > 1);
|
||||
assertEquals(0, notebookRepoSync.list(0).size());
|
||||
assertEquals(0, notebookRepoSync.list(1).size());
|
||||
|
||||
File srcDir = new File("src/test/resources/2A94M5J1Z");
|
||||
File destDir = new File(secNotebookDir + "/2A94M5J1Z");
|
||||
|
||||
/* copy manually new notebook into secondary storage repo and check repos */
|
||||
try {
|
||||
FileUtils.copyDirectory(srcDir, destDir);
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
assertEquals(0, notebookRepoSync.list(0).size());
|
||||
assertEquals(1, notebookRepoSync.list(1).size());
|
||||
|
||||
// After reloading notebooks repos should be synchronized
|
||||
notebookSync.reloadAllNotes();
|
||||
assertEquals(1, notebookRepoSync.list(0).size());
|
||||
assertEquals(1, notebookRepoSync.list(1).size());
|
||||
}
|
||||
|
||||
static void delete(File file){
|
||||
if(file.isFile()) file.delete();
|
||||
else if(file.isDirectory()){
|
||||
|
|
|
|||
Loading…
Reference in a new issue