Package org.msgpack.unpacker

Examples of org.msgpack.unpacker.Unpacker.readValue()


    @Test
    public void serializeString() throws Exception {
        byte[] bytes = ScriptResponseMessage.convertResultToBytes("xyz");
        Unpacker unpacker = msgpack.createUnpacker(new ByteArrayInputStream(bytes));
        Object dst = ResultsConverter.deserializeObject(unpacker.readValue());

        Assert.assertEquals("xyz", dst);
    }

    @Test
View Full Code Here


    @Test
    public void serializeInt() throws Exception {
        byte[] bytes = ScriptResponseMessage.convertResultToBytes(31);
        Unpacker unpacker = msgpack.createUnpacker(new ByteArrayInputStream(bytes));
        Object dst = ResultsConverter.deserializeObject(unpacker.readValue());

        Assert.assertEquals(31L, dst);
    }

    @Test
View Full Code Here

    @Test
    public void serializeFloat() throws Exception {
        byte[] bytes = ScriptResponseMessage.convertResultToBytes(1.2);
        Unpacker unpacker = msgpack.createUnpacker(new ByteArrayInputStream(bytes));
        Object dst = ResultsConverter.deserializeObject(unpacker.readValue());

        Assert.assertEquals(1.2, dst);
    }

    @Test
View Full Code Here

    @Test
    public void serializeBool() throws Exception {
        byte[] bytes = ScriptResponseMessage.convertResultToBytes(true);
        Unpacker unpacker = msgpack.createUnpacker(new ByteArrayInputStream(bytes));
        Object dst = ResultsConverter.deserializeObject(unpacker.readValue());

        Assert.assertEquals(true, dst);
    }

    @Test
View Full Code Here

        srcArray.add("abc");
        srcArray.add(1L);

        byte[] bytes = ScriptResponseMessage.convertResultToBytes(srcArray);
        Unpacker unpacker = msgpack.createUnpacker(new ByteArrayInputStream(bytes));
        Object dst = ResultsConverter.deserializeObject(unpacker.readValue());

        Assert.assertEquals(srcArray, dst);
    }

    @Test
View Full Code Here

        arr.add(true);
        srcMap.put(1.2d, arr);

        byte[] bytes = ScriptResponseMessage.convertResultToBytes(srcMap);
        Unpacker unpacker = msgpack.createUnpacker(new ByteArrayInputStream(bytes));
        Object dst = ResultsConverter.deserializeObject(unpacker.readValue());
        for (Object key : srcMap.keySet()) {
            Assert.assertEquals(srcMap.get(key), ((HashMap<Object, Object>) dst).get(key));
        }
    }
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.