Package org.apache.thrift.transport

Examples of org.apache.thrift.transport.TMemoryBuffer


   
    testServerRequest();
  }
 
  public static void testNakedByte() throws Exception {
    TMemoryBuffer buf = new TMemoryBuffer(0);
    TProtocol proto = factory.getProtocol(buf);
    proto.writeByte((byte)123);
    byte out = proto.readByte();
    if (out != 123) {
      throw new RuntimeException("Byte was supposed to be " + (byte)123 + " but was " + out);
View Full Code Here


      }
    });
  }

  public static void testNakedI16(short n) throws Exception {
    TMemoryBuffer buf = new TMemoryBuffer(0);
    TProtocol proto = factory.getProtocol(buf);
    proto.writeI16(n);
    // System.out.println(buf.inspect());
    int out = proto.readI16();
    if (out != n) {
View Full Code Here

      }
    });
  }
 
  public static void testNakedI32(int n) throws Exception {
    TMemoryBuffer buf = new TMemoryBuffer(0);
    TProtocol proto = factory.getProtocol(buf);
    proto.writeI32(n);
    // System.out.println(buf.inspect());
    int out = proto.readI32();
    if (out != n) {
View Full Code Here

    });
   
  }

  public static void testNakedI64(long n) throws Exception {
    TMemoryBuffer buf = new TMemoryBuffer(0);
    TProtocol proto = factory.getProtocol(buf);
    proto.writeI64(n);
    // System.out.println(buf.inspect());
    long out = proto.readI64();
    if (out != n) {
View Full Code Here

      }
    });
  }
   
  public static void testDouble() throws Exception {
    TMemoryBuffer buf = new TMemoryBuffer(1000);
    TProtocol proto = factory.getProtocol(buf);
    proto.writeDouble(123.456);
    double out = proto.readDouble();
    if (out != 123.456) {
      throw new RuntimeException("Double was supposed to be " + 123.456 + " but was " + out);
View Full Code Here

      throw new RuntimeException("Double was supposed to be " + 123.456 + " but was " + out);
    }
  }
   
  public static void testNakedString(String str) throws Exception {
    TMemoryBuffer buf = new TMemoryBuffer(0);
    TProtocol proto = factory.getProtocol(buf);
    proto.writeString(str);
    // System.out.println(buf.inspect());
    String out = proto.readString();
    if (!str.equals(out)) {
View Full Code Here

      }
    });
  }

  public static void testNakedBinary(byte[] data) throws Exception {
    TMemoryBuffer buf = new TMemoryBuffer(0);
    TProtocol proto = factory.getProtocol(buf);
    proto.writeBinary(data);
    // System.out.println(buf.inspect());
    byte[] out = proto.readBinary();
    if (!Arrays.equals(data, out)) {
View Full Code Here

    });
   
  }

  public static <T extends TBase> void testSerialization(Class<T> klass, T obj) throws Exception {
    TMemoryBuffer buf = new TMemoryBuffer(0);
    TBinaryProtocol binproto = new TBinaryProtocol(buf);
   
    try {
      obj.write(binproto);
      // System.out.println("Size in binary protocol: " + buf.length());
   
      buf = new TMemoryBuffer(0);
      TProtocol proto = factory.getProtocol(buf);
   
      obj.write(proto);
      System.out.println("Size in compact protocol: " + buf.length());
      // System.out.println(buf.inspect());
   
      T objRead = klass.newInstance();
      objRead.read(proto);
      if (!obj.equals(objRead)) {
        System.out.println("Expected: " + obj.toString());
        System.out.println("Actual: " + objRead.toString());
        // System.out.println(buf.inspect());
        throw new RuntimeException("Objects didn't match!");
      }
    } catch (Exception e) {
      System.out.println(buf.inspect());
      throw e;
    }
  }
View Full Code Here

      new TMessage("loooooooooooooooooooooooooooooooooong", TMessageType.EXCEPTION, 1 << 16),
      new TMessage("Janky", TMessageType.CALL, 0),
    });
   
    for (TMessage msg : msgs) {
      TMemoryBuffer buf = new TMemoryBuffer(0);
      TProtocol proto = factory.getProtocol(buf);
      TMessage output = null;
     
      proto.writeMessageBegin(msg);
      proto.writeMessageEnd();
View Full Code Here

      }
    };
   
    Srv.Processor testProcessor = new Srv.Processor(handler);

    TMemoryBuffer clientOutTrans = new TMemoryBuffer(0);
    TProtocol clientOutProto = factory.getProtocol(clientOutTrans);
    TMemoryBuffer clientInTrans = new TMemoryBuffer(0);
    TProtocol clientInProto = factory.getProtocol(clientInTrans);
   
    Srv.Client testClient = new Srv.Client(clientInProto, clientOutProto);
   
    testClient.send_Janky(1);
View Full Code Here

TOP

Related Classes of org.apache.thrift.transport.TMemoryBuffer

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.