Exemple #1
0
  public static void testWriteAddress() throws Exception {
    Address a1 = Util.createRandomAddress();
    Address a2 = Util.createRandomAddress();
    Address a4 = Util.createRandomAddress();

    ByteArrayOutputStream outstream = new ByteArrayOutputStream();
    DataOutputStream dos = new DataOutputStream(outstream);
    Util.writeAddress(a1, dos);
    Util.writeAddress(a2, dos);
    Util.writeAddress(a4, dos);
    dos.close();
    byte[] buf = outstream.toByteArray();
    ByteArrayInputStream instream = new ByteArrayInputStream(buf);
    DataInputStream dis = new DataInputStream(instream);

    Assert.assertEquals(a1, Util.readAddress(dis));
    Assert.assertEquals(a2, Util.readAddress(dis));
    Assert.assertEquals(a4, Util.readAddress(dis));
  }
Exemple #2
0
 public static void testWriteNullAddress() throws Exception {
   Address a1 = null;
   ByteArrayOutputStream outstream = new ByteArrayOutputStream();
   DataOutputStream dos = new DataOutputStream(outstream);
   Util.writeAddress(a1, dos);
   dos.close();
   byte[] buf = outstream.toByteArray();
   ByteArrayInputStream instream = new ByteArrayInputStream(buf);
   DataInputStream dis = new DataInputStream(instream);
   assert Util.readAddress(dis) == null;
 }
Exemple #3
0
 public void writeTo(DataOutput out) throws Exception {
   out.writeByte(type);
   boolean isMergeView = view != null && view instanceof MergeView;
   out.writeBoolean(isMergeView);
   Util.writeStreamable(view, out);
   Util.writeAddress(mbr, out);
   Util.writeAddresses(mbrs, out);
   Util.writeStreamable(join_rsp, out);
   Util.writeStreamable(my_digest, out);
   Util.writeStreamable(merge_id, out);
   out.writeBoolean(merge_rejected);
   out.writeBoolean(useFlushIfPresent);
 }