out.writeObject(b1); out.close(); final ObjectInput in = new ObjectInputStream(new ByteArrayInputStream(buffer.toByteArray())); b2 = (TextBlock) in.readObject(); in.close(); } catch (Exception e) { System.out.println(e.toString()); } assertEquals(b1, b2); } }