Author: dlanglais Date: 2010-03-14 22:06:55 +0100 (Sun, 14 Mar 2010) New Revision: 242 Log: Ajout de test sur BigHashMap et BigHashMapV2. Modified: trunk/msm-bighashmap/src/test/java/org/nuiton/mapstoragemanager/plugins/bighashmap/BigHashMapTest.java trunk/msm-bighashmapV2/src/test/java/org/nuiton/mapstoragemanager/plugins/bighashmapv2/BigHashMapV2Test.java Modified: trunk/msm-bighashmap/src/test/java/org/nuiton/mapstoragemanager/plugins/bighashmap/BigHashMapTest.java =================================================================== --- trunk/msm-bighashmap/src/test/java/org/nuiton/mapstoragemanager/plugins/bighashmap/BigHashMapTest.java 2010-03-14 20:06:23 UTC (rev 241) +++ trunk/msm-bighashmap/src/test/java/org/nuiton/mapstoragemanager/plugins/bighashmap/BigHashMapTest.java 2010-03-14 21:06:55 UTC (rev 242) @@ -5,9 +5,12 @@ package org.nuiton.mapstoragemanager.plugins.bighashmap; +import java.util.HashSet; +import java.util.Set; import junit.framework.TestCase; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; +import org.nuiton.mapstoragemanager.plugins.BigTable; import org.nuiton.mapstoragemanager.plugins.Plugin; /** @@ -29,4 +32,167 @@ + "'} - {actual,'" + actualPluginName + "'}"); assertEquals(expectedPluginName, actualPluginName); } + + /** + * We put tables, get tablesNames and control the result. + * We delete tables, get tablesNames and control the result. + */ + public void testCreateAndDeleteTable() { + /** We create a new BigTable */ + BigTable bigHashMapV2 = new BigHashMap(); + Set<String> tablesName = new HashSet<String>(); + + assertEquals(tablesName, bigHashMapV2.getTablesNames()); + + /** We put a new table TestTable1 */ + String tableName1 = "TestTable1"; + bigHashMapV2.createTable(tableName1); + tablesName.add(tableName1); + + assertEquals(tablesName, bigHashMapV2.getTablesNames()); + + /** We put a new table TestTable2 */ + String tableName2 = "TestTable2"; + bigHashMapV2.createTable(tableName2); + tablesName.add(tableName2); + + assertEquals(tablesName, bigHashMapV2.getTablesNames()); + + /** We remove the table TestTable1 */ + bigHashMapV2.deleteTable(tableName1); + tablesName.remove(tableName1); + + assertEquals(tablesName, bigHashMapV2.getTablesNames()); + + /** We remove the table TestTable2 */ + bigHashMapV2.deleteTable(tableName1); + tablesName.remove(tableName1); + + assertEquals(tablesName, bigHashMapV2.getTablesNames()); + + } + + /** + * We create a table. + * We put columns, get columnsNames and control the result. + * We delete columns, get columnsNames and control the result. + */ + public void testCreateAndDeleteColumns() { + /** We create a new BigTable */ + BigTable bigHashMapV2 = new BigHashMap(); + Set<String> columnsName = new HashSet<String>(); + + /** We create a new table TestTable1 */ + String tableName1 = "TestTable1"; + bigHashMapV2.createTable(tableName1); + + /** We put a column TestColumn1 */ + String columnName1 = "TestColumn1"; + bigHashMapV2.createColumn(tableName1, columnName1); + columnsName.add(columnName1); + assertEquals(columnsName, bigHashMapV2.getColumnsNames(tableName1)); + + /** We put a column TestColumn2 */ + String columnName2 = "TestColumn2"; + bigHashMapV2.createColumn(tableName1, columnName2); + columnsName.add(columnName2); + assertEquals(columnsName, bigHashMapV2.getColumnsNames(tableName1)); + + /** We remove the column TestColumn1 */ + bigHashMapV2.deleteColumn(tableName1, columnName1); + columnsName.remove(columnName1); + assertEquals(columnsName, bigHashMapV2.getColumnsNames(tableName1)); + + /** We remove the column TestColumn2 */ + bigHashMapV2.deleteColumn(tableName1, columnName2); + columnsName.remove(columnName2); + assertEquals(columnsName, bigHashMapV2.getColumnsNames(tableName1)); + } + + /** + * We create a table with a column. + * We put and try to get String in the BigHashMap. + */ + public void testPutAndGet() { + /** We create a new BigTable */ + BigTable bigHashMapV2 = new BigHashMap(); + + /** We create a new table TestTable1 */ + String tableName1 = "TestTable1"; + bigHashMapV2.createTable(tableName1); + + /** We create a column TestColumn1 */ + String columnName1 = "TestColumn1"; + bigHashMapV2.createColumn(tableName1, columnName1); + + /** We put and try to get String in the BigHashMap */ + String string = "TestString"; + String key = "testKey"; + bigHashMapV2.put(tableName1, columnName1, key, string); + assertEquals(string, bigHashMapV2.get(tableName1, columnName1, key)); + + /** We put and try to get String in the BigHashMap */ + String string1 = "TestString1"; + String key1 = "testKey1"; + bigHashMapV2.put(tableName1, columnName1, key1, string1); + assertEquals(string1, bigHashMapV2.get(tableName1, columnName1, key1)); + + /** We put and try to get String in the BigHashMap */ + String string2 = "TestString2"; + String key2 = "testKey2"; + bigHashMapV2.put(tableName1, columnName1, key2, string2); + assertEquals(string2, bigHashMapV2.get(tableName1, columnName1, key2)); + + /** We put and try to get String in the BigHashMap */ + String string3 = "TestString3"; + String key3 = "testKey3"; + bigHashMapV2.put(tableName1, columnName1, key3, string3); + assertEquals(string3, bigHashMapV2.get(tableName1, columnName1, key3)); + } + + /** + * We create a table with a column. + * We put and try to get String in the BigHashMap. + */ + public void testGetKeys() { + /** We create a new BigTable */ + BigTable bigHashMapV2 = new BigHashMap(); + Set<String> keys = new HashSet<String>(); + + /** We create a new table TestTable1 */ + String tableName1 = "TestTable1"; + bigHashMapV2.createTable(tableName1); + + /** We create a column TestColumn1 */ + String columnName1 = "TestColumn1"; + bigHashMapV2.createColumn(tableName1, columnName1); + + /** We put and try to get String in the BigHashMap */ + String string = "TestString"; + String key = "testKey"; + keys.add(key); + bigHashMapV2.put(tableName1, columnName1, key, string); + assertEquals(keys, bigHashMapV2.getKeys(tableName1)); + + /** We put and try to get String in the BigHashMap */ + String string1 = "TestString1"; + String key1 = "testKey1"; + keys.add(key1); + bigHashMapV2.put(tableName1, columnName1, key1, string1); + assertEquals(keys, bigHashMapV2.getKeys(tableName1)); + + /** We put and try to get String in the BigHashMap */ + String string2 = "TestString2"; + String key2 = "testKey2"; + keys.add(key2); + bigHashMapV2.put(tableName1, columnName1, key2, string2); + assertEquals(keys, bigHashMapV2.getKeys(tableName1)); + + /** We put and try to get String in the BigHashMap */ + String string3 = "TestString3"; + String key3 = "testKey3"; + keys.add(key3); + bigHashMapV2.put(tableName1, columnName1, key3, string3); + assertEquals(keys, bigHashMapV2.getKeys(tableName1)); + } } Modified: trunk/msm-bighashmapV2/src/test/java/org/nuiton/mapstoragemanager/plugins/bighashmapv2/BigHashMapV2Test.java =================================================================== --- trunk/msm-bighashmapV2/src/test/java/org/nuiton/mapstoragemanager/plugins/bighashmapv2/BigHashMapV2Test.java 2010-03-14 20:06:23 UTC (rev 241) +++ trunk/msm-bighashmapV2/src/test/java/org/nuiton/mapstoragemanager/plugins/bighashmapv2/BigHashMapV2Test.java 2010-03-14 21:06:55 UTC (rev 242) @@ -5,9 +5,12 @@ package org.nuiton.mapstoragemanager.plugins.bighashmapv2; +import java.util.HashSet; +import java.util.Set; import junit.framework.TestCase; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; +import org.nuiton.mapstoragemanager.plugins.BigTable; import org.nuiton.mapstoragemanager.plugins.Plugin; /** @@ -29,4 +32,167 @@ + "'} - {actual,'" + actualPluginName + "'}"); assertEquals(expectedPluginName, actualPluginName); } + + /** + * We put tables, get tablesNames and control the result. + * We delete tables, get tablesNames and control the result. + */ + public void testCreateAndDeleteTable() { + /** We create a new BigTable */ + BigTable bigHashMapV2 = new BigHashMapV2(); + Set<String> tablesName = new HashSet<String>(); + + assertEquals(tablesName, bigHashMapV2.getTablesNames()); + + /** We put a new table TestTable1 */ + String tableName1 = "TestTable1"; + bigHashMapV2.createTable(tableName1); + tablesName.add(tableName1); + + assertEquals(tablesName, bigHashMapV2.getTablesNames()); + + /** We put a new table TestTable2 */ + String tableName2 = "TestTable2"; + bigHashMapV2.createTable(tableName2); + tablesName.add(tableName2); + + assertEquals(tablesName, bigHashMapV2.getTablesNames()); + + /** We remove the table TestTable1 */ + bigHashMapV2.deleteTable(tableName1); + tablesName.remove(tableName1); + + assertEquals(tablesName, bigHashMapV2.getTablesNames()); + + /** We remove the table TestTable2 */ + bigHashMapV2.deleteTable(tableName1); + tablesName.remove(tableName1); + + assertEquals(tablesName, bigHashMapV2.getTablesNames()); + + } + + /** + * We create a table. + * We put columns, get columnsNames and control the result. + * We delete columns, get columnsNames and control the result. + */ + public void testCreateAndDeleteColumns() { + /** We create a new BigTable */ + BigTable bigHashMapV2 = new BigHashMapV2(); + Set<String> columnsName = new HashSet<String>(); + + /** We create a new table TestTable1 */ + String tableName1 = "TestTable1"; + bigHashMapV2.createTable(tableName1); + + /** We put a column TestColumn1 */ + String columnName1 = "TestColumn1"; + bigHashMapV2.createColumn(tableName1, columnName1); + columnsName.add(columnName1); + assertEquals(columnsName, bigHashMapV2.getColumnsNames(tableName1)); + + /** We put a column TestColumn2 */ + String columnName2 = "TestColumn2"; + bigHashMapV2.createColumn(tableName1, columnName2); + columnsName.add(columnName2); + assertEquals(columnsName, bigHashMapV2.getColumnsNames(tableName1)); + + /** We remove the column TestColumn1 */ + bigHashMapV2.deleteColumn(tableName1, columnName1); + columnsName.remove(columnName1); + assertEquals(columnsName, bigHashMapV2.getColumnsNames(tableName1)); + + /** We remove the column TestColumn2 */ + bigHashMapV2.deleteColumn(tableName1, columnName2); + columnsName.remove(columnName2); + assertEquals(columnsName, bigHashMapV2.getColumnsNames(tableName1)); + } + + /** + * We create a table with a column. + * We put and try to get String in the BigHashMap. + */ + public void testPutAndGet() { + /** We create a new BigTable */ + BigTable bigHashMapV2 = new BigHashMapV2(); + + /** We create a new table TestTable1 */ + String tableName1 = "TestTable1"; + bigHashMapV2.createTable(tableName1); + + /** We create a column TestColumn1 */ + String columnName1 = "TestColumn1"; + bigHashMapV2.createColumn(tableName1, columnName1); + + /** We put and try to get String in the BigHashMap */ + String string = "TestString"; + String key = "testKey"; + bigHashMapV2.put(tableName1, columnName1, key, string); + assertEquals(string, bigHashMapV2.get(tableName1, columnName1, key)); + + /** We put and try to get String in the BigHashMap */ + String string1 = "TestString1"; + String key1 = "testKey1"; + bigHashMapV2.put(tableName1, columnName1, key1, string1); + assertEquals(string1, bigHashMapV2.get(tableName1, columnName1, key1)); + + /** We put and try to get String in the BigHashMap */ + String string2 = "TestString2"; + String key2 = "testKey2"; + bigHashMapV2.put(tableName1, columnName1, key2, string2); + assertEquals(string2, bigHashMapV2.get(tableName1, columnName1, key2)); + + /** We put and try to get String in the BigHashMap */ + String string3 = "TestString3"; + String key3 = "testKey3"; + bigHashMapV2.put(tableName1, columnName1, key3, string3); + assertEquals(string3, bigHashMapV2.get(tableName1, columnName1, key3)); + } + + /** + * We create a table with a column. + * We put and try to get String in the BigHashMap. + */ + public void testGetKeys() { + /** We create a new BigTable */ + BigTable bigHashMapV2 = new BigHashMapV2(); + Set<String> keys = new HashSet<String>(); + + /** We create a new table TestTable1 */ + String tableName1 = "TestTable1"; + bigHashMapV2.createTable(tableName1); + + /** We create a column TestColumn1 */ + String columnName1 = "TestColumn1"; + bigHashMapV2.createColumn(tableName1, columnName1); + + /** We put and try to get String in the BigHashMap */ + String string = "TestString"; + String key = "testKey"; + keys.add(key); + bigHashMapV2.put(tableName1, columnName1, key, string); + assertEquals(keys, bigHashMapV2.getKeys(tableName1)); + + /** We put and try to get String in the BigHashMap */ + String string1 = "TestString1"; + String key1 = "testKey1"; + keys.add(key1); + bigHashMapV2.put(tableName1, columnName1, key1, string1); + assertEquals(keys, bigHashMapV2.getKeys(tableName1)); + + /** We put and try to get String in the BigHashMap */ + String string2 = "TestString2"; + String key2 = "testKey2"; + keys.add(key2); + bigHashMapV2.put(tableName1, columnName1, key2, string2); + assertEquals(keys, bigHashMapV2.getKeys(tableName1)); + + /** We put and try to get String in the BigHashMap */ + String string3 = "TestString3"; + String key3 = "testKey3"; + keys.add(key3); + bigHashMapV2.put(tableName1, columnName1, key3, string3); + assertEquals(keys, bigHashMapV2.getKeys(tableName1)); + } }