Package org.msgpack.unpacker

Examples of org.msgpack.unpacker.Converter


    public void testInteger(int v) throws Exception {
  MessagePack msgpack = new MessagePack();
        Unconverter packer = new Unconverter(msgpack);
        packer.writeInt(v);
        Value r = packer.getResult();
        Converter unpacker = new Converter(msgpack, r);
        int ret = unpacker.readInt();
        assertEquals(v, ret);
    }
View Full Code Here


    public void testLong(long v) throws Exception {
  MessagePack msgpack = new MessagePack();
        Unconverter packer = new Unconverter(msgpack);
        packer.writeLong(v);
        Value r = packer.getResult();
        Converter unpacker = new Converter(msgpack, r);
        long ret = unpacker.readLong();
        assertEquals(v, ret);
    }
View Full Code Here

    public void testFloat(float v) throws Exception {
  MessagePack msgpack = new MessagePack();
        Unconverter packer = new Unconverter(msgpack);
        packer.writeFloat(v);
        Value r = packer.getResult();
        Converter unpacker = new Converter(msgpack, r);
        float ret = unpacker.readFloat();
  assertEquals(v, ret, 10e-10);
    }
View Full Code Here

    public void testDouble(double v) throws Exception {
  MessagePack msgpack = new MessagePack();
        Unconverter packer = new Unconverter(msgpack);
        packer.writeDouble(v);
        Value r = packer.getResult();
        Converter unpacker = new Converter(msgpack, r);
        double ret = unpacker.readDouble();
  assertEquals(v, ret, 10e-10);
    }
View Full Code Here

    public void testNil() throws Exception {
  MessagePack msgpack = new MessagePack();
        Unconverter packer = new Unconverter(msgpack);
        packer.writeNil();
        Value r = packer.getResult();
        Converter unpacker = new Converter(msgpack, r);
        unpacker.readNil();
    }
View Full Code Here

    public void testBigInteger(BigInteger v) throws Exception {
  MessagePack msgpack = new MessagePack();
        Unconverter packer = new Unconverter(msgpack);
        packer.writeBigInteger(v);
        Value r = packer.getResult();
        Converter unpacker = new Converter(msgpack, r);
        BigInteger ret = unpacker.readBigInteger();
        assertEquals(v, ret);
    }
View Full Code Here

    public void testString(String v) throws Exception {
  MessagePack msgpack = new MessagePack();
        Unconverter packer = new Unconverter(msgpack);
        packer.writeString(v);
        Value r = packer.getResult();
        Converter unpacker = new Converter(msgpack, r);
        String ret = unpacker.readString();
        assertEquals(v, ret);
    }
View Full Code Here

    public void testByteArray(byte[] v) throws Exception {
  MessagePack msgpack = new MessagePack();
        Unconverter packer = new Unconverter(msgpack);
        packer.writeByteArray(v);
        Value r = packer.getResult();
        Converter unpacker = new Converter(msgpack, r);
        byte[] ret = unpacker.readByteArray();
  assertArrayEquals(v, ret);
    }
View Full Code Here

          packer.write(o);
            }
            packer.writeArrayEnd();
        }
        Value r = packer.getResult();
  Converter unpacker = new Converter(msgpack, r);
  if (unpacker.trySkipNil()) {
      assertEquals(null, v);
      return;
  }
  int size = unpacker.readArrayBegin();
  List<E> ret = new ArrayList<E>(size);
  for (int i = 0; i < size; ++i) {
      ret.add(unpacker.read(elementClass));
  }
  unpacker.readArrayEnd();
  assertEquals(v.size(), ret.size());
  Iterator<E> v_iter = v.iterator();
  Iterator<E> ret_iter = ret.iterator();
  while (v_iter.hasNext()) {
      assertEquals(v_iter.next(), ret_iter.next());
View Full Code Here

          packer.write(e.getValue());
            }
            packer.writeMapEnd();
        }
        Value r = packer.getResult();
  Converter unpacker = new Converter(msgpack, r);
  if (unpacker.trySkipNil()) {
      assertEquals(null, v);
      return;
  }
  int size = unpacker.readMapBegin();
  Map<K, V> ret = new HashMap<K, V>(size);
  for (int i = 0; i < size; ++i) {
      K key = unpacker.read(keyElementClass);
      V value = unpacker.read(valueElementClass);
      ret.put(key, value);
  }
  unpacker.readMapEnd();
  assertEquals(v.size(), ret.size());
  for (Map.Entry<K, V> e : ((Map<K, V>) v).entrySet()) {
      Object value = ret.get(e.getKey());
      assertEquals(e.getValue(), value);
  }
View Full Code Here

TOP

Related Classes of org.msgpack.unpacker.Converter

Copyright © 2018 www.massapicom. 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.