package de.retest.recheck.persistence;

import java.io.File;
import java.io.IOException;
import java.io.UncheckedIOException;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import de.retest.recheck.Properties;
import de.retest.recheck.SuiteAggregator;
import de.retest.recheck.persistence.bin.KryoPersistence;
import de.retest.recheck.report.SuiteReplayResult;
import de.retest.recheck.report.TestReport;
import de.retest.recheck.util.FileUtil;

public class RecheckTestReportUtil {

	private static final Logger logger = LoggerFactory.getLogger( RecheckTestReportUtil.class );

	private static final Persistence<TestReport> persistence = new KryoPersistence<>();

	private RecheckTestReportUtil() {}

	public static void persist( final SuiteReplayResult suite, final File file ) {
		logger.info( "Persisting test report to file '{}'.", FileUtil.canonicalPathQuietly( file ) );
		try {
			FileUtil.ensureFolder( file );

			// Save separate test report for suite.
			persistence.save( file.toURI(), TestReport.fromApi( suite ) );

			// Save/update aggregated test report for all suites.
			final File testReportFile = new File( file.getParent(), Properties.AGGREGATED_TEST_REPORT_FILE_NAME );
			final TestReport aggregatedTestReport = SuiteAggregator.getInstance().getAggregatedTestReport();
			persistence.save( testReportFile.toURI(), aggregatedTestReport );
		} catch ( final IOException e ) {
			throw new UncheckedIOException( "Could not save test report.", e );
		}
	}
}

@@ -33,16 +33,87 @@
 tence;%0A%0A
+import static de.retest.recheck.XmlTransformerUtil.getXmlTransformer;%0A%0A
 import j
@@ -332,66 +332,8 @@
 or;%0A
-import de.retest.recheck.persistence.bin.KryoPersistence;%0A
 impo
@@ -634,20 +634,15 @@
 ence
-%3CTestReport%3E
+Factory
  per
@@ -653,19 +653,22 @@
 ence
+Factory
  = new 
-Kryo
 Pers
@@ -678,11 +678,37 @@
 ence
-%3C%3E(
+Factory( getXmlTransformer() 
 );%0A%0A
@@ -741,16 +741,18 @@
 Util() %7B
+%0A%09
 %7D%0A%0A%09publ
@@ -1018,24 +1018,48 @@
 %09persistence
+Factory.getPersistence()
 .save( file.
@@ -1376,16 +1376,40 @@
 sistence
+Factory.getPersistence()
 .save( t

Use dynamic persistence factory