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());
  }
  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 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());
  }