Exemple #1
0
  /** 同一ファイル名、同一時刻でも、完全に比較する場合のテスト。 */
  @Test
  public void testSame() throws Exception {
    long current = System.currentTimeMillis() - 10000L;
    File a = tempdir.newFolder("a");
    File a1 = tempdir.newFile("a/1");
    touch(a1, "data 11", current);
    File a2 = tempdir.newFile("a/2");
    touch(a2, "data 2222", current);
    File a3 = tempdir.newFile("a/3");
    touch(a3, "data 333333", current);

    current += 10000L;
    File b = tempdir.newFolder("b");
    File b1 = tempdir.newFile("b/1");
    touch(b1, "data 11", a1.lastModified());
    File b2 = tempdir.newFile("b/2");
    touch(b2, "data 1212", a2.lastModified());
    File b3 = tempdir.newFile("b/3");
    touch(b3, "data 131313", a3.lastModified());

    BackuperEx target = new BackuperEx(a, b);

    target.doCompare(System.out);

    assertEquals(new ArrayList<File>(), target.fromOnlyList);
    assertEquals(makeFilePairList(new File[] {a1, b1, a2, b2, a3, b3}), target.sameList);
    assertEquals(new ArrayList<File>(), target.toOnlyList);
    assertEquals(new ArrayList<FilePair>(), target.touchList);
    assertEquals(new ArrayList<File>(), target.moveList);

    target.compareSameList(System.out);

    assertEquals(Arrays.asList(new File[] {a2, a3}), target.fromOnlyList);
    assertEquals(makeFilePairList(new File[] {a1, b1}), target.sameList);
    assertEquals(Arrays.asList(new File[] {b2, b3}), target.toOnlyList);
    assertEquals(new ArrayList<FilePair>(), target.touchList);
    assertEquals(new ArrayList<File>(), target.moveList);

    target.doExecute(System.out);

    assertDirectory(
        b,
        new String[][] {
          {"1", "data 11"},
          {"2", "data 2222"},
          {"3", "data 333333"},
        });
  }
Exemple #2
0
  /** ディレクトリ内のファイル移動があった場合のテスト:単純コピー。 doCompare(), doExecute(); */
  @Test
  public void testMove1() throws Exception {
    File dir = tempdir.getRoot();
    BackuperEx target = prepareMove(dir);

    System.out.println("----------------------------------------");
    target.doExecute(System.out);

    assertDirectory(
        new File(dir, "b"),
        new String[][] {
          {"1/1", "data 11"},
          {"1/2", "data 1212"},
          {"1/3", "data 333333"},
        });
  }
Exemple #3
0
  /** 同じ名前のファイルとディレクトリがあった場合のテスト:時刻違いのファイル比較付き。 doCompare(), compareTouchList(), doExecute() */
  @Test
  public void testSimpleDir2() throws Exception {
    BackuperEx target = prepareSimple();

    target.compareTouchList(System.out);

    System.out.println("----------------------------------------");
    target.doExecute(System.out);

    assertDirectory(
        new File(tempdir.getRoot(), "b"),
        new String[][] {
          {"1", "1"},
          {"2", "2"},
          {"4/1", "4/1"},
          {"5", "5"},
          {"6/1", "6/1"},
          {"6/2", "6/2"},
        });
  }
Exemple #4
0
  /** 同じ名前のファイルとディレクトリがあった場合のテスト:単純コピー。 doCompare(), doExecute() */
  @Test
  public void testSimpleDir1() throws Exception {
    BackuperEx target = prepareSimple();

    long origmod = new File(tempdir.getRoot(), "a/6/2").lastModified();
    assertEquals(origmod + 10000L, new File(tempdir.getRoot(), "b/6/2").lastModified());

    System.out.println("----------------------------------------");
    target.doExecute(System.out);

    assertEquals(origmod, new File(tempdir.getRoot(), "b/6/2").lastModified());

    assertDirectory(
        new File(tempdir.getRoot(), "b"),
        new String[][] {
          {"1", "1"},
          {"2", "2"},
          {"4/1", "4/1"},
          {"5", "5"},
          {"6/1", "6/1"},
          {"6/2", "6/2"},
        });
  }