Mercurial > hg > Members > kazz > msgpack
changeset 2:e3e4ad3e797b
test code of msgpack
author | one |
---|---|
date | Mon, 01 Aug 2011 13:23:52 +0900 |
parents | ededd57fc173 |
children | 52e5fa933097 |
files | src/org/msgpack/test/Employee.java src/org/msgpack/test/MessagePackTest.java |
diffstat | 2 files changed, 39 insertions(+), 0 deletions(-) [+] |
line wrap: on
line diff
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/org/msgpack/test/Employee.java Mon Aug 01 13:23:52 2011 +0900 @@ -0,0 +1,17 @@ +package org.msgpack.test; + +import org.msgpack.annotation.MessagePackMessage; + +@MessagePackMessage +public class Employee { + public String name; + public int age; + + public Employee() {} + + public Employee(String name, int age) { + this.name = name; + this.age = age; + } + +}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/org/msgpack/test/MessagePackTest.java Mon Aug 01 13:23:52 2011 +0900 @@ -0,0 +1,22 @@ +package org.msgpack.test; + +import java.io.IOException; + +import org.msgpack.MessagePack; +import org.msgpack.type.Value; + +public class MessagePackTest { + public static void main(String args[]) { + Employee src = new Employee("taro", 25); + MessagePack msgpack = new MessagePack(); + msgpack.register(Employee.class); + try { + byte[] buf = msgpack.write(src); + Value dst = msgpack.read(buf); + System.out.println(dst); + + } catch (IOException e1) { + e1.printStackTrace(); + } + } +}