/** * Test file open in case it doesn't exist both locally and remotely. * * @throws Exception If failed. */ @Test public void testOpenDoesNotExist() throws Exception { igfsSecondary.delete(FILE.toString(), false); GridTestUtils.assertThrows(log(), new Callable<Object>() { @Override public Object call() throws Exception { IgfsInputStream is = null; try { is = igfs.open(FILE); } finally { U.closeQuiet(is); } return null; } }, IgfsPathNotFoundException.class, "File not found: " + FILE); }
/** * Test subsequent "create" commands on the same file without closing the output streams. * * @throws Exception If failed. */ @Test public void testCreateNoClose() throws Exception { if (mode != PRIMARY) return; create(igfs, paths(DIR, SUBDIR), null); GridTestUtils.assertThrows(log(), new Callable<Object>() { @Override public Object call() throws Exception { IgfsOutputStream os1 = null; IgfsOutputStream os2 = null; try { os1 = igfs.create(FILE, true); os2 = igfs.create(FILE, true); } finally { U.closeQuiet(os1); U.closeQuiet(os2); } return null; } }, IgfsException.class, null); }
/** * Test subsequent "append" commands on the same file without closing the output streams. * * @throws Exception If failed. */ @Test public void testAppendNoClose() throws Exception { if (mode != PRIMARY) return; if (appendSupported()) { create(igfs, paths(DIR, SUBDIR), null); createFile(igfs, FILE, false); GridTestUtils.assertThrowsInherited(log(), new Callable<Object>() { @Override public Object call() throws Exception { IgfsOutputStream os1 = null; IgfsOutputStream os2 = null; try { os1 = igfs.append(FILE, false); os2 = igfs.append(FILE, false); } finally { U.closeQuiet(os1); U.closeQuiet(os2); } return null; } }, IgniteException.class, null); } }