package org.msgpack.template.builder;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;
import static org.junit.Assert.fail;
import org.junit.Test;
import org.msgpack.MessagePack;
import org.msgpack.packer.BufferPacker;
import org.msgpack.template.TemplateRegistry;
import org.msgpack.template.Template;
import org.msgpack.testclasses.AbstractClass;
import org.msgpack.testclasses.FinalClass;
import org.msgpack.testclasses.InheritanceClass;
import org.msgpack.testclasses.InheritanceClassNotNullable;
import org.msgpack.testclasses.Interface;
import org.msgpack.testclasses.ListTypeFieldsClass;
import org.msgpack.testclasses.ListTypeFieldsClassNotNullable;
import org.msgpack.testclasses.MapTypeFieldsClass;
import org.msgpack.testclasses.MapTypeFieldsClassNotNullable;
import org.msgpack.testclasses.MessagePackableTypeFieldsClass;
import org.msgpack.testclasses.MessagePackableTypeFieldsClassNotNullable;
import org.msgpack.testclasses.ModifiersFieldsClass;
import org.msgpack.testclasses.ModifiersFieldsClassNotNullable;
import org.msgpack.testclasses.PrimitiveTypeFieldsClass;
import org.msgpack.testclasses.PrimitiveTypeFieldsClassNotNullable;
import org.msgpack.testclasses.ReferenceTypeFieldsClass;
import org.msgpack.testclasses.ReferenceTypeFieldsClassNotNullable;
import org.msgpack.testclasses.UserDefinedTypeFieldsClass;
import org.msgpack.testclasses.UserDefinedTypeFieldsClassNotNullable;
import org.msgpack.type.Value;
import org.msgpack.unpacker.BufferUnpacker;
import org.msgpack.unpacker.Converter;
public class TestReflectionBeansBufferPackConvert extends TestSet {
@Test @Override
public void testPrimitiveTypeFieldsClass() throws Exception {
super.testPrimitiveTypeFieldsClass();
}
@Override
public void testPrimitiveTypeFieldsClass(PrimitiveTypeFieldsClass v) throws Exception {
MessagePack msgpack = new MessagePack();
TemplateRegistry registry = new TemplateRegistry();
ReflectionBeansTemplateBuilder builder = new ReflectionBeansTemplateBuilder(registry);
Template<PrimitiveTypeFieldsClass> tmpl = builder.buildTemplate(PrimitiveTypeFieldsClass.class);
BufferPacker packer = msgpack.createBufferPacker();
tmpl.write(packer, v);
byte[] bytes = packer.toByteArray();
BufferUnpacker u = msgpack.createBufferUnpacker();
u.wrap(bytes);
Value value = u.readValue();
Converter unpacker = new Converter(value);
PrimitiveTypeFieldsClass ret = tmpl.read(unpacker, null);
assertEquals(v, ret);
}
@Test @Override
public void testPrimitiveTypeFieldsClassNotNullable() throws Exception {
super.testPrimitiveTypeFieldsClassNotNullable();
}
@Override
public void testPrimitiveTypeFieldsClassNotNullable(PrimitiveTypeFieldsClassNotNullable v) throws Exception {
MessagePack msgpack = new MessagePack();
TemplateRegistry registry = new TemplateRegistry();
ReflectionBeansTemplateBuilder builder = new ReflectionBeansTemplateBuilder(registry);
Template<PrimitiveTypeFieldsClassNotNullable> tmpl = builder.buildTemplate(PrimitiveTypeFieldsClassNotNullable.class);
BufferPacker packer = msgpack.createBufferPacker();
tmpl.write(packer, v);
byte[] bytes = packer.toByteArray();
BufferUnpacker u = msgpack.createBufferUnpacker();
u.wrap(bytes);
Value value = u.readValue();
Converter unpacker = new Converter(value);
PrimitiveTypeFieldsClassNotNullable ret = tmpl.read(unpacker, null);
assertEquals(v, ret);
}
@Test @Override
public void testReferenceTypeFieldsClass() throws Exception {
super.testReferenceTypeFieldsClass();
}
@Override
public void testReferenceTypeFieldsClass(ReferenceTypeFieldsClass v) throws Exception {
MessagePack msgpack = new MessagePack();
TemplateRegistry registry = new TemplateRegistry();
ReflectionBeansTemplateBuilder builder = new ReflectionBeansTemplateBuilder(registry);
Template<ReferenceTypeFieldsClass> tmpl = builder.buildTemplate(ReferenceTypeFieldsClass.class);
BufferPacker packer = msgpack.createBufferPacker();
tmpl.write(packer, v);
byte[] bytes = packer.toByteArray();
BufferUnpacker u = msgpack.createBufferUnpacker();
u.wrap(bytes);
Value value = u.readValue();
Converter unpacker = new Converter(value);
ReferenceTypeFieldsClass ret = tmpl.read(unpacker, null);
assertEquals(v, ret);
}
@Test @Override
public void testReferenceTypeFieldsClassNotNullable() throws Exception {
super.testReferenceTypeFieldsClassNotNullable();
}
@Override
public void testReferenceTypeFieldsClassNotNullable(ReferenceTypeFieldsClassNotNullable v) throws Exception {
MessagePack msgpack = new MessagePack();
TemplateRegistry registry = new TemplateRegistry();
ReflectionBeansTemplateBuilder builder = new ReflectionBeansTemplateBuilder(registry);
Template<ReferenceTypeFieldsClassNotNullable> tmpl = builder.buildTemplate(ReferenceTypeFieldsClassNotNullable.class);
BufferPacker packer = msgpack.createBufferPacker();
tmpl.write(packer, v);
byte[] bytes = packer.toByteArray();
BufferUnpacker u = msgpack.createBufferUnpacker();
u.wrap(bytes);
Value value = u.readValue();
Converter unpacker = new Converter(value);
ReferenceTypeFieldsClassNotNullable ret = tmpl.read(unpacker, null);
assertEquals(v, ret);
}
@Test @Override
public void testListTypeFieldsClass() throws Exception {
super.testListTypeFieldsClass();
}
@Override
public void testListTypeFieldsClass(ListTypeFieldsClass v) throws Exception {
MessagePack msgpack = new MessagePack();
TemplateRegistry registry = new TemplateRegistry();
ReflectionBeansTemplateBuilder builder = new ReflectionBeansTemplateBuilder(registry);
Template<ListTypeFieldsClass> tmpl = builder.buildTemplate(ListTypeFieldsClass.class);
BufferPacker packer = msgpack.createBufferPacker();
tmpl.write(packer, v);
byte[] bytes = packer.toByteArray();
BufferUnpacker u = msgpack.createBufferUnpacker();
u.wrap(bytes);
Value value = u.readValue();
Converter unpacker = new Converter(value);
ListTypeFieldsClass ret = tmpl.read(unpacker, null);
assertEquals(v, ret);
}
@Test @Override
public void testListTypeFieldsClassNotNullable() throws Exception {
super.testListTypeFieldsClassNotNullable();
}
@Override
public void testListTypeFieldsClassNotNullable(ListTypeFieldsClassNotNullable v) throws Exception {
MessagePack msgpack = new MessagePack();
TemplateRegistry registry = new TemplateRegistry();
ReflectionBeansTemplateBuilder builder = new ReflectionBeansTemplateBuilder(registry);
Template<ListTypeFieldsClassNotNullable> tmpl = builder.buildTemplate(ListTypeFieldsClassNotNullable.class);
BufferPacker packer = msgpack.createBufferPacker();
tmpl.write(packer, v);
byte[] bytes = packer.toByteArray();
BufferUnpacker u = msgpack.createBufferUnpacker();
u.wrap(bytes);
Value value = u.readValue();
Converter unpacker = new Converter(value);
ListTypeFieldsClassNotNullable ret = tmpl.read(unpacker, null);
assertEquals(v, ret);
}
@Test @Override
public void testMapTypeFieldsClass() throws Exception {
super.testMapTypeFieldsClass();
}
@Override
public void testMapTypeFieldsClass(MapTypeFieldsClass v) throws Exception {
MessagePack msgpack = new MessagePack();
TemplateRegistry registry = new TemplateRegistry();
ReflectionBeansTemplateBuilder builder = new ReflectionBeansTemplateBuilder(registry);
Template<MapTypeFieldsClass> tmpl = builder.buildTemplate(MapTypeFieldsClass.class);
BufferPacker packer = msgpack.createBufferPacker();
tmpl.write(packer, v);
byte[] bytes = packer.toByteArray();
BufferUnpacker u = msgpack.createBufferUnpacker();
u.wrap(bytes);
Value value = u.readValue();
Converter unpacker = new Converter(value);
MapTypeFieldsClass ret = tmpl.read(unpacker, null);
assertEquals(v, ret);
}
@Test @Override
public void testMapTypeFieldsClassNotNullable() throws Exception {
super.testMapTypeFieldsClassNotNullable();
}
@Override
public void testMapTypeFieldsClassNotNullable(MapTypeFieldsClassNotNullable v) throws Exception {
MessagePack msgpack = new MessagePack();
TemplateRegistry registry = new TemplateRegistry();
ReflectionBeansTemplateBuilder builder = new ReflectionBeansTemplateBuilder(registry);
Template<MapTypeFieldsClassNotNullable> tmpl = builder.buildTemplate(MapTypeFieldsClassNotNullable.class);
BufferPacker packer = msgpack.createBufferPacker();
tmpl.write(packer, v);
byte[] bytes = packer.toByteArray();
BufferUnpacker u = msgpack.createBufferUnpacker();
u.wrap(bytes);
Value value = u.readValue();
Converter unpacker = new Converter(value);
MapTypeFieldsClassNotNullable ret = tmpl.read(unpacker, null);
assertEquals(v, ret);
}
@Test @Override
public void testFinalClass() throws Exception {
super.testFinalClass();
}
@Override
public void testFinalClass(FinalClass v) throws Exception {
MessagePack msgpack = new MessagePack();
TemplateRegistry registry = new TemplateRegistry();
ReflectionBeansTemplateBuilder builder = new ReflectionBeansTemplateBuilder(registry);
Template<FinalClass> tmpl = builder.buildTemplate(FinalClass.class);
BufferPacker packer = msgpack.createBufferPacker();
tmpl.write(packer, v);
byte[] bytes = packer.toByteArray();
BufferUnpacker u = msgpack.createBufferUnpacker();
u.wrap(bytes);
Value value = u.readValue();
Converter unpacker = new Converter(value);
FinalClass ret = tmpl.read(unpacker, null);
assertEquals(v, ret);
}
@Test @Override
public void testAbstractClass() throws Exception {
TemplateRegistry registry = new TemplateRegistry();
ReflectionBeansTemplateBuilder builder = new ReflectionBeansTemplateBuilder(registry);
try {
builder.buildTemplate(AbstractClass.class);
} catch (Throwable t) {
assertTrue(t instanceof TemplateBuildException);
}
}
@Test @Override
public void testInterface() throws Exception {
TemplateRegistry registry = new TemplateRegistry();
ReflectionBeansTemplateBuilder builder = new ReflectionBeansTemplateBuilder(registry);
try {
builder.buildTemplate(Interface.class);
fail();
} catch (Throwable t) {
assertTrue(t instanceof TemplateBuildException);
}
}
@Test @Override
public void testModifiersFieldsClass() throws Exception {
super.testModifiersFieldsClass();
}
@Override
public void testModifiersFieldsClass(ModifiersFieldsClass v) throws Exception {
MessagePack msgpack = new MessagePack();
TemplateRegistry registry = new TemplateRegistry();
ReflectionBeansTemplateBuilder builder = new ReflectionBeansTemplateBuilder(registry);
Template<ModifiersFieldsClass> tmpl = builder.buildTemplate(ModifiersFieldsClass.class);
BufferPacker packer = msgpack.createBufferPacker();
tmpl.write(packer, v);
byte[] bytes = packer.toByteArray();
BufferUnpacker u = msgpack.createBufferUnpacker();
u.wrap(bytes);
Value value = u.readValue();
Converter unpacker = new Converter(value);
ModifiersFieldsClass ret = tmpl.read(unpacker, null);
assertEquals(v, ret);
}
@Test @Override
public void testModifiersFieldsClassNotNullable() throws Exception {
super.testModifiersFieldsClassNotNullable();
}
@Override
public void testModifiersFieldsClassNotNullable(ModifiersFieldsClassNotNullable v) throws Exception {
MessagePack msgpack = new MessagePack();
TemplateRegistry registry = new TemplateRegistry();
ReflectionBeansTemplateBuilder builder = new ReflectionBeansTemplateBuilder(registry);
Template<ModifiersFieldsClassNotNullable> tmpl = builder.buildTemplate(ModifiersFieldsClassNotNullable.class);
BufferPacker packer = msgpack.createBufferPacker();
tmpl.write(packer, v);
byte[] bytes = packer.toByteArray();
BufferUnpacker u = msgpack.createBufferUnpacker();
u.wrap(bytes);
Value value = u.readValue();
Converter unpacker = new Converter(value);
ModifiersFieldsClassNotNullable ret = tmpl.read(unpacker, null);
assertEquals(v, ret);
}
@Test @Override
public void testUserDefinedTypeFieldsClass() throws Exception {
super.testUserDefinedTypeFieldsClass();
}
@Override
public void testUserDefinedTypeFieldsClass(UserDefinedTypeFieldsClass v) throws Exception {
MessagePack msgpack = new MessagePack();
TemplateRegistry registry = new TemplateRegistry();
ReflectionBeansTemplateBuilder builder = new ReflectionBeansTemplateBuilder(registry);
Template<UserDefinedTypeFieldsClass> tmpl = builder.buildTemplate(UserDefinedTypeFieldsClass.class);
BufferPacker packer = msgpack.createBufferPacker();
tmpl.write(packer, v);
byte[] bytes = packer.toByteArray();
BufferUnpacker u = msgpack.createBufferUnpacker();
u.wrap(bytes);
Value value = u.readValue();
Converter unpacker = new Converter(value);
UserDefinedTypeFieldsClass ret = tmpl.read(unpacker, null);
assertEquals(v, ret);
}
@Test @Override
public void testUserDefinedTypeFieldsClassNotNullable() throws Exception {
super.testUserDefinedTypeFieldsClassNotNullable();
}
@Override
public void testUserDefinedTypeFieldsClassNotNullable(UserDefinedTypeFieldsClassNotNullable v) throws Exception {
MessagePack msgpack = new MessagePack();
TemplateRegistry registry = new TemplateRegistry();
ReflectionBeansTemplateBuilder builder = new ReflectionBeansTemplateBuilder(registry);
Template<UserDefinedTypeFieldsClassNotNullable> tmpl = builder.buildTemplate(UserDefinedTypeFieldsClassNotNullable.class);
BufferPacker packer = msgpack.createBufferPacker();
tmpl.write(packer, v);
byte[] bytes = packer.toByteArray();
BufferUnpacker u = msgpack.createBufferUnpacker();
u.wrap(bytes);
Value value = u.readValue();
Converter unpacker = new Converter(value);
UserDefinedTypeFieldsClassNotNullable ret = tmpl.read(unpacker, null);
assertEquals(v, ret);
}
@Test @Override
public void testInheritanceClass() throws Exception {
super.testInheritanceClass();
}
@Override
public void testInheritanceClass(InheritanceClass v) throws Exception {
MessagePack msgpack = new MessagePack();
TemplateRegistry registry = new TemplateRegistry();
ReflectionBeansTemplateBuilder builder = new ReflectionBeansTemplateBuilder(registry);
Template<InheritanceClass> tmpl = builder.buildTemplate(InheritanceClass.class);
BufferPacker packer = msgpack.createBufferPacker();
tmpl.write(packer, v);
byte[] bytes = packer.toByteArray();
BufferUnpacker u = msgpack.createBufferUnpacker();
u.wrap(bytes);
Value value = u.readValue();
Converter unpacker = new Converter(value);
InheritanceClass ret = tmpl.read(unpacker, null);
assertEquals(v, ret);
}
@Test @Override
public void testInheritanceClassNotNullable() throws Exception {
super.testInheritanceClassNotNullable();
}
@Override
public void testInheritanceClassNotNullable(InheritanceClassNotNullable v) throws Exception {
MessagePack msgpack = new MessagePack();
TemplateRegistry registry = new TemplateRegistry();
ReflectionBeansTemplateBuilder builder = new ReflectionBeansTemplateBuilder(registry);
Template<InheritanceClassNotNullable> tmpl = builder.buildTemplate(InheritanceClassNotNullable.class);
BufferPacker packer = msgpack.createBufferPacker();
tmpl.write(packer, v);
byte[] bytes = packer.toByteArray();
BufferUnpacker u = msgpack.createBufferUnpacker();
u.wrap(bytes);
Value value = u.readValue();
Converter unpacker = new Converter(value);
InheritanceClassNotNullable ret = tmpl.read(unpacker, null);
assertEquals(v, ret);
}
@Test @Override
public void testMessagePackableTypeFieldsClass() throws Exception {
super.testMessagePackableTypeFieldsClass();
}
@Override
public void testMessagePackableTypeFieldsClass(MessagePackableTypeFieldsClass v) throws Exception {
MessagePack msgpack = new MessagePack();
TemplateRegistry registry = new TemplateRegistry();
ReflectionBeansTemplateBuilder builder = new ReflectionBeansTemplateBuilder(registry);
Template<MessagePackableTypeFieldsClass> tmpl = builder.buildTemplate(MessagePackableTypeFieldsClass.class);
BufferPacker packer = msgpack.createBufferPacker();
tmpl.write(packer, v);
byte[] bytes = packer.toByteArray();
BufferUnpacker u = msgpack.createBufferUnpacker();
u.wrap(bytes);
Value value = u.readValue();
Converter unpacker = new Converter(value);
MessagePackableTypeFieldsClass ret = tmpl.read(unpacker, null);
assertEquals(v, ret);
}
@Test @Override
public void testMessagePackableTypeFieldsClassNotNullable() throws Exception {
super.testMessagePackableTypeFieldsClassNotNullable();
}
@Override
public void testMessagePackableTypeFieldsClassNotNullable(MessagePackableTypeFieldsClassNotNullable v) throws Exception {
MessagePack msgpack = new MessagePack();
TemplateRegistry registry = new TemplateRegistry();
ReflectionBeansTemplateBuilder builder = new ReflectionBeansTemplateBuilder(registry);
Template<MessagePackableTypeFieldsClassNotNullable> tmpl = builder.buildTemplate(MessagePackableTypeFieldsClassNotNullable.class);
BufferPacker packer = msgpack.createBufferPacker();
tmpl.write(packer, v);
byte[] bytes = packer.toByteArray();
BufferUnpacker u = msgpack.createBufferUnpacker();
u.wrap(bytes);
Value value = u.readValue();
Converter unpacker = new Converter(value);
MessagePackableTypeFieldsClassNotNullable ret = tmpl.read(unpacker, null);
assertEquals(v, ret);
}
}