### Question:
FileStoreUtil { static public boolean areOnSameFileStore(File a, File b) throws RolloverFailure { if (!a.exists()) { throw new IllegalArgumentException("File [" + a + "] does not exist."); } if (!b.exists()) { throw new IllegalArgumentException("File [" + b + "] does not exist."); } try { Class<?> pathClass = Class.forName(PATH_CLASS_STR); Class<?> filesClass = Class.forName(FILES_CLASS_STR); Method toPath = File.class.getMethod("toPath"); Method getFileStoreMethod = filesClass.getMethod("getFileStore", pathClass); Object pathA = toPath.invoke(a); Object pathB = toPath.invoke(b); Object fileStoreA = getFileStoreMethod.invoke(null, pathA); Object fileStoreB = getFileStoreMethod.invoke(null, pathB); return fileStoreA.equals(fileStoreB); } catch (Exception e) { throw new RolloverFailure("Failed to check file store equality for [" + a + "] and [" + b + "]", e); } }  static boolean areOnSameFileStore(File a, File b);  }### Answer:
@Test public void filesOnSameFolderShouldBeOnTheSameFileStore() throws RolloverFailure, IOException { if(!EnvUtil.isJDK7OrHigher()) return; File parent = new File(pathPrefix); File file = new File(pathPrefix+"filesOnSameFolderShouldBeOnTheSameFileStore"); FileUtil.createMissingParentDirectories(file); file.createNewFile(); assertTrue(FileStoreUtil.areOnSameFileStore(parent, file)); }
@Ignore @Test public void manual_filesOnDifferentVolumesShouldBeDetectedAsSuch() throws RolloverFailure { if(!EnvUtil.isJDK7OrHigher()) return; File c = new File("c:/tmp/"); File d = new File("d:/"); assertFalse(FileStoreUtil.areOnSameFileStore(c, d)); }