}
public void testEncodeDecode() {
// simple type
CachedData cachedData = tokyoTyrantTranscoder.encode(1);
assertEquals(8, cachedData.getData().length);
assertEquals(1, tokyoTyrantTranscoder.decode(cachedData));
long currentTimeMillis = System.currentTimeMillis();
cachedData = tokyoTyrantTranscoder.encode(currentTimeMillis);
assertEquals(12, cachedData.getData().length);
assertEquals(currentTimeMillis, tokyoTyrantTranscoder
.decode(cachedData));
cachedData = tokyoTyrantTranscoder.encode("hello");
assertEquals(9, cachedData.getData().length);
assertEquals("hello", tokyoTyrantTranscoder.decode(cachedData));
cachedData = tokyoTyrantTranscoder.encode(2.3d);
assertEquals(12, cachedData.getData().length);
assertEquals(2.3d, tokyoTyrantTranscoder.decode(cachedData));
// collection
List<String> list = new ArrayList<String>();
list.add("1");
cachedData = tokyoTyrantTranscoder.encode(list);
int oldLength = cachedData.getData().length;
List<String> decodedList = (List) tokyoTyrantTranscoder
.decode(cachedData);
assertEquals(1, decodedList.size());
assertTrue(decodedList.contains("1"));