@Test public void testDataRoot() throws IOException { RuntimeEnvironment instance = RuntimeEnvironment.getInstance(); assertNull(instance.getDataRootFile()); assertNull(instance.getDataRootPath()); File f = File.createTempFile("dataroot", null); String path = f.getCanonicalPath(); assertTrue(f.delete()); assertFalse(f.exists()); instance.setDataRoot(path); // setDataRoot() used to create path if it didn't exist, but that // logic has been moved. Verify that it is so. assertFalse(f.exists()); assertTrue(f.mkdirs()); assertEquals(path, instance.getDataRootPath()); assertEquals(path, instance.getDataRootFile().getCanonicalPath()); }
@Test public void testBug3095() throws IOException { RuntimeEnvironment instance = RuntimeEnvironment.getInstance(); File file = new File("foobar"); assertTrue(file.createNewFile()); assertFalse(file.isAbsolute()); instance.setDataRoot(file.getName()); File f = instance.getDataRootFile(); assertNotNull(f); assertEquals("foobar", f.getName()); assertTrue(f.isAbsolute()); assertTrue(file.delete()); }