ByteArrayOutputStream bos=new ByteArrayOutputStream();
DataOutputStream oos=new DataOutputStream(bos);
byte[] buf=null;
ByteArrayInputStream bis=null;
DataInputStream ois;
IpAddress a2, b2, x, x2, y, y2;
x=createStackConformantAddress(5555);
x.setAdditionalData(new byte[]{'b','e','l','a'});
y=createStackConformantAddress(1111);
y.setAdditionalData(new byte[]{'b','e','l','a'});
a.setAdditionalData(null);
b.setAdditionalData("Bela Ban".getBytes());
a.writeTo(oos);
b.writeTo(oos);
x.writeTo(oos);
y.writeTo(oos);
buf=bos.toByteArray();
bis=new ByteArrayInputStream(buf);
ois=new DataInputStream(bis);
a2=new IpAddress();
a2.readFrom(ois);
b2=new IpAddress();
b2.readFrom(ois);
x2=new IpAddress();
x2.readFrom(ois);
y2=new IpAddress();
y2.readFrom(ois);
Assert.assertEquals(a, a2);
Assert.assertEquals(b, b2);
assert a2.getAdditionalData() == null;
Assert.assertEquals("Bela Ban", new String(b2.getAdditionalData()));
assert x2.getAdditionalData() != null;
Assert.assertEquals(4, x2.getAdditionalData().length);