File tree 1 file changed +29
-0
lines changed
formats/avro/src/test/java/io/cloudevents/avro
1 file changed +29
-0
lines changed Original file line number Diff line number Diff line change @@ -60,4 +60,33 @@ public void testSerde() {
60
60
assertThat (cloudEvent2 .getType ()).isEqualTo ("testdata" );
61
61
}
62
62
63
+ @ Test
64
+ public void testV03Serde () {
65
+ EventFormat avroFormat = new AvroFormat ();
66
+ CloudEventData cloudEventData = new AvroCloudEventDataWrapper (testData );
67
+
68
+ assertThat (cloudEventData ).isNotNull ();
69
+ assertThat (cloudEventData .toBytes ()).isNotNull ();
70
+
71
+ CloudEvent cloudEvent = CloudEventBuilder .v03 ()
72
+ .withId ("1" )
73
+ .withType ("testdata" )
74
+ .withSource (URI .create ("http://localhost/test" ))
75
+ .withData ("application/avro" , cloudEventData )
76
+ .build ();
77
+ assertThat (cloudEvent ).isNotNull ();
78
+ assertThat (cloudEvent .getSpecVersion ()).isEqualTo (SpecVersion .V03 );
79
+
80
+ byte [] bytes = avroFormat .serialize (cloudEvent );
81
+
82
+ assertThat (bytes ).isNotNull ();
83
+ assertThat (bytes ).hasSizeGreaterThan (0 );
84
+
85
+ CloudEvent cloudEvent2 = avroFormat .deserialize (bytes );
86
+
87
+ assertThat (cloudEvent2 ).isNotNull ();
88
+ assertThat (cloudEvent2 .getId ()).isEqualTo ("1" );
89
+ assertThat (cloudEvent2 .getType ()).isEqualTo ("testdata" );
90
+ }
91
+
63
92
}
You can’t perform that action at this time.
0 commit comments