示例#1
0
  @Test
  public void testSerializeIndexed() throws Exception {
    idbm.wipeDatabase();
    Random r = new Random(1L);
    Set<TestThrift> tts = new HashSet<TestThrift>();
    for (int test = 0; test < 10000; test++) {
      TestThrift tt =
          new TestThrift(
              null,
              r.nextInt(),
              r.nextLong(),
              r.nextBoolean(),
              (byte) r.nextInt(),
              (short) r.nextInt(),
              r.nextDouble(),
              generateString(r, 16),
              "abc");
      tts.add(tt);
      idbm.create(tt);
      idbm.commit();
    }

    idbm.dump(TestThrift.class, new File("."));
    idbm.wipeDatabase();

    idbm.load(TestThrift.class, new File("."));
    for (TestThrift tt : tts) {
      TestThrift tt2 = idbm.get(TestThrift.class, tt.id);
      Assert.assertEquals(tt, tt2);
    }

    new File("TestThrift.zombiedb.bz2").delete();
  }