Example #1
0
  @Test
  public void testFileEventAndCmdNonPropagation() throws IOException {
    when(fileSystemState_.updateState(any(FileChangeEvent.class))).thenReturn(false);

    FileEvent evt =
        new FileEvent(StandardWatchEventKinds.ENTRY_CREATE, TEST_FILE_PATH, new byte[1]);
    client_.handleEvent(evt);
    verify(transport_, never()).publish(any(DropboxCmd.class));

    DropboxCmd update = new DropboxCmd(OpCode.UPDATE, TEST_FILE, new byte[1]);
    client_.handleCmd(update);
    verify(fileManager_, never()).write(any(Path.class), any(byte[].class), any(boolean.class));
  }
Example #2
0
  @Test
  public void testCmdToFileChanges() throws Exception {
    byte[] data = new byte[3];
    data[1] = 1;

    DropboxCmd add = new DropboxCmd(OpCode.ADD, TEST_FILE, data);
    client_.handleCmd(add);
    verify(fileManager_).write(TEST_FILE_RESOLVED_PATH, data, true);

    DropboxCmd update = new DropboxCmd(OpCode.UPDATE, TEST_FILE, data);
    client_.handleCmd(update);
    verify(fileManager_, times(2)).write(TEST_FILE_RESOLVED_PATH, data, true);

    DropboxCmd delete = new DropboxCmd(OpCode.REMOVE, TEST_FILE, data);
    client_.handleCmd(delete);
    verify(fileManager_).delete(TEST_FILE_RESOLVED_PATH);
  }
Example #3
0
  @Test
  public void testFileEventToCmd() {

    DropboxCmd expected = new DropboxCmd(OpCode.ADD, TEST_FILE, new byte[1]);
    FileEvent evt =
        new FileEvent(StandardWatchEventKinds.ENTRY_CREATE, TEST_FILE_PATH, new byte[1]);
    client_.handleEvent(evt);
    verify(transport_).publish(eq(expected));

    DropboxCmd expected2 = new DropboxCmd(OpCode.UPDATE, TEST_FILE, new byte[1]);
    FileEvent evt2 =
        new FileEvent(StandardWatchEventKinds.ENTRY_MODIFY, TEST_FILE_PATH, new byte[1]);
    client_.handleEvent(evt2);
    verify(transport_).publish(eq(expected2));

    DropboxCmd expected3 = new DropboxCmd(OpCode.REMOVE, TEST_FILE, new byte[1]);
    FileEvent evt3 =
        new FileEvent(StandardWatchEventKinds.ENTRY_DELETE, TEST_FILE_PATH, new byte[1]);
    client_.handleEvent(evt3);
    verify(transport_).publish(eq(expected3));
  }