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 testInvalidChildrenNames() throws Exception {
    NbPreferences subnode = pref;
    assertNotNull(subnode);
    PropertiesStorage ps = (PropertiesStorage) pref.fileStorage;
    FileObject fold = ps.toFolder(true);
    assertNotNull(FileUtil.createData(fold, "a/b/c/invalid1"));
    subnode.sync();
    assertEquals(0, subnode.childrenNames().length);

    assertNotNull(FileUtil.createData(fold, "a/b/c/invalid2.huh"));
    subnode.sync();
    assertEquals(0, subnode.childrenNames().length);

    assertNotNull(FileUtil.createData(fold, "a/b/c/invalid3.properties.huh"));
    subnode.sync();
    assertEquals(0, subnode.childrenNames().length);

    assertNotNull(FileUtil.createData(fold, "a/b/c/valid.properties"));
    subnode.sync();
    assertEquals(1, subnode.childrenNames().length);
    assertEquals("a", subnode.childrenNames()[0]);
  }
  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());
  }
  @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();
  }