public void testNode() throws BackingStoreException {
   assertNull(storage.toFolder());
   assertNull(storage.toPropertiesFile());
   pref.flush();
   assertNull(storage.toFolder());
   assertNull(storage.toPropertiesFile());
   pref.put("key", "value");
 }
  public void testRemove() throws BackingStoreException {
    assertNull(storage.toFolder());
    assertNull(storage.toPropertiesFile());

    pref.put("key", "value");
    pref.flush();
    assertNotNull(storage.toPropertiesFile());
    pref.remove("key");
    assertTrue(pref.properties.isEmpty());
    pref.flush();
    assertNull(storage.toPropertiesFile());
  }
  private void deleteStorageEntry(String key) throws IOException {
    String currentText = storage.toPropertiesFile().asText();
    int index = currentText.indexOf(key);

    String before = currentText.substring(0, index);
    String after = currentText.substring(index + key.length() + 1);
    String newText = before.concat(after);

    OutputStream storageOutputStream = storage.toPropertiesFile().getOutputStream();
    storageOutputStream.write(newText.getBytes("ISO-8859-1"));
    storageOutputStream.close();
  }
 private void overrideStorageEntryWithNewValue(String oldValue, String newValue)
     throws IOException {
   String newText = constructNewEntryText(oldValue, newValue);
   OutputStream storageOutputStream = storage.toPropertiesFile().getOutputStream();
   storageOutputStream.write(newText.getBytes("ISO-8859-1"));
   storageOutputStream.close();
 }
 public void testNode5() throws BackingStoreException {
   Preferences child = pref.node("a");
   child.put("key", "value");
   child.flush();
   assertNotNull(storage.toFolder());
   assertNull(storage.toPropertiesFile());
 }
  public void testRemoveParentNode() throws BackingStoreException {
    assertNull(storage.toFolder());
    assertNull(storage.toPropertiesFile());

    Preferences subnode = pref.node("subnode");
    assertNull(storage.toFolder());
    assertNull(storage.toPropertiesFile());
    subnode.put("key", "value");
    subnode.flush();
    assertNotNull(storage.toFolder());
    assertNull(storage.toPropertiesFile());
    subnode.removeNode();
    pref.flush();
    assertNull(storage.toPropertiesFile());
    assertNull(storage.toFolder());
    assertFalse(storage.existsNode());
  }
  @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();
  }
 private String constructNewEntryText(String oldValue, String newValue) throws IOException {
   String currentText = storage.toPropertiesFile().asText();
   String newText = currentText.replace(oldValue, newValue);
   return newText;
 }
 private void overrideStorageEntryWithNewData(String newData) throws IOException {
   OutputStream storageOutputStream = storage.toPropertiesFile(true).getOutputStream();
   storageOutputStream.write(newData.getBytes("ISO-8859-1"));
   storageOutputStream.close();
 }
 public void testNode3() throws BackingStoreException {
   testNode();
   pref.flushTask.waitFinished();
   assertNotNull(storage.toPropertiesFile());
 }
 public void testNode2() throws BackingStoreException {
   testNode();
   pref.flush();
   assertNotNull(storage.toPropertiesFile());
 }