Package marauroa.common.net

Examples of marauroa.common.net.InputSerializer


    rpo.put("map2", "key22", "value22");
    ByteArrayOutputStream out = new ByteArrayOutputStream();
    OutputSerializer os = new OutputSerializer(out);
    os.write(rpo);
    ByteArrayInputStream in = new ByteArrayInputStream(out.toByteArray());
    InputSerializer is = new InputSerializer(in);
    RPObject result = (RPObject) is.readObject(new RPObject());
    assertEquals(rpo, result);
  }
View Full Code Here


      input.close();
      output.close();

      ByteArrayInputStream inStream = new ByteArrayInputStream(content);
      InflaterInputStream szlib = new InflaterInputStream(inStream, new Inflater());
      InputSerializer inputSerializer = new InputSerializer(szlib);
      inputSerializer.setProtocolVersion(protocolVersion);

      RPObject object = (RPObject) inputSerializer.readObject(new RPObject());

      if (transform) {
        object = factory.transform(object);
      }
View Full Code Here

      input.close();
      output.close();

      ByteArrayInputStream inStream = new ByteArrayInputStream(content);
      InflaterInputStream szlib = new InflaterInputStream(inStream, new Inflater());
      InputSerializer inputSerializer = new InputSerializer(szlib);

      int protocolVersion = NetConst.FIRST_VERSION_WITH_MULTI_VERSION_SUPPORT - 1;
      Object temp = resultSet.getObject("protocol_version");
      if (temp != null) {
        protocolVersion = ((Integer) temp).intValue();
      }
      inputSerializer.setProtocolVersion(protocolVersion);

      int amount = inputSerializer.readInt();

      for (int i = 0; i < amount; i++) {
        try {
          RPObject object = factory.transform((RPObject) inputSerializer.readObject(new RPObject()));

          if (object != null) {
            /* Give the object a valid id and add it */
            zone.assignRPObjectID(object);
            zone.add(object);
 
View Full Code Here

    super.readObject(in);

    ByteArrayInputStream array = new ByteArrayInputStream(in.readByteArray());
    java.util.zip.InflaterInputStream szlib = new java.util.zip.InflaterInputStream(array,
            new java.util.zip.Inflater());
    InputSerializer serializer = new InputSerializer(szlib);
    serializer.setProtocolVersion(protocolVersion);

    contents = serializer.readStringArray();

    int size = serializer.readInt();
    for (int i = 0; i < size; ++i) {
      serializer.readObject(new RPClass());
    }

    if (type != MessageType.S2C_SERVERINFO) {
      throw new IOException();
    }
View Full Code Here

  public final void testReadWriteObject() throws IOException {
    MockMessage mmOut = new MockMessage(MessageType.C2S_ACTION, SocketChannel.open());
    ByteArrayOutputStream out = new ByteArrayOutputStream();
    mmOut.setClientID(1);
    mmOut.writeObject(new OutputSerializer(out));
    InputSerializer in = new InputSerializer(new ByteArrayInputStream(out.toByteArray()));
    MockMessage mmInn = new MockMessage(MessageType.C2S_ACTION, SocketChannel.open());

    mmInn.readObject(in);
    assertEquals(mmOut.getClientID(), mmInn.getClientID());
    assertEquals(mmOut.getMessageTimestamp(), mmInn.getMessageTimestamp());
View Full Code Here

  public final void testInvalidClientId() throws IOException {
    MockMessage mmOut = new MockMessage(MessageType.C2S_ACTION, SocketChannel.open());
    ByteArrayOutputStream out = new ByteArrayOutputStream();
    mmOut.setClientID(Message.CLIENTID_INVALID);
    mmOut.writeObject(new OutputSerializer(out));
    InputSerializer in = new InputSerializer(new ByteArrayInputStream(out.toByteArray()));
    MockMessage mmInn = new MockMessage(MessageType.C2S_ACTION, SocketChannel.open());

    mmInn.readObject(in);
    assertEquals(mmOut.getClientID(), mmInn.getClientID());
    assertEquals(mmOut.getMessageTimestamp(), mmInn.getMessageTimestamp());
View Full Code Here

    tcInn.data=new byte[64];
   
    ByteArrayOutputStream out = new ByteArrayOutputStream();

    tcInn.writeREQ(new OutputSerializer(out));
    InputSerializer in = new InputSerializer(new ByteArrayInputStream(out.toByteArray()));

    TransferContent tcOut = new TransferContent();
    tcOut.readREQ(in);
    assertTrue(tcInn.ack == tcOut.ack);
    assertTrue(tcInn.cacheable == tcOut.cacheable);
View Full Code Here

    tcInn.data=new byte[64];

    ByteArrayOutputStream out = new ByteArrayOutputStream();

    tcInn.writeACK(new OutputSerializer(out));
    InputSerializer in = new InputSerializer(new ByteArrayInputStream(out.toByteArray()));

    TransferContent tcOut = new TransferContent();
    tcOut.readACK(in);
    assertTrue(tcInn.ack == tcOut.ack);
    assertTrue(tcInn.name.equals(tcOut.name));
View Full Code Here

    }

    ByteArrayOutputStream out = new ByteArrayOutputStream();

    tcInn.writeFULL(new OutputSerializer(out));
    InputSerializer in = new InputSerializer(new ByteArrayInputStream(out.toByteArray()));

    TransferContent tcOut = new TransferContent();
    tcOut.readFULL(in);
    assertEquals(tcInn.ack,tcOut.ack);
    assertEquals(tcInn.cacheable,tcOut.cacheable);
View Full Code Here

  public static LayerDefinition decode(final InputStream in) throws IOException,
      ClassNotFoundException {
    LayerDefinition layer = new LayerDefinition(0, 0);

    final InflaterInputStream szlib = new InflaterInputStream(in, new Inflater());
    final InputSerializer ser = new InputSerializer(szlib);

    layer = (LayerDefinition) ser.readObject(layer);
    layer.build();
    return layer;
  }
View Full Code Here

TOP

Related Classes of marauroa.common.net.InputSerializer

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.