Ejemplo n.º 1
0
  public PastryEndpointMessage(
      int address,
      InputBuffer buf,
      MessageDeserializer md,
      short type,
      int priority,
      NodeHandle sender)
      throws IOException {
    super(address);

    byte version = 0; // buf.readByte();
    switch (version) {
      case 0:
        setSender(sender);
        //    isRaw = buf.readBoolean();
        //        byte priority = buf.readByte();
        //        short type = buf.readShort();
        if (type == 0) {
          message = new JavaSerializedMessage(md.deserialize(buf, type, priority, sender));
        } else {
          message = (RawMessage) md.deserialize(buf, type, priority, sender);
        }
        if (getMessage() == null)
          throw new IOException("PEM.deserialize() message = null type:" + type + " md:" + md);
        //    System.out.println("PEM.deserialize() message:"+message+" type:"+type+" md:"+md);
        break;
      default:
        throw new IOException("Unknown Version: " + version);
    }
  }
Ejemplo n.º 2
0
  @Test
  public void testDeserializer() throws IOException {
    InputBuffer inBuf = mock(InputBuffer.class);
    when(inBuf.readByte()).thenReturn(new Byte((byte) 0));

    Object message =
        koalaDeserializer.deserialize(
            inBuf,
            InsertRequestMessage.TYPE,
            InsertRequestMessage.DEFAULT_PRIORITY,
            mock(NodeHandle.class));

    assertTrue(message instanceof InsertRequestMessage);
  }