public void testRemove2() throws BackingStoreException { assertNull(storage.toFolder()); assertNull(storage.toPropertiesFile()); pref.put("key", "value"); pref.put("key1", "value1"); pref.flush(); assertNotNull(storage.toPropertiesFile()); pref.remove("key"); assertFalse(pref.properties.isEmpty()); pref.flush(); assertNotNull(storage.toPropertiesFile()); }
public void testClear() throws BackingStoreException { assertNull(storage.toFolder()); assertNull(storage.toPropertiesFile()); pref.put("key", "value"); pref.put("key1", "value"); pref.put("key2", "value"); pref.put("key3", "value"); pref.put("key5", "value"); pref.flush(); assertNotNull(storage.toPropertiesFile()); pref.clear(); pref.flush(); assertNull(storage.toPropertiesFile()); }
public void testKeyRemovalFireEvent() throws Exception { pref.put("key", "value"); pref.put("key0", "value10"); pref.put("key1", "value11"); pref.addPreferenceChangeListener(new PrefListener()); pref.sync(); assertEquals("value10", pref.get("key0", null)); deleteStorageEntry("key0=value10"); assertEquals(null, pref.get("key0", null)); prefRemovedEvent.await(); assertEquals( "No preference changed event was fired for key removal", 0, prefRemovedEvent.getCount()); }
public void testValueChangeFireEvent() throws Exception { pref.put("key0", "value10"); pref.addPreferenceChangeListener(new PrefListener()); pref.sync(); assertEquals("value10", pref.get("key0", null)); overrideStorageEntryWithNewData("key0=value0"); assertEquals("value0", pref.get("key0", null)); prefChangedEvent.await(); assertEquals( "No preference changed event was fired for value change", 0, prefChangedEvent.getCount()); }
@RandomlyFails // FSException: Invalid lock (from flush) public void testRemoveNode() throws BackingStoreException { assertNull(storage.toFolder()); assertNull(storage.toPropertiesFile()); pref.put("key", "value"); pref.node("subnode").put("key", "value"); pref.flush(); assertNotNull(storage.toPropertiesFile()); assertNotNull(storage.toFolder()); pref.removeNode(); pref.flush(); assertNull(storage.toPropertiesFile()); assertNull(storage.toFolder()); assertFalse(storage.existsNode()); pref.sync(); }
public void testPreferencesEvents2() throws Exception { pref.addNodeChangeListener(new NodeListener()); pref.addPreferenceChangeListener(new PrefListener()); Preferences child = pref.node("a"); nodeAddedEvent.await(); assertEquals("Missing node added event", 0, nodeAddedEvent.getCount()); pref.put("key", "value"); prefChangedEvent.await(); assertEquals("Missing preference change event", 0, prefChangedEvent.getCount()); pref.remove("key"); prefRemovedEvent.await(); assertEquals("Missing preference removed event", 0, prefRemovedEvent.getCount()); child.removeNode(); nodeRemovedEvent.await(); assertEquals("Missing node removed event", 0, nodeRemovedEvent.getCount()); }
private void storeEntry(String keyName, String oldValue) throws BackingStoreException { pref.put(keyName, oldValue); pref.flush(); }