コード例 #1
0
  @Test
  public void testGetMergeWithNewLine() throws Exception {
    String fName1 = UUID.randomUUID() + ".txt";
    String name1 = "local/merge/" + fName1;
    TestUtils.writeToFS(cfg, name1);

    String fName2 = UUID.randomUUID() + ".txt";
    String name2 = "local/merge/" + fName2;
    TestUtils.writeToFS(cfg, name2);

    File dir = new File("local");
    dir.mkdir();

    String localName = "local/merge.txt";
    File fl1 = new File(localName);

    try {
      shell.getmerge("local/merge/", localName, true);
      assertTrue(fl1.exists());
      String content = FileCopyUtils.copyToString(new FileReader(fl1));
      assertTrue(content.contains(name1 + "\n"));
      assertTrue(content.contains(name2));
      assertEquals(content.length(), name1.length() + name2.length() + 2);
    } finally {
      FileSystemUtils.deleteRecursively(dir);
    }
  }
コード例 #2
0
  @Test
  public void testCopyToLocalMulti() throws Exception {
    String fName1 = UUID.randomUUID() + ".txt";
    String name1 = "local/" + fName1;
    String fName2 = UUID.randomUUID() + ".txt";
    String name2 = "local/" + fName2;

    File dir = new File("local");
    dir.mkdir();

    Resource res1 = TestUtils.writeToFS(cfg, name1);
    Resource res2 = TestUtils.writeToFS(cfg, name2);
    shell.copyToLocal(name1, "local");
    shell.copyToLocal(false, true, name2, "local");
    File fl1 = new File(name1);
    File fl2 = new File(name2);
    try {
      assertTrue(fl1.exists());
      assertTrue(fl2.exists());
      assertArrayEquals(
          FileCopyUtils.copyToByteArray(res1.getInputStream()), FileCopyUtils.copyToByteArray(fl1));
      assertArrayEquals(
          FileCopyUtils.copyToByteArray(res2.getInputStream()), FileCopyUtils.copyToByteArray(fl2));
    } finally {
      FileSystemUtils.deleteRecursively(dir);
    }
  }
コード例 #3
0
  @Test
  public void testRMR() throws Exception {
    String name1 = "local/rmr/" + UUID.randomUUID() + ".txt";
    String name2 = "local/rmr/" + UUID.randomUUID() + ".txt";

    TestUtils.writeToFS(cfg, name1);
    TestUtils.writeToFS(cfg, name2);

    assertTrue(shell.test(name1));
    assertTrue(shell.test(name2));
    shell.rmr("local/rmr/");
    assertFalse(shell.test(name1));
    assertFalse(shell.test(name2));
  }
コード例 #4
0
 // @Test - disabled for now as Trash is disabled by default as well
 public void testTrash() throws Exception {
   String name1 = "local/rmr/" + UUID.randomUUID() + ".txt";
   TestUtils.writeToFS(cfg, name1);
   shell.rmr("local/rmr/");
   assertTrue(shell.test(".Trash"));
   System.out.println(shell.ls(".Trash"));
 }
コード例 #5
0
  @Test(expected = IllegalStateException.class)
  public void testRMDirectoryNonRecursive() throws Exception {
    String name1 = "local/rmr/" + UUID.randomUUID() + ".txt";

    TestUtils.writeToFS(cfg, name1);

    assertTrue(shell.test(name1));
    shell.rm("local/rmr/");
  }
コード例 #6
0
  @Test
  public void testCpMulti() throws Exception {
    String fName1 = UUID.randomUUID() + ".txt";
    String name1 = "local/" + fName1;
    TestUtils.writeToFS(cfg, name1);

    String fName2 = UUID.randomUUID() + ".txt";
    String name2 = "local/" + fName2;
    TestUtils.writeToFS(cfg, name2);

    String dst = "local/cp/";
    shell.mkdir(dst);
    shell.cp(name1, name2, dst);

    assertTrue(shell.test(dst + fName1));
    assertTrue(shell.test(dst + fName2));
    assertEquals(shell.cat(name1).toString(), shell.cat(dst + fName1).toString());
    assertEquals(shell.cat(name2).toString(), shell.cat(dst + fName2).toString());
  }
コード例 #7
0
  @Test
  public void testMvMulti() throws Exception {
    String name1 = UUID.randomUUID() + "-1.txt";
    String name2 = UUID.randomUUID() + "-2.txt";
    String dst = "local/";
    String mv = "local/mv/";

    Resource res1 = TestUtils.writeToFS(cfg, dst + name1);
    Resource res2 = TestUtils.writeToFS(cfg, dst + name2);

    assertTrue(res1.exists());
    assertTrue(res2.exists());

    shell.mkdir(mv);

    shell.mv(dst + name1, mv);
    shell.mv(dst + name2, mv);

    assertTrue(shell.test(mv + name1));
    assertTrue(shell.test(mv + name2));
    assertFalse(shell.test(dst + name1));
    assertFalse(shell.test(dst + name2));
  }
コード例 #8
0
 @Test
 public void testCopyToLocal() throws Exception {
   String fName = UUID.randomUUID() + ".txt";
   String name = "local/" + fName;
   Resource res = TestUtils.writeToFS(cfg, name);
   shell.copyToLocal(name, ".");
   File fl = new File(fName);
   try {
     assertTrue(fl.exists());
     assertArrayEquals(
         FileCopyUtils.copyToByteArray(res.getInputStream()), FileCopyUtils.copyToByteArray(fl));
   } finally {
     fl.delete();
   }
 }
コード例 #9
0
  @Test
  public void testMvSingle() throws Exception {
    String name1 = UUID.randomUUID() + "-1.txt";
    String dst = "local/";
    String mv = "local/mv" + name1;

    Resource res1 = TestUtils.writeToFS(cfg, dst + name1);

    assertTrue(res1.exists());

    shell.mv(dst + name1, mv);

    assertTrue(shell.test(mv));
    assertFalse(shell.test(dst + name1));
  }
コード例 #10
0
 {
   System.setProperty("java.io.tmpdir", "");
   TestUtils.hackHadoopStagingOnWin();
 }
コード例 #11
0
 {
   TestUtils.hackHadoopStagingOnWin();
 }