@Test
public void testSerialize() throws Exception {

    System.setProperty("jvoicexml.xml.encoding", "UTF-8");
    final VoiceXmlDocument doc = new VoiceXmlDocument();
    final Vxml vxml = doc.getVxml();
    final Form form = vxml.appendChild(Form.class);
    final Block block = form.appendChild(Block.class);
    block.setName("testäöü");
    final File file = File.createTempFile("jvxmltest", null);
    file.deleteOnExit();
    final FileOutputStream fout = new FileOutputStream(file);
    final ObjectOutputStream oo = new ObjectOutputStream(fout);
    oo.writeObject(doc);
    oo.close();
    fout.close();
    final String expected = doc.toString();
    // Another encoding should have no influence onto the deserialization
    System.setProperty("jvoicexml.xml.encoding", "UTF-16");
    final FileInputStream fin = new FileInputStream(file);
    final ObjectInputStream oi = new ObjectInputStream(fin);
    final Object o = oi.readObject();
    oi.close();
    fin.close();
    Assert.assertEquals(expected, o.toString());
}