mirror of
https://github.com/msgpack/msgpack-python.git
synced 2026-02-07 18:29:53 +00:00
java: removes ReflectionPacker and ReflectionTemplate (replaced by DynamicCodeGen)
This commit is contained in:
parent
77698cd924
commit
19fd4e755c
4 changed files with 0 additions and 219 deletions
|
|
@ -1,70 +0,0 @@
|
|||
package org.msgpack;
|
||||
|
||||
import static org.msgpack.Templates.*;
|
||||
|
||||
import java.util.*;
|
||||
import java.io.*;
|
||||
|
||||
import org.junit.Test;
|
||||
import static org.junit.Assert.*;
|
||||
|
||||
public class TestReflectionPackerTemplate {
|
||||
|
||||
public static class StringFieldClass {
|
||||
public String s1;
|
||||
public String s2;
|
||||
public StringFieldClass() { }
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testPackConvert() throws Exception {
|
||||
ByteArrayOutputStream out = new ByteArrayOutputStream();
|
||||
|
||||
MessagePacker packer = ReflectionPacker.create(StringFieldClass.class);
|
||||
|
||||
StringFieldClass src = new StringFieldClass();
|
||||
|
||||
src.s1 = "kumofs";
|
||||
src.s2 = "frsyuki";
|
||||
|
||||
packer.pack(new Packer(out), 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);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testPackConvert02() throws Exception {
|
||||
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