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;
|