use of com.fasterxml.jackson.dataformat.avro.AvroSchema in project jvm-serializers by eishay.
the class JacksonAvroDatabind method register.
public static void register(TestGroups groups) {
ObjectMapper mapper = new ObjectMapper(new AvroFactory());
mapper.enable(SerializationFeature.WRITE_ENUMS_USING_INDEX);
JavaType type = mapper.constructType(MediaContent.class);
AvroSchema schema = new AvroSchema(Avro.Media.sMediaContent);
ObjectReader reader = mapper.readerFor(type).with(schema);
ObjectWriter writer = mapper.writerFor(type).with(schema);
groups.media.add(JavaBuiltIn.mediaTransformer, new StdJacksonDataBind<MediaContent>("avro/jackson/databind", type, mapper, reader, writer), new SerFeatures(SerFormat.JSON, SerGraph.FLAT_TREE, SerClass.ZERO_KNOWLEDGE, ""));
}
use of com.fasterxml.jackson.dataformat.avro.AvroSchema in project redisson by redisson.
the class RedissonCodecTest method testAvro.
@Test
public void testAvro() throws IOException {
AvroMapper am = new AvroMapper();
AvroSchema schema = am.schemaFor(TestObject.class);
Codec avroCodec = new AvroJacksonCodec(TestObject.class, schema);
Config config = createConfig();
config.setCodec(avroCodec);
RedissonClient redisson = Redisson.create(config);
RBucket<TestObject> b = redisson.getBucket("bucket");
b.set(new TestObject("1", "2"));
assertThat(b.get()).isEqualTo(new TestObject("1", "2"));
}
Aggregations