### Question:
MillenniumDomainPrincipal implements Principal, Serializable { private void writeObject(final ObjectOutputStream out) throws IOException { out.writeObject(username); out.writeObject(domainName); } MillenniumDomainPrincipal(final String username, final String domainName); String getDomainName(); @Override String getName(); String getUsername();  }### Answer:
@Test public void testWriteObject() throws Exception { final MillenniumDomainPrincipal principal = new MillenniumDomainPrincipal(username, domainName); final ObjectOutputStream out = new ObjectOutputStream( new FileOutputStream("target/test-classes/testWriteObject.out")); out.writeObject(principal); out.close(); final ObjectInputStream in = new ObjectInputStream( new FileInputStream("target/test-classes/testWriteObject.out")); final MillenniumDomainPrincipal p = (MillenniumDomainPrincipal) in.readObject(); in.close(); assertThat(p.getUsername()).isEqualTo(principal.getUsername()); assertThat(p.getDomainName()).isEqualTo(principal.getDomainName()); }