You can subscribe to this list here.
2002 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
(5) |
Jul
(7) |
Aug
(37) |
Sep
|
Oct
|
Nov
(1) |
Dec
(22) |
---|---|---|---|---|---|---|---|---|---|---|---|---|
2003 |
Jan
(8) |
Feb
(68) |
Mar
(72) |
Apr
(149) |
May
(32) |
Jun
(46) |
Jul
(26) |
Aug
(59) |
Sep
(25) |
Oct
(18) |
Nov
(4) |
Dec
(3) |
2004 |
Jan
(90) |
Feb
(19) |
Mar
(38) |
Apr
(41) |
May
(44) |
Jun
(2) |
Jul
(10) |
Aug
|
Sep
(14) |
Oct
|
Nov
(1) |
Dec
|
2005 |
Jan
|
Feb
|
Mar
|
Apr
(1) |
May
(15) |
Jun
(1) |
Jul
|
Aug
(9) |
Sep
|
Oct
(17) |
Nov
|
Dec
|
2006 |
Jan
(1) |
Feb
(16) |
Mar
|
Apr
(1) |
May
(48) |
Jun
|
Jul
(2) |
Aug
(1) |
Sep
|
Oct
|
Nov
|
Dec
(29) |
2007 |
Jan
|
Feb
(3) |
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
2008 |
Jan
|
Feb
(23) |
Mar
(31) |
Apr
|
May
(26) |
Jun
(6) |
Jul
(1) |
Aug
|
Sep
(7) |
Oct
(1) |
Nov
(8) |
Dec
(8) |
2009 |
Jan
(5) |
Feb
(9) |
Mar
(1) |
Apr
|
May
(23) |
Jun
(3) |
Jul
|
Aug
(1) |
Sep
(9) |
Oct
(28) |
Nov
(18) |
Dec
(8) |
2010 |
Jan
(19) |
Feb
(24) |
Mar
(3) |
Apr
|
May
(5) |
Jun
(4) |
Jul
|
Aug
(1) |
Sep
(11) |
Oct
|
Nov
(2) |
Dec
(1) |
2011 |
Jan
|
Feb
(7) |
Mar
|
Apr
(6) |
May
(3) |
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
2012 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
(32) |
Oct
(6) |
Nov
|
Dec
|
From: <mla...@us...> - 2003-02-16 17:41:18
|
Update of /cvsroot/dbunit/dbunit/src/java/org/dbunit/operation/mssqlserver In directory sc8-pr-cvs1:/tmp/cvs-serv27766/dbunit/src/java/org/dbunit/operation/mssqlserver Modified Files: InsertIdentityOperation.java Log Message: Added <classpath> nested element in ant task. It is used to load the JDBC classes. Index: InsertIdentityOperation.java =================================================================== RCS file: /cvsroot/dbunit/dbunit/src/java/org/dbunit/operation/mssqlserver/InsertIdentityOperation.java,v retrieving revision 1.13 retrieving revision 1.14 diff -C2 -d -r1.13 -r1.14 *** InsertIdentityOperation.java 14 Feb 2003 17:22:22 -0000 1.13 --- InsertIdentityOperation.java 16 Feb 2003 17:41:14 -0000 1.14 *************** *** 73,81 **** throws DataSetException { ! Column[] primaryKeys = metaData.getColumns(); // check all columns to see if they are an identity column ! for (int i = 0; i < primaryKeys.length; i++) { ! if (primaryKeys[i].getSqlTypeName().endsWith("identity")) { return true; --- 73,82 ---- throws DataSetException { ! // check all columns to see if they are an identity column ! Column[] columns = metaData.getColumns(); ! for (int i = 0; i < columns.length; i++) { ! if (columns[i].getSqlTypeName().endsWith("identity")) { return true; |
From: <mla...@us...> - 2003-02-16 17:41:17
|
Update of /cvsroot/dbunit/dbunit/src/java/org/dbunit/ant In directory sc8-pr-cvs1:/tmp/cvs-serv27766/dbunit/src/java/org/dbunit/ant Modified Files: DbUnitTask.java Log Message: Added <classpath> nested element in ant task. It is used to load the JDBC classes. Index: DbUnitTask.java =================================================================== RCS file: /cvsroot/dbunit/dbunit/src/java/org/dbunit/ant/DbUnitTask.java,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** DbUnitTask.java 15 Jul 2002 01:00:29 -0000 1.3 --- DbUnitTask.java 16 Feb 2003 17:41:14 -0000 1.4 *************** *** 31,34 **** --- 31,36 ---- import org.apache.tools.ant.*; + import org.apache.tools.ant.types.Path; + import org.apache.tools.ant.types.Reference; /** *************** *** 80,83 **** --- 82,89 ---- private List steps = new ArrayList(); + private Path classpath; + + private AntClassLoader loader; + /** * Flag for using the qualified table names. *************** *** 140,144 **** /** * Set the flag for supporting batch statements. ! * NOTE: This property cannot be used to force the usage of batch * statement if your database does not support it. */ --- 146,150 ---- /** * Set the flag for supporting batch statements. ! * NOTE: This property cannot be used to force the usage of batch * statement if your database does not support it. */ *************** *** 149,152 **** --- 155,193 ---- /** + * Set the classpath for loading the driver. + */ + public void setClasspath(Path classpath) + { + if (this.classpath == null) + { + this.classpath = classpath; + } + else + { + this.classpath.append(classpath); + } + } + + /** + * Create the classpath for loading the driver. + */ + public Path createClasspath() + { + if (this.classpath == null) + { + this.classpath = new Path(project); + } + return this.classpath.createPath(); + } + + /** + * Set the classpath for loading the driver using the classpath reference. + */ + public void setClasspathRef(Reference r) + { + createClasspath().setRefid(r); + } + + /** * Gets the Steps. */ *************** *** 218,223 **** { Class dc; ! log("Loading " + driver + " using system loader.", Project.MSG_VERBOSE); ! dc = Class.forName(driver); driverInstance = (Driver)dc.newInstance(); } --- 259,275 ---- { Class dc; ! if (classpath != null) ! { ! log("Loading " + driver + " using AntClassLoader with classpath " + classpath, ! Project.MSG_VERBOSE); ! ! loader = new AntClassLoader(project, classpath); ! dc = loader.loadClass(driver); ! } ! else ! { ! log("Loading " + driver + " using system loader.", Project.MSG_VERBOSE); ! dc = Class.forName(driver); ! } driverInstance = (Driver)dc.newInstance(); } |
From: <mla...@us...> - 2003-02-16 06:27:31
|
Update of /cvsroot/dbunit/./dbunit/src/test/org/dbunit/database In directory sc8-pr-cvs1:/tmp/cvs-serv5903/dbunit/src/test/org/dbunit/database Modified Files: QueryDataSetTest.java Log Message: QueryDataSet is now case insensitive and supports duplicate table names. I also fixed the QueryDataSetTest fixture to perform tests against QueryDataSet instead of DatabaseDataSet. Index: QueryDataSetTest.java =================================================================== RCS file: /cvsroot/dbunit/./dbunit/src/test/org/dbunit/database/QueryDataSetTest.java,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** QueryDataSetTest.java 16 Feb 2003 06:01:00 -0000 1.1 --- QueryDataSetTest.java 16 Feb 2003 06:27:28 -0000 1.2 *************** *** 24,36 **** import org.dbunit.DatabaseEnvironment; ! import org.dbunit.*; ! ! import org.dbunit.database.*; ! import org.dbunit.dataset.datatype.DataType; import org.dbunit.dataset.*; import java.util.Arrays; import java.util.Comparator; - import java.lang.reflect.Array; /** --- 24,34 ---- import org.dbunit.DatabaseEnvironment; ! import org.dbunit.HypersonicEnvironment; import org.dbunit.dataset.*; + import org.dbunit.database.IDatabaseConnection; + import org.dbunit.operation.DatabaseOperation; import java.util.Arrays; import java.util.Comparator; /** *************** *** 40,45 **** public class QueryDataSetTest extends AbstractDataSetTest { - private static final String ESCAPE_PATTERN_KEY = "dbunit.name.escapePattern"; - private IDatabaseConnection _connection; --- 38,41 ---- *************** *** 56,60 **** super.setUp(); ! _connection = DatabaseEnvironment.getInstance().getConnection(); } --- 52,59 ---- super.setUp(); ! DatabaseEnvironment env = DatabaseEnvironment.getInstance(); ! _connection = env.getConnection(); ! ! DatabaseOperation.CLEAN_INSERT.execute(_connection, env.getInitDataSet()); } *************** *** 71,151 **** protected IDataSet createDataSet() throws Exception { ! return _connection.createDataSet(); ! } ! ! protected IDataSet createDuplicateDataSet() throws Exception ! { ! throw new UnsupportedOperationException(); ! } ! protected void sort(Object[] array) ! { ! if (ITable[].class.isInstance(array)) ! { ! Arrays.sort(array, new TableComparator()); ! } ! else { ! Arrays.sort(array); } } ! private class TableComparator implements Comparator { ! public int compare(Object o1, Object o2) ! { ! String name1 = ((ITable)o1).getTableMetaData().getTableName(); ! String name2 = ((ITable)o2).getTableMetaData().getTableName(); ! ! return name1.compareTo(name2); ! } ! } ! ! //////////////////////////////////////////////////////////////////////////// ! // Test methods ! public void testGetSelectStatement() throws Exception ! { ! String schemaName = "schema"; ! String tableName = "table"; ! String query = "select c1, c2, c3 from schema.table where c1 > 100"; ! Column[] columns = new Column[]{ ! new Column("c1", DataType.UNKNOWN), ! new Column("c2", DataType.UNKNOWN), ! new Column("c3", DataType.UNKNOWN), ! }; ! String expected = "select c1, c2, c3 from schema.table where c1 > 100"; ! ITableMetaData metaData = new DefaultTableMetaData(tableName, columns); ! QueryDataSet ptds = new QueryDataSet(_connection); ! ptds.addTable(tableName,query); ! String s = ptds.getQuery(tableName); ! assertEquals("where clause coming out",query,s); } ! ! public void testGetSelectStatementWith2Tables() throws Exception ! { ! String sql = null; ! String tableName="table"; ! String tableName2="table2"; ! String query = "select c1, c2, c3 from schema.table where c1 > 100 order by c1, c2, c3"; ! String query2 = "select a1, a2, a3 from schema.table2 where c1 > 100 order by c1, c2, c3"; ! ! ! ! QueryDataSet ptds = new QueryDataSet(_connection); ! ptds.addTable(tableName,query); ! ! String s = ptds.getQuery(tableName); ! assertEquals("where clause coming out",query,s); ! ! ptds.addTable(tableName2,query2); ! s = ptds.getQuery(tableName2); ! assertEquals("where clause coming out",query2,s); ! ! } public void testGetSelectPartialData() throws Exception --- 70,107 ---- protected IDataSet createDataSet() throws Exception { ! String[] names = getExpectedNames(); ! QueryDataSet dataSet = new QueryDataSet(_connection); ! for (int i = 0; i < names.length; i++) { ! String name = names[i]; ! String query = "select * from " + name; ! dataSet.addTable(name, query); } + return dataSet; } ! protected IDataSet createDuplicateDataSet() throws Exception { ! QueryDataSet dataSet = new QueryDataSet(_connection); ! String[] names = getExpectedDuplicateNames(); ! // first table expect 1 row ! String queryOneRow = "select * from ONLY_PK_TABLE"; ! dataSet.addTable(names[0], queryOneRow); ! // second table expect 0 row ! String queryNoRow = "select * from EMPTY_TABLE"; ! dataSet.addTable(names[1], queryNoRow); ! // third table expect 2 row ! String queryTwoRow = "select * from PK_TABLE where PK0=0 or PK0=1"; ! dataSet.addTable(names[2], queryTwoRow); + return dataSet; } ! //////////////////////////////////////////////////////////////////////////// ! // Test methods public void testGetSelectPartialData() throws Exception *************** *** 153,161 **** QueryDataSet ptds = new QueryDataSet(_connection); ! ptds.addTable("PK_TABLE","SELECT PK0, PK1 FROM PK_TABLE where PK0 = 0"); ITable table = ptds.getTable("PK_TABLE"); ! assertEquals("","0",table.getValue(0,"PK0").toString()); ! assertEquals("","1",new String(table.getRowCount() + "")); } --- 109,117 ---- QueryDataSet ptds = new QueryDataSet(_connection); ! ptds.addTable("PK_TABLE", "SELECT PK0, PK1 FROM PK_TABLE where PK0 = 0"); ITable table = ptds.getTable("PK_TABLE"); ! assertEquals("", "0", table.getValue(0, "PK0").toString()); ! assertEquals("", "1", new String(table.getRowCount() + "")); } *************** *** 165,173 **** QueryDataSet ptds = new QueryDataSet(_connection); ! ptds.addTable("PK_TABLE","SELECT * FROM PK_TABLE where PK0 = 0"); ITable table = ptds.getTable("PK_TABLE"); ! assertEquals("","0",table.getValue(0,"PK0").toString()); ! assertEquals("","1",new String(table.getRowCount() + "")); } --- 121,129 ---- QueryDataSet ptds = new QueryDataSet(_connection); ! ptds.addTable("PK_TABLE", "SELECT * FROM PK_TABLE where PK0 = 0"); ITable table = ptds.getTable("PK_TABLE"); ! assertEquals("", "0", table.getValue(0, "PK0").toString()); ! assertEquals("", "1", new String(table.getRowCount() + "")); } *************** *** 177,185 **** QueryDataSet ptds = new QueryDataSet(_connection); ! ptds.addTable("PK_TABLE","SELECT PK0 FROM PK_TABLE"); ITable table = ptds.getTable("PK_TABLE"); ! assertEquals("","0",table.getValue(0,"PK0").toString()); ! assertEquals("","3",new String(table.getRowCount() + "")); } --- 133,141 ---- QueryDataSet ptds = new QueryDataSet(_connection); ! ptds.addTable("PK_TABLE", "SELECT PK0 FROM PK_TABLE"); ITable table = ptds.getTable("PK_TABLE"); ! assertEquals("", "0", table.getValue(0, "PK0").toString()); ! assertEquals("", "3", new String(table.getRowCount() + "")); } *************** *** 189,204 **** QueryDataSet ptds = new QueryDataSet(_connection); ! ptds.addTable("PK_TABLE","SELECT PK0 FROM PK_TABLE"); ITable table = ptds.getTable("PK_TABLE"); ! assertEquals("","0",table.getValue(0,"PK0").toString()); ! try { ! String test = table.getValue(0,"PK1").toString(); fail("Should not have reached here, we should have thrown a NoSuchColumnException"); } ! catch (NoSuchColumnException nsce){ String errorMsg = "org.dbunit.dataset.NoSuchColumnException: PK_TABLE.PK1"; ! assertTrue("Find text:" + errorMsg,nsce.toString().indexOf(errorMsg)>=0); --- 145,162 ---- QueryDataSet ptds = new QueryDataSet(_connection); ! ptds.addTable("PK_TABLE", "SELECT PK0 FROM PK_TABLE"); ITable table = ptds.getTable("PK_TABLE"); ! assertEquals("", "0", table.getValue(0, "PK0").toString()); ! try ! { ! String test = table.getValue(0, "PK1").toString(); fail("Should not have reached here, we should have thrown a NoSuchColumnException"); } ! catch (NoSuchColumnException nsce) ! { String errorMsg = "org.dbunit.dataset.NoSuchColumnException: PK_TABLE.PK1"; ! assertTrue("Find text:" + errorMsg, nsce.toString().indexOf(errorMsg) >= 0); *************** *** 210,219 **** QueryDataSet ptds = new QueryDataSet(_connection); ! ptds.addTable("SECOND_TABLE","SELECT * FROM SECOND_TABLE where COLUMN0='row 0 col 0'"); ITable table = ptds.getTable("SECOND_TABLE"); ! assertEquals("","row 0 col 0",table.getValue(0,"COLUMN0").toString()); ! assertEquals("","row 0 col 3",table.getValue(0,"COLUMN3").toString()); ! assertEquals("","1",new String(table.getRowCount() + "")); } --- 168,177 ---- QueryDataSet ptds = new QueryDataSet(_connection); ! ptds.addTable("SECOND_TABLE", "SELECT * FROM SECOND_TABLE where COLUMN0='row 0 col 0'"); ITable table = ptds.getTable("SECOND_TABLE"); ! assertEquals("", "row 0 col 0", table.getValue(0, "COLUMN0").toString()); ! assertEquals("", "row 0 col 3", table.getValue(0, "COLUMN3").toString()); ! assertEquals("", "1", new String(table.getRowCount() + "")); } *************** *** 223,232 **** QueryDataSet ptds = new QueryDataSet(_connection); ! ptds.addTable("SECOND_TABLE","SELECT COLUMN0, COLUMN3 FROM SECOND_TABLE where COLUMN0='row 0 col 0' and COLUMN2='row 0 col 2'"); ITable table = ptds.getTable("SECOND_TABLE"); ! assertEquals("","row 0 col 0",table.getValue(0,"COLUMN0").toString()); ! assertEquals("","row 0 col 3",table.getValue(0,"COLUMN3").toString()); ! assertEquals("","1",new String(table.getRowCount() + "")); } --- 181,190 ---- QueryDataSet ptds = new QueryDataSet(_connection); ! ptds.addTable("SECOND_TABLE", "SELECT COLUMN0, COLUMN3 FROM SECOND_TABLE where COLUMN0='row 0 col 0' and COLUMN2='row 0 col 2'"); ITable table = ptds.getTable("SECOND_TABLE"); ! assertEquals("", "row 0 col 0", table.getValue(0, "COLUMN0").toString()); ! assertEquals("", "row 0 col 3", table.getValue(0, "COLUMN3").toString()); ! assertEquals("", "1", new String(table.getRowCount() + "")); } *************** *** 237,251 **** QueryDataSet ptds = new QueryDataSet(_connection); ! ptds.addTable("SECOND_TABLE","SELECT * from SECOND_TABLE where COLUMN0='row 0 col 0' and COLUMN2='row 0 col 2'"); ! ptds.addTable("PK_TABLE","SELECT * FROM PK_TABLE where PK0 = 0"); table = ptds.getTable("SECOND_TABLE"); ! assertEquals("","row 0 col 0",table.getValue(0,"COLUMN0").toString()); ! assertEquals("","row 0 col 3",table.getValue(0,"COLUMN3").toString()); ! assertEquals("","1",new String(table.getRowCount() + "")); table = ptds.getTable("PK_TABLE"); ! assertEquals("","0",table.getValue(0,"PK0").toString()); ! assertEquals("","1",new String(table.getRowCount() + "")); } --- 195,209 ---- QueryDataSet ptds = new QueryDataSet(_connection); ! ptds.addTable("SECOND_TABLE", "SELECT * from SECOND_TABLE where COLUMN0='row 0 col 0' and COLUMN2='row 0 col 2'"); ! ptds.addTable("PK_TABLE", "SELECT * FROM PK_TABLE where PK0 = 0"); table = ptds.getTable("SECOND_TABLE"); ! assertEquals("", "row 0 col 0", table.getValue(0, "COLUMN0").toString()); ! assertEquals("", "row 0 col 3", table.getValue(0, "COLUMN3").toString()); ! assertEquals("", "1", new String(table.getRowCount() + "")); table = ptds.getTable("PK_TABLE"); ! assertEquals("", "0", table.getValue(0, "PK0").toString()); ! assertEquals("", "1", new String(table.getRowCount() + "")); } *************** *** 254,268 **** public void testLengthSyntax() throws Exception { ! if (DatabaseEnvironment.getInstance() instanceof HypersonicEnvironment){ ITable table = null; QueryDataSet ptds = new QueryDataSet(_connection); ! ptds.addTable("ATABLE","CALL LENGTH('hello world')"); table = ptds.getTable("ATABLE"); ! assertEquals("","1",new String(table.getRowCount() + "")); } - - - } --- 212,224 ---- public void testLengthSyntax() throws Exception { ! if (DatabaseEnvironment.getInstance() instanceof HypersonicEnvironment) ! { ITable table = null; QueryDataSet ptds = new QueryDataSet(_connection); ! ptds.addTable("ATABLE", "CALL LENGTH('hello world')"); table = ptds.getTable("ATABLE"); ! assertEquals("", "1", new String(table.getRowCount() + "")); } } *************** *** 272,310 **** QueryDataSet ptds = new QueryDataSet(_connection); ! ptds.addTable("SECOND_TABLE","SELECT * from SECOND_TABLE where COLUMN0='row 0 col 0' and COLUMN2='row 0 col 2'"); ! ptds.addTable("PK_TABLE",null); ! ! } ! ! ! public void testGetDuplicateTable() throws Exception ! { ! // Cannot test! Unsupported feature. ! } ! ! public void testGetDuplicateTableMetaData() throws Exception ! { ! // Cannot test! Unsupported feature. ! } ! ! public void testGetDuplicateTableNames() throws Exception ! { ! // Cannot test! Unsupported feature. ! } ! ! public void testGetDuplicateTables() throws Exception ! { ! // Cannot test! Unsupported feature. ! } - public void testGetCaseInsensitiveDuplicateTable() throws Exception - { - // Cannot test! Unsupported feature. } - public void testGetCaseInsensitiveDuplicateTableMetaData() throws Exception - { - // Cannot test! Unsupported feature. - } } --- 228,236 ---- QueryDataSet ptds = new QueryDataSet(_connection); ! ptds.addTable("SECOND_TABLE", "SELECT * from SECOND_TABLE where COLUMN0='row 0 col 0' and COLUMN2='row 0 col 2'"); ! ptds.addTable("PK_TABLE", null); } } |
From: <mla...@us...> - 2003-02-16 06:27:31
|
Update of /cvsroot/dbunit/./dbunit/src/java/org/dbunit/database In directory sc8-pr-cvs1:/tmp/cvs-serv5903/dbunit/src/java/org/dbunit/database Modified Files: QueryDataSet.java Log Message: QueryDataSet is now case insensitive and supports duplicate table names. I also fixed the QueryDataSetTest fixture to perform tests against QueryDataSet instead of DatabaseDataSet. Index: QueryDataSet.java =================================================================== RCS file: /cvsroot/dbunit/./dbunit/src/java/org/dbunit/database/QueryDataSet.java,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** QueryDataSet.java 16 Feb 2003 06:01:01 -0000 1.1 --- QueryDataSet.java 16 Feb 2003 06:27:27 -0000 1.2 *************** *** 21,40 **** */ package org.dbunit.database; import java.sql.*; import java.util.*; import org.dbunit.database.*; ! import org.dbunit.dataset.*; /** * @author Eric Pugh ! * @created December 4, 2002 * @version $Revision$ */ ! public class QueryDataSet implements IDataSet { private final IDatabaseConnection _connection; ! private Map _tableMap = new HashMap(); ! private Map _queryMap = null; --- 21,43 ---- */ package org.dbunit.database; + import java.sql.*; import java.util.*; import org.dbunit.database.*; ! import org.dbunit.dataset.AbstractDataSet; ! import org.dbunit.dataset.DataSetException; ! import org.dbunit.dataset.ITable; /** * @author Eric Pugh ! * @since December 4, 2002 * @version $Revision$ */ ! public class QueryDataSet extends AbstractDataSet ! { private final IDatabaseConnection _connection; ! private final List _tables = new ArrayList(); *************** *** 46,68 **** */ public QueryDataSet(IDatabaseConnection connection) ! throws SQLException { _connection = connection; } - /** ! * Gets the tableMap attribute of the QueryDataSet object * ! * @return The tableMap value ! * @exception org.dbunit.dataset.DataSetException Thrown if there is an issue. */ ! private Map getTableMap() ! throws DataSetException { ! ! return _tableMap; } - - //////////////////////////////////////////////////////////////////////////// // IDataSet interface --- 49,68 ---- */ public QueryDataSet(IDatabaseConnection connection) ! throws SQLException ! { _connection = connection; } /** ! * Adds a table and it's associted query to this dataset. * ! * @param tableName The name of the table ! * @param query The query to retrieve data with for this table */ ! public void addTable(String tableName, String query) ! { ! _tables.add(new TableEntry(tableName, query)); } //////////////////////////////////////////////////////////////////////////// // IDataSet interface *************** *** 74,186 **** * @exception org.dbunit.dataset.DataSetException Thrown if there is an issue. */ ! public String[] getTableNames() ! throws DataSetException { ! return (String[]) getTableMap().keySet().toArray(new String[0]); ! } ! ! ! /** ! * Gets the tableMetaData attribute of the QueryDataSet object ! * ! * @param tableName The name of the table to retrieve ! * @return The tableMetaData value ! * @exception org.dbunit.dataset.DataSetException Thrown if there is an issue. ! */ ! public ITableMetaData getTableMetaData(String tableName) ! throws DataSetException { ! ITableMetaData metaData = (ITableMetaData) getTableMap().get(tableName); ! if (metaData != null) { ! return metaData; ! } ! ! if (!getTableMap().containsKey(tableName)) { ! throw new NoSuchTableException(tableName); } ! metaData = new DatabaseTableMetaData(tableName, _connection); ! getTableMap().put(tableName, metaData); ! return metaData; } - /** ! * Gets a specific table of the QueryDataSet object * ! * @param tableName The name of the table to retrieve ! * @return The table * @exception org.dbunit.dataset.DataSetException Thrown if there is an issue. */ ! public ITable getTable(String tableName) ! throws DataSetException { ! try { ! ! Connection jdbcConnection = _connection.getConnection(); ! // String schema = _connection.getSchema(); ! Statement statement = jdbcConnection.createStatement(); ! try { ! String sql = getQuery(tableName); ! ResultSet resultSet = statement.executeQuery(sql); ! try { ! ITableMetaData metaData = ResultSetTable.createTableMetaData(tableName, resultSet); ! return new CachedResultSetTable(metaData, resultSet); ! } ! finally { ! resultSet.close(); } } ! finally { ! statement.close(); ! } } ! catch (SQLException e) { throw new DataSetException(e); } } ! /** ! * Gets the tables attribute of the QueryDataSet object ! * ! * @return The tables value ! * @exception org.dbunit.dataset.DataSetException Thrown if there is an issue. ! */ ! public ITable[] getTables() ! throws DataSetException { ! String[] names = getTableNames(); ! List tableList = new ArrayList(names.length); ! for (int i = 0; i < names.length; i++) { ! tableList.add(getTable(names[i])); } - return (ITable[]) tableList.toArray(new ITable[0]); - } - ! /** ! * Gets the query to be used for a specific table added to the QueryDataSet object ! * ! * @param tableName The name of the table ! * @return The query value ! */ ! public String getQuery(String tableName) { ! return (String) _queryMap.get(tableName); ! } ! /** ! * Adds a table and it's associted query to this dataset. ! * ! * @param tableName The name of the table ! * @param query The query to retrieve data with for this table ! */ ! public void addTable(String tableName, String query) { ! if (_queryMap == null) { ! _queryMap = new HashMap(); } - _queryMap.put(tableName, query); - _tableMap.put(tableName, null); } - } --- 74,154 ---- * @exception org.dbunit.dataset.DataSetException Thrown if there is an issue. */ ! public String[] getTableNames() throws DataSetException ! { ! List names = new ArrayList(); ! for (Iterator it = _tables.iterator(); it.hasNext();) ! { ! TableEntry entry = (TableEntry)it.next(); ! names.add(entry.getTableName()); } ! return (String[])names.toArray(new String[0]); } /** ! * Gets the tables attribute of the QueryDataSet object * ! * @return The tables value * @exception org.dbunit.dataset.DataSetException Thrown if there is an issue. */ ! public ITable[] getTables() throws DataSetException ! { ! try ! { ! List tableList = new ArrayList(); ! for (Iterator it = _tables.iterator(); it.hasNext();) ! { ! TableEntry entry = (TableEntry)it.next(); ! ITable table = entry.getTable(); ! if (table == null) ! { ! table = _connection.createQueryTable( ! entry.getTableName(), entry.getQuery()); ! entry.setTable(table); } + tableList.add(table); } ! ! return (ITable[])tableList.toArray(new ITable[0]); } ! catch (SQLException e) ! { throw new DataSetException(e); } } + private static class TableEntry + { + private final String _tableName; + private final String _query; + private ITable _table; ! public TableEntry(String tableName, String query) ! { ! _tableName = tableName; ! _query = query; } ! public String getTableName() ! { ! return _tableName; ! } + public String getQuery() + { + return _query; + } ! public ITable getTable() ! { ! return _table; } + public void setTable(ITable table) + { + _table = table; + } } } |
From: <mla...@us...> - 2003-02-16 06:01:05
|
Update of /cvsroot/dbunit/dbunit/src/test/org/dbunit/dataset In directory sc8-pr-cvs1:/tmp/cvs-serv966/dbunit/src/test/org/dbunit/dataset Modified Files: AllTests.java AbstractDataSetTest.java Removed Files: QueryDataSetTest.java Log Message: Moved QueryDataSet from the "dataset" package to the "database" package Index: AllTests.java =================================================================== RCS file: /cvsroot/dbunit/dbunit/src/test/org/dbunit/dataset/AllTests.java,v retrieving revision 1.9 retrieving revision 1.10 diff -C2 -d -r1.9 -r1.10 *** AllTests.java 15 Feb 2003 05:42:43 -0000 1.9 --- AllTests.java 16 Feb 2003 06:01:00 -0000 1.10 *************** *** 23,26 **** --- 23,28 ---- package org.dbunit.dataset; + import org.dbunit.database.QueryDataSetTest; + import junit.framework.Test; import junit.framework.TestSuite; *************** *** 49,53 **** suite.addTest(new TestSuite(LowerCaseDataSetTest.class)); suite.addTest(new TestSuite(LowerCaseTableMetaDataTest.class)); - suite.addTest(new TestSuite(QueryDataSetTest.class)); return suite; --- 51,54 ---- Index: AbstractDataSetTest.java =================================================================== RCS file: /cvsroot/dbunit/dbunit/src/test/org/dbunit/dataset/AbstractDataSetTest.java,v retrieving revision 1.18 retrieving revision 1.19 diff -C2 -d -r1.18 -r1.19 *** AbstractDataSetTest.java 15 Feb 2003 05:42:43 -0000 1.18 --- AbstractDataSetTest.java 16 Feb 2003 06:01:00 -0000 1.19 *************** *** 44,49 **** }; - - private static final String[] DUPLICATE_TABLE_NAMES = { "DUPLICATE_TABLE", --- 44,47 ---- --- QueryDataSetTest.java DELETED --- |
From: <mla...@us...> - 2003-02-16 06:01:04
|
Update of /cvsroot/dbunit/dbunit/src/test/org/dbunit/database In directory sc8-pr-cvs1:/tmp/cvs-serv966/dbunit/src/test/org/dbunit/database Modified Files: AllTests.java ResultsetTableTest.java Added Files: QueryDataSetTest.java Log Message: Moved QueryDataSet from the "dataset" package to the "database" package --- NEW FILE: QueryDataSetTest.java --- /* * QueryDataSetTest.java Feb 18, 2002 * * The DbUnit Database Testing Framework * Copyright (C)2002, Manuel Laflamme * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 2.1 of the License, or (at your option) any later version. * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * */ package org.dbunit.database; import org.dbunit.DatabaseEnvironment; import org.dbunit.*; import org.dbunit.database.*; import org.dbunit.dataset.datatype.DataType; import org.dbunit.dataset.*; import java.util.Arrays; import java.util.Comparator; import java.lang.reflect.Array; /** * @author Manuel Laflamme * @version $Revision: 1.1 $ */ public class QueryDataSetTest extends AbstractDataSetTest { private static final String ESCAPE_PATTERN_KEY = "dbunit.name.escapePattern"; private IDatabaseConnection _connection; public QueryDataSetTest(String s) { super(s); } //////////////////////////////////////////////////////////////////////////// // TestCase class protected void setUp() throws Exception { super.setUp(); _connection = DatabaseEnvironment.getInstance().getConnection(); } protected void tearDown() throws Exception { super.tearDown(); _connection = null; } //////////////////////////////////////////////////////////////////////////// // AbstractDataSetTest class protected IDataSet createDataSet() throws Exception { return _connection.createDataSet(); } protected IDataSet createDuplicateDataSet() throws Exception { throw new UnsupportedOperationException(); } protected void sort(Object[] array) { if (ITable[].class.isInstance(array)) { Arrays.sort(array, new TableComparator()); } else { Arrays.sort(array); } } private class TableComparator implements Comparator { public int compare(Object o1, Object o2) { String name1 = ((ITable)o1).getTableMetaData().getTableName(); String name2 = ((ITable)o2).getTableMetaData().getTableName(); return name1.compareTo(name2); } } //////////////////////////////////////////////////////////////////////////// // Test methods public void testGetSelectStatement() throws Exception { String schemaName = "schema"; String tableName = "table"; String query = "select c1, c2, c3 from schema.table where c1 > 100"; Column[] columns = new Column[]{ new Column("c1", DataType.UNKNOWN), new Column("c2", DataType.UNKNOWN), new Column("c3", DataType.UNKNOWN), }; String expected = "select c1, c2, c3 from schema.table where c1 > 100"; ITableMetaData metaData = new DefaultTableMetaData(tableName, columns); QueryDataSet ptds = new QueryDataSet(_connection); ptds.addTable(tableName,query); String s = ptds.getQuery(tableName); assertEquals("where clause coming out",query,s); } public void testGetSelectStatementWith2Tables() throws Exception { String sql = null; String tableName="table"; String tableName2="table2"; String query = "select c1, c2, c3 from schema.table where c1 > 100 order by c1, c2, c3"; String query2 = "select a1, a2, a3 from schema.table2 where c1 > 100 order by c1, c2, c3"; QueryDataSet ptds = new QueryDataSet(_connection); ptds.addTable(tableName,query); String s = ptds.getQuery(tableName); assertEquals("where clause coming out",query,s); ptds.addTable(tableName2,query2); s = ptds.getQuery(tableName2); assertEquals("where clause coming out",query2,s); } public void testGetSelectPartialData() throws Exception { QueryDataSet ptds = new QueryDataSet(_connection); ptds.addTable("PK_TABLE","SELECT PK0, PK1 FROM PK_TABLE where PK0 = 0"); ITable table = ptds.getTable("PK_TABLE"); assertEquals("","0",table.getValue(0,"PK0").toString()); assertEquals("","1",new String(table.getRowCount() + "")); } public void testGetAllColumnsWithStar() throws Exception { QueryDataSet ptds = new QueryDataSet(_connection); ptds.addTable("PK_TABLE","SELECT * FROM PK_TABLE where PK0 = 0"); ITable table = ptds.getTable("PK_TABLE"); assertEquals("","0",table.getValue(0,"PK0").toString()); assertEquals("","1",new String(table.getRowCount() + "")); } public void testGetAllRowsSingleColumn() throws Exception { QueryDataSet ptds = new QueryDataSet(_connection); ptds.addTable("PK_TABLE","SELECT PK0 FROM PK_TABLE"); ITable table = ptds.getTable("PK_TABLE"); assertEquals("","0",table.getValue(0,"PK0").toString()); assertEquals("","3",new String(table.getRowCount() + "")); } public void testOnlySpecifiedColumnsReturned() throws Exception { QueryDataSet ptds = new QueryDataSet(_connection); ptds.addTable("PK_TABLE","SELECT PK0 FROM PK_TABLE"); ITable table = ptds.getTable("PK_TABLE"); assertEquals("","0",table.getValue(0,"PK0").toString()); try { String test = table.getValue(0,"PK1").toString(); fail("Should not have reached here, we should have thrown a NoSuchColumnException"); } catch (NoSuchColumnException nsce){ String errorMsg = "org.dbunit.dataset.NoSuchColumnException: PK_TABLE.PK1"; assertTrue("Find text:" + errorMsg,nsce.toString().indexOf(errorMsg)>=0); } } public void testGetSelectPartialData2() throws Exception { QueryDataSet ptds = new QueryDataSet(_connection); ptds.addTable("SECOND_TABLE","SELECT * FROM SECOND_TABLE where COLUMN0='row 0 col 0'"); ITable table = ptds.getTable("SECOND_TABLE"); assertEquals("","row 0 col 0",table.getValue(0,"COLUMN0").toString()); assertEquals("","row 0 col 3",table.getValue(0,"COLUMN3").toString()); assertEquals("","1",new String(table.getRowCount() + "")); } public void testCombinedWhere() throws Exception { QueryDataSet ptds = new QueryDataSet(_connection); ptds.addTable("SECOND_TABLE","SELECT COLUMN0, COLUMN3 FROM SECOND_TABLE where COLUMN0='row 0 col 0' and COLUMN2='row 0 col 2'"); ITable table = ptds.getTable("SECOND_TABLE"); assertEquals("","row 0 col 0",table.getValue(0,"COLUMN0").toString()); assertEquals("","row 0 col 3",table.getValue(0,"COLUMN3").toString()); assertEquals("","1",new String(table.getRowCount() + "")); } public void testMultipleTables() throws Exception { ITable table = null; QueryDataSet ptds = new QueryDataSet(_connection); ptds.addTable("SECOND_TABLE","SELECT * from SECOND_TABLE where COLUMN0='row 0 col 0' and COLUMN2='row 0 col 2'"); ptds.addTable("PK_TABLE","SELECT * FROM PK_TABLE where PK0 = 0"); table = ptds.getTable("SECOND_TABLE"); assertEquals("","row 0 col 0",table.getValue(0,"COLUMN0").toString()); assertEquals("","row 0 col 3",table.getValue(0,"COLUMN3").toString()); assertEquals("","1",new String(table.getRowCount() + "")); table = ptds.getTable("PK_TABLE"); assertEquals("","0",table.getValue(0,"PK0").toString()); assertEquals("","1",new String(table.getRowCount() + "")); } /* This JUNIT test case only works against Hypersonic! */ public void testLengthSyntax() throws Exception { if (DatabaseEnvironment.getInstance() instanceof HypersonicEnvironment){ ITable table = null; QueryDataSet ptds = new QueryDataSet(_connection); ptds.addTable("ATABLE","CALL LENGTH('hello world')"); table = ptds.getTable("ATABLE"); assertEquals("","1",new String(table.getRowCount() + "")); } } public void testMultipleTablesWithMissingWhere() throws Exception { ITable table = null; QueryDataSet ptds = new QueryDataSet(_connection); ptds.addTable("SECOND_TABLE","SELECT * from SECOND_TABLE where COLUMN0='row 0 col 0' and COLUMN2='row 0 col 2'"); ptds.addTable("PK_TABLE",null); } public void testGetDuplicateTable() throws Exception { // Cannot test! Unsupported feature. } public void testGetDuplicateTableMetaData() throws Exception { // Cannot test! Unsupported feature. } public void testGetDuplicateTableNames() throws Exception { // Cannot test! Unsupported feature. } public void testGetDuplicateTables() throws Exception { // Cannot test! Unsupported feature. } public void testGetCaseInsensitiveDuplicateTable() throws Exception { // Cannot test! Unsupported feature. } public void testGetCaseInsensitiveDuplicateTableMetaData() throws Exception { // Cannot test! Unsupported feature. } } Index: AllTests.java =================================================================== RCS file: /cvsroot/dbunit/dbunit/src/test/org/dbunit/database/AllTests.java,v retrieving revision 1.8 retrieving revision 1.9 diff -C2 -d -r1.8 -r1.9 *** AllTests.java 13 Jun 2002 17:24:59 -0000 1.8 --- AllTests.java 16 Feb 2003 06:01:00 -0000 1.9 *************** *** 39,42 **** --- 39,43 ---- suite.addTest(new TestSuite(DatabaseDataSetTest.class)); suite.addTest(new TestSuite(DatabaseTableMetaDataTest.class)); + suite.addTest(new TestSuite(QueryDataSetTest.class)); suite.addTest(new TestSuite(ResultsetTableTest.class)); Index: ResultsetTableTest.java =================================================================== RCS file: /cvsroot/dbunit/dbunit/src/test/org/dbunit/database/ResultsetTableTest.java,v retrieving revision 1.7 retrieving revision 1.8 diff -C2 -d -r1.7 -r1.8 *** ResultsetTableTest.java 13 Jun 2002 17:24:59 -0000 1.7 --- ResultsetTableTest.java 16 Feb 2003 06:01:00 -0000 1.8 *************** *** 24,27 **** --- 24,28 ---- import org.dbunit.DatabaseEnvironment; + import org.dbunit.operation.DatabaseOperation; import org.dbunit.dataset.AbstractTableTest; import org.dbunit.dataset.ITable; *************** *** 40,45 **** protected ITable createTable() throws Exception { ! IDatabaseConnection connection = ! DatabaseEnvironment.getInstance().getConnection(); String sql = "select * from TEST_TABLE order by COLUMN0"; --- 41,48 ---- protected ITable createTable() throws Exception { ! DatabaseEnvironment env = DatabaseEnvironment.getInstance(); ! IDatabaseConnection connection = env.getConnection(); ! ! DatabaseOperation.CLEAN_INSERT.execute(connection, env.getInitDataSet()); String sql = "select * from TEST_TABLE order by COLUMN0"; |
From: <mla...@us...> - 2003-02-16 06:01:04
|
Update of /cvsroot/dbunit/dbunit/src/test/org/dbunit In directory sc8-pr-cvs1:/tmp/cvs-serv966/dbunit/src/test/org/dbunit Modified Files: HypersonicEnvironment.java DatabaseEnvironment.java AbstractDatabaseTest.java Log Message: Moved QueryDataSet from the "dataset" package to the "database" package Index: HypersonicEnvironment.java =================================================================== RCS file: /cvsroot/dbunit/dbunit/src/test/org/dbunit/HypersonicEnvironment.java,v retrieving revision 1.8 retrieving revision 1.9 diff -C2 -d -r1.8 -r1.9 *** HypersonicEnvironment.java 7 Aug 2002 01:32:12 -0000 1.8 --- HypersonicEnvironment.java 16 Feb 2003 06:00:59 -0000 1.9 *************** *** 23,26 **** --- 23,28 ---- package org.dbunit; + import org.dbunit.operation.DatabaseOperation; + import java.io.*; import java.sql.Connection; *************** *** 59,62 **** --- 61,68 ---- } + public void closeConnection() throws Exception + { + DatabaseOperation.DELETE_ALL.execute(getConnection(), getInitDataSet()); + } } Index: DatabaseEnvironment.java =================================================================== RCS file: /cvsroot/dbunit/dbunit/src/test/org/dbunit/DatabaseEnvironment.java,v retrieving revision 1.12 retrieving revision 1.13 diff -C2 -d -r1.12 -r1.13 *** DatabaseEnvironment.java 14 Feb 2003 03:21:59 -0000 1.12 --- DatabaseEnvironment.java 16 Feb 2003 06:00:59 -0000 1.13 *************** *** 27,30 **** --- 27,31 ---- import org.dbunit.dataset.IDataSet; import org.dbunit.dataset.xml.XmlDataSet; + import org.dbunit.operation.DatabaseOperation; import java.io.File; *************** *** 77,87 **** _profile = profile; ! String name = profile.getDriverClass(); ! Class driverClass = Class.forName(name); ! Connection connection = DriverManager.getConnection( ! _profile.getConnectionUrl(), _profile.getUser(), ! _profile.getPassword()); ! _connection = new DatabaseConnection(connection, ! _profile.getSchema()); File file = new File("src/xml/dataSetTest.xml"); --- 78,88 ---- _profile = profile; ! // String name = profile.getDriverClass(); ! // Class.forName(name); ! // Connection connection = DriverManager.getConnection( ! // _profile.getConnectionUrl(), _profile.getUser(), ! // _profile.getPassword()); ! // _connection = new DatabaseConnection(connection, ! // _profile.getSchema()); File file = new File("src/xml/dataSetTest.xml"); *************** *** 91,95 **** --- 92,115 ---- public IDatabaseConnection getConnection() throws Exception { + if (_connection == null) + { + String name = _profile.getDriverClass(); + Class.forName(name); + Connection connection = DriverManager.getConnection( + _profile.getConnectionUrl(), _profile.getUser(), + _profile.getPassword()); + _connection = new DatabaseConnection(connection, + _profile.getSchema()); + } return _connection; + } + + public void closeConnection() throws Exception + { + if (_connection != null) + { + _connection.close(); + _connection = null; + } } Index: AbstractDatabaseTest.java =================================================================== RCS file: /cvsroot/dbunit/dbunit/src/test/org/dbunit/AbstractDatabaseTest.java,v retrieving revision 1.10 retrieving revision 1.11 diff -C2 -d -r1.10 -r1.11 *** AbstractDatabaseTest.java 4 Aug 2002 01:07:13 -0000 1.10 --- AbstractDatabaseTest.java 16 Feb 2003 06:00:59 -0000 1.11 *************** *** 26,29 **** --- 26,30 ---- import org.dbunit.dataset.IDataSet; import org.dbunit.dataset.ITable; + import org.dbunit.operation.DatabaseOperation; /** *************** *** 77,80 **** --- 78,83 ---- super.tearDown(); + DatabaseOperation.DELETE_ALL.execute(_connection, _connection.createDataSet()); + _connection = null; setEscapePattern(null); *************** *** 100,104 **** --- 103,113 ---- protected void closeConnection(IDatabaseConnection connection) throws Exception { + // getEnvironment().closeConnection(); } + // + // protected DatabaseOperation getTearDownOperation() throws Exception + // { + // return DatabaseOperation.DELETE_ALL; + // } } |
From: <mla...@us...> - 2003-02-16 06:01:04
|
Update of /cvsroot/dbunit/./dbunit/src/java/org/dbunit/database In directory sc8-pr-cvs1:/tmp/cvs-serv966/dbunit/src/java/org/dbunit/database Added Files: QueryDataSet.java Log Message: Moved QueryDataSet from the "dataset" package to the "database" package --- NEW FILE: QueryDataSet.java --- /* * QueryDataSet.java Dec 4, 2002 * * The DbUnit Database Testing Framework * Copyright (C)2002, Manuel Laflamme * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 2.1 of the License, or (at your option) any later version. * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * */ package org.dbunit.database; import java.sql.*; import java.util.*; import org.dbunit.database.*; import org.dbunit.dataset.*; /** * @author Eric Pugh * @created December 4, 2002 * @version $Revision: 1.1 $ */ public class QueryDataSet implements IDataSet { private final IDatabaseConnection _connection; private Map _tableMap = new HashMap(); private Map _queryMap = null; /** * Create a QueryDataSet by passing in the connection to the database to use. * * @param connection The connection object to the database. * @exception java.sql.SQLException Description of the Exception */ public QueryDataSet(IDatabaseConnection connection) throws SQLException { _connection = connection; } /** * Gets the tableMap attribute of the QueryDataSet object * * @return The tableMap value * @exception org.dbunit.dataset.DataSetException Thrown if there is an issue. */ private Map getTableMap() throws DataSetException { return _tableMap; } //////////////////////////////////////////////////////////////////////////// // IDataSet interface /** * Gets the tableNames attribute of the QueryDataSet object * * @return An array of all the table names * @exception org.dbunit.dataset.DataSetException Thrown if there is an issue. */ public String[] getTableNames() throws DataSetException { return (String[]) getTableMap().keySet().toArray(new String[0]); } /** * Gets the tableMetaData attribute of the QueryDataSet object * * @param tableName The name of the table to retrieve * @return The tableMetaData value * @exception org.dbunit.dataset.DataSetException Thrown if there is an issue. */ public ITableMetaData getTableMetaData(String tableName) throws DataSetException { ITableMetaData metaData = (ITableMetaData) getTableMap().get(tableName); if (metaData != null) { return metaData; } if (!getTableMap().containsKey(tableName)) { throw new NoSuchTableException(tableName); } metaData = new DatabaseTableMetaData(tableName, _connection); getTableMap().put(tableName, metaData); return metaData; } /** * Gets a specific table of the QueryDataSet object * * @param tableName The name of the table to retrieve * @return The table * @exception org.dbunit.dataset.DataSetException Thrown if there is an issue. */ public ITable getTable(String tableName) throws DataSetException { try { Connection jdbcConnection = _connection.getConnection(); // String schema = _connection.getSchema(); Statement statement = jdbcConnection.createStatement(); try { String sql = getQuery(tableName); ResultSet resultSet = statement.executeQuery(sql); try { ITableMetaData metaData = ResultSetTable.createTableMetaData(tableName, resultSet); return new CachedResultSetTable(metaData, resultSet); } finally { resultSet.close(); } } finally { statement.close(); } } catch (SQLException e) { throw new DataSetException(e); } } /** * Gets the tables attribute of the QueryDataSet object * * @return The tables value * @exception org.dbunit.dataset.DataSetException Thrown if there is an issue. */ public ITable[] getTables() throws DataSetException { String[] names = getTableNames(); List tableList = new ArrayList(names.length); for (int i = 0; i < names.length; i++) { tableList.add(getTable(names[i])); } return (ITable[]) tableList.toArray(new ITable[0]); } /** * Gets the query to be used for a specific table added to the QueryDataSet object * * @param tableName The name of the table * @return The query value */ public String getQuery(String tableName) { return (String) _queryMap.get(tableName); } /** * Adds a table and it's associted query to this dataset. * * @param tableName The name of the table * @param query The query to retrieve data with for this table */ public void addTable(String tableName, String query) { if (_queryMap == null) { _queryMap = new HashMap(); } _queryMap.put(tableName, query); _tableMap.put(tableName, null); } } |
From: <mla...@us...> - 2003-02-16 06:01:03
|
Update of /cvsroot/dbunit/dbunit/src/java/org/dbunit/dataset In directory sc8-pr-cvs1:/tmp/cvs-serv966/dbunit/src/java/org/dbunit/dataset Removed Files: QueryDataSet.java Log Message: Moved QueryDataSet from the "dataset" package to the "database" package --- QueryDataSet.java DELETED --- |
From: <mla...@us...> - 2003-02-15 18:57:50
|
Update of /cvsroot/dbunit/dbunit/src/test/org/dbunit/ant In directory sc8-pr-cvs1:/tmp/cvs-serv19497/dbunit/src/test/org/dbunit/ant Modified Files: DbUnitTaskTest.java Log Message: Keep the <table> and <query> elements sequence as defined in <export> subtask Index: DbUnitTaskTest.java =================================================================== RCS file: /cvsroot/dbunit/dbunit/src/test/org/dbunit/ant/DbUnitTaskTest.java,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -d -r1.6 -r1.7 *** DbUnitTaskTest.java 11 Dec 2002 15:56:46 -0000 1.6 --- DbUnitTaskTest.java 15 Feb 2003 18:57:47 -0000 1.7 *************** *** 259,278 **** String targetName = "test-export-query"; Export export = (Export)getFirstStepFromTarget(targetName); ! assertTrue("Should have been a flat format, " ! + "but was: " + export.getFormat(), ! export.getFormat().equalsIgnoreCase("flat")); ! List queries = export.getQueries(); ! assertTrue("Export should have had two sub queries, but has: " ! + queries.size(), queries.size() == 2); Query testTable = (Query)queries.get(0); Query pkTable = (Query)queries.get(1); ! assertTrue("Should have been been TABLE TEST_TABLE, but was: " ! + testTable.getName(), testTable.getName().equals("TEST_TABLE")); ! assertTrue("Should have been been TABLE PK_TABLE, but was: " ! + pkTable.getName(), pkTable.getName().equals("PK_TABLE")); ! assertTrue("Should have been been query for TABLE TEST_TABLE, but was: " ! + testTable.getSql(), testTable.getSql().equals("SELECT * FROM TEST_TABLE")); ! assertTrue("Should have been been query for TABLE PK_TABLE, but was: " ! + pkTable.getSql(), pkTable.getSql().equals("SELECT * FROM PK_TABLE")); } --- 259,274 ---- String targetName = "test-export-query"; Export export = (Export)getFirstStepFromTarget(targetName); ! assertEquals("format", "flat", export.getFormat()); ! ! List queries = export.getTables(); ! assertEquals("query count", 2, getQueryCount(queries)); ! Query testTable = (Query)queries.get(0); + assertEquals("name", "TEST_TABLE", testTable.getName()); + assertEquals("sql", "SELECT * FROM TEST_TABLE", testTable.getSql()); + Query pkTable = (Query)queries.get(1); ! assertEquals("name", "PK_TABLE", pkTable.getName()); ! assertEquals("sql", "SELECT * FROM PK_TABLE", pkTable.getSql()); } *************** *** 281,299 **** String targetName = "test-export-query-mixed"; Export export = (Export)getFirstStepFromTarget(targetName); ! assertTrue("Should have been a flat format, " ! + "but was: " + export.getFormat(), ! export.getFormat().equalsIgnoreCase("flat")); List tables = export.getTables(); ! assertTrue("Export should have had one table, but has: " ! + tables.size(), tables.size() == 1); ! Table testTable = (Table)tables.get(0); ! List queries = export.getQueries(); ! assertTrue("Export should have had one querie, but has: " ! + queries.size(), queries.size() == 1); ! Query pkTable = (Query)queries.get(0); ! assertTrue("Should have been been a query for TABLE PK_TABLE, but was: " ! + pkTable.getSql(), pkTable.getSql()!= null); } --- 277,292 ---- String targetName = "test-export-query-mixed"; Export export = (Export)getFirstStepFromTarget(targetName); ! assertEquals("format", "flat", export.getFormat()); ! List tables = export.getTables(); ! assertEquals("total count", 2, tables.size()); ! assertEquals("table count", 1, getTableCount(tables)); ! assertEquals("query count", 1, getQueryCount(tables)); ! Table testTable = (Table)tables.get(0); ! assertEquals("name", "TEST_TABLE", testTable.getName()); + Query pkTable = (Query)tables.get(1); + assertEquals("name", "PK_TABLE", pkTable.getName()); } *************** *** 303,306 **** --- 296,327 ---- DatabaseOperation dbOper = oper.getDbOperation(); assertTrue(failMessage + ", but was: " + dbOper, expected.equals(dbOper)); + } + + protected int getQueryCount(List tables) + { + int count = 0; + for (Iterator it = tables.iterator(); it.hasNext();) + { + if (it.next() instanceof Query) + { + count++; + } + } + + return count; + } + + protected int getTableCount(List tables) + { + int count = 0; + for (Iterator it = tables.iterator(); it.hasNext();) + { + if (it.next() instanceof Table) + { + count++; + } + } + + return count; } |
From: <mla...@us...> - 2003-02-15 18:57:50
|
Update of /cvsroot/dbunit/dbunit/src/java/org/dbunit/ant In directory sc8-pr-cvs1:/tmp/cvs-serv19497/dbunit/src/java/org/dbunit/ant Modified Files: Export.java Table.java Log Message: Keep the <table> and <query> elements sequence as defined in <export> subtask Index: Export.java =================================================================== RCS file: /cvsroot/dbunit/dbunit/src/java/org/dbunit/ant/Export.java,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -d -r1.6 -r1.7 *** Export.java 14 Feb 2003 17:22:21 -0000 1.6 --- Export.java 15 Feb 2003 18:57:47 -0000 1.7 *************** *** 25,32 **** import org.dbunit.DatabaseUnitException; import org.dbunit.database.IDatabaseConnection; ! import org.dbunit.dataset.IDataSet; ! import org.dbunit.dataset.QueryDataSet; ! import org.dbunit.dataset.CompositeDataSet; ! import org.dbunit.dataset.xml.*; import java.io.*; --- 25,32 ---- import org.dbunit.DatabaseUnitException; import org.dbunit.database.IDatabaseConnection; ! import org.dbunit.dataset.*; ! import org.dbunit.dataset.xml.FlatDtdDataSet; ! import org.dbunit.dataset.xml.FlatXmlDataSet; ! import org.dbunit.dataset.xml.XmlDataSet; import java.io.*; *************** *** 34,37 **** --- 34,38 ---- import java.util.ArrayList; import java.util.List; + import java.util.Iterator; /** *************** *** 43,55 **** * @author Timothy Ruppert && Ben Cox * @version $Revision$ ! * @see org.dbunit.ant.DbUnitTaskStep */ public class Export implements DbUnitTaskStep { ! private File dest; ! private String format = "flat"; ! private List tables = new ArrayList(); ! private List queries = new ArrayList(); public Export() --- 44,56 ---- * @author Timothy Ruppert && Ben Cox * @version $Revision$ ! * @see DbUnitTaskStep */ public class Export implements DbUnitTaskStep { ! private File _dest; ! private String _format = "flat"; ! private List _tables = new ArrayList(); ! // private List queries = new ArrayList(); public Export() *************** *** 64,88 **** public File getDest() { ! return dest; } public String getFormat() { ! return format; } public List getTables() { ! return tables; ! } ! ! public List getQueries() ! { ! return queries; } public void setDest(File dest) { ! this.dest = dest; } --- 65,84 ---- public File getDest() { ! return _dest; } public String getFormat() { ! return _format; } public List getTables() { ! return _tables; } public void setDest(File dest) { ! _dest = dest; } *************** *** 93,97 **** || format.equalsIgnoreCase("dtd")) { ! this.format = format; } else --- 89,93 ---- || format.equalsIgnoreCase("dtd")) { ! _format = format; } else *************** *** 103,126 **** public void addTable(Table table) { ! tables.add(table); } public void addQuery(Query query) { ! queries.add(query); } public void execute(IDatabaseConnection connection) throws DatabaseUnitException { - IDataSet dataset = null; try { ! if (dest == null) { ! throw new DatabaseUnitException("'dest' is a required attribute of the <export> step."); } ! // retrieve the dataset if no tables or queries specifedid. ! if (tables.size() == 0 && queries.size()==0) { dataset = connection.createDataSet(); --- 99,123 ---- public void addTable(Table table) { ! _tables.add(table); } public void addQuery(Query query) { ! _tables.add(query); } public void execute(IDatabaseConnection connection) throws DatabaseUnitException { try { + IDataSet dataset = null; ! if (_dest == null) { ! throw new DatabaseUnitException("'_dest' is a required attribute of the <export> step."); } ! ! // retrieve the complete database if no tables or queries specified. ! if (_tables.size() == 0) { dataset = connection.createDataSet(); *************** *** 128,167 **** else { ! if (tables.size() > 0) { ! dataset = connection.createDataSet(getTableArray()); ! } ! if (queries.size() > 0) { ! QueryDataSet queryDataSet = new QueryDataSet(connection); ! for (int i = 0; i < queries.size(); i++){ ! Query query = (Query)queries.get(i); ! if (query.getSql() == null){ ! throw new DatabaseUnitException("'sql' is a required attribute of the <query> step."); ! } ! queryDataSet.addTable(query.getName(),query.getSql()); ! ! } ! //crummy merge! ! if(dataset != null) { ! dataset = new CompositeDataSet(queryDataSet,dataset); } ! else { ! dataset = queryDataSet; } } } // save the dataset ! OutputStream out = new FileOutputStream(dest); try { ! if (format.equalsIgnoreCase("flat")) { FlatXmlDataSet.write(dataset, out); } ! else if (format.equalsIgnoreCase("xml")) { XmlDataSet.write(dataset, out); } ! else if (format.equalsIgnoreCase("dtd")) { FlatDtdDataSet.write(dataset, out); --- 125,159 ---- else { ! List tableList = new ArrayList(); ! for (Iterator it = _tables.iterator(); it.hasNext();) ! { ! Object table = it.next(); ! if (table instanceof Query) ! { ! tableList.add(createTable((Query)table, connection)); } ! else ! { ! tableList.add(createTable((Table)table, connection)); } } + ITable[] tables = (ITable[])tableList.toArray(new ITable[0]); + dataset = new DefaultDataSet(tables); + } // save the dataset ! Writer out = new FileWriter(_dest); try { ! if (_format.equalsIgnoreCase("flat")) { FlatXmlDataSet.write(dataset, out); } ! else if (_format.equalsIgnoreCase("xml")) { XmlDataSet.write(dataset, out); } ! else if (_format.equalsIgnoreCase("dtd")) { FlatDtdDataSet.write(dataset, out); *************** *** 184,193 **** } private String[] getTableArray() { ! String[] result = new String[tables.size()]; ! for (int i = 0; i < tables.size(); i++) { ! Table table = (Table)tables.get(i); result[i] = table.getName(); } --- 176,197 ---- } + private ITable createTable(Table table, IDatabaseConnection connection) + throws DataSetException, SQLException + { + return connection.createDataSet().getTable(table.getName()); + } + + private ITable createTable(Query query, IDatabaseConnection connection) + throws DataSetException, SQLException + { + return connection.createQueryTable(query.getName(), query.getSql()); + } + private String[] getTableArray() { ! String[] result = new String[_tables.size()]; ! for (int i = 0; i < _tables.size(); i++) { ! Table table = (Table)_tables.get(i); result[i] = table.getName(); } *************** *** 195,213 **** } - // private String[] convertListToStringArray(List list){ - // String []strArray = new String[list.size()]; - // for (int i = 0; i < list.size(); i++) - // { - // Table table = (Table)list.get(i); - // strArray[i] = table.getName(); - // } - // return strArray; - // } - // public String getLogMessage() { return "Executing export: " ! + "\n in format: " + format ! + " to datafile: " + getAbsolutePath(dest); } --- 199,207 ---- } public String getLogMessage() { return "Executing export: " ! + "\n in _format: " + _format ! + " to datafile: " + getAbsolutePath(_dest); } *************** *** 217,224 **** StringBuffer result = new StringBuffer(); result.append("Export: "); ! result.append(" dest=" + getAbsolutePath(dest)); ! result.append(", format= " + format); ! result.append(", tables= " + tables); ! result.append(", queries= " + queries); return result.toString(); --- 211,217 ---- StringBuffer result = new StringBuffer(); result.append("Export: "); ! result.append(" _dest=" + getAbsolutePath(_dest)); ! result.append(", _format= " + _format); ! result.append(", _tables= " + _tables); return result.toString(); Index: Table.java =================================================================== RCS file: /cvsroot/dbunit/dbunit/src/java/org/dbunit/ant/Table.java,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** Table.java 11 Dec 2002 15:53:50 -0000 1.3 --- Table.java 15 Feb 2003 18:57:47 -0000 1.4 *************** *** 34,38 **** private String name; - private String query; public Table() --- 34,37 ---- *************** *** 56,73 **** result.append("Table: "); result.append(" name=" + name); - result.append(" query=" + query); - return result.toString(); - } - - public String getQuery() - { - return query; - } - - public void setQuery(String query) - { - this.query = query; } } --- 55,60 ---- |
From: <mla...@us...> - 2003-02-15 18:57:50
|
Update of /cvsroot/dbunit/dbunit/src/java/org/dbunit/dataset In directory sc8-pr-cvs1:/tmp/cvs-serv19497/dbunit/src/java/org/dbunit/dataset Modified Files: QueryDataSet.java Log Message: Keep the <table> and <query> elements sequence as defined in <export> subtask Index: QueryDataSet.java =================================================================== RCS file: /cvsroot/dbunit/dbunit/src/java/org/dbunit/dataset/QueryDataSet.java,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** QueryDataSet.java 14 Feb 2003 17:22:23 -0000 1.2 --- QueryDataSet.java 15 Feb 2003 18:57:47 -0000 1.3 *************** *** 1,4 **** /* ! * QueryDataSet.java Feb 17, 2002 * * The DbUnit Database Testing Framework --- 1,4 ---- /* ! * QueryDataSet.java Dec 4, 2002 * * The DbUnit Database Testing Framework *************** *** 39,43 **** /** ! *Create a QueryDataSet by passing in the connection to the database to use. * * @param connection The connection object to the database. --- 39,43 ---- /** ! * Create a QueryDataSet by passing in the connection to the database to use. * * @param connection The connection object to the database. |
From: <mla...@us...> - 2003-02-15 05:42:47
|
Update of /cvsroot/dbunit/dbunit/src/test/org/dbunit/dataset/xml In directory sc8-pr-cvs1:/tmp/cvs-serv29584/dbunit/src/test/org/dbunit/dataset/xml Modified Files: FlatXmlDataSetTest.java Log Message: DbUnit is now case insensitive!!! Index: FlatXmlDataSetTest.java =================================================================== RCS file: /cvsroot/dbunit/dbunit/src/test/org/dbunit/dataset/xml/FlatXmlDataSetTest.java,v retrieving revision 1.11 retrieving revision 1.12 diff -C2 -d -r1.11 -r1.12 *** FlatXmlDataSetTest.java 14 Feb 2003 03:22:00 -0000 1.11 --- FlatXmlDataSetTest.java 15 Feb 2003 05:42:43 -0000 1.12 *************** *** 52,98 **** } ! // public void testWrite() throws Exception ! // { ! // List tableList = new ArrayList(); ! // ! // IDataSet dataSet = createDataSet(); ! // File tempFile = File.createTempFile("flatXmlDataSetTest", ".xml"); ! // try ! // { ! // OutputStream out = new FileOutputStream(tempFile); ! // try ! // { ! // // write dataset in temp file ! // FlatXmlDataSet.write(dataSet, out); ! // ! // // load new dataset from temp file ! // FlatXmlDataSet xmlDataSet2 = new FlatXmlDataSet( ! // new FileInputStream(tempFile)); ! // ! // // verify table count ! // assertEquals("table count", dataSet.getTableNames().length, ! // xmlDataSet2.getTableNames().length); ! // ! // // verify each table ! // String[] tableNames = dataSet.getTableNames(); ! // for (int i = 0; i < tableNames.length; i++) ! // { ! // String name = tableNames[i]; ! // ITable table1 = dataSet.getTable(name); ! // ITable table2 = xmlDataSet2.getTable(name); ! // assertTrue("not same instance", table1 != table2); ! // Assertion.assertEquals(table1, table2); ! // } ! // } ! // finally ! // { ! // out.close(); ! // } ! // } ! // finally ! // { ! // tempFile.delete(); ! // } ! // } public void testWrite() throws Exception --- 52,76 ---- } ! public void testMissingColumnAndEnableDtdMetadata() throws Exception ! { ! IDataSet dataSet = new FlatXmlDataSet( ! new File("src/xml/flatXmlTableTest.xml"), true); ! ! ITable table = dataSet.getTable("MISSING_VALUES"); ! ! Column[] columns = table.getTableMetaData().getColumns(); ! assertEquals("column count", 3, columns.length); ! } ! ! public void testMissingColumnAndDisableDtdMetadata() throws Exception ! { ! IDataSet dataSet = new FlatXmlDataSet( ! new File("src/xml/flatXmlTableTest.xml"), false); ! ! ITable table = dataSet.getTable("MISSING_VALUES"); ! ! Column[] columns = table.getTableMetaData().getColumns(); ! assertEquals("column count", 2, columns.length); ! } public void testWrite() throws Exception |
Update of /cvsroot/dbunit/dbunit/src/java/org/dbunit/dataset In directory sc8-pr-cvs1:/tmp/cvs-serv29584/dbunit/src/java/org/dbunit/dataset Modified Files: AbstractTableMetaData.java AbstractTable.java DataSetUtils.java CompositeDataSet.java Added Files: LowerCaseTableMetaData.java LowerCaseDataSet.java Log Message: DbUnit is now case insensitive!!! --- NEW FILE: LowerCaseTableMetaData.java --- /* * DefaultTableMetaData.java Feb 14, 2003 * * The DbUnit Database Testing Framework * Copyright (C)2002, Manuel Laflamme * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 2.1 of the License, or (at your option) any later version. * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * */ package org.dbunit.dataset; /** * Specialized ITableMetaData implementation that convert the table name and * column names to lower case. Used in DbUnit own test suite to verify that * operations are case insensitive. * * @author Manuel Laflamme * @version $Revision: 1.1 $ */ public class LowerCaseTableMetaData extends AbstractTableMetaData { private final String _tableName; private final Column[] _columns; private final Column[] _primaryKeys; public LowerCaseTableMetaData(String tableName, Column[] columns) //throws DataSetException { this(tableName, columns, new Column[0]); } public LowerCaseTableMetaData(String tableName, Column[] columns, String[] primaryKeys) //throws DataSetException { this(tableName, columns, getPrimaryKeys(columns, primaryKeys)); } public LowerCaseTableMetaData(ITableMetaData metaData) throws DataSetException { this(metaData.getTableName(), metaData.getColumns(), metaData.getPrimaryKeys()); } public LowerCaseTableMetaData(String tableName, Column[] columns, Column[] primaryKeys) //throws DataSetException { _tableName = tableName.toLowerCase(); _columns = createLowerColumns(columns); _primaryKeys = createLowerColumns(primaryKeys); } private Column[] createLowerColumns(Column[] columns) { Column[] lowerColumns = new Column[columns.length]; for (int i = 0; i < columns.length; i++) { lowerColumns[i] = createLowerColumn(columns[i]); } return lowerColumns; } private Column createLowerColumn(Column column) { return new Column( column.getColumnName().toLowerCase(), column.getDataType(), column.getSqlTypeName(), column.getNullable()); } //////////////////////////////////////////////////////////////////////////// // ITableMetaData interface public String getTableName() { return _tableName; } public Column[] getColumns() { return _columns; } public Column[] getPrimaryKeys() { return _primaryKeys; } } --- NEW FILE: LowerCaseDataSet.java --- /* * DefaultDataSet.java Feb 14, 2003 * * The DbUnit Database Testing Framework * Copyright (C)2002, Manuel Laflamme * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 2.1 of the License, or (at your option) any later version. * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * */ package org.dbunit.dataset; /** * Specialized IDataSet decorator that convert the table name and * column names to lower case. Used in DbUnit own test suite to verify that * operations are case insensitive. * * @author Manuel Laflamme * @version $Revision: 1.1 $ */ public class LowerCaseDataSet extends AbstractDataSet { private final ITable[] _tables; public LowerCaseDataSet(ITable table) throws DataSetException { this(new ITable[]{table}); } public LowerCaseDataSet(IDataSet dataSet) throws DataSetException { this(dataSet.getTables()); } public LowerCaseDataSet(ITable[] tables) throws DataSetException { ITable[] lowerTables = new ITable[tables.length]; for (int i = 0; i < tables.length; i++) { lowerTables[i] = createLowerTable(tables[i]); } _tables = lowerTables; } private ITable createLowerTable(ITable table) throws DataSetException { return new CompositeTable( new LowerCaseTableMetaData(table.getTableMetaData()), table); } //////////////////////////////////////////////////////////////////////////// // IDataSet interface public ITable[] getTables() throws DataSetException { return cloneTables(_tables); } } Index: AbstractTableMetaData.java =================================================================== RCS file: /cvsroot/dbunit/dbunit/src/java/org/dbunit/dataset/AbstractTableMetaData.java,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -d -r1.6 -r1.7 *** AbstractTableMetaData.java 13 Jun 2002 17:24:56 -0000 1.6 --- AbstractTableMetaData.java 15 Feb 2003 05:42:42 -0000 1.7 *************** *** 32,36 **** public abstract class AbstractTableMetaData implements ITableMetaData { ! protected Column[] getPrimaryKeys(Column[] columns, String[] keyNames) { List keyList = new ArrayList(); --- 32,36 ---- public abstract class AbstractTableMetaData implements ITableMetaData { ! protected static Column[] getPrimaryKeys(Column[] columns, String[] keyNames) { List keyList = new ArrayList(); Index: AbstractTable.java =================================================================== RCS file: /cvsroot/dbunit/dbunit/src/java/org/dbunit/dataset/AbstractTable.java,v retrieving revision 1.10 retrieving revision 1.11 diff -C2 -d -r1.10 -r1.11 *** AbstractTable.java 13 Jun 2002 17:24:56 -0000 1.10 --- AbstractTable.java 15 Feb 2003 05:42:42 -0000 1.11 *************** *** 59,63 **** { Column column = columns[i]; ! if (column.getColumnName().equals(columnName)) { return i; --- 59,63 ---- { Column column = columns[i]; ! if (column.getColumnName().equalsIgnoreCase(columnName)) { return i; Index: DataSetUtils.java =================================================================== RCS file: /cvsroot/dbunit/dbunit/src/java/org/dbunit/dataset/DataSetUtils.java,v retrieving revision 1.13 retrieving revision 1.14 diff -C2 -d -r1.13 -r1.14 *** DataSetUtils.java 4 Aug 2002 01:07:13 -0000 1.13 --- DataSetUtils.java 15 Feb 2003 05:42:42 -0000 1.14 *************** *** 80,86 **** * returns <code>"PREFIX1.NAME"</code>. * ! * @param schema the prefix * @param name the name ! * @returns the qualified name */ public static String getQualifiedName(String prefix, String name) --- 80,86 ---- * returns <code>"PREFIX1.NAME"</code>. * ! * @param prefix the prefix * @param name the name ! * @return the qualified name */ public static String getQualifiedName(String prefix, String name) *************** *** 132,136 **** * @param value the value * @param dataType the value data type ! * @returns the SQL string value */ public static String getSqlValueString(Object value, DataType dataType) --- 132,136 ---- * @param value the value * @param dataType the value data type ! * @return the SQL string value */ public static String getSqlValueString(Object value, DataType dataType) *************** *** 200,204 **** { Column column = columns[i]; ! if (columnName.equals(columns[i].getColumnName())) { return column; --- 200,204 ---- { Column column = columns[i]; ! if (columnName.equalsIgnoreCase(columns[i].getColumnName())) { return column; Index: CompositeDataSet.java =================================================================== RCS file: /cvsroot/dbunit/dbunit/src/java/org/dbunit/dataset/CompositeDataSet.java,v retrieving revision 1.10 retrieving revision 1.11 diff -C2 -d -r1.10 -r1.11 *** CompositeDataSet.java 3 Aug 2002 02:26:40 -0000 1.10 --- CompositeDataSet.java 15 Feb 2003 05:42:42 -0000 1.11 *************** *** 142,146 **** { ITable table = (ITable)list.get(i); ! if (tableName.equals(table.getTableMetaData().getTableName())) { return i; --- 142,146 ---- { ITable table = (ITable)list.get(i); ! if (tableName.equalsIgnoreCase(table.getTableMetaData().getTableName())) { return i; |
From: <mla...@us...> - 2003-02-15 05:42:46
|
Update of /cvsroot/dbunit/dbunit/src/java/org/dbunit In directory sc8-pr-cvs1:/tmp/cvs-serv29584/dbunit/src/java/org/dbunit Modified Files: Assertion.java Log Message: DbUnit is now case insensitive!!! Index: Assertion.java =================================================================== RCS file: /cvsroot/dbunit/dbunit/src/java/org/dbunit/Assertion.java,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -d -r1.6 -r1.7 *** Assertion.java 3 Aug 2002 02:26:40 -0000 1.6 --- Assertion.java 15 Feb 2003 05:42:42 -0000 1.7 *************** *** 54,59 **** } ! String[] expectedNames = expectedDataSet.getTableNames(); ! String[] actualNames = actualDataSet.getTableNames(); // tables count --- 54,59 ---- } ! String[] expectedNames = getSortedUpperTableNames(expectedDataSet); ! String[] actualNames = getSortedUpperTableNames(actualDataSet); // tables count *************** *** 62,67 **** // table names in no specific order - Arrays.sort(expectedNames); - Arrays.sort(actualNames); for (int i = 0; i < expectedNames.length; i++) { --- 62,65 ---- *************** *** 108,113 **** // column count ! String[] expectedNames = getSortedColumnNames(expectedMetaData); ! String[] actualNames = getSortedColumnNames(actualMetaData); Assert.assertEquals("column count (table=" + expectedTableName + ")", expectedNames.length, actualNames.length); --- 106,111 ---- // column count ! String[] expectedNames = getSortedUpperColumnNames(expectedMetaData); ! String[] actualNames = getSortedUpperColumnNames(actualMetaData); Assert.assertEquals("column count (table=" + expectedTableName + ")", expectedNames.length, actualNames.length); *************** *** 149,153 **** } ! private static String[] getSortedColumnNames(ITableMetaData metaData) throws DataSetException { --- 147,151 ---- } ! private static String[] getSortedUpperColumnNames(ITableMetaData metaData) throws DataSetException { *************** *** 156,160 **** for (int i = 0; i < columns.length; i++) { ! names[i] = columns[i].getColumnName(); } Arrays.sort(names); --- 154,170 ---- for (int i = 0; i < columns.length; i++) { ! names[i] = columns[i].getColumnName().toUpperCase(); ! } ! Arrays.sort(names); ! return names; ! } ! ! private static String[] getSortedUpperTableNames(IDataSet dataSet) ! throws DataSetException ! { ! String[] names = dataSet.getTableNames(); ! for (int i = 0; i < names.length; i++) ! { ! names[i] = names[i].toUpperCase(); } Arrays.sort(names); |
From: <mla...@us...> - 2003-02-15 05:42:46
|
Update of /cvsroot/dbunit/dbunit/src/test/org/dbunit In directory sc8-pr-cvs1:/tmp/cvs-serv29584/dbunit/src/test/org/dbunit Modified Files: AssertionTest.java Log Message: DbUnit is now case insensitive!!! Index: AssertionTest.java =================================================================== RCS file: /cvsroot/dbunit/dbunit/src/test/org/dbunit/AssertionTest.java,v retrieving revision 1.7 retrieving revision 1.8 diff -C2 -d -r1.7 -r1.8 *** AssertionTest.java 14 Feb 2003 03:21:59 -0000 1.7 --- AssertionTest.java 15 Feb 2003 05:42:43 -0000 1.8 *************** *** 52,56 **** // Test methods ! public void testAssertsTablesEquals() throws Exception { IDataSet dataSet = getDataSet(); --- 52,56 ---- // Test methods ! public void testAssertTablesEquals() throws Exception { IDataSet dataSet = getDataSet(); *************** *** 59,62 **** --- 59,69 ---- } + public void testAssertTablesEqualsColumnNamesCaseInsensitive() throws Exception + { + IDataSet dataSet = getDataSet(); + Assertion.assertEquals(dataSet.getTable("TEST_TABLE"), + dataSet.getTable("TEST_TABLE_WITH_LOWER_COLUMN_NAMES")); + } + public void testAssertTablesAndNamesNotEquals() throws Exception { *************** *** 140,143 **** --- 147,166 ---- // change table names order String[] names = DataSetUtils.getReverseTableNames(dataSet1); + IDataSet dataSet2 = new FilteredDataSet(names, dataSet1); + + assertTrue("assert not same", dataSet1 != dataSet2); + Assertion.assertEquals(dataSet1, dataSet2); + } + + public void testAssertDataSetsEqualsTableNamesCaseInsensitive() throws Exception + { + IDataSet dataSet1 = getDataSet(); + + // change table names case + String[] names = dataSet1.getTableNames(); + for (int i = 0; i < names.length; i++) + { + names[i] = names[i].toLowerCase(); + } IDataSet dataSet2 = new FilteredDataSet(names, dataSet1); |
From: <mla...@us...> - 2003-02-15 05:42:46
|
Update of /cvsroot/dbunit/dbunit/src/java/org/dbunit/dataset/xml In directory sc8-pr-cvs1:/tmp/cvs-serv29584/dbunit/src/java/org/dbunit/dataset/xml Modified Files: FlatXmlTable.java Log Message: DbUnit is now case insensitive!!! Index: FlatXmlTable.java =================================================================== RCS file: /cvsroot/dbunit/dbunit/src/java/org/dbunit/dataset/xml/FlatXmlTable.java,v retrieving revision 1.9 retrieving revision 1.10 diff -C2 -d -r1.9 -r1.10 *** FlatXmlTable.java 13 Jun 2002 17:24:57 -0000 1.9 --- FlatXmlTable.java 15 Feb 2003 05:42:43 -0000 1.10 *************** *** 87,91 **** assertValidColumn(column); ! return _rows[row].getAttributeValue(column); } --- 87,101 ---- assertValidColumn(column); ! Attributes attributes = _rows[row].getAttributes(); ! while (attributes.hasMoreElements()) ! { ! Attribute attribute = (Attribute)attributes.nextElement(); ! if (column.equalsIgnoreCase(attribute.getName())) ! { ! return attribute.getValue(); ! } ! } ! ! return null; } |
From: <mla...@us...> - 2003-02-15 05:42:46
|
Update of /cvsroot/dbunit/dbunit/src/test/org/dbunit/dataset In directory sc8-pr-cvs1:/tmp/cvs-serv29584/dbunit/src/test/org/dbunit/dataset Modified Files: CompositeDataSetTest.java AllTests.java AbstractTableTest.java AbstractDataSetTest.java DataSetUtilsTest.java Added Files: LowerCaseDataSetTest.java LowerCaseTableMetaDataTest.java Log Message: DbUnit is now case insensitive!!! --- NEW FILE: LowerCaseDataSetTest.java --- /* * CaseInsensitiveDataSetTest.java Feb 14, 2003 * * Copyright (c)2002 Manuel Laflamme. All Rights Reserved. * * This software is the proprietary information of Manuel Laflamme. * Use is subject to license terms. * */ package org.dbunit.dataset; import org.dbunit.dataset.xml.XmlDataSet; import org.dbunit.dataset.xml.FlatXmlDataSet; import java.io.FileInputStream; import java.io.FileReader; /** * @author Manuel Laflamme * @version $Revision: 1.1 $ */ public class LowerCaseDataSetTest extends AbstractDataSetTest { public LowerCaseDataSetTest(String s) { super(s); } protected IDataSet createDataSet() throws Exception { return new LowerCaseDataSet(new FlatXmlDataSet(new FileReader( "src/xml/flatXmlDataSetTest.xml"))); } protected IDataSet createDuplicateDataSet() throws Exception { return new LowerCaseDataSet(new FlatXmlDataSet(new FileReader( "src/xml/flatXmlDataSetDuplicateTest.xml"))); } protected String[] getExpectedNames() throws Exception { return getExpectedLowerNames(); } protected String[] getExpectedDuplicateNames() { String[] names = super.getExpectedDuplicateNames(); for (int i = 0; i < names.length; i++) { names[i] = names[i].toLowerCase(); } return names; } } --- NEW FILE: LowerCaseTableMetaDataTest.java --- /* * DefaultTableMetaDataTest.java Feb 17, 2002 * * DbUnit Database Testing Framework * Copyright (C)2002, Manuel Laflamme * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 2.1 of the License, or (at your option) any later version. * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * */ package org.dbunit.dataset; import org.dbunit.dataset.datatype.DataType; import junit.framework.TestCase; /** * @author Manuel Laflamme * @version $Revision: 1.1 $ */ public class LowerCaseTableMetaDataTest extends TestCase { public LowerCaseTableMetaDataTest(String s) { super(s); } public void testGetTableName() throws Exception { String original = "TABLE_NAME"; String expected = original.toLowerCase(); ITableMetaData metaData = new LowerCaseTableMetaData( new DefaultTableMetaData(original, new Column[0])); assertEquals("table name", expected, metaData.getTableName()); } public void testGetColumns() throws Exception { Column[] columns = new Column[]{ new Column("NUMBER_COLUMN", DataType.NUMERIC, "qwerty", Column.NULLABLE), new Column("STRING_COLUMN", DataType.VARCHAR, "toto", Column.NO_NULLS), new Column("BOOLEAN_COLUMN", DataType.BOOLEAN), }; ITableMetaData metaData = new LowerCaseTableMetaData( "TABLE_NAME", columns); Column[] lowerColumns = metaData.getColumns(); assertEquals("column count", columns.length, lowerColumns.length); for (int i = 0; i < columns.length; i++) { Column column = columns[i]; Column lowerColumn = lowerColumns[i]; assertEquals("name", column.getColumnName().toLowerCase(), lowerColumn.getColumnName()); assertTrue("name not equals", !column.getColumnName().equals(lowerColumn.getColumnName())); assertEquals("type", column.getDataType(), lowerColumn.getDataType()); assertEquals("sql type", column.getSqlTypeName(), lowerColumn.getSqlTypeName()); assertEquals("nullable", column.getNullable(), lowerColumn.getNullable()); } assertEquals("key count", 0, metaData.getPrimaryKeys().length); } public void testGetPrimaryKeys() throws Exception { Column[] columns = new Column[]{ new Column("NUMBER_COLUMN", DataType.NUMERIC, "qwerty", Column.NULLABLE), new Column("STRING_COLUMN", DataType.VARCHAR, "toto", Column.NO_NULLS), new Column("BOOLEAN_COLUMN", DataType.BOOLEAN), }; String[] keyNames = new String[]{"Boolean_Column", "Number_Column"}; ITableMetaData metaData = new LowerCaseTableMetaData( "TABLE_NAME", columns, keyNames); Column[] keys = metaData.getPrimaryKeys(); assertEquals("key count", keyNames.length, keys.length); for (int i = 0; i < keys.length; i++) { assertTrue("name not equals", !keyNames[i].equals(keys[i].getColumnName())); assertEquals("key name", keyNames[i].toLowerCase(), keys[i].getColumnName()); } } } Index: CompositeDataSetTest.java =================================================================== RCS file: /cvsroot/dbunit/dbunit/src/test/org/dbunit/dataset/CompositeDataSetTest.java,v retrieving revision 1.7 retrieving revision 1.8 diff -C2 -d -r1.7 -r1.8 *** CompositeDataSetTest.java 14 Feb 2003 03:22:00 -0000 1.7 --- CompositeDataSetTest.java 15 Feb 2003 05:42:43 -0000 1.8 *************** *** 69,72 **** --- 69,82 ---- return new CompositeDataSet(dataSet1, dataSet2, false); } + + public void testCombineTables() throws Exception + { + IDataSet originaldataSet = createMultipleCaseDuplicateDataSet(); + assertEquals("table count before", 3, originaldataSet.getTableNames().length); + + IDataSet combinedDataSet = new CompositeDataSet(originaldataSet.getTables()); + assertEquals("table count combined", 2, combinedDataSet.getTableNames().length); + } + } Index: AllTests.java =================================================================== RCS file: /cvsroot/dbunit/dbunit/src/test/org/dbunit/dataset/AllTests.java,v retrieving revision 1.8 retrieving revision 1.9 diff -C2 -d -r1.8 -r1.9 *** AllTests.java 11 Dec 2002 15:57:34 -0000 1.8 --- AllTests.java 15 Feb 2003 05:42:43 -0000 1.9 *************** *** 47,50 **** --- 47,52 ---- suite.addTest(new TestSuite(DefaultTableTest.class)); suite.addTest(new TestSuite(FilteredDataSetTest.class)); + suite.addTest(new TestSuite(LowerCaseDataSetTest.class)); + suite.addTest(new TestSuite(LowerCaseTableMetaDataTest.class)); suite.addTest(new TestSuite(QueryDataSetTest.class)); Index: AbstractTableTest.java =================================================================== RCS file: /cvsroot/dbunit/dbunit/src/test/org/dbunit/dataset/AbstractTableTest.java,v retrieving revision 1.8 retrieving revision 1.9 diff -C2 -d -r1.8 -r1.9 *** AbstractTableTest.java 13 Jun 2002 17:25:00 -0000 1.8 --- AbstractTableTest.java 15 Feb 2003 05:42:43 -0000 1.9 *************** *** 81,84 **** --- 81,99 ---- } + public void testGetValueCaseInsensitive() throws Exception + { + ITable table = createTable(); + for (int i = 0; i < ROW_COUNT; i++) + { + for (int j = 0; j < COLUMN_COUNT; j++) + { + String columnName = "CoLUmN" + j; + String expected = "row " + i + " col " + j; + Object value = table.getValue(i, columnName); + assertEquals("value", expected, value); + } + } + } + public abstract void testGetMissingValue() throws Exception; Index: AbstractDataSetTest.java =================================================================== RCS file: /cvsroot/dbunit/dbunit/src/test/org/dbunit/dataset/AbstractDataSetTest.java,v retrieving revision 1.17 retrieving revision 1.18 diff -C2 -d -r1.17 -r1.18 *** AbstractDataSetTest.java 13 Feb 2003 04:32:42 -0000 1.17 --- AbstractDataSetTest.java 15 Feb 2003 05:42:43 -0000 1.18 *************** *** 24,28 **** import org.dbunit.database.AmbiguousTableNameException; - import org.dbunit.*; import java.util.*; --- 24,27 ---- *************** *** 58,67 **** } ! protected static String[] getExpectedNames() throws Exception { return (String[])TABLE_NAMES.clone(); } ! protected static String[] getExpectedLowerNames() throws Exception { String[] names = (String[])TABLE_NAMES.clone(); --- 57,66 ---- } ! protected String[] getExpectedNames() throws Exception { return (String[])TABLE_NAMES.clone(); } ! protected String[] getExpectedLowerNames() throws Exception { String[] names = (String[])TABLE_NAMES.clone(); Index: DataSetUtilsTest.java =================================================================== RCS file: /cvsroot/dbunit/dbunit/src/test/org/dbunit/dataset/DataSetUtilsTest.java,v retrieving revision 1.12 retrieving revision 1.13 diff -C2 -d -r1.12 -r1.13 *** DataSetUtilsTest.java 4 Aug 2002 01:07:13 -0000 1.12 --- DataSetUtilsTest.java 15 Feb 2003 05:42:43 -0000 1.13 *************** *** 79,83 **** } - public void testGetColumn() throws Exception { --- 79,82 ---- *************** *** 87,90 **** --- 86,106 ---- new Column("c2", DataType.UNKNOWN), new Column("c3", DataType.UNKNOWN), + new Column("c4", DataType.UNKNOWN), + }; + + for (int i = 0; i < columns.length; i++) + { + assertEquals("find column same", columns[i], + DataSetUtils.getColumn("c" + i, columns)); + } + } + + public void testGetColumnCaseInsensitive() throws Exception + { + Column[] columns = new Column[]{ + new Column("c0", DataType.UNKNOWN), + new Column("C1", DataType.UNKNOWN), + new Column("c2", DataType.UNKNOWN), + new Column("C3", DataType.UNKNOWN), new Column("c4", DataType.UNKNOWN), }; |
From: <mla...@us...> - 2003-02-15 05:42:46
|
Update of /cvsroot/dbunit/dbunit/src/xml In directory sc8-pr-cvs1:/tmp/cvs-serv29584/dbunit/src/xml Modified Files: assertionTest.xml Log Message: DbUnit is now case insensitive!!! Index: assertionTest.xml =================================================================== RCS file: /cvsroot/dbunit/dbunit/src/xml/assertionTest.xml,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** assertionTest.xml 17 Apr 2002 17:04:26 -0000 1.1 --- assertionTest.xml 15 Feb 2003 05:42:42 -0000 1.2 *************** *** 5,8 **** --- 5,10 ---- <TEST_TABLE_WITH_SAME_VALUE COLUMN0="row 0 col 0" COLUMN1="row 0 col 1" COLUMN2="row 0 col 2" COLUMN3="row 0 col 3"/> <TEST_TABLE_WITH_SAME_VALUE COLUMN0="row 1 col 0" COLUMN1="row 1 col 1" COLUMN2="row 1 col 2" COLUMN3="row 1 col 3"/> + <TEST_TABLE_WITH_LOWER_COLUMN_NAMES column0="row 0 col 0" column1="row 0 col 1" column2="row 0 col 2" column3="row 0 col 3"/> + <TEST_TABLE_WITH_LOWER_COLUMN_NAMES column0="row 1 col 0" column1="row 1 col 1" column2="row 1 col 2" column3="row 1 col 3"/> <TEST_TABLE_WITH_DIFFERENT_NAME COLUMN0="row 0 col 0" COLUMN1="row 0 col 1" COLUMN2="row 0 col 2" COLUMN3="row 0 col 3"/> <TEST_TABLE_WITH_DIFFERENT_NAME COLUMN0="row 1 col 0" COLUMN1="row 1 col 1" COLUMN2="row 1 col 2" COLUMN3="row 1 col 3"/> |
Update of /cvsroot/dbunit/dbunit/src/test/org/dbunit/operation In directory sc8-pr-cvs1:/tmp/cvs-serv29584/dbunit/src/test/org/dbunit/operation Modified Files: DeleteAllOperationTest.java UpdateOperationTest.java RefreshOperationTest.java InsertOperationTest.java DeleteOperationTest.java Log Message: DbUnit is now case insensitive!!! Index: DeleteAllOperationTest.java =================================================================== RCS file: /cvsroot/dbunit/dbunit/src/test/org/dbunit/operation/DeleteAllOperationTest.java,v retrieving revision 1.10 retrieving revision 1.11 diff -C2 -d -r1.10 -r1.11 *** DeleteAllOperationTest.java 4 Aug 2002 01:07:13 -0000 1.10 --- DeleteAllOperationTest.java 15 Feb 2003 05:42:42 -0000 1.11 *************** *** 24,27 **** --- 24,28 ---- import org.dbunit.AbstractDatabaseTest; + import org.dbunit.DatabaseUnitException; import org.dbunit.database.MockDatabaseConnection; import org.dbunit.database.statement.MockBatchStatement; *************** *** 29,32 **** --- 30,35 ---- import org.dbunit.dataset.*; + import java.sql.SQLException; + /** * @author Manuel Laflamme *************** *** 151,166 **** public void testExecute() throws Exception { ! IDataSet databaseDataSet = AbstractDataSetTest.removeExtraTestTables( _connection.createDataSet()); ! ITable[] tablesBefore = DataSetUtils.getTables(databaseDataSet); ! DatabaseOperation.DELETE_ALL.execute(_connection, databaseDataSet); ! ITable[] tablesAfter = DataSetUtils.getTables(databaseDataSet); ! // ITable[] tablesBefore = DataSetUtils.getTables(_connection.createDataSet()); ! // DatabaseOperation.DELETE_ALL.execute(_connection, ! // _connection.createDataSet()); ! // ITable[] tablesAfter = DataSetUtils.getTables(_connection.createDataSet()); assertTrue("table count > 0", tablesBefore.length > 0); --- 154,176 ---- public void testExecute() throws Exception { ! IDataSet dataSet = AbstractDataSetTest.removeExtraTestTables( _connection.createDataSet()); ! testExecute(dataSet); ! } + public void testExecuteCaseInsentive() throws Exception + { + IDataSet dataSet = AbstractDataSetTest.removeExtraTestTables( + _connection.createDataSet()); ! testExecute(new LowerCaseDataSet(dataSet)); ! } ! ! private void testExecute(IDataSet dataSet) throws Exception ! { ! ITable[] tablesBefore = DataSetUtils.getTables(_connection.createDataSet()); ! DatabaseOperation.DELETE_ALL.execute(_connection, dataSet); ! ITable[] tablesAfter = DataSetUtils.getTables(_connection.createDataSet()); assertTrue("table count > 0", tablesBefore.length > 0); *************** *** 171,175 **** String name = table.getTableMetaData().getTableName(); ! if (!name.startsWith("EMPTY")) { assertTrue(name + " before", table.getRowCount() > 0); --- 181,185 ---- String name = table.getTableMetaData().getTableName(); ! if (!name.toUpperCase().startsWith("EMPTY")) { assertTrue(name + " before", table.getRowCount() > 0); *************** *** 181,185 **** ITable table = tablesAfter[i]; String name = table.getTableMetaData().getTableName(); ! assertEquals(name + "after", 0, table.getRowCount()); } } --- 191,195 ---- ITable table = tablesAfter[i]; String name = table.getTableMetaData().getTableName(); ! assertEquals(name + " after " + i, 0, table.getRowCount()); } } Index: UpdateOperationTest.java =================================================================== RCS file: /cvsroot/dbunit/dbunit/src/test/org/dbunit/operation/UpdateOperationTest.java,v retrieving revision 1.15 retrieving revision 1.16 diff -C2 -d -r1.15 -r1.16 *** UpdateOperationTest.java 14 Feb 2003 03:22:02 -0000 1.15 --- UpdateOperationTest.java 15 Feb 2003 05:42:42 -0000 1.16 *************** *** 49,57 **** } - // public static Test suite() - // { - // return new UpdateOperationTest("testUpdateBlob"); - // } - //////////////////////////////////////////////////////////////////////////// // --- 49,52 ---- *************** *** 330,340 **** public void testExecute() throws Exception { ! String tableName = "PK_TABLE"; ! String[] columnNames = {"PK0", "PK1", "PK2", "NORMAL0", "NORMAL1"}; ! int modifiedRow = 1; Reader in = new FileReader( new File("src/xml/updateOperationTest.xml")); ! IDataSet xmlDataSet = new XmlDataSet(in); // verify table before --- 325,350 ---- public void testExecute() throws Exception { ! Reader in = new FileReader( ! new File("src/xml/updateOperationTest.xml")); ! IDataSet dataSet = new XmlDataSet(in); ! ! testExecute(dataSet); ! ! } + public void testExecuteCaseInsensitive() throws Exception + { Reader in = new FileReader( new File("src/xml/updateOperationTest.xml")); ! IDataSet dataSet = new XmlDataSet(in); ! ! testExecute(new LowerCaseDataSet(dataSet)); ! } ! ! private void testExecute(IDataSet dataSet) throws Exception ! { ! String tableName = "PK_TABLE"; ! String[] columnNames = {"PK0", "PK1", "PK2", "NORMAL0", "NORMAL1"}; ! int modifiedRow = 1; // verify table before *************** *** 342,346 **** assertEquals("row count before", 3, tableBefore.getRowCount()); ! DatabaseOperation.UPDATE.execute(_connection, xmlDataSet); ITable tableAfter = createOrderedTable(tableName, columnNames[0]); --- 352,356 ---- assertEquals("row count before", 3, tableBefore.getRowCount()); ! DatabaseOperation.UPDATE.execute(_connection, dataSet); ITable tableAfter = createOrderedTable(tableName, columnNames[0]); Index: RefreshOperationTest.java =================================================================== RCS file: /cvsroot/dbunit/dbunit/src/test/org/dbunit/operation/RefreshOperationTest.java,v retrieving revision 1.10 retrieving revision 1.11 diff -C2 -d -r1.10 -r1.11 *** RefreshOperationTest.java 14 Feb 2003 03:22:01 -0000 1.10 --- RefreshOperationTest.java 15 Feb 2003 05:42:42 -0000 1.11 *************** *** 33,36 **** --- 33,37 ---- import java.io.FileInputStream; import java.io.FileReader; + import java.io.Reader; import java.util.ArrayList; *************** *** 48,58 **** public void testExecute() throws Exception { String[] tableNames = {"PK_TABLE", "ONLY_PK_TABLE"}; int[] tableRowCount = {3, 1}; String primaryKey = "PK0"; - IDataSet xmlDataSet = new FlatXmlDataSet( - new FileReader("src/xml/refreshOperationTest.xml")); - // verify table before assertEquals("array lenght", tableNames.length, tableRowCount.length); --- 49,72 ---- public void testExecute() throws Exception { + Reader reader = new FileReader("src/xml/refreshOperationTest.xml"); + IDataSet dataSet = new FlatXmlDataSet(reader); + + testExecute(dataSet); + } + + public void testExecuteCaseInsensitive() throws Exception + { + Reader reader = new FileReader("src/xml/refreshOperationTest.xml"); + IDataSet dataSet = new FlatXmlDataSet(reader); + + testExecute(new LowerCaseDataSet(dataSet)); + } + + private void testExecute(IDataSet dataSet) throws Exception + { String[] tableNames = {"PK_TABLE", "ONLY_PK_TABLE"}; int[] tableRowCount = {3, 1}; String primaryKey = "PK0"; // verify table before assertEquals("array lenght", tableNames.length, tableRowCount.length); *************** *** 63,67 **** } ! DatabaseOperation.REFRESH.execute(_connection, xmlDataSet); // verify table after --- 77,81 ---- } ! DatabaseOperation.REFRESH.execute(_connection, dataSet); // verify table after *************** *** 76,79 **** --- 90,94 ---- } } + public void testExecuteWithDuplicateTables() throws Exception { Index: InsertOperationTest.java =================================================================== RCS file: /cvsroot/dbunit/dbunit/src/test/org/dbunit/operation/InsertOperationTest.java,v retrieving revision 1.17 retrieving revision 1.18 diff -C2 -d -r1.17 -r1.18 *** InsertOperationTest.java 14 Feb 2003 03:22:01 -0000 1.17 --- InsertOperationTest.java 15 Feb 2003 05:42:42 -0000 1.18 *************** *** 35,38 **** --- 35,39 ---- import java.util.ArrayList; import java.util.List; + import java.sql.SQLException; /** *************** *** 47,55 **** } - // public static Test suite() - // { - // return new InsertOperationTest("testInsertBlob"); - // } - public void testMockExecute() throws Exception { --- 48,51 ---- *************** *** 332,368 **** { // this won't work because of the timestamp column. ! if (!(DatabaseEnvironment.getInstance() instanceof MSSQLServerEnvironment)){ Reader in = new FileReader("src/xml/insertOperationTest.xml"); ! IDataSet xmlDataSet = new XmlDataSet(in); ! ITable[] tablesBefore = DataSetUtils.getTables(_connection.createDataSet()); ! DatabaseOperation.INSERT.execute(_connection, xmlDataSet); ! ITable[] tablesAfter = DataSetUtils.getTables(_connection.createDataSet()); ! assertEquals("table count", tablesBefore.length, tablesAfter.length); ! for (int i = 0; i < tablesBefore.length; i++) ! { ! ITable table = tablesBefore[i]; ! String name = table.getTableMetaData().getTableName(); ! if (name.startsWith("EMPTY")) ! { ! assertEquals(name + "before", 0, table.getRowCount()); ! } ! } ! for (int i = 0; i < tablesAfter.length; i++) ! { ! ITable table = tablesAfter[i]; ! String name = table.getTableMetaData().getTableName(); ! if (name.startsWith("EMPTY")) ! { ! Assertion.assertEquals(xmlDataSet.getTable(name), table); ! } } } } } --- 328,381 ---- { // this won't work because of the timestamp column. ! if (!(DatabaseEnvironment.getInstance() instanceof MSSQLServerEnvironment)) ! { Reader in = new FileReader("src/xml/insertOperationTest.xml"); ! IDataSet dataSet = new XmlDataSet(in); ! testExecute(dataSet); ! } ! } ! public void testExecuteCaseInsensitive() throws Exception ! { ! // this won't work because of the timestamp column. ! if (!(DatabaseEnvironment.getInstance() instanceof MSSQLServerEnvironment)) ! { ! Reader in = new FileReader("src/xml/insertOperationTest.xml"); ! IDataSet dataSet = new XmlDataSet(in); + testExecute(new LowerCaseDataSet(dataSet)); + } + } ! private void testExecute(IDataSet dataSet) throws Exception, SQLException ! { ! ITable[] tablesBefore = DataSetUtils.getTables(_connection.createDataSet()); ! DatabaseOperation.INSERT.execute(_connection, dataSet); ! ITable[] tablesAfter = DataSetUtils.getTables(_connection.createDataSet()); ! assertEquals("table count", tablesBefore.length, tablesAfter.length); ! for (int i = 0; i < tablesBefore.length; i++) ! { ! ITable table = tablesBefore[i]; ! String name = table.getTableMetaData().getTableName(); ! ! if (name.startsWith("EMPTY")) ! { ! assertEquals(name + "before", 0, table.getRowCount()); } } + for (int i = 0; i < tablesAfter.length; i++) + { + ITable table = tablesAfter[i]; + String name = table.getTableMetaData().getTableName(); + + if (name.startsWith("EMPTY")) + { + Assertion.assertEquals(dataSet.getTable(name), table); + } + } } } Index: DeleteOperationTest.java =================================================================== RCS file: /cvsroot/dbunit/dbunit/src/test/org/dbunit/operation/DeleteOperationTest.java,v retrieving revision 1.13 retrieving revision 1.14 diff -C2 -d -r1.13 -r1.14 *** DeleteOperationTest.java 14 Feb 2003 03:22:01 -0000 1.13 --- DeleteOperationTest.java 15 Feb 2003 05:42:42 -0000 1.14 *************** *** 240,248 **** public void testExecute() throws Exception { - String tableName = "PK_TABLE"; - String columnName = "PK0"; Reader in = new FileReader( new File("src/xml/deleteOperationTest.xml")); ! IDataSet xmlDataSet = new XmlDataSet(in); // verify table before --- 240,264 ---- public void testExecute() throws Exception { Reader in = new FileReader( new File("src/xml/deleteOperationTest.xml")); ! IDataSet dataSet = new XmlDataSet(in); ! ! testExecute(dataSet); ! ! } ! ! public void testExecuteCaseInsensitive() throws Exception ! { ! Reader in = new FileReader( ! new File("src/xml/deleteOperationTest.xml")); ! IDataSet dataSet = new XmlDataSet(in); ! ! testExecute(new LowerCaseDataSet(dataSet)); ! } ! ! private void testExecute(IDataSet dataSet) throws Exception ! { ! String tableName = "PK_TABLE"; ! String columnName = "PK0"; // verify table before *************** *** 253,257 **** assertEquals("before", "2", tableBefore.getValue(2, columnName).toString()); ! DatabaseOperation.DELETE.execute(_connection, xmlDataSet); ITable tableAfter = createOrderedTable(tableName, columnName); --- 269,273 ---- assertEquals("before", "2", tableBefore.getValue(2, columnName).toString()); ! DatabaseOperation.DELETE.execute(_connection, dataSet); ITable tableAfter = createOrderedTable(tableName, columnName); |
From: <mla...@us...> - 2003-02-14 17:22:26
|
Update of /cvsroot/dbunit/dbunit/src/java/org/dbunit/dataset In directory sc8-pr-cvs1:/tmp/cvs-serv17452/src/java/org/dbunit/dataset Modified Files: QueryDataSet.java Log Message: Cosmetic only -> removed unused code reported by PMD Java source code analysis tool (http://pmd.sourceforge.net/cgi-bin/webpmd.pl). Index: QueryDataSet.java =================================================================== RCS file: /cvsroot/dbunit/dbunit/src/java/org/dbunit/dataset/QueryDataSet.java,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** QueryDataSet.java 11 Dec 2002 15:55:50 -0000 1.1 --- QueryDataSet.java 14 Feb 2003 17:22:23 -0000 1.2 *************** *** 115,119 **** Connection jdbcConnection = _connection.getConnection(); ! String schema = _connection.getSchema(); Statement statement = jdbcConnection.createStatement(); --- 115,119 ---- Connection jdbcConnection = _connection.getConnection(); ! // String schema = _connection.getSchema(); Statement statement = jdbcConnection.createStatement(); |
From: <mla...@us...> - 2003-02-14 17:22:25
|
Update of /cvsroot/dbunit/dbunit/src/java/org/dbunit/database In directory sc8-pr-cvs1:/tmp/cvs-serv17452/src/java/org/dbunit/database Modified Files: DatabaseDataSet.java Log Message: Cosmetic only -> removed unused code reported by PMD Java source code analysis tool (http://pmd.sourceforge.net/cgi-bin/webpmd.pl). Index: DatabaseDataSet.java =================================================================== RCS file: /cvsroot/dbunit/dbunit/src/java/org/dbunit/database/DatabaseDataSet.java,v retrieving revision 1.18 retrieving revision 1.19 diff -C2 -d -r1.18 -r1.19 *** DatabaseDataSet.java 13 Feb 2003 04:32:42 -0000 1.18 --- DatabaseDataSet.java 14 Feb 2003 17:22:22 -0000 1.19 *************** *** 124,128 **** String schemaName = resultSet.getString(2); String tableName = resultSet.getString(3); ! String tableType = resultSet.getString(4); // System.out.println("schema=" + schemaName + ", table=" + tableName + ", type=" + tableType + ""); tableName = getQualifiedName(schemaName, tableName); --- 124,128 ---- String schemaName = resultSet.getString(2); String tableName = resultSet.getString(3); ! // String tableType = resultSet.getString(4); // System.out.println("schema=" + schemaName + ", table=" + tableName + ", type=" + tableType + ""); tableName = getQualifiedName(schemaName, tableName); |
From: <mla...@us...> - 2003-02-14 17:22:25
|
Update of /cvsroot/dbunit/dbunit/src/java/org/dbunit/operation/mssqlserver In directory sc8-pr-cvs1:/tmp/cvs-serv17452/src/java/org/dbunit/operation/mssqlserver Modified Files: InsertIdentityOperation.java Log Message: Cosmetic only -> removed unused code reported by PMD Java source code analysis tool (http://pmd.sourceforge.net/cgi-bin/webpmd.pl). Index: InsertIdentityOperation.java =================================================================== RCS file: /cvsroot/dbunit/dbunit/src/java/org/dbunit/operation/mssqlserver/InsertIdentityOperation.java,v retrieving revision 1.12 retrieving revision 1.13 diff -C2 -d -r1.12 -r1.13 *** InsertIdentityOperation.java 29 Jan 2003 13:01:12 -0000 1.12 --- InsertIdentityOperation.java 14 Feb 2003 17:22:22 -0000 1.13 *************** *** 95,100 **** Statement statement = jdbcConnection.createStatement(); - IDataSet databaseDataSet = connection.createDataSet(); - try { --- 95,98 ---- |
From: <mla...@us...> - 2003-02-14 17:22:25
|
Update of /cvsroot/dbunit/dbunit/src/java/org/dbunit/operation In directory sc8-pr-cvs1:/tmp/cvs-serv17452/src/java/org/dbunit/operation Modified Files: RefreshOperation.java Log Message: Cosmetic only -> removed unused code reported by PMD Java source code analysis tool (http://pmd.sourceforge.net/cgi-bin/webpmd.pl). Index: RefreshOperation.java =================================================================== RCS file: /cvsroot/dbunit/dbunit/src/java/org/dbunit/operation/RefreshOperation.java,v retrieving revision 1.20 retrieving revision 1.21 diff -C2 -d -r1.20 -r1.21 *** RefreshOperation.java 4 Aug 2002 01:07:13 -0000 1.20 --- RefreshOperation.java 14 Feb 2003 17:22:21 -0000 1.21 *************** *** 135,141 **** String schema = connection.getSchema(); - // this dataset is used to get metadata from database - IDataSet databaseDataSet = connection.createDataSet(); - // for each table ITable[] tables = dataSet.getTables(); --- 135,138 ---- |
From: <mla...@us...> - 2003-02-14 17:22:24
|
Update of /cvsroot/dbunit/dbunit/src/java/org/dbunit/ant In directory sc8-pr-cvs1:/tmp/cvs-serv17452/src/java/org/dbunit/ant Modified Files: Composite.java Export.java Log Message: Cosmetic only -> removed unused code reported by PMD Java source code analysis tool (http://pmd.sourceforge.net/cgi-bin/webpmd.pl). Index: Composite.java =================================================================== RCS file: /cvsroot/dbunit/dbunit/src/java/org/dbunit/ant/Composite.java,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** Composite.java 15 Jul 2002 01:00:29 -0000 1.3 --- Composite.java 14 Feb 2003 17:22:20 -0000 1.4 *************** *** 75,79 **** * their src and flat value, and calls execute on each one. * ! * @param conn a <code>IDatabaseConnection</code> value * @exception DatabaseUnitException if an error occurs */ --- 75,79 ---- * their src and flat value, and calls execute on each one. * ! * @param connection a <code>IDatabaseConnection</code> value * @exception DatabaseUnitException if an error occurs */ *************** *** 116,120 **** { Operation operation = (Operation)operIter.next(); ! result.append("\n operation: " + type); } return result.toString(); --- 116,120 ---- { Operation operation = (Operation)operIter.next(); ! result.append("\n operation: " + operation.getType()); } return result.toString(); Index: Export.java =================================================================== RCS file: /cvsroot/dbunit/dbunit/src/java/org/dbunit/ant/Export.java,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** Export.java 11 Dec 2002 15:53:50 -0000 1.5 --- Export.java 14 Feb 2003 17:22:21 -0000 1.6 *************** *** 195,208 **** } ! private String[] convertListToStringArray(List list){ ! String []strArray = new String[list.size()]; ! for (int i = 0; i < list.size(); i++) ! { ! Table table = (Table)list.get(i); ! strArray[i] = table.getName(); ! } ! return strArray; ! } ! public String getLogMessage() { --- 195,208 ---- } ! // private String[] convertListToStringArray(List list){ ! // String []strArray = new String[list.size()]; ! // for (int i = 0; i < list.size(); i++) ! // { ! // Table table = (Table)list.get(i); ! // strArray[i] = table.getName(); ! // } ! // return strArray; ! // } ! // public String getLogMessage() { |