@Test public void testFetchWithoutIterator() throws MdbmException, UnsupportedEncodingException { String key = "testkey"; MdbmDatum datum = new MdbmDatum(key.getBytes("UTF-8")); MdbmInterface mdbm = null; try { mdbm = MdbmProvider.open( fetchMdbmV3Path, Open.MDBM_CREATE_V3 | Open.MDBM_O_RDWR | Open.MDBM_O_CREAT, 0755, 0, 0); mdbm.plock(datum, 0); mdbm.store(datum, datum, Constants.MDBM_REPLACE, mdbm.iterator()); mdbm.punlock(datum, 0); System.err.println("Calling fetch"); MdbmDatum data = mdbm.fetch(datum); Assert.assertNotNull(data); Assert.assertNotNull(data.getData()); Assert.assertEquals(new String(data.getData()), key); } finally { if (null != mdbm) mdbm.close(); } }
@Test public void testFetchString() throws MdbmException, UnsupportedEncodingException { String key = "testkey"; MdbmDatum datum = new MdbmDatum(key.getBytes("UTF-8")); MdbmInterface mdbm = null; try { mdbm = MdbmProvider.open( fetchMdbmV3Path, Open.MDBM_CREATE_V3 | Open.MDBM_O_RDWR | Open.MDBM_O_CREAT, 0755, 0, 0); mdbm.plock(datum, 0); mdbm.storeString(key, key, Constants.MDBM_REPLACE); mdbm.punlock(datum, 0); Assert.assertEquals(mdbm.fetchString(key), key); } finally { if (null != mdbm) mdbm.close(); } }