Minor improvement ...

This commit is contained in:
Paulo Gustavo Veiga 2011-03-27 19:48:11 -03:00
parent cff3d7cc8a
commit a527404aa2

View File

@ -17,16 +17,23 @@ import java.io.*;
@Test
public class ImportExportTest {
private static final String DATA_DIR_PATH = "src/test/data/freemind/";
final private Importer importer;
final private FreemindExporter exporter;
public ImportExportTest() throws ImporterException {
ImporterFactory exporterFactory = ImporterFactory.getInstance();
importer = exporterFactory.getImporter(ImportFormat.FREEMIND);
exporter = new FreemindExporter();
}
@Test(dataProvider = "Data-Provider-Function")
public void exportImportExportTest(@NotNull final File freeMindFile, @NotNull final File recFile) throws ImporterException, IOException, ExportException {
ImporterFactory instance = ImporterFactory.getInstance();
Importer importer = instance.getImporter(ImportFormat.FREEMIND);
FileInputStream fileInputStream = new FileInputStream(freeMindFile.getAbsolutePath());
final MindMap mindMap = importer.importMap("basic", "basic", fileInputStream);
final FreemindExporter freemindExporter = new FreemindExporter();
if (recFile.exists()) {
// Compare rec and file ...
@ -48,18 +55,17 @@ public class ImportExportTest {
// Export mile content ...
final ByteArrayOutputStream bos = new ByteArrayOutputStream();
freemindExporter.export(mindMap, bos);
exporter.export(mindMap, bos);
final String exportContent = new String(bos.toByteArray());
Assert.assertEquals(recContent.toString(), exportContent);
} else {
final FileOutputStream fos = new FileOutputStream(recFile);
freemindExporter.export(mindMap, fos);
exporter.export(mindMap, fos);
fos.close();
}
}
//This function will provide the parameter data