@Test
  public void testEmptyDB() {
    StringWriter out = new StringWriter();

    ZooXmlExport ex = new ZooXmlExport(out);
    ex.writeDB(TestTools.getDbName());

    // System.out.println(out.getBuffer());

    Scanner sc = new Scanner(new StringReader(out.getBuffer().toString()));
    ZooXmlImport im = new ZooXmlImport(sc);
    im.readDB(TestTools.getDbName());
  }
  @Test
  public void testSimpleClassesToFile() {
    // populate
    populateSimple();
    String file = System.getProperty("user.home") + File.separator + FILE;
    File f = new File(file);
    if (f.exists()) {
      f.delete();
    }

    ZooXmlExport.main(new String[] {TestTools.getDbName(), file});

    ZooXmlImport.main(new String[] {TestTools.getDbName(), file});
  }
  /** Test import of ZooDB 0.3 xml files. */
  @Test
  public void testImport0_3() {
    String path = Test_014_XmlImportExport.class.getResource("XmlComplexTest.xml").getPath();

    // import to DB
    TestTools.defineSchema(TestSerializer.class, TestSuper.class, DBLargeVector.class);
    ZooXmlImport.main(new String[] {TestTools.getDbName(), path});

    // check target
    PersistenceManager pm2 = TestTools.openPM();
    pm2.currentTransaction().begin();

    // Check for content in target
    Extent<TestSerializer> ext = pm2.getExtent(TestSerializer.class);
    TestSerializer ts2 = ext.iterator().next();
    ts2.check(false);
    pm2.currentTransaction().rollback();
    TestTools.closePM();
  }
  @Test
  public void testComplexClass() {
    // populate
    Object oid = null;
    TestTools.defineSchema(TestSerializer.class, TestSuper.class, DBLargeVector.class);
    PersistenceManager pm = TestTools.openPM();
    pm.currentTransaction().begin();
    TestSerializer ts1 = new TestSerializer();
    ts1.init();
    ts1.check(true);
    pm.makePersistent(ts1);
    oid = pm.getObjectId(ts1);
    pm.currentTransaction().commit();
    TestTools.closePM();
    pm = null;

    TestSerializer.resetStatic();

    // export to XML
    StringWriter out = new StringWriter();
    ZooXmlExport ex = new ZooXmlExport(out);
    ex.writeDB(TestTools.getDbName());
    System.out.println(out.getBuffer());
    Scanner sc = new Scanner(new StringReader(out.getBuffer().toString()));
    ZooXmlImport im = new ZooXmlImport(sc);

    // import to new DB
    DataStoreManager dsm = ZooHelper.getDataStoreManager();
    if (dsm.dbExists(DB2)) {
      dsm.removeDb(DB2);
    }
    dsm.createDb(DB2);
    TestTools.defineSchema(DB2, TestSerializer.class, TestSuper.class, DBLargeVector.class);
    im.readDB(DB2);

    // check target
    PersistenceManager pm2 = TestTools.openPM(DB2);
    pm2.currentTransaction().begin();

    // Check for content in target
    TestSerializer ts2 = (TestSerializer) pm2.getObjectById(oid, true);
    ts2.check(false);
    pm2.currentTransaction().rollback();
    TestTools.closePM();

    TestSerializer.resetStatic();

    // Now try the same thing again, this time with an existing object.
    pm2 = TestTools.openPM(DB2);
    pm2.currentTransaction().begin();

    TestSerializer ts3 = (TestSerializer) pm2.getObjectById(oid);
    ts3.check(false);
    // mark dirty to enforce rewrite.
    ts3.markDirtyTS();
    pm2.currentTransaction().commit();
    TestTools.closePM();

    TestSerializer.resetStatic();
    // Check target
    pm2 = TestTools.openPM(DB2);
    pm2.currentTransaction().begin();

    TestSerializer ts4 = (TestSerializer) pm2.getObjectById(oid, true);
    ts4.check(false);
    pm2.currentTransaction().rollback();
    TestTools.closePM();
  }