@Test public void testLong() { DB db = DBMaker.memoryDB().make(); Map m = db.treeMap("test").keySerializer(Serializer.LONG).createOrOpen(); for (long i = 0; i < 1000; i++) { m.put(i * i, i * i + 1); } for (long i = 0; i < 1000; i++) { assertEquals(i * i + 1, m.get(i * i)); } }
@Test public void testString() { DB db = DBMaker.memoryDB().make(); Map m = db.treeMap("test").keySerializer(Serializer.STRING).createOrOpen(); List<String> list = new ArrayList<String>(); for (long i = 0; i < 1000; i++) { String s = "" + Math.random() + (i * i * i); m.put(s, s + "aa"); } for (String s : list) { assertEquals(s + "aa", m.get(s)); } }