ContextStore implements Iterable<Resource> { void sync() throws IOException { if (contentsChanged) { writeContextsToFile(); contentsChanged = false; } } ContextStore(NativeSailStore store, File dataDir); @Override Iterator<Resource> iterator();  }
@Test public void testSync() throws Exception { File datafile = new File(dir, "contexts.dat"); assertThat(datafile.exists()); long size = datafile.length(); assertThat(size).isEqualTo(8L); subject.increment(g1); subject.sync(); assertThat(datafile.length()).isGreaterThan(8L); subject.decrementBy(g1, 1); subject.sync(); assertThat(datafile.length()).isEqualTo(8L); }