public static void rm(File file) { if (!file.exists()) { return; } if (file.isDirectory()) { for (File f : file.listFiles()) { rm(f); } } file.delete(); }
@Test public void testRandomAccessWrites() throws IOException { int i = 0; try { for (; i < 10; i++) { Directory fsDir = FSDirectory.open(new File(file, "normal")); String name = getName(); createFile(name, fsDir, directory); assertInputsEquals(name, fsDir, directory); } } catch (Exception e) { e.printStackTrace(); fail("Test failed with seed [" + seed + "] on pass [" + i + "]"); } }
@Before public void setUp() throws IOException { file = new File("./tmp"); rm(file); file.mkdirs(); FSDirectory dir = FSDirectory.open(new File(file, "base")); directory = new BlockDirectory("test", dir, getBasicCache()); seed = new Random().nextLong(); random = new Random(seed); }
@Test public void testEOF() throws IOException { Directory fsDir = FSDirectory.open(new File(file, "normal")); String name = "test.eof"; createFile(name, fsDir, directory); long fsLength = fsDir.fileLength(name); long hdfsLength = directory.fileLength(name); assertEquals(fsLength, hdfsLength); testEof(name, fsDir, fsLength); testEof(name, directory, hdfsLength); }