Conversation
formats/protobuf/src/main/java/io/cloudevents/protobuf/ProtoDataWrapper.java
Show resolved
Hide resolved
| byte[] raw1 = format.serialize(event); | ||
| io.cloudevents.CloudEvent act1 = format.deserialize(raw1); | ||
| assertThat(event).withFailMessage("Mismatch on 1st round trip").isEqualTo(act1); | ||
|
|
||
| // 2nd Round Trip | ||
| byte[] raw2 = format.serialize(act1); | ||
| io.cloudevents.CloudEvent act2 = format.deserialize(raw2); | ||
| assertThat(event).withFailMessage("Mismatch on 2nd round trip").isEqualTo(act2); | ||
|
|
||
| // 3rd Time's a charm | ||
| byte[] raw3 = format.serialize(act2); | ||
| io.cloudevents.CloudEvent act3 = format.deserialize(raw3); | ||
| assertThat(event).withFailMessage("Mismatch on 3rd round trip").isEqualTo(act3); |
There was a problem hiding this comment.
I would compare the actual bytes with each other in addition to the event
There was a problem hiding this comment.
This test is more around asserting that the CloudEvent Object is consistent across the various serialize/deserialize operations than the wire-format.
If we wanted to add that level of check I'd suggest re-working the equals() implementation from your prior comment.
There was a problem hiding this comment.
What we make sure by comparing additionally raw bytes is that also the equals method is correct
There was a problem hiding this comment.
Added new UnitTests to address byte[] equality.
|
Thanks @JemDay |
|
I think I'd like to roll-in a fix to address the inconsistencies raised by @mishap4 - that might simplify the implementation a bit more as well. |
formats/protobuf/src/test/java/io/cloudevents/protobuf/ProtobufFormatTest.java
Show resolved
Hide resolved
| byte[] raw1 = format.serialize(event); | ||
| io.cloudevents.CloudEvent act1 = format.deserialize(raw1); | ||
| assertThat(event).withFailMessage("Mismatch on 1st round trip").isEqualTo(act1); | ||
|
|
||
| // 2nd Round Trip | ||
| byte[] raw2 = format.serialize(act1); | ||
| io.cloudevents.CloudEvent act2 = format.deserialize(raw2); | ||
| assertThat(event).withFailMessage("Mismatch on 2nd round trip").isEqualTo(act2); | ||
|
|
||
| // 3rd Time's a charm | ||
| byte[] raw3 = format.serialize(act2); | ||
| io.cloudevents.CloudEvent act3 = format.deserialize(raw3); | ||
| assertThat(event).withFailMessage("Mismatch on 3rd round trip").isEqualTo(act3); |
There was a problem hiding this comment.
What we make sure by comparing additionally raw bytes is that also the equals method is correct
formats/protobuf/src/main/java/io/cloudevents/protobuf/ProtoDataWrapper.java
Show resolved
Hide resolved
|
I will get some additional/refactored tests in tomorrow whilst retaining backward compatibility |
|
I think the various comments are addressed now .. There is more change than expected in the ProtobuffFormatTest file as I (foolishly) reformatted to address the review comment ... |
…ult in corrupted data if the data was a protobuf message object. Introduced equality checks for ProtoDataWrapper. Refactored and cleaned up data-wrappers. Signed-off-by: Jem Day <Jem.Day@cliffhanger.com>
… several times (cloudevents#524) Fixed issue where mutiple serialize/de-serialize operations would result in corrupted data if the data was a protobuf message object. - Introduced equality checks for ProtoDataWrapper. - Refactored and cleaned up data-wrappers. Fixes cloudevents#523 Signed-off-by: Jem Day <Jem.Day@cliffhanger.com>
… several times (#524) (#525) Fixed issue where mutiple serialize/de-serialize operations would result in corrupted data if the data was a protobuf message object. - Introduced equality checks for ProtoDataWrapper. - Refactored and cleaned up data-wrappers. Fixes #523 Signed-off-by: Jem Day <Jem.Day@cliffhanger.com>
… several times (cloudevents#524) Fixed issue where mutiple serialize/de-serialize operations would result in corrupted data if the data was a protobuf message object. - Introduced equality checks for ProtoDataWrapper. - Refactored and cleaned up data-wrappers. Fixes cloudevents#523 Signed-off-by: Jem Day <Jem.Day@cliffhanger.com> Signed-off-by: Randi Sheaffer-Klass <97033958+skepticoitusInteruptus@users.noreply.github.com>
Fixed issue where mutiple serialize/de-serialize operations would result in corrupted data if the data was a protobuf message object.
Introduced equality checks for ProtoDataWrapper.
Refactored and cleaned up data-wrappers.
Fixes #523