KryoWritableWrapper implements Writable { public T get() { return object; } KryoWritableWrapper(T object);  KryoWritableWrapper(); T get(); void set(T object); @Override void readFields(DataInput in); @Override void write(DataOutput out); static Writable wrapIfNeeded(Object object); static T unwrapIfNeeded(Writable value); static T wrapAndCopy(T object); static byte [] convertToByteArray(T object); static T convertFromByteArray(byte [] arr);  }
@Test public void testArraysAsList() throws IOException { List res = kryoSerDeser(Arrays.asList(1, 2, 3)); assertEquals(3, res.size()); assertEquals(1, res.get(0)); assertEquals(2, res.get(1)); assertEquals(3, res.get(2)); }
@Test public void testCollectionsNCopiesList() throws IOException { List res = kryoSerDeser(Collections.nCopies(3, 42)); assertEquals(3, res.size()); assertEquals(42, res.get(0)); assertEquals(42, res.get(1)); assertEquals(42, res.get(2)); }
@Test public void testCollectionsNCopiesObjectList() throws IOException { String testObject = "Hello World!"; List<String> res = kryoSerDeser(Collections.nCopies(3, testObject)); assertEquals(3, res.size()); assertEquals(testObject, res.get(0)); assertEquals(testObject, res.get(1)); assertEquals(testObject, res.get(2)); }
@Test public void testImmutableList() throws IOException { { List res = kryoSerDeser(ImmutableList.of(1, 2)); assertEquals(2, res.size()); assertEquals(1, res.get(0)); assertEquals(2, res.get(1)); } { List list = ImmutableList.of(1, 2, 3); Object obj = new Object(); List wanted = ImmutableList.of(list, list, obj, obj); List res = kryoSerDeser(wanted); assertTrue(res.get(0) == res.get(1)); assertTrue(res.get(2) == res.get(3)); } }
@Test(expected=RuntimeException.class) public void testRecursive() throws ClassNotFoundException, IOException { kryoSerDeser(new KryoWritableWrapper<>(new Object())).get().hashCode(); }