Mercurial > hg > Members > sugi > MessagePack-java
comparison src/test/java/org/msgpack/annotation/TestOptionalReflectionBufferPackUnpack.java @ 0:cb825acd883a
first commit
author | sugi |
---|---|
date | Sat, 18 Oct 2014 15:06:15 +0900 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
-1:000000000000 | 0:cb825acd883a |
---|---|
1 package org.msgpack.annotation; | |
2 | |
3 import static org.junit.Assert.assertEquals; | |
4 | |
5 import java.io.ByteArrayInputStream; | |
6 | |
7 import org.junit.Test; | |
8 import org.msgpack.MessagePack; | |
9 import org.msgpack.packer.BufferPacker; | |
10 import org.msgpack.template.Template; | |
11 import org.msgpack.template.TemplateRegistry; | |
12 import org.msgpack.template.builder.ReflectionTemplateBuilder; | |
13 import org.msgpack.unpacker.Unpacker; | |
14 | |
15 | |
16 public class TestOptionalReflectionBufferPackUnpack { | |
17 | |
18 @org.junit.Ignore | |
19 public static class TestMessagePack extends TestSetOptional { | |
20 public void testOptional0101() throws Exception { | |
21 super.testOptional0101(); | |
22 } | |
23 | |
24 public MyMessage01 testOptional0101(MyMessage01 src) throws Exception { | |
25 MessagePack msgpack = new MessagePack(); | |
26 TemplateRegistry registry = new TemplateRegistry(null); | |
27 ReflectionTemplateBuilder builder = new ReflectionTemplateBuilder(registry); | |
28 Template<MyMessage01> tmpl01 = builder.buildTemplate(MyMessage01.class); | |
29 BufferPacker packer = msgpack.createBufferPacker(); | |
30 tmpl01.write(packer, src); | |
31 byte[] bytes = packer.toByteArray(); | |
32 ByteArrayInputStream in = new ByteArrayInputStream(bytes); | |
33 Unpacker unpacker = msgpack.createUnpacker(in); | |
34 unpacker.resetReadByteCount(); | |
35 MyMessage01 dst = tmpl01.read(unpacker, null); | |
36 assertEquals(bytes.length, unpacker.getReadByteCount()); | |
37 return dst; | |
38 } | |
39 | |
40 public void testOptional0102() throws Exception { | |
41 super.testOptional0102(); | |
42 } | |
43 | |
44 public MyMessage02 testOptional0102(MyMessage01 src) throws Exception { | |
45 MessagePack msgpack = new MessagePack(); | |
46 TemplateRegistry registry = new TemplateRegistry(null); | |
47 ReflectionTemplateBuilder builder = new ReflectionTemplateBuilder(registry); | |
48 Template<MyMessage01> tmpl01 = builder.buildTemplate(MyMessage01.class); | |
49 Template<MyMessage02> tmpl02 = builder.buildTemplate(MyMessage02.class); | |
50 BufferPacker packer = msgpack.createBufferPacker(); | |
51 tmpl01.write(packer, src); | |
52 byte[] bytes = packer.toByteArray(); | |
53 ByteArrayInputStream in = new ByteArrayInputStream(bytes); | |
54 Unpacker unpacker = msgpack.createUnpacker(in); | |
55 unpacker.resetReadByteCount(); | |
56 MyMessage02 dst = tmpl02.read(unpacker, null); | |
57 assertEquals(bytes.length, unpacker.getReadByteCount()); | |
58 return dst; | |
59 } | |
60 | |
61 public void testOptional0103() throws Exception { | |
62 super.testOptional0103(); | |
63 } | |
64 | |
65 public MyMessage03 testOptional0103(MyMessage01 src) throws Exception { | |
66 MessagePack msgpack = new MessagePack(); | |
67 TemplateRegistry registry = new TemplateRegistry(null); | |
68 ReflectionTemplateBuilder builder = new ReflectionTemplateBuilder(registry); | |
69 Template<MyMessage01> tmpl01 = builder.buildTemplate(MyMessage01.class); | |
70 Template<MyMessage03> tmpl03 = builder.buildTemplate(MyMessage03.class); | |
71 BufferPacker packer = msgpack.createBufferPacker(); | |
72 tmpl01.write(packer, src); | |
73 byte[] bytes = packer.toByteArray(); | |
74 ByteArrayInputStream in = new ByteArrayInputStream(bytes); | |
75 Unpacker unpacker = msgpack.createUnpacker(in); | |
76 unpacker.resetReadByteCount(); | |
77 MyMessage03 dst = tmpl03.read(unpacker, null); | |
78 assertEquals(bytes.length, unpacker.getReadByteCount()); | |
79 return dst; | |
80 } | |
81 | |
82 public void testOptional0203() throws Exception { | |
83 super.testOptional0203(); | |
84 } | |
85 | |
86 public MyMessage03 testOptional0202(MyMessage02 src) throws Exception { | |
87 MessagePack msgpack = new MessagePack(); | |
88 TemplateRegistry registry = new TemplateRegistry(null); | |
89 ReflectionTemplateBuilder builder = new ReflectionTemplateBuilder(registry); | |
90 Template<MyMessage02> tmpl02 = builder.buildTemplate(MyMessage02.class); | |
91 Template<MyMessage03> tmpl03 = builder.buildTemplate(MyMessage03.class); | |
92 BufferPacker packer = msgpack.createBufferPacker(); | |
93 tmpl02.write(packer, src); | |
94 byte[] bytes = packer.toByteArray(); | |
95 ByteArrayInputStream in = new ByteArrayInputStream(bytes); | |
96 Unpacker unpacker = msgpack.createUnpacker(in); | |
97 unpacker.resetReadByteCount(); | |
98 MyMessage03 dst = tmpl03.read(unpacker, null); | |
99 assertEquals(bytes.length, unpacker.getReadByteCount()); | |
100 return dst; | |
101 } | |
102 } | |
103 | |
104 @Test | |
105 public void test0101() throws Exception { | |
106 new TestMessagePack().testOptional0101(); | |
107 } | |
108 @Test | |
109 public void test0102() throws Exception { | |
110 new TestMessagePack().testOptional0102(); | |
111 } | |
112 @Test | |
113 public void test0103() throws Exception { | |
114 new TestMessagePack().testOptional0103(); | |
115 } | |
116 @Test | |
117 public void test0203() throws Exception { | |
118 new TestMessagePack().testOptional0203(); | |
119 } | |
120 } |