@Test public void testSerialize() throws IOException, ClassNotFoundException { final ByteArrayOutputStream out = new ByteArrayOutputStream(); final String myObject = "myObject"; final ObjectSerDe serDe = new ObjectSerDe(); serDe.serialize(myObject, out); final ByteArrayInputStream bIn = new ByteArrayInputStream(out.toByteArray()); final ObjectInputStream in = new ObjectInputStream(bIn); final Object deserialized = in.readObject(); Assert.assertTrue(deserialized instanceof String); Assert.assertEquals(myObject, deserialized); }
@Override public void serialize(Object value, OutputStream output) throws SerializationException, IOException { try (final ByteArrayOutputStream bOut = new ByteArrayOutputStream(); final ObjectOutputStream objOut = new ObjectOutputStream(bOut)) { objOut.writeObject(value); output.write(bOut.toByteArray()); } }
ObjectSerDe implements Serializer<Object>, Deserializer<Object> { @Override public void serialize(Object value, OutputStream output) throws SerializationException, IOException { try (final ByteArrayOutputStream bOut = new ByteArrayOutputStream(); final ObjectOutputStream objOut = new ObjectOutputStream(bOut)) { objOut.writeObject(value); output.write(bOut.toByteArray()); } } }
ObjectSerDe implements Serializer<Object>, Deserializer<Object> { @Override public void serialize(Object value, OutputStream output) throws SerializationException, IOException { try (final ByteArrayOutputStream bOut = new ByteArrayOutputStream(); final ObjectOutputStream objOut = new ObjectOutputStream(bOut)) { objOut.writeObject(value); output.write(bOut.toByteArray()); } }  }
ObjectSerDe implements Serializer<Object>, Deserializer<Object> { @Override public void serialize(Object value, OutputStream output) throws SerializationException, IOException { try (final ByteArrayOutputStream bOut = new ByteArrayOutputStream(); final ObjectOutputStream objOut = new ObjectOutputStream(bOut)) { objOut.writeObject(value); output.write(bOut.toByteArray()); } }  @Override Object deserialize(byte[] input); @Override void serialize(Object value, OutputStream output); }
ObjectSerDe implements Serializer<Object>, Deserializer<Object> { @Override public void serialize(Object value, OutputStream output) throws SerializationException, IOException { try (final ByteArrayOutputStream bOut = new ByteArrayOutputStream(); final ObjectOutputStream objOut = new ObjectOutputStream(bOut)) { objOut.writeObject(value); output.write(bOut.toByteArray()); } }  @Override Object deserialize(byte[] input); @Override void serialize(Object value, OutputStream output);  }