@Test public void testSomeMethod() throws IOException { TestKryoStreamCodec coder = new TestKryoStreamCodec(); TestKryoStreamCodec decoder = new TestKryoStreamCodec(); KryoSerializableStreamCodec<Object> objCoder = new KryoSerializableStreamCodec<Object>(); Slice sliceOfObj = objCoder.toByteArray(10); Integer decodedObj = (Integer) objCoder.fromByteArray(sliceOfObj); Assert.assertEquals("codec", decodedObj.intValue(), 10); TestTuple tp = new TestTuple(5); Slice dsp1 = coder.toByteArray(tp); Slice dsp2 = coder.toByteArray(tp); Assert.assertEquals(dsp1, dsp2); Object tcObject1 = decoder.fromByteArray(dsp1); assert (tp.equals(tcObject1)); Object tcObject2 = decoder.fromByteArray(dsp2); assert (tp.equals(tcObject2)); dsp1 = coder.toByteArray(tp); dsp2 = coder.toByteArray(tp); Assert.assertEquals(dsp1, dsp2); }
@Test public void testFinalFieldSerialization() throws Exception { TestTuple t1 = new TestTuple(5); TestKryoStreamCodec codec = new TestKryoStreamCodec(); Slice dsp = codec.toByteArray(t1); TestTuple t2 = (TestTuple) codec.fromByteArray(dsp); Assert.assertEquals("", t1.field, t2.field); }