Mercurial > hg > Members > sugi > MessagePack-java
view src/test/java/org/msgpack/annotation/TestOptionalReflectionBufferPackBufferUnpack.java @ 0:cb825acd883a
first commit
author | sugi |
---|---|
date | Sat, 18 Oct 2014 15:06:15 +0900 |
parents | |
children |
line wrap: on
line source
package org.msgpack.annotation; import static org.junit.Assert.assertEquals; import java.io.ByteArrayOutputStream; import org.junit.Test; import org.msgpack.MessagePack; import org.msgpack.packer.Packer; import org.msgpack.template.Template; import org.msgpack.template.TemplateRegistry; import org.msgpack.template.builder.ReflectionTemplateBuilder; import org.msgpack.unpacker.BufferUnpacker; public class TestOptionalReflectionBufferPackBufferUnpack { @org.junit.Ignore public static class TestMessagePack extends TestSetOptional { public void testOptional0101() throws Exception { super.testOptional0101(); } public MyMessage01 testOptional0101(MyMessage01 src) throws Exception { MessagePack msgpack = new MessagePack(); TemplateRegistry registry = new TemplateRegistry(null); ReflectionTemplateBuilder builder = new ReflectionTemplateBuilder(registry); Template<MyMessage01> tmpl01 = builder.buildTemplate(MyMessage01.class); ByteArrayOutputStream out = new ByteArrayOutputStream(); Packer packer = msgpack.createPacker(out); tmpl01.write(packer, src); byte[] bytes = out.toByteArray(); BufferUnpacker unpacker = msgpack.createBufferUnpacker(); unpacker.resetReadByteCount(); unpacker.wrap(bytes); MyMessage01 dst = tmpl01.read(unpacker, null); assertEquals(bytes.length, unpacker.getReadByteCount()); return dst; } public void testOptional0102() throws Exception { super.testOptional0102(); } public MyMessage02 testOptional0102(MyMessage01 src) throws Exception { MessagePack msgpack = new MessagePack(); TemplateRegistry registry = new TemplateRegistry(null); ReflectionTemplateBuilder builder = new ReflectionTemplateBuilder(registry); Template<MyMessage01> tmpl01 = builder.buildTemplate(MyMessage01.class); Template<MyMessage02> tmpl02 = builder.buildTemplate(MyMessage02.class); ByteArrayOutputStream out = new ByteArrayOutputStream(); Packer packer = msgpack.createPacker(out); tmpl01.write(packer, src); byte[] bytes = out.toByteArray(); BufferUnpacker unpacker = msgpack.createBufferUnpacker(); unpacker.resetReadByteCount(); unpacker.wrap(bytes); MyMessage02 dst = tmpl02.read(unpacker, null); assertEquals(bytes.length, unpacker.getReadByteCount()); return dst; } public void testOptional0103() throws Exception { super.testOptional0103(); } public MyMessage03 testOptional0103(MyMessage01 src) throws Exception { MessagePack msgpack = new MessagePack(); TemplateRegistry registry = new TemplateRegistry(null); ReflectionTemplateBuilder builder = new ReflectionTemplateBuilder(registry); Template<MyMessage01> tmpl01 = builder.buildTemplate(MyMessage01.class); Template<MyMessage03> tmpl03 = builder.buildTemplate(MyMessage03.class); ByteArrayOutputStream out = new ByteArrayOutputStream(); Packer packer = msgpack.createPacker(out); tmpl01.write(packer, src); byte[] bytes = out.toByteArray(); BufferUnpacker unpacker = msgpack.createBufferUnpacker(); unpacker.resetReadByteCount(); unpacker.wrap(bytes); MyMessage03 dst = tmpl03.read(unpacker, null); assertEquals(bytes.length, unpacker.getReadByteCount()); return dst; } public void testOptional0203() throws Exception { super.testOptional0203(); } public MyMessage03 testOptional0202(MyMessage02 src) throws Exception { MessagePack msgpack = new MessagePack(); TemplateRegistry registry = new TemplateRegistry(null); ReflectionTemplateBuilder builder = new ReflectionTemplateBuilder(registry); Template<MyMessage02> tmpl02 = builder.buildTemplate(MyMessage02.class); Template<MyMessage03> tmpl03 = builder.buildTemplate(MyMessage03.class); ByteArrayOutputStream out = new ByteArrayOutputStream(); Packer packer = msgpack.createPacker(out); tmpl02.write(packer, src); byte[] bytes = out.toByteArray(); BufferUnpacker unpacker = msgpack.createBufferUnpacker(); unpacker.resetReadByteCount(); unpacker.wrap(bytes); MyMessage03 dst = tmpl03.read(unpacker, null); assertEquals(bytes.length, unpacker.getReadByteCount()); return dst; } } @Test public void test0101() throws Exception { new TestMessagePack().testOptional0101(); } @Test public void test0102() throws Exception { new TestMessagePack().testOptional0102(); } @Test public void test0103() throws Exception { new TestMessagePack().testOptional0103(); } @Test public void test0203() throws Exception { new TestMessagePack().testOptional0203(); } }