### Question:
TextDescriptor extends AbstractTextDescriptor { public static TextDescriptor newTextDescriptor(AbstractTextDescriptor td) { if (td instanceof TextDescriptor) { return (TextDescriptor) td; } return getUniqueTextDescriptor(td); } private  TextDescriptor(AbstractTextDescriptor descriptor); static TextDescriptor newTextDescriptor(AbstractTextDescriptor td); TextDescriptor withDisplay(boolean state); TextDescriptor withDisplay(Display display); TextDescriptor withPos(Position p); TextDescriptor withAbsSize(int s); TextDescriptor withRelSize(double s); TextDescriptor withFace(int f); TextDescriptor withRotation(Rotation r); TextDescriptor withDispPart(DispPos dispPos); TextDescriptor withItalic(boolean state); TextDescriptor withBold(boolean state); TextDescriptor withUnderline(boolean state); TextDescriptor withInterior(boolean state); TextDescriptor withInherit(boolean state); TextDescriptor withParam(boolean state); TextDescriptor withOff(double xd, double yd); TextDescriptor withUnit(Unit u); TextDescriptor withColorIndex(int colorIndex); TextDescriptor withDisplayWithoutParam(); TextDescriptor withoutParam(); static int cacheSize(); @Override Display getDisplay(); @Override long lowLevelGet(); @Override int getColorIndex(); static TextDescriptor getNodeTextDescriptor(); static TextDescriptor getArcTextDescriptor(); static TextDescriptor getExportTextDescriptor(); static TextDescriptor getPortInstTextDescriptor(); static TextDescriptor getAnnotationTextDescriptor(); static TextDescriptor getInstanceTextDescriptor(); static TextDescriptor getCellTextDescriptor(); static final TextDescriptor EMPTY; }### Answer:
@Test public void testSerialization() { TextDescriptor emptyImmutableDescriptor = TextDescriptor.newTextDescriptor(emptyDescriptor); try { ByteArrayOutputStream byteStream = new ByteArrayOutputStream(); ObjectOutputStream out = new ObjectOutputStream(byteStream); out.writeObject(emptyDescriptor); out.writeObject(emptyImmutableDescriptor); out.close(); byte[] serializedRect = byteStream.toByteArray(); ObjectInputStream in = new ObjectInputStream(new ByteArrayInputStream(serializedRect)); MutableTextDescriptor mtd = (MutableTextDescriptor) in.readObject(); TextDescriptor td = (TextDescriptor) in.readObject(); in.close(); assertEquals(emptyDescriptor, mtd); assertSame(emptyImmutableDescriptor, td); } catch (IOException e) { fail(e.getMessage()); } catch (ClassNotFoundException e) { fail(e.getMessage()); } }