Package com.alibaba.dubbo.common.io

Examples of com.alibaba.dubbo.common.io.UnsafeByteArrayOutputStream.toByteArray()


    System.out.println((new byte[2]).hashCode());
    Builder<String> builder = Builder.register(String.class);
    UnsafeByteArrayOutputStream os = new UnsafeByteArrayOutputStream();
    String v = "123";
    builder.writeTo(v, os);
    byte[] b = os.toByteArray();
    System.out.println(b.length+":"+Bytes.bytes2hex(b));
    v = builder.parseFrom(b);
    builder.writeTo(v, os);
    b = os.toByteArray();
    System.out.println(b.length+":"+Bytes.bytes2hex(b));
View Full Code Here


    builder.writeTo(v, os);
    byte[] b = os.toByteArray();
    System.out.println(b.length+":"+Bytes.bytes2hex(b));
    v = builder.parseFrom(b);
    builder.writeTo(v, os);
    b = os.toByteArray();
    System.out.println(b.length+":"+Bytes.bytes2hex(b));
  }

    @Test
  public void testEnumBuilder() throws Exception
View Full Code Here

  {
    Builder<Type> builder = Builder.register(Type.class);
    UnsafeByteArrayOutputStream os = new UnsafeByteArrayOutputStream();
    Type v = Type.High;
    builder.writeTo(v, os);
    byte[] b = os.toByteArray();
    System.out.println(b.length+":"+Bytes.bytes2hex(b));
    v = builder.parseFrom(b);
  }

    @Test
View Full Code Here

  {
    Builder<Throwable> builder = Builder.register(Throwable.class);
    Throwable th = new Throwable();
    UnsafeByteArrayOutputStream os = new UnsafeByteArrayOutputStream();
    builder.writeTo(th, os);
    byte[] b = os.toByteArray();
    System.out.println(b.length+":"+Bytes.bytes2hex(b));

    th = builder.parseFrom(b);
  }
View Full Code Here

    byte[] b;

    Builder<Object[]> osb = Builder.register(Object[].class);
    os = new UnsafeByteArrayOutputStream();
    osb.writeTo(new Object[]{ new String[0] }, os);
    b = os.toByteArray();

    Builder<long[]> lsb = Builder.register(long[].class);
    os = new UnsafeByteArrayOutputStream();
    lsb.writeTo(new long[]{ 1,121232,-3,4,-5,61321432413l }, os);
    lsb.writeTo(new long[]{ 1,121232,-3,4,-5,61321432413l }, os);
View Full Code Here

    Builder<long[]> lsb = Builder.register(long[].class);
    os = new UnsafeByteArrayOutputStream();
    lsb.writeTo(new long[]{ 1,121232,-3,4,-5,61321432413l }, os);
    lsb.writeTo(new long[]{ 1,121232,-3,4,-5,61321432413l }, os);
    lsb.writeTo(new long[]{ 1,2,3,12131314,123132313135l,-6 }, os);
    b = os.toByteArray();
    long[] ls = lsb.parseFrom(b);
    assertEquals(ls.length, 6);

    Builder<byte[]> bsb = Builder.register(byte[].class);
    os = new UnsafeByteArrayOutputStream();
View Full Code Here

    assertEquals(ls.length, 6);

    Builder<byte[]> bsb = Builder.register(byte[].class);
    os = new UnsafeByteArrayOutputStream();
    bsb.writeTo("i am a string.".getBytes(), os);
    b = os.toByteArray();

    Builder<int[][]> iisb = Builder.register(int[][].class);
    os = new UnsafeByteArrayOutputStream();
    iisb.writeTo(new int[][]{ {1,2,3,4}, {5,6,7,8}, {9,10}, {122,123,444} }, os);
    b = os.toByteArray();
View Full Code Here

    b = os.toByteArray();

    Builder<int[][]> iisb = Builder.register(int[][].class);
    os = new UnsafeByteArrayOutputStream();
    iisb.writeTo(new int[][]{ {1,2,3,4}, {5,6,7,8}, {9,10}, {122,123,444} }, os);
    b = os.toByteArray();
    int[][] iis = iisb.parseFrom(b);
    assertEquals(iis.length, 4);

    Builder<int[][][]> iiisb = Builder.register(int[][][].class);
    os = new UnsafeByteArrayOutputStream();
View Full Code Here

    iiisb.writeTo(new int[][][]{
      {{1,2,3,4}},
      {{5,6,7,8}},
      {{122,123,444}}
    }, os);
    b = os.toByteArray();
    int[][][] iii = iiisb.parseFrom(b);
    assertEquals(iii.length, 3);
  }

    @Test
View Full Code Here

    bean.name = "ql";
    bean.type = Type.High;
    bean.types = new Type[]{ Type.High, Type.High };
    BeanBuilder.writeTo(bean, os);

    byte[] b = os.toByteArray();
    System.out.println(b.length+":"+Bytes.bytes2hex(b));

    bean = BeanBuilder.parseFrom(b);
    assertNull(bean.time);
    assertEquals(bean.i, 123123);
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.