Esempio n. 1
0
 @Test
 public void testPutGetDelete() throws IOException {
   assertEquals("Empty store", 0, store.count());
   assertNull("Should find no previous record", store.put(record));
   assertEquals("Empty store", 1, store.count());
   assertEquals("Should find the record by key.", record, this.store.get(key));
   assertEquals("Should delete the record and return previous", record, this.store.delete(key));
   assertEquals("Empty store", 0, store.count());
   assertNull("Should not find the record by key.", this.store.get(key));
 }
Esempio n. 2
0
 @Test
 public void testOverwrite() throws IOException {
   assertNull("Should find no previous record", store.put(record));
   assertEquals("Should find the record by key.", record, this.store.get(key));
   assertEquals("Should find the record by key.", record, this.store.put(record2));
   assertEquals("Should find the record by key.", record2, this.store.get(key));
 }
Esempio n. 3
0
 private List<Record> records(HashStore store) {
   ClosableIterator<Record> iter = store.iterator();
   List<Record> l = new ArrayList<Record>();
   while (iter.hasNext()) l.add(iter.next());
   iter.close();
   return l;
 }
Esempio n. 4
0
  @Test
  public void testRecoveryCorruptMessage() throws IOException {
    List<Record> records = StoreTestUtils.randomRecords(10);
    putAll(records);

    // append a message with a crc that won't possibly validate
    Record invalid = new Record(ByteBuffer.wrap(StoreTestUtils.randomBytes(10)));
    store.log().append(invalid);
    this.store.close();
    this.store = new HashStore(config);
    // assertEquals("Same records should be present after close and re-open", records,
    // records(store));
  }