meanbeanlib / meanbean

Automated JavaBean Testing
Apache License 2.0
15 stars 3 forks source link

Serialization testing #14

Open andreoss opened 4 years ago

andreoss commented 4 years ago

It would be nice to have a ability to check either serialization preserves object's properties (such as equality)

For example:

BeanVerifier.forClass(Entity.class)
    .withSerializer(new BeanSerializer(...))
        .withDeserializer(new BeanDeserializer(...))
    .verify()
meanbeanlib commented 4 years ago

Cool idea. On the syntax, it may make it more consistent if a Serializer and Deserializer could be set at the same time. Perhaps:

BeanVerifier.forClass(Entity.class)
    .withSerializer(new BeanSerializer(...), new BeanDeserializer(...))
    .verify()

or

BeanVerifier.forClass(Entity.class)
    .withSerializationContext(new MySerializationContext())
    .verify()

interface SerializationContext {
    byte[] serialize(Object in)
    Object deserialize(byte[] data)
}
andreoss commented 4 years ago

@meanbeanlib Great, I will give it a try