Skip to content

Commit

Permalink
update CacheTest
Browse files Browse the repository at this point in the history
  • Loading branch information
lxb1111 committed Dec 9, 2021
1 parent fc84151 commit 1f04cbf
Showing 1 changed file with 22 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -216,6 +216,28 @@ protected Cache<Id, Object> newCache(long capacity) {
OffheapCache l2cache = (OffheapCache) super.newCache(capacity);
return new LevelCache(l1cache, l2cache);
}

@Test
@Override
public void testUpdateAndGetWithInvalidDataType() {
// LevelCache includes level-1 RamCache, which can cache any object
Cache<Id, Object> cache = newCache();
Id id = IdGenerator.of("1");

cache.update(id, 'c');
Assert.assertEquals('c', cache.get(id));

Object obj = new Object();
cache.update(id, obj);
Assert.assertEquals(obj, cache.get(id));

byte[] bytes = new byte[]{1};
cache.update(id, bytes);
Assert.assertArrayEquals(bytes, (byte[]) cache.get(id));

cache.update(id, "string");
Assert.assertEquals("string", cache.get(id));
}
}

@Test
Expand Down

0 comments on commit 1f04cbf

Please sign in to comment.