FromXmlTest.java| Commit | Date | Message |
|---|---|---|
9ebb88522 | 2016-07-18 | Initial commit |
-cleardb — drops ALL tables before import. Only run against postgres2, never postgres.// @Test
public void testImp() {
System.getProperties().setProperty("projectForgeDs", "postgres2");
//SchemaExpMain.main(new String[] { "-imp", "-cleardb", "-insertall", "target/pf-dump.xml" });
SchemaExpMain.main(new String[] { "-imp", "-cleardb", "-insertall",
"../../projectforge-webapp/src/main/resources/data/init-test-data-new.xml" });
}Line 8: postgres2 — deliberately a DIFFERENT database from the export test's postgres. This prevents accidentally destroying your primary development database.
Line 10: The commented-out alternate path documents the export→import workflow: first run ToXmlTest to generate pf-dump.xml, then run this test to import it.
Lines 10-11: Imports from init-test-data-new.xml — the canonical test seed file. When a user selects "Test system" during ProjectForge setup, the wizard imports this exact file to populate the database with sample data. This test validates that the import pipeline correctly handles real-world seed data.
Path traversal: ../../projectforge-webapp/src/main/resources/data/ — navigates from tools/org.projectforge.tools.schemaexp/ up two directories, then into the webapp module. Fragile relative path — depends on the working directory being the tool's root.
The import counterpart of
ToXmlTest. Forces thepostgres2data source (a separate, disposable PostgreSQL instance), then invokesSchemaExpMainwith three flags:-imp(import),-cleardb(drop all tables first), and-insertall(insert all entities from XML). The current code imports frominit-test-data-new.xml— the pre-generated test data file distributed with the webapp. An older commented-out line shows the same test importing fromtarget/pf-dump.xml(the output of ToXmlTest).