@Test protected void testSerializingByteArrays() throws Exception { byte[] bytes = new byte[10]; IntStream.range(0, 10).forEach(i -> bytes[i] = (byte) i); byte[] marshalledBytes = marshaller.objectToBuffer(bytes).getBuf(); byte[] unmarsalledBytes = (byte[]) marshaller.objectFromByteBuffer(marshalledBytes); IntStream.range(0, 10).forEach(i -> assertEquals(unmarsalledBytes[i], i)); } }
@Test protected void testObjectMarshallingTest() throws Exception { List<ByteBuffer> serializedObjects = new ArrayList<>(testObjects.size()); for (TestObject object : testObjects) { serializedObjects.add(marshaller.objectToBuffer(object)); } assert serializedObjects.size() == testObjects.size(); for (int i = 0; i < testObjects.size(); i++) { byte[] bytes = serializedObjects.get(i).getBuf(); Object testObj = testObjects.get(i); Object unmarshalledObj = marshaller.objectFromByteBuffer(bytes); assert testObj.equals(unmarshalledObj); } }