/** Write some objects to files. */
  @Test
  public void testWriteToFile() {
    File out = new File("xml_test_helper_out.xml");

    SimpleXml simpleXml = new SimpleXml();
    simpleXml.setField("testing");

    XmlTestHelper.writeObjectToFile(
        simpleXml, XmlTestHelper.createXmlManagerFor(SimpleXml.class), out);

    // and validate results
    XPathHelper helper = new XPathHelper(out);
    assertEquals(
        "The SimpleXml instance was not correctly unmarshalled.",
        simpleXml.getField(),
        helper.evaluateXPathAsString("//field"));

    // and clean.
    out.delete();
  }
  /**
   * Test to see if the XmlManager is properly constructed and can unmarshall some instances of the
   * registered types.
   *
   * @throws Exception
   */
  @Test
  public void testXmlManagerCreation() throws Exception {
    XmlManager manager = XmlTestHelper.createXmlManagerFor(SimpleXml.class, SimpleXml2.class);

    SimpleXml simpleXml = manager.unmarshall(xmlFile1);
    // just check to see if it read something
    assertNotNull(simpleXml);

    SimpleXml2 simpleXml2 = manager.unmarshall(xmlFile2);
    assertNotNull(simpleXml2);
  }
 /** If the file is null, an IllegalArgumentException is thrown. */
 @Test(expected = IllegalArgumentException.class)
 public void testWriteToBadFile() {
   XmlTestHelper.writeObjectToFile(
       new SimpleXml(), XmlTestHelper.createXmlManagerFor(SimpleXml.class), null);
 }
 /** Tries to initialize an XmlManager without any classes to register. It should fail. */
 @Test(expected = IllegalArgumentException.class)
 public void testXmlManagerCreationWithNoClasses() {
   XmlTestHelper.createXmlManagerFor();
 }