Exemplo n.º 1
0
  /** Basic tests */
  public void testBasics() throws IOException {

    Properties props = new Properties();
    RecordManager recman =
        RecordManagerFactory.createRecordManager(TestRecordFile.testFileName, props);
    HashBucket bucket = new HashBucket(0);

    // add
    bucket.addElement("key", "value");
    String s = (String) bucket.getValue("key");
    assertEquals("value", s);

    // replace
    bucket.addElement("key", "value2");
    s = (String) bucket.getValue("key");
    assertEquals("value2", s);

    // add
    bucket.addElement("key2", "value3");
    s = (String) bucket.getValue("key2");
    assertEquals("value3", s);

    // remove
    bucket.removeElement("key2");
    s = (String) bucket.getValue("key2");
    assertEquals(null, s);
    bucket.removeElement("key");
    s = (String) bucket.getValue("key");
    assertEquals(null, s);

    recman.close();
  }
Exemplo n.º 2
0
 /** Stop the stage. */
 public void shutdown() {
   // Commit and close the database
   if (recman != null) {
     try {
       recman.commit();
       recman.close();
     } catch (Exception ex) {
       logger.warn("Unable to commit and close the database.");
     }
   }
   // Set stop so the isDown method will return the correct value.
   stop = true;
 }