#4320: ToXmlTest.java

tools/org.projectforge.tools.schemaexp/src/test/java/org/projectforge/tools/schemaexp/ToXmlTest.java

Path: tools/org.projectforge.tools.schemaexp/src/test/java/org/projectforge/tools/schemaexp/ToXmlTest.java

Type: Manual dev test (commented @Test) · Lines: 12

Purpose: Developer utility for exporting the entire ProjectForge database to a single XML dump file via SchemaExpMain. NOT run in CI.

Source: GitHub

12 lines · 9 code · 1 comments · 2 blank
CommitDateMessage
9ebb885222016-07-18Initial commit

What it does

This is the export-side developer test — the counterpart to FromXmlTest (#4106). It initializes a Spring context, overrides the data source to PostgreSQL, then invokes SchemaExpMain.main() with -exp to export the entire database to target/pf-dump.xml. The @Test annotation is commented out because this test requires a live, populated PostgreSQL database — it cannot run in CI without a database fixture.

The resulting XML file can be hundreds of megabytes for a production database, containing all entities (users, groups, addresses, time sheets, tasks, invoices, history entries) serialized via the Genome JPA XML Dump library with XStream's ReferenceByIdMarshallingStrategy.

//  @Test                           // Commented out — requires live DB
public void testExp() {
  System.getProperties().setProperty("projectForgeDs", "postgres");
  SchemaExpMain.main(new String[] { "-exp", "target/pf-dump.xml" });
}

Line 8: Sets the system property projectForgeDs to "postgres" — this selects which Spring DataSource bean to activate. The value postgres corresponds to the primary development database defined in local-settings.properties (#4101).

Line 9: Passes two arguments: -exp (the export operation flag) and target/pf-dump.xml (the output path, relative to Maven's build directory). The -exp flag is parsed by SchemaExpMain.parseOption() which sets op = Operation.Export, then delegates to SchemaExpService.doExport() which calls jpaXmlDumpService.dumpToXml().

Key takeaways