Ejemplo n.º 1
0
  /** Tests whether different stores are really independent. */
  public void testIndependentStores() throws StorageException {
    IStore store2 = storageSystem.openStore("other");

    store.put(KEY, VALUE);
    assertTrue(Arrays.equals(VALUE, store.get(KEY)));
    assertNull(store2.get(KEY));
  }
Ejemplo n.º 2
0
  /** Tests removal of elements. */
  public void testRemoveElement() throws StorageException {
    store.put(KEY, VALUE);
    assertTrue(Arrays.equals(VALUE, store.get(KEY)));

    store.remove(KEY);
    assertNull(store.get(KEY));
  }
Ejemplo n.º 3
0
  /** Tests whether data is really lost during deletion of store. */
  public void testDeleteStore() throws StorageException {
    store.put(KEY, VALUE);
    assertTrue(Arrays.equals(VALUE, store.get(KEY)));

    storageSystem.removeStore(STORE);
    store = storageSystem.openStore(STORE);
    assertNull(store.get(KEY));
  }
Ejemplo n.º 4
0
  /** Tests whether persistence between open/close works. */
  public void testPersistence() throws StorageException {
    store.put(KEY, VALUE);
    assertTrue(Arrays.equals(VALUE, store.get(KEY)));

    storageSystem.close();
    storageSystem = openStorage(baseDir);

    store = storageSystem.openStore(STORE);
    assertTrue(Arrays.equals(VALUE, store.get(KEY)));
  }
Ejemplo n.º 5
0
  /** Tests the very basic set/get interface. */
  public void testSetGet() throws StorageException {
    // key does not exist in empty store
    assertNull(store.get(KEY));

    // put affects result of get
    store.put(KEY, VALUE);
    assertTrue(Arrays.equals(VALUE, store.get(KEY)));

    // other keys do not affect result of get
    store.put(new byte[] {7, 8, 9}, new byte[] {17, 18, 19});
    assertTrue(Arrays.equals(VALUE, store.get(KEY)));
  }
Ejemplo n.º 6
0
  /** Test for multi-get and set. */
  public void testSetGetMultiple() throws StorageException {
    PairList<byte[], byte[]> entries = new PairList<byte[], byte[]>();
    entries.add(new byte[] {1}, new byte[] {1});
    entries.add(new byte[] {2}, new byte[] {2});
    store.put(entries);
    List<byte[]> values = store.get(Arrays.asList(new byte[] {1}, new byte[] {3}, new byte[] {2}));
    assertEquals(3, values.size());
    assertTrue(Arrays.equals(new byte[] {1}, values.get(0)));
    assertNull(values.get(1));
    assertTrue(Arrays.equals(new byte[] {2}, values.get(2)));

    store.remove(entries.extractFirstList());
    store.scan(new byte[] {}, callback);
    assertEquals(0, callback.keys.size());
  }