From 2173228b27d01881514dbacb746fd9633348780c Mon Sep 17 00:00:00 2001 From: Dominic Fox Date: Tue, 26 Feb 2019 18:22:32 +0000 Subject: [PATCH] Unit test covering https://r3-cev.atlassian.net/browse/CORDA-2674 --- .../internal/amqp/JavaEvolutionTests.java | 49 ++++++++++++++++++ .../JavaEvolutionTests.testNullableInteger | Bin 0 -> 261 bytes 2 files changed, 49 insertions(+) create mode 100644 serialization/src/test/resources/net/corda/serialization/internal/amqp/JavaEvolutionTests.testNullableInteger diff --git a/serialization/src/test/java/net/corda/serialization/internal/amqp/JavaEvolutionTests.java b/serialization/src/test/java/net/corda/serialization/internal/amqp/JavaEvolutionTests.java index fa8449840e..f488505710 100644 --- a/serialization/src/test/java/net/corda/serialization/internal/amqp/JavaEvolutionTests.java +++ b/serialization/src/test/java/net/corda/serialization/internal/amqp/JavaEvolutionTests.java @@ -97,4 +97,53 @@ public class JavaEvolutionTests { N2.class, TestSerializationContext.testSerializationContext); } + + // Class as it was when it was serialized and written to disk. Uncomment + // if the test referencing the object needs regenerating. + /* + @SuppressWarnings("unused") + static class POJOWithInteger { + private Integer id; + + public Integer getId() { + return id; + } + + public void setId(Integer id) { + this.id = id; + } + } + */ + + public interface ForceEvolution { } + + // Class as it exists now with the newly added element + @SuppressWarnings("unused") + static class POJOWithInteger implements ForceEvolution { + private Integer id; + + public Integer getId() { + return id; + } + + public void setId(Integer id) { + this.id = id; + } + } + + @Test + public void testNullableInteger() throws IOException { + // Uncomment to regenerate the base state of the test + //POJOWithInteger n = new POJOWithInteger(); + //n.setId(100); + //AMQPTestUtilsKt.writeTestResource(this, new SerializationOutput(factory).serialize( + // n, TestSerializationContext.testSerializationContext)); + + POJOWithInteger n2 = new DeserializationInput(factory).deserialize( + new SerializedBytes<>(AMQPTestUtilsKt.readTestResource(this)), + POJOWithInteger.class, + TestSerializationContext.testSerializationContext); + + assertEquals(Integer.valueOf(100), n2.getId()); + } } diff --git a/serialization/src/test/resources/net/corda/serialization/internal/amqp/JavaEvolutionTests.testNullableInteger b/serialization/src/test/resources/net/corda/serialization/internal/amqp/JavaEvolutionTests.testNullableInteger new file mode 100644 index 0000000000000000000000000000000000000000..4d60a11a6011eaacde85d8e7a9c12f58989aaf2d GIT binary patch literal 261 zcmYe!FG@*dWME)uIGO|`85kH3d}L-=tdy5pqL&PkvvT(^3-IwZ_VFxCO)DrZH%YIE zNQ-o|wLQSh7?J|l#&lpU1F1Xq!#5R z=IABn78dAvC6*<+mgVP^g5*L{i%W`C0{p%F!!t`VJb?<+Q;Qs2;RZ7wP-7y-c@76; e5Uyc4z|X#rDKljuGtg#N2L~r7xOtoh85sb>d{OHF literal 0 HcmV?d00001