Skip to content

Commit 7553e76

Browse files
committed
Add a failing test for #177
1 parent 970786b commit 7553e76

File tree

1 file changed

+41
-0
lines changed

1 file changed

+41
-0
lines changed
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
package com.fasterxml.jackson.dataformat.avro.failing;
2+
3+
import org.apache.avro.Schema;
4+
import org.apache.avro.SchemaBuilder;
5+
6+
import com.fasterxml.jackson.annotation.JsonAutoDetect;
7+
8+
import com.fasterxml.jackson.dataformat.avro.AvroMapper;
9+
import com.fasterxml.jackson.dataformat.avro.AvroSchema;
10+
import com.fasterxml.jackson.dataformat.avro.AvroTestBase;
11+
12+
public class EmptyRecordRead177Test extends AvroTestBase
13+
{
14+
private final AvroMapper MAPPER = getMapper();
15+
16+
private Schema SCHEMA = SchemaBuilder
17+
.builder(EmptyRecordRead177Test.class.getName() + "$")
18+
.record(Empty.class.getSimpleName())
19+
.fields()
20+
.endRecord();
21+
22+
@JsonAutoDetect // just a marker to avoid "no properties found" exception
23+
static final class Empty {
24+
@Override
25+
public boolean equals(Object o) {
26+
return o instanceof Empty;
27+
}
28+
}
29+
30+
public void testEmptyRecord() throws Exception {
31+
final Empty empty = new Empty();
32+
33+
byte[] ser = MAPPER.writer().with(new AvroSchema(SCHEMA)).writeValueAsBytes(empty);
34+
35+
final Empty result = MAPPER.readerFor(Empty.class)
36+
.with(new AvroSchema(SCHEMA))
37+
.readValue(ser);
38+
39+
assertEquals(empty, result);
40+
}
41+
}

0 commit comments

Comments
 (0)