r212 - in trunk/msm-fromtoXPP3/src: main/java/org/nuiton/mapstoragemanager/plugins/exporter main/java/org/nuiton/mapstoragemanager/plugins/importer test/java/org/nuiton/mapstoragemanager/plugins/exporter test/java/org/nuiton/mapstoragemanager/plugins/importer
Author: dlanglais Date: 2010-03-11 08:30:09 +0100 (Thu, 11 Mar 2010) New Revision: 212 Log: Renommage de la classe de test FromXMLTest.java en FromXMLXPP3Test.java. Ajout d'un g?\195?\169n?\195?\169rateur. Test d'import/export avec 1 millions de lignes et 5 colonnes (un element par ligne) fichier produit de 150 Mo. - ?\195?\169criture ~= 20 secondes. - lecture ~= 15 secondes. Donc, largement plus raisonnable qu'avec le plugin utilisant JDom. Added: trunk/msm-fromtoXPP3/src/test/java/org/nuiton/mapstoragemanager/plugins/exporter/Generator.java trunk/msm-fromtoXPP3/src/test/java/org/nuiton/mapstoragemanager/plugins/importer/FromXMLXPP3Test.java Removed: trunk/msm-fromtoXPP3/src/test/java/org/nuiton/mapstoragemanager/plugins/importer/FromXMLTest.java Modified: trunk/msm-fromtoXPP3/src/main/java/org/nuiton/mapstoragemanager/plugins/exporter/ToXMLXPP3.java trunk/msm-fromtoXPP3/src/main/java/org/nuiton/mapstoragemanager/plugins/importer/FromXMLXPP3.java Modified: trunk/msm-fromtoXPP3/src/main/java/org/nuiton/mapstoragemanager/plugins/exporter/ToXMLXPP3.java =================================================================== --- trunk/msm-fromtoXPP3/src/main/java/org/nuiton/mapstoragemanager/plugins/exporter/ToXMLXPP3.java 2010-03-11 06:52:56 UTC (rev 211) +++ trunk/msm-fromtoXPP3/src/main/java/org/nuiton/mapstoragemanager/plugins/exporter/ToXMLXPP3.java 2010-03-11 07:30:09 UTC (rev 212) @@ -51,7 +51,7 @@ */ @Override public final void exportTo(final BigTable bigTable, final File file) { - + XmlSerializer serializer = null; /** * Initialisation of the serializer. @@ -64,9 +64,11 @@ } catch (XmlPullParserException ex) { LOG.fatal(ex, ex); } - + try { - + + final long t1 = System.currentTimeMillis(); + serializer.setOutput(new FileWriter(file)); serializer.startTag(NAMESPACE, "database"); @@ -82,6 +84,9 @@ serializer.endDocument(); serializer.flush(); + + final long t2 = System.currentTimeMillis(); + LOG.info("temps d'enregistrement : " + (t2 - t1) + " ms."); } catch (IOException ex) { LOG.fatal(ex, ex); } catch (IllegalArgumentException ex) { Modified: trunk/msm-fromtoXPP3/src/main/java/org/nuiton/mapstoragemanager/plugins/importer/FromXMLXPP3.java =================================================================== --- trunk/msm-fromtoXPP3/src/main/java/org/nuiton/mapstoragemanager/plugins/importer/FromXMLXPP3.java 2010-03-11 06:52:56 UTC (rev 211) +++ trunk/msm-fromtoXPP3/src/main/java/org/nuiton/mapstoragemanager/plugins/importer/FromXMLXPP3.java 2010-03-11 07:30:09 UTC (rev 212) @@ -55,6 +55,9 @@ public void importFrom(BigTable bigTable, File file) { try { + + final long t1 = System.currentTimeMillis(); + XmlPullParserFactory factory = XmlPullParserFactory.newInstance(System.getProperty(XmlPullParserFactory.PROPERTY_NAME), null); //factory.setNamespaceAware(true); factory.setFeature(XmlPullParser.FEATURE_PROCESS_NAMESPACES, true); @@ -67,6 +70,8 @@ xpp.setInput(new FileReader(file)); app.processDocument(bigTable, xpp); + final long t2 = System.currentTimeMillis(); + LOG.info("temps de chargement : " + (t2 - t1) + " ms."); } catch (FileNotFoundException ex) { LOG.fatal(ex, ex); } catch (IOException ex) { @@ -170,7 +175,7 @@ // attributes.get("value")); // } else { - LOG.info("Insert : " + attributes.get("table") + ":" + LOG.trace("Insert : " + attributes.get("table") + ":" + attributes.get("column") + ":" + attributes.get("key") + " -> " + attributes.get("value")); @@ -213,8 +218,8 @@ */ private boolean isState(ParsingState ... states) { boolean isState = false; - for (ParsingState state : states) { - if (this.state.equals(state)) { + for (ParsingState parsingState : states) { + if (this.state.equals(parsingState)) { isState = true; } } Added: trunk/msm-fromtoXPP3/src/test/java/org/nuiton/mapstoragemanager/plugins/exporter/Generator.java =================================================================== --- trunk/msm-fromtoXPP3/src/test/java/org/nuiton/mapstoragemanager/plugins/exporter/Generator.java (rev 0) +++ trunk/msm-fromtoXPP3/src/test/java/org/nuiton/mapstoragemanager/plugins/exporter/Generator.java 2010-03-11 07:30:09 UTC (rev 212) @@ -0,0 +1,75 @@ +/* + * To change this template, choose Tools | Templates + * and open the template in the editor. + */ + +package org.nuiton.mapstoragemanager.plugins.exporter; + +import java.io.File; +import java.util.ArrayList; +import java.util.Random; +import java.util.Set; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.nuiton.mapstoragemanager.plugins.BigTable; +import org.nuiton.mapstoragemanager.plugins.Exporter; +import org.nuiton.mapstoragemanager.plugins.bighashmapv2.BigHashMapV2; +import org.nuiton.mapstoragemanager.plugins.getFile; + +/** + * + * @author Dorian Langlais + */ +public class Generator { + + /** + * Logger. + */ + private static final Log LOG = LogFactory.getLog(Generator.class); + + public static void main(String[] args) { + + BigTable bt = new BigHashMapV2(); + String btName = "Random"; + ArrayList<String> columnsNames = new ArrayList<String>(); + columnsNames.add(0,"1er Quart"); + columnsNames.add(1,"2nd Quart"); + columnsNames.add(2,"3eme Quart"); + columnsNames.add(3,"4eme Quart"); + + bt.createTable(btName); + bt.createColumn(btName, "Iteration"); + bt.createColumn(btName, columnsNames.get(0)); + bt.createColumn(btName, columnsNames.get(1)); + bt.createColumn(btName, columnsNames.get(2)); + bt.createColumn(btName, columnsNames.get(3)); + + Set<String> columns = bt.getColumnsNames(btName); + Integer nbIteration = 1000000; + Random random = new java.util.Random(); + Double currentRandom; + int nbColumns = columns.size() - 1; + + while (nbIteration-->0) { + currentRandom = random.nextDouble(); + + bt.put( + btName, + "Iteration", + nbIteration.toString(), + nbIteration.toString()); + + bt.put( + btName, + columnsNames.get((int) (currentRandom * nbColumns)), + nbIteration.toString(), + currentRandom.toString()); + } + + Exporter exporter = new ToXMLXPP3(); + File exportTest = + getFile.getTestFile("/src/test/resources/generator.xml"); + exporter.exportTo(bt,exportTest); +// exportTest.delete(); + } +} Deleted: trunk/msm-fromtoXPP3/src/test/java/org/nuiton/mapstoragemanager/plugins/importer/FromXMLTest.java =================================================================== --- trunk/msm-fromtoXPP3/src/test/java/org/nuiton/mapstoragemanager/plugins/importer/FromXMLTest.java 2010-03-11 06:52:56 UTC (rev 211) +++ trunk/msm-fromtoXPP3/src/test/java/org/nuiton/mapstoragemanager/plugins/importer/FromXMLTest.java 2010-03-11 07:30:09 UTC (rev 212) @@ -1,308 +0,0 @@ -/* - * To change this template, choose Tools | Templates - * and open the template in the editor. - */ -package org.nuiton.mapstoragemanager.plugins.importer; - -import java.io.File; -import java.util.HashMap; -import java.util.HashSet; -import java.util.Map; -import java.util.NoSuchElementException; -import java.util.Set; -import javax.swing.filechooser.FileNameExtensionFilter; -import junit.framework.Assert; -import junit.framework.TestCase; -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; -import org.nuiton.mapstoragemanager.plugins.Importer; -import org.nuiton.mapstoragemanager.plugins.BigTable; -import org.nuiton.mapstoragemanager.plugins.Plugin; -import org.nuiton.mapstoragemanager.plugins.bighashmapv2.BigHashMapV2; -import org.nuiton.mapstoragemanager.plugins.getFile; - -/** - * - * @author Dorian Langlais - */ -public class FromXMLTest extends TestCase { - - /** - * Logger. - */ - private static final Log LOG = LogFactory.getLog(FromXMLTest.class); - -// public void testImportFrom() { -// Assert.fail(); -// } - - /** - * Import the database from the file fiveTables. - * Verify the content. - */ - public void testImportFromFiveTables() { - - File fiveTables = - getFile.getTestFile("/src/test/resources/fiveTables.xml"); - - // import fiveTables. - Importer importer = new FromXMLXPP3(); - BigTable bigTable = new BigHashMapV2(); - - importer.importFrom(bigTable, fiveTables); - - /************************ - * Test Tables * - ************************/ - Set<String> tableNamesExpected; - { - /** - * Init tableNames. - */ - tableNamesExpected = new HashSet<String>(); - tableNamesExpected.add("table1"); - tableNamesExpected.add("table2"); - tableNamesExpected.add("table3"); - tableNamesExpected.add("table4"); - tableNamesExpected.add("table5"); - } - Set<String> tableNamesActual = bigTable.getTablesNames(); - assertEquals(tableNamesExpected, tableNamesActual); - - - for (String tableName : tableNamesActual) { - Set<String> columnNamesExpected = new HashSet<String>(); - assertEquals(columnNamesExpected, - bigTable.getColumnsNames(tableName)); - } - } - - /** - * Import the database from the file fiveColumns. - * Verify the content. - */ - public void testImportFromFiveColumns() { - - File twoTablesFiveColumns = - getFile.getTestFile("/src/test/resources/fiveColumns.xml"); - - // import fiveTables. - Importer importer = new FromXMLXPP3(); - BigTable bigTable = new BigHashMapV2(); - - importer.importFrom(bigTable, twoTablesFiveColumns); - - /************************ - * Test Tables * - ************************/ - Set<String> tableNamesExpected; - { - /** - * Init tableNames. - */ - tableNamesExpected = new HashSet<String>(); - tableNamesExpected.add("table1"); - tableNamesExpected.add("table2"); - } - Set<String> tableNamesActual = bigTable.getTablesNames(); - assertEquals(tableNamesExpected, tableNamesActual); - - /************************ - * Test Columns * - ************************/ - Map<String, Set<String>> columnNamesExpected; - { - /** - * Init columnNames. - */ - columnNamesExpected = new HashMap<String, Set<String>>(); - Set<String> table1ColumnNames = new HashSet<String>(); - table1ColumnNames.add("column1"); - table1ColumnNames.add("column2"); - Set<String> table2ColumnNames = new HashSet<String>(); - table2ColumnNames.add("column3"); - table2ColumnNames.add("column4"); - table2ColumnNames.add("column5"); - columnNamesExpected.put("table1", table1ColumnNames); - columnNamesExpected.put("table2", table2ColumnNames); - } - - Set<String> columnNamesActual; - for (String tableName : tableNamesActual) { - columnNamesActual = bigTable.getColumnsNames(tableName); - assertEquals(columnNamesExpected.get(tableName), columnNamesActual); - } - } - - /** - * Import the database from the file tenCells. - * Verify the content. - */ - public void testImportFromThreeTenCells() { - - File twoTablesFiveColumns = - getFile.getTestFile("/src/test/resources/sixCells.xml"); - - // import fiveTables. - Importer importer = new FromXMLXPP3(); - BigTable bigTable = new BigHashMapV2(); - - importer.importFrom(bigTable, twoTablesFiveColumns); - - /************************ - * Test Tables * - ************************/ - Set<String> tableNamesExpected; - { - /** - * Init tableNames. - */ - tableNamesExpected = new HashSet<String>(); - tableNamesExpected.add("table1"); - tableNamesExpected.add("table2"); - } - Set<String> tableNamesActual = bigTable.getTablesNames(); - assertEquals(tableNamesExpected, tableNamesActual); - - /************************ - * Test Columns * - ************************/ - Map<String, Set<String>> columnNamesExpected; - { - /** - * Init columnNames. - */ - columnNamesExpected = new HashMap<String, Set<String>>(); - Set<String> table1ColumnNames = new HashSet<String>(); - table1ColumnNames.add("column1"); - Set<String> table2ColumnNames = new HashSet<String>(); - table2ColumnNames.add("column2"); - table2ColumnNames.add("column3"); - columnNamesExpected.put("table1", table1ColumnNames); - columnNamesExpected.put("table2", table2ColumnNames); - } - - Set<String> columnNamesActual; - for (String tableName : tableNamesActual) { - columnNamesActual = bigTable.getColumnsNames(tableName); - assertEquals(columnNamesExpected.get(tableName), columnNamesActual); - } - - /************************ - * Test Cells * - ************************/ - Map<String, Map<String, Map<String, String>>> CellContentExpected; - { - /** - * Init cellContent. - */ - CellContentExpected = new HashMap<String, - Map<String, Map<String, String>>>(); - // table 1. - Map<String, Map<String, String>> table1 = - new HashMap<String, Map<String, String>>(); - // column 1. - Map<String,String> column1 = new HashMap<String, String>(); - column1.put("111", "111"); - table1.put("column1", column1); - // table 2. - Map<String, Map<String, String>> table2 = - new HashMap<String, Map<String, String>>(); - // column 2. - Map<String,String> column2 = new HashMap<String, String>(); - column2.put("221", "221"); - column2.put("222", "222"); - table2.put("column2", column2); - // column 3. - Map<String,String> column3 = new HashMap<String, String>(); - column3.put("231", "231"); - column3.put("232", "232"); - column3.put("233", "233"); - table2.put("column3", column3); - - CellContentExpected.put("table1", table1); - CellContentExpected.put("table2", table2); - LOG.info(CellContentExpected); - } - - Set<String> tableKeys; - String cellContentActual; - String cellContentExpected = null; - for (String tableName : tableNamesActual) { - columnNamesActual = bigTable.getColumnsNames(tableName); - tableKeys = bigTable.getKeys(tableName); - for (String columnName : columnNamesActual) { - for (String cellKey : tableKeys) { - - try { - try{ - cellContentExpected = - CellContentExpected - .get(tableName) - .get(columnName) - .get(cellKey); - } catch (NullPointerException ex) { - LOG.trace(ex); - } - - LOG.info(tableName + ' ' - + columnName + ' ' - + cellKey + ' ' - + cellContentExpected); - - cellContentActual = - bigTable.get(tableName, columnName, cellKey); - assertEquals(cellContentExpected, cellContentActual); - } catch (NoSuchElementException ex) { - if(cellContentExpected != null) { - LOG.error(ex, ex); - Assert.fail(); - } else { - LOG.trace(ex); - } - } - } - } - } - } - - /** - * Test of getPluginName(). - */ - public void testGetPluginName() { - Plugin fromXML = new FromXMLXPP3(); - String expectedPluginName = fromXML.getClass().getSimpleName(); - String actualPluginName = fromXML.getPluginName(); - LOG.info("pluginName : {expected,'" + expectedPluginName - + "'} - {actual,'" + actualPluginName + "'}"); - assertEquals(expectedPluginName, actualPluginName); - } - - /** - * Test of getFileFilter. - */ - public void testGetFileFilter(){ - - Importer fromXML = new FromXMLXPP3(); - - FileNameExtensionFilter fileFilterExpected - = new FileNameExtensionFilter("Fichiers XML", "xml"); - FileNameExtensionFilter fileFilterActual = - (FileNameExtensionFilter) fromXML.getFileFilter(); - - /** Same Description */ - assertEquals(fileFilterExpected.getDescription(), - fileFilterActual.getDescription()); - - /** get extension Set and assertEquals */ - Set<String> acceptedExtensionExpected = new HashSet<String>(); - Set<String> acceptedExtensionActual = new HashSet<String>(); - for (String extension : fileFilterExpected.getExtensions()) { - acceptedExtensionExpected.add(extension); - } - for (String extension : fileFilterActual.getExtensions()) { - acceptedExtensionActual.add(extension); - } - assertEquals(acceptedExtensionExpected, acceptedExtensionActual); - } -} Added: trunk/msm-fromtoXPP3/src/test/java/org/nuiton/mapstoragemanager/plugins/importer/FromXMLXPP3Test.java =================================================================== --- trunk/msm-fromtoXPP3/src/test/java/org/nuiton/mapstoragemanager/plugins/importer/FromXMLXPP3Test.java (rev 0) +++ trunk/msm-fromtoXPP3/src/test/java/org/nuiton/mapstoragemanager/plugins/importer/FromXMLXPP3Test.java 2010-03-11 07:30:09 UTC (rev 212) @@ -0,0 +1,308 @@ +/* + * To change this template, choose Tools | Templates + * and open the template in the editor. + */ +package org.nuiton.mapstoragemanager.plugins.importer; + +import java.io.File; +import java.util.HashMap; +import java.util.HashSet; +import java.util.Map; +import java.util.NoSuchElementException; +import java.util.Set; +import javax.swing.filechooser.FileNameExtensionFilter; +import junit.framework.Assert; +import junit.framework.TestCase; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.nuiton.mapstoragemanager.plugins.Importer; +import org.nuiton.mapstoragemanager.plugins.BigTable; +import org.nuiton.mapstoragemanager.plugins.Plugin; +import org.nuiton.mapstoragemanager.plugins.bighashmapv2.BigHashMapV2; +import org.nuiton.mapstoragemanager.plugins.getFile; + +/** + * + * @author Dorian Langlais + */ +public class FromXMLXPP3Test extends TestCase { + + /** + * Logger. + */ + private static final Log LOG = LogFactory.getLog(FromXMLXPP3Test.class); + +// public void testImportFrom() { +// Assert.fail(); +// } + + /** + * Import the database from the file fiveTables. + * Verify the content. + */ + public void testImportFromFiveTables() { + + File fiveTables = + getFile.getTestFile("/src/test/resources/fiveTables.xml"); + + // import fiveTables. + Importer importer = new FromXMLXPP3(); + BigTable bigTable = new BigHashMapV2(); + + importer.importFrom(bigTable, fiveTables); + + /************************ + * Test Tables * + ************************/ + Set<String> tableNamesExpected; + { + /** + * Init tableNames. + */ + tableNamesExpected = new HashSet<String>(); + tableNamesExpected.add("table1"); + tableNamesExpected.add("table2"); + tableNamesExpected.add("table3"); + tableNamesExpected.add("table4"); + tableNamesExpected.add("table5"); + } + Set<String> tableNamesActual = bigTable.getTablesNames(); + assertEquals(tableNamesExpected, tableNamesActual); + + + for (String tableName : tableNamesActual) { + Set<String> columnNamesExpected = new HashSet<String>(); + assertEquals(columnNamesExpected, + bigTable.getColumnsNames(tableName)); + } + } + + /** + * Import the database from the file fiveColumns. + * Verify the content. + */ + public void testImportFromFiveColumns() { + + File twoTablesFiveColumns = + getFile.getTestFile("/src/test/resources/fiveColumns.xml"); + + // import fiveTables. + Importer importer = new FromXMLXPP3(); + BigTable bigTable = new BigHashMapV2(); + + importer.importFrom(bigTable, twoTablesFiveColumns); + + /************************ + * Test Tables * + ************************/ + Set<String> tableNamesExpected; + { + /** + * Init tableNames. + */ + tableNamesExpected = new HashSet<String>(); + tableNamesExpected.add("table1"); + tableNamesExpected.add("table2"); + } + Set<String> tableNamesActual = bigTable.getTablesNames(); + assertEquals(tableNamesExpected, tableNamesActual); + + /************************ + * Test Columns * + ************************/ + Map<String, Set<String>> columnNamesExpected; + { + /** + * Init columnNames. + */ + columnNamesExpected = new HashMap<String, Set<String>>(); + Set<String> table1ColumnNames = new HashSet<String>(); + table1ColumnNames.add("column1"); + table1ColumnNames.add("column2"); + Set<String> table2ColumnNames = new HashSet<String>(); + table2ColumnNames.add("column3"); + table2ColumnNames.add("column4"); + table2ColumnNames.add("column5"); + columnNamesExpected.put("table1", table1ColumnNames); + columnNamesExpected.put("table2", table2ColumnNames); + } + + Set<String> columnNamesActual; + for (String tableName : tableNamesActual) { + columnNamesActual = bigTable.getColumnsNames(tableName); + assertEquals(columnNamesExpected.get(tableName), columnNamesActual); + } + } + + /** + * Import the database from the file tenCells. + * Verify the content. + */ + public void testImportFromThreeTenCells() { + + File twoTablesFiveColumns = + getFile.getTestFile("/src/test/resources/sixCells.xml"); + + // import fiveTables. + Importer importer = new FromXMLXPP3(); + BigTable bigTable = new BigHashMapV2(); + + importer.importFrom(bigTable, twoTablesFiveColumns); + + /************************ + * Test Tables * + ************************/ + Set<String> tableNamesExpected; + { + /** + * Init tableNames. + */ + tableNamesExpected = new HashSet<String>(); + tableNamesExpected.add("table1"); + tableNamesExpected.add("table2"); + } + Set<String> tableNamesActual = bigTable.getTablesNames(); + assertEquals(tableNamesExpected, tableNamesActual); + + /************************ + * Test Columns * + ************************/ + Map<String, Set<String>> columnNamesExpected; + { + /** + * Init columnNames. + */ + columnNamesExpected = new HashMap<String, Set<String>>(); + Set<String> table1ColumnNames = new HashSet<String>(); + table1ColumnNames.add("column1"); + Set<String> table2ColumnNames = new HashSet<String>(); + table2ColumnNames.add("column2"); + table2ColumnNames.add("column3"); + columnNamesExpected.put("table1", table1ColumnNames); + columnNamesExpected.put("table2", table2ColumnNames); + } + + Set<String> columnNamesActual; + for (String tableName : tableNamesActual) { + columnNamesActual = bigTable.getColumnsNames(tableName); + assertEquals(columnNamesExpected.get(tableName), columnNamesActual); + } + + /************************ + * Test Cells * + ************************/ + Map<String, Map<String, Map<String, String>>> CellContentExpected; + { + /** + * Init cellContent. + */ + CellContentExpected = new HashMap<String, + Map<String, Map<String, String>>>(); + // table 1. + Map<String, Map<String, String>> table1 = + new HashMap<String, Map<String, String>>(); + // column 1. + Map<String,String> column1 = new HashMap<String, String>(); + column1.put("111", "111"); + table1.put("column1", column1); + // table 2. + Map<String, Map<String, String>> table2 = + new HashMap<String, Map<String, String>>(); + // column 2. + Map<String,String> column2 = new HashMap<String, String>(); + column2.put("221", "221"); + column2.put("222", "222"); + table2.put("column2", column2); + // column 3. + Map<String,String> column3 = new HashMap<String, String>(); + column3.put("231", "231"); + column3.put("232", "232"); + column3.put("233", "233"); + table2.put("column3", column3); + + CellContentExpected.put("table1", table1); + CellContentExpected.put("table2", table2); + LOG.info(CellContentExpected); + } + + Set<String> tableKeys; + String cellContentActual; + String cellContentExpected = null; + for (String tableName : tableNamesActual) { + columnNamesActual = bigTable.getColumnsNames(tableName); + tableKeys = bigTable.getKeys(tableName); + for (String columnName : columnNamesActual) { + for (String cellKey : tableKeys) { + + try { + try{ + cellContentExpected = + CellContentExpected + .get(tableName) + .get(columnName) + .get(cellKey); + } catch (NullPointerException ex) { + LOG.trace(ex); + } + + LOG.info(tableName + ' ' + + columnName + ' ' + + cellKey + ' ' + + cellContentExpected); + + cellContentActual = + bigTable.get(tableName, columnName, cellKey); + assertEquals(cellContentExpected, cellContentActual); + } catch (NoSuchElementException ex) { + if(cellContentExpected != null) { + LOG.error(ex, ex); + Assert.fail(); + } else { + LOG.trace(ex); + } + } + } + } + } + } + + /** + * Test of getPluginName(). + */ + public void testGetPluginName() { + Plugin fromXML = new FromXMLXPP3(); + String expectedPluginName = fromXML.getClass().getSimpleName(); + String actualPluginName = fromXML.getPluginName(); + LOG.info("pluginName : {expected,'" + expectedPluginName + + "'} - {actual,'" + actualPluginName + "'}"); + assertEquals(expectedPluginName, actualPluginName); + } + + /** + * Test of getFileFilter. + */ + public void testGetFileFilter(){ + + Importer fromXML = new FromXMLXPP3(); + + FileNameExtensionFilter fileFilterExpected + = new FileNameExtensionFilter("Fichiers XML", "xml"); + FileNameExtensionFilter fileFilterActual = + (FileNameExtensionFilter) fromXML.getFileFilter(); + + /** Same Description */ + assertEquals(fileFilterExpected.getDescription(), + fileFilterActual.getDescription()); + + /** get extension Set and assertEquals */ + Set<String> acceptedExtensionExpected = new HashSet<String>(); + Set<String> acceptedExtensionActual = new HashSet<String>(); + for (String extension : fileFilterExpected.getExtensions()) { + acceptedExtensionExpected.add(extension); + } + for (String extension : fileFilterActual.getExtensions()) { + acceptedExtensionActual.add(extension); + } + assertEquals(acceptedExtensionExpected, acceptedExtensionActual); + } +}
participants (1)
-
dlanglais@users.nuiton.org