Package be.demmel.jgws.packets.serialization.reflection

Examples of be.demmel.jgws.packets.serialization.reflection.ReflectionPacketDeserializer


      int header = extractHeader(packetClass);

      PacketDeserializer packetDeserializer = packetDeserializers.get(header);

      if (packetDeserializer == null) {
        packetDeserializer = new ReflectionPacketDeserializer(header, packetClass);
        packetDeserializers.put(header, packetDeserializer);
      } else {
        LOGGER.error("Duplicate packet (header {})", header);
      }
    }
View Full Code Here


public class ReflectionPacketDeserializerTest {

    @Test
    public void deserializesCorrectly() throws IOException, Exception {
        // create a new deserializer
        ReflectionPacketDeserializer packetDeserializer = new ReflectionPacketDeserializer(8, P008_TestPacket.class);
       
        // build the fake inputstream
        // The stream represents the data shown in the "assertEqual" tests
        ByteBuf buffer = Unpooled.buffer();
        buffer = buffer.order(ByteOrder.LITTLE_ENDIAN);
        String source = "0 0 1 0 0 0 2 0 0 0 3 0 20 21 22 23 24 25 4 0 116 0 111 0 116 0 111 0 4 0 26 27 28 29 5 0 0 0 5 0 30 31 32 33 34 6 7 0 0 0 4 0 116 0 105 0 116 0 105 0";
        String[] bytes = source.split("\\s");
        for (String byteString : bytes) {
            buffer.writeByte(Byte.parseByte(byteString));
        }

        // the header isn't parsed by using reflection
        buffer.readByte();
        buffer.readByte();
       
        // deserializer the object
        P008_TestPacket testIncomingPacket = (P008_TestPacket) packetDeserializer.deserialize(buffer);

        // test that the deserializer correctly extracted all values
        assertEquals(1, testIncomingPacket.getUnsignedInteger1());
        assertEquals(2, testIncomingPacket.getUnsignedInteger2());
        assertEquals(3, testIncomingPacket.getUnsignedShort1());
View Full Code Here

TOP

Related Classes of be.demmel.jgws.packets.serialization.reflection.ReflectionPacketDeserializer

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.