@@ -37,23 +37,23 @@ public class TestAvroEncode {
3737 @ Test
3838 void testWithinClass () throws IOException {
3939
40- var wrapper = new Wrapper (new R1 ("test " ));
40+ var wrapper = new Wrapper (new R1 ("321 " ));
4141
4242 var read = readWrite (wrapper );
4343
44- assertEquals ("test " , wrapper .getR1 ().getValue ());
45- assertEquals ("test used this" , read .getR1 ().getValue ());
44+ assertEquals ("321 " , wrapper .getR1 ().getValue ());
45+ assertEquals ("321 used this" , read .getR1 ().getValue ());
4646 }
4747
4848 @ Test
4949 void testDirect () throws IOException {
5050
51- var r1 = new R1 ("test " );
51+ var r1 = new R1 ("123 " );
5252
5353 var read = readWrite (r1 );
5454
55- assertEquals ("test " , r1 .getValue ());
56- assertEquals ("test used this" , read .getValue ());
55+ assertEquals ("123 " , r1 .getValue ());
56+ assertEquals ("123 used this" , read .getValue ());
5757 }
5858
5959 @ Test
@@ -127,14 +127,15 @@ public String getValue() {
127127 public static class R1Encoding extends CustomEncoding <R1 > {
128128
129129 {
130- schema = Schema .createRecord ("R1" , null , null , false ,
131- Arrays .asList (new Schema .Field ("value" , Schema .create (Schema .Type .STRING ), null , null )));
130+ schema = Schema .createRecord ("R1" , null , "org.apache.avro.reflect.TestAvroEncode" , false ,
131+ Arrays .asList (new Schema .Field ("value" , Schema .create (Schema .Type .INT ), null , null )));
132132 }
133133
134134 @ Override
135135 protected void write (Object datum , Encoder out ) throws IOException {
136136 if (datum instanceof R1 ) {
137- out .writeString (((R1 ) datum ).getValue ());
137+ var value = ((R1 ) datum ).getValue ();
138+ out .writeInt (Integer .parseInt (value ));
138139 } else {
139140 throw new AvroTypeException ("Expected R1, got " + datum .getClass ());
140141 }
@@ -143,7 +144,7 @@ protected void write(Object datum, Encoder out) throws IOException {
143144
144145 @ Override
145146 protected R1 read (Object reuse , Decoder in ) throws IOException {
146- return new R1 (in .readString () + " used this" );
147+ return new R1 (in .readInt () + " used this" );
147148 }
148149 }
149150
0 commit comments