mirror of
https://github.com/msgpack/msgpack-python.git
synced 2026-02-07 18:29:53 +00:00
java: adds several annotations in an org.msgpack.annotation package and edits Packer.java and its test program
This commit is contained in:
parent
0a41b253f3
commit
dfb97e7961
6 changed files with 101 additions and 18 deletions
|
|
@ -42,5 +42,33 @@ public class TestReflectionPackerTemplate {
|
|||
assertEquals(src.s1, dst.s1);
|
||||
assertEquals(src.s2, dst.s2);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testPackConvert02() throws Exception {
|
||||
tString(); // FIXME link StringTemplate
|
||||
|
||||
ByteArrayOutputStream out = new ByteArrayOutputStream();
|
||||
|
||||
CustomPacker.register(StringFieldClass.class, ReflectionPacker.create(StringFieldClass.class));
|
||||
|
||||
|
||||
StringFieldClass src = new StringFieldClass();
|
||||
|
||||
src.s1 = "kumofs";
|
||||
src.s2 = "frsyuki";
|
||||
|
||||
new Packer(out).pack(src);
|
||||
|
||||
Template tmpl = ReflectionTemplate.create(StringFieldClass.class);
|
||||
|
||||
ByteArrayInputStream in = new ByteArrayInputStream(out.toByteArray());
|
||||
|
||||
Object obj = tmpl.unpack(new Unpacker(in));
|
||||
assertEquals(obj.getClass(), StringFieldClass.class);
|
||||
|
||||
StringFieldClass dst = (StringFieldClass)obj;
|
||||
assertEquals(src.s1, dst.s1);
|
||||
assertEquals(src.s2, dst.s2);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue