Examples of Unpacker


Examples of org.msgpack.unpacker.Unpacker

    public void testShort(short v) throws Exception {
  MessagePack msgpack = new JSON();
  BufferPacker packer = msgpack.createBufferPacker();
  packer.writeShort(v);
  byte[] bytes = packer.toByteArray();
        Unpacker unpacker = msgpack.createBufferUnpacker(bytes);
  short ret = unpacker.readShort();
  assertEquals(v, ret);
    }
View Full Code Here

Examples of org.msgpack.unpacker.Unpacker

    public void testInteger(int v) throws Exception {
  MessagePack msgpack = new JSON();
  BufferPacker packer = msgpack.createBufferPacker();
  packer.writeInt(v);
  byte[] bytes = packer.toByteArray();
        Unpacker unpacker = msgpack.createBufferUnpacker(bytes);
  int ret = unpacker.readInt();
  assertEquals(v, ret);
    }
View Full Code Here

Examples of org.msgpack.unpacker.Unpacker

    public void testLong(long v) throws Exception {
  MessagePack msgpack = new JSON();
  BufferPacker packer = msgpack.createBufferPacker();
  packer.writeLong(v);
  byte[] bytes = packer.toByteArray();
        Unpacker unpacker = msgpack.createBufferUnpacker(bytes);
  long ret = unpacker.readLong();
  assertEquals(v, ret);
    }
View Full Code Here

Examples of org.msgpack.unpacker.Unpacker

            }
            return;
        }
  packer.writeFloat(v);
  byte[] bytes = packer.toByteArray();
        Unpacker unpacker = msgpack.createBufferUnpacker(bytes);
  float ret = unpacker.readFloat();
  assertEquals(v, ret, 10e-10);
    }
View Full Code Here

Examples of org.msgpack.unpacker.Unpacker

            }
            return;
        }
  packer.writeDouble(v);
  byte[] bytes = packer.toByteArray();
        Unpacker unpacker = msgpack.createBufferUnpacker(bytes);
  double ret = unpacker.readDouble();
  assertEquals(v, ret, 10e-10);
    }
View Full Code Here

Examples of org.msgpack.unpacker.Unpacker

    public void testNil() throws Exception {
  MessagePack msgpack = new JSON();
  BufferPacker packer = msgpack.createBufferPacker();
  packer.writeNil();
  byte[] bytes = packer.toByteArray();
        Unpacker unpacker = msgpack.createBufferUnpacker(bytes);
  unpacker.readNil();
    }
View Full Code Here

Examples of org.msgpack.unpacker.Unpacker

    public void testBigInteger(BigInteger v) throws Exception {
  MessagePack msgpack = new JSON();
  BufferPacker packer = msgpack.createBufferPacker();
  packer.writeBigInteger(v);
  byte[] bytes = packer.toByteArray();
        Unpacker unpacker = msgpack.createBufferUnpacker(bytes);
  BigInteger ret = unpacker.readBigInteger();
  assertEquals(v, ret);
    }
View Full Code Here

Examples of org.msgpack.unpacker.Unpacker

    public void testString(String v) throws Exception {
  MessagePack msgpack = new JSON();
  BufferPacker packer = msgpack.createBufferPacker();
  packer.writeString(v);
  byte[] bytes = packer.toByteArray();
        Unpacker unpacker = msgpack.createBufferUnpacker(bytes);
  String ret = unpacker.readString();
  assertEquals(v, ret);
    }
View Full Code Here

Examples of org.msgpack.unpacker.Unpacker

  BufferPacker packer = msgpack.createBufferPacker();
  //packer.writeByteArray(v);
        String str = new String(v);
  packer.writeString(str);
  byte[] bytes = packer.toByteArray();
        Unpacker unpacker = msgpack.createBufferUnpacker(bytes);
  //byte[] ret = unpacker.readByteArray();
  String ret = unpacker.readString();
  assertEquals(str, ret);
    }
View Full Code Here

Examples of org.msgpack.unpacker.Unpacker

          packer.write(o);
            }
            packer.writeArrayEnd();
        }
  byte[] bytes = packer.toByteArray();
        Unpacker unpacker = msgpack.createBufferUnpacker(bytes);
        if (unpacker.trySkipNil()) {
            assertEquals(null, v);
            return;
        }
  int size = unpacker.readArrayBegin();
  List ret = new ArrayList(size);
  for (int i = 0; i < size; ++i) {
      ret.add(unpacker.read(elementClass));
  }
  unpacker.readArrayEnd();
  assertEquals(v.size(), ret.size());
  Iterator v_iter = v.iterator();
  Iterator ret_iter = ret.iterator();
  while (v_iter.hasNext()) {
      assertEquals(v_iter.next(), ret_iter.next());
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.