use of org.apache.felix.prefs.impl.DataFileBackingStoreImpl in project felix by apache.
the class PreferencesImplTest method testAddRemoveAdd.
@Test
public void testAddRemoveAdd() throws Exception {
final BackingStore store = new DataFileBackingStoreImpl(null, Files.createTempDirectory("prefs").toFile());
final PreferencesImpl prefs = new PreferencesImpl(new PreferencesDescription(5L, null), new BackingStoreManager() {
public BackingStore getStore() throws BackingStoreException {
return store;
}
});
Preferences firstA = prefs.node("A");
firstA.node("1");
firstA.node("2");
assertEquals(1, prefs.childrenNames().length);
assertEquals(2, firstA.childrenNames().length);
firstA.removeNode();
prefs.flush();
assertEquals(0, prefs.childrenNames().length);
firstA = prefs.node("A");
assertEquals(1, prefs.childrenNames().length);
assertEquals(0, firstA.childrenNames().length);
firstA.node("1");
firstA.node("2");
assertEquals(2, firstA.childrenNames().length);
}
Aggregations