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: <fsp...@us...> - 2004-03-12 09:14:16
|
Update of /cvsroot/dbunit/dbunit/src/test/org/dbunit/dataset/csv/handlers In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv26281/handlers Log Message: Directory /cvsroot/dbunit/dbunit/src/test/org/dbunit/dataset/csv/handlers added to the repository |
From: <fsp...@us...> - 2004-03-12 09:13:30
|
Update of /cvsroot/dbunit/dbunit/src/test/org/dbunit/dataset/csv In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv26173/csv Log Message: Directory /cvsroot/dbunit/dbunit/src/test/org/dbunit/dataset/csv added to the repository |
From: <fsp...@us...> - 2004-03-12 09:12:43
|
Update of /cvsroot/dbunit/dbunit/src/java/org/dbunit/dataset/csv/handlers In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv26021/handlers Log Message: Directory /cvsroot/dbunit/dbunit/src/java/org/dbunit/dataset/csv/handlers added to the repository |
From: <fsp...@us...> - 2004-03-12 09:12:28
|
Update of /cvsroot/dbunit/dbunit/src/java/org/dbunit/dataset/csv In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv25976/csv Log Message: Directory /cvsroot/dbunit/dbunit/src/java/org/dbunit/dataset/csv added to the repository |
From: <fsp...@us...> - 2004-03-12 09:11:11
|
Update of /cvsroot/dbunit/dbunit/src/csv/orders In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv25738/orders Log Message: Directory /cvsroot/dbunit/dbunit/src/csv/orders added to the repository |
From: <fsp...@us...> - 2004-03-12 09:10:47
|
Update of /cvsroot/dbunit/dbunit/src/csv In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv25666/csv Log Message: Directory /cvsroot/dbunit/dbunit/src/csv added to the repository |
From: <mla...@us...> - 2004-03-08 22:26:57
|
Update of /cvsroot/dbunit/dbunit/src/java/org/dbunit/database In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv1746/src/java/org/dbunit/database Modified Files: DatabaseSequenceFilter.java Log Message: Throws a CyclicTablesDependencyException when encountering cyclic dependencies. Also removed unsafe static field. Index: DatabaseSequenceFilter.java =================================================================== RCS file: /cvsroot/dbunit/dbunit/src/java/org/dbunit/database/DatabaseSequenceFilter.java,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** DatabaseSequenceFilter.java 22 Jan 2004 02:54:18 -0000 1.4 --- DatabaseSequenceFilter.java 8 Mar 2004 22:02:21 -0000 1.5 *************** *** 21,24 **** --- 21,25 ---- package org.dbunit.database; + import org.dbunit.DatabaseUnitRuntimeException; import org.dbunit.dataset.DataSetException; import org.dbunit.dataset.filter.SequenceTableFilter; *************** *** 28,36 **** import java.sql.SQLException; import java.util.Arrays; import java.util.HashMap; import java.util.HashSet; - import java.util.Iterator; - import java.util.LinkedList; - import java.util.List; import java.util.Map; import java.util.Set; --- 29,35 ---- import java.sql.SQLException; import java.util.Arrays; + import java.util.Comparator; import java.util.HashMap; import java.util.HashSet; import java.util.Map; import java.util.Set; *************** *** 47,55 **** public class DatabaseSequenceFilter extends SequenceTableFilter { - - /** Cache for tablename/foreign key mappings. */ - private static Map _dependentMap; - - /** * Create a DatabaseSequenceFilter that only exposes specified table names. --- 46,49 ---- *************** *** 76,198 **** * @param tableNames A string array of table names to be ordered. * @return The re-ordered array of table names. ! * @throws DataSetException ! * @throws SQLException If an exception is encountered in accessing the database. */ ! static String[] sortTableNames( ! IDatabaseConnection connection, ! String[] tableNames) ! throws DataSetException, SQLException ! // not sure why this throws DataSetException ? - ENP { ! boolean reprocess = true; ! List tmpTableNames = Arrays.asList(tableNames); ! List sortedTableNames = null; ! DatabaseSequenceFilter._dependentMap = new HashMap(); ! ! while (reprocess) { ! sortedTableNames = new LinkedList(); ! ! // re-order 'tmpTableNames' into 'sortedTableNames' ! for (Iterator i = tmpTableNames.iterator(); i.hasNext();) { ! boolean foundDependentInSortedTableNames = false; ! String tmpTable = (String)i.next(); ! Set tmpTableDependents = getDependentTableNames(connection, tmpTable); ! ! int sortedTableIndex = -1; ! for (Iterator k = sortedTableNames.iterator(); k.hasNext();) { ! String sortedTable = (String)k.next(); ! if (tmpTableDependents.contains(sortedTable)) { ! sortedTableIndex = sortedTableNames.indexOf(sortedTable); ! foundDependentInSortedTableNames = true; ! break; // end for loop; we know the index } } ! ! // add 'tmpTable' to 'sortedTableNames'. ! // Insert it before its first dependent if there are any, ! // otherwise append it to the end of 'sortedTableNames' ! if (foundDependentInSortedTableNames) { ! if (sortedTableIndex < 0) { ! throw new IllegalStateException( ! "sortedTableIndex should be 0 or greater, but is " ! + sortedTableIndex); ! } ! sortedTableNames.add(sortedTableIndex, tmpTable); ! } ! else { ! sortedTableNames.add(tmpTable); } } ! ! ! ! // don't stop processing until we have a perfect run (no re-ordering) ! if (tmpTableNames.equals(sortedTableNames)) { ! reprocess = false; } ! else { ! ! tmpTableNames = null; ! tmpTableNames = (List)((LinkedList)sortedTableNames).clone(); } - }// end 'while (reprocess)' - - return (String[])sortedTableNames.toArray(new String[0]); - } - ! /** ! * Returns a Set containing the names of all tables which are dependent upon ! * <code>tableName</code>'s primary key as foreign keys. ! * ! * @param connection An IDatabaseConnection to a database that supports ! * referential integrity. ! * @param tableName The table whose primary key is to be used in determining ! * dependent foreign key tables. ! * @return The Set of dependent foreign key table names. ! * @throws SQLException If an exception is encountered in accessing the database. ! */ ! private static Set getDependentTableNames( ! IDatabaseConnection connection, ! String tableName) ! throws SQLException ! { ! if (_dependentMap.containsKey(tableName)) ! { ! return (Set)_dependentMap.get(tableName); } ! DatabaseMetaData metaData = connection.getConnection().getMetaData(); ! String schema = connection.getSchema(); ! ! ResultSet resultSet = metaData.getExportedKeys(null, schema, tableName); ! try { ! Set foreignTableSet = new HashSet(); ! while (resultSet.next()) { ! // TODO : add support for qualified table names // String foreignSchemaName = resultSet.getString(6); ! String foreignTableName = resultSet.getString(7); ! foreignTableSet.add(foreignTableName); ! } ! _dependentMap.put(tableName, foreignTableSet); ! return foreignTableSet; ! } ! finally ! { ! resultSet.close(); } } --- 70,196 ---- * @param tableNames A string array of table names to be ordered. * @return The re-ordered array of table names. ! * @throws SQLException if a database access error occurs ! * @throws CyclicTablesDependencyException if encounter a cyclic dependency */ ! private static String[] sortTableNames(IDatabaseConnection connection, ! String[] tableNames) throws DataSetException, SQLException { ! try ! { ! TableSequenceComparator tableSequenceComparator = ! new TableSequenceComparator(connection); ! String[] lastNames = tableNames; ! String[] cloneNames = tableNames; ! do { ! lastNames = cloneNames; ! cloneNames = (String[])lastNames.clone(); ! Arrays.sort(cloneNames, ! tableSequenceComparator); ! } while(!Arrays.equals(lastNames, cloneNames)); ! return lastNames; ! } ! catch (DatabaseUnitRuntimeException e) ! { ! if (e.getException() instanceof CyclicTablesDependencyException) ! { ! throw (CyclicTablesDependencyException)e.getException(); ! } ! if (e.getException() instanceof SQLException) ! { ! throw (SQLException)e.getException(); ! } ! ! throw e; ! } ! } ! ! private static class TableSequenceComparator implements Comparator ! { ! IDatabaseConnection _connection; ! Map _dependentMap = new HashMap(); ! ! public TableSequenceComparator(IDatabaseConnection connection) ! { ! _connection = connection; ! } ! ! public int compare(Object o1, Object o2) ! { ! String tableName1 = (String)o1; ! String tableName2 = (String)o2; ! ! try ! { ! if (getDependentTableNames(tableName1).contains(tableName2)) { ! if (getDependentTableNames(tableName2).contains(tableName1)) { ! throw new CyclicTablesDependencyException(tableName1, tableName2); } + return -1; } ! if (getDependentTableNames(tableName2).contains(tableName1)) { ! return 1; } } ! catch (SQLException e) { ! throw new DatabaseUnitRuntimeException(e); } ! catch (CyclicTablesDependencyException e) { ! throw new DatabaseUnitRuntimeException(e); } ! return tableName1.compareTo(tableName2); } ! /** ! * Returns a Set containing the names of all tables which are dependent upon ! * <code>tableName</code>'s primary key as foreign keys. ! * ! * @param tableName The table whose primary key is to be used in determining ! * dependent foreign key tables. ! * @return The Set of dependent foreign key table names. ! * @throws SQLException if a database access error occurs ! */ ! private Set getDependentTableNames(String tableName) ! throws SQLException { ! if (_dependentMap.containsKey(tableName)) ! { ! return (Set)_dependentMap.get(tableName); ! } ! DatabaseMetaData metaData = _connection.getConnection().getMetaData(); ! String schema = _connection.getSchema(); ! ! ResultSet resultSet = metaData.getExportedKeys(null, schema, tableName); ! try { ! Set foreignTableSet = new HashSet(); ! ! while (resultSet.next()) ! { ! // TODO : add support for qualified table names // String foreignSchemaName = resultSet.getString(6); ! String foreignTableName = resultSet.getString(7); ! foreignTableSet.add(foreignTableName); ! } ! _dependentMap.put(tableName, foreignTableSet); ! return foreignTableSet; ! } ! finally ! { ! resultSet.close(); ! } } + } |
From: Butt, D. <db...@me...> - 2004-03-05 16:27:24
|
Hi, I see DBUNIT can create xml files for sample data and key references to use when doing template design. I would however not like to have my objects to use the database naming eg @INVEST.TBL_MEMBER.MB_NO@. What I would like to do is create my POJO's and then have something generate me an XML file of those objects. Is there anything that wil do this? NOTICE: This message contains privileged and confidential information intended only for the person or entity to which it is addressed. Any review, retransmission, dissemination, copy or other use of, or taking of any action in reliance upon this information by persons or entities other than the intended recipient, is prohibited. If you received this message in error, please notify the sender immediately by e-mail, facsimile or telephone and thereafter delete the material from any computer. Metropolitan Holdings Limited, its subsidiaries or associates do not accept liability for any personal views expressed in this message. |
From: <mla...@us...> - 2004-03-01 18:06:00
|
Update of /cvsroot/dbunit/dbunit/src/java/org/dbunit/database In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv26310/src/java/org/dbunit/database Modified Files: AbstractResultSetTable.java Log Message: Now closing ResultSet before Statement to fix the SQLException thrown by the Firebird JDBC driver. Index: AbstractResultSetTable.java =================================================================== RCS file: /cvsroot/dbunit/dbunit/src/java/org/dbunit/database/AbstractResultSetTable.java,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -d -r1.6 -r1.7 *** AbstractResultSetTable.java 25 Feb 2004 19:08:15 -0000 1.6 --- AbstractResultSetTable.java 1 Mar 2004 17:46:57 -0000 1.7 *************** *** 121,130 **** try { - if (_statement != null) - { - _statement.close(); - _statement = null; - } - if (_resultSet != null) { --- 121,124 ---- *************** *** 132,135 **** --- 126,135 ---- _resultSet = null; } + + if (_statement != null) + { + _statement.close(); + _statement = null; + } } catch (SQLException e) |
From: <mla...@us...> - 2004-02-25 19:23:41
|
Update of /cvsroot/dbunit/dbunit/src/java/org/dbunit/database In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv32275/src/java/org/dbunit/database Modified Files: AbstractDatabaseConnection.java AbstractResultSetTable.java DatabaseTableMetaData.java Log Message: Moved createMetaData() static method from AbstractResultSet to DatabaseTableMetaData and made it public. Index: AbstractDatabaseConnection.java =================================================================== RCS file: /cvsroot/dbunit/dbunit/src/java/org/dbunit/database/AbstractDatabaseConnection.java,v retrieving revision 1.18 retrieving revision 1.19 diff -C2 -d -r1.18 -r1.19 *** AbstractDatabaseConnection.java 22 Jan 2004 02:54:17 -0000 1.18 --- AbstractDatabaseConnection.java 25 Feb 2004 19:08:15 -0000 1.19 *************** *** 79,83 **** IDataTypeFactory typeFactory = (IDataTypeFactory)_databaseConfig.getProperty( DatabaseConfig.PROPERTY_DATATYPE_FACTORY); ! ITableMetaData metaData = AbstractResultSetTable.createTableMetaData( resultName, resultSet, typeFactory); return new CachedResultSetTable(metaData, resultSet); --- 79,83 ---- IDataTypeFactory typeFactory = (IDataTypeFactory)_databaseConfig.getProperty( DatabaseConfig.PROPERTY_DATATYPE_FACTORY); ! ITableMetaData metaData = DatabaseTableMetaData.createMetaData( resultName, resultSet, typeFactory); return new CachedResultSetTable(metaData, resultSet); Index: AbstractResultSetTable.java =================================================================== RCS file: /cvsroot/dbunit/dbunit/src/java/org/dbunit/database/AbstractResultSetTable.java,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** AbstractResultSetTable.java 22 Jan 2004 02:54:17 -0000 1.5 --- AbstractResultSetTable.java 25 Feb 2004 19:08:15 -0000 1.6 *************** *** 22,35 **** import org.dbunit.dataset.AbstractTable; - import org.dbunit.dataset.Column; import org.dbunit.dataset.DataSetException; - import org.dbunit.dataset.DefaultTableMetaData; import org.dbunit.dataset.ITableMetaData; - import org.dbunit.dataset.datatype.DataType; import org.dbunit.dataset.datatype.IDataTypeFactory; import java.sql.Connection; import java.sql.ResultSet; - import java.sql.ResultSetMetaData; import java.sql.SQLException; import java.sql.Statement; --- 22,31 ---- *************** *** 69,73 **** { _resultSet = _statement.executeQuery(selectStatement); ! _metaData = createTableMetaData(tableName, _resultSet, dataTypeFactory); } catch (SQLException e) --- 65,70 ---- { _resultSet = _statement.executeQuery(selectStatement); ! _metaData = DatabaseTableMetaData.createMetaData(tableName, ! _resultSet, dataTypeFactory); } catch (SQLException e) *************** *** 109,133 **** } - static ITableMetaData createTableMetaData(String name, - ResultSet resultSet, IDataTypeFactory dataTypeFactory) throws DataSetException, SQLException - { - ResultSetMetaData metaData = resultSet.getMetaData(); - Column[] columns = new Column[metaData.getColumnCount()]; - for (int i = 0; i < columns.length; i++) - { - int columnType = metaData.getColumnType(i + 1); - String columnTypeName = metaData.getColumnTypeName(i + 1); - DataType dataType = dataTypeFactory.createDataType( - columnType, columnTypeName); - columns[i] = new Column( - metaData.getColumnName(i + 1), - dataType, - columnTypeName, - Column.nullableValue(metaData.isNullable(i + 1))); - } - - return new DefaultTableMetaData(name, columns); - } - //////////////////////////////////////////////////////////////////////////// // ITable interface --- 106,109 ---- Index: DatabaseTableMetaData.java =================================================================== RCS file: /cvsroot/dbunit/dbunit/src/java/org/dbunit/database/DatabaseTableMetaData.java,v retrieving revision 1.18 retrieving revision 1.19 diff -C2 -d -r1.18 -r1.19 *** DatabaseTableMetaData.java 22 Jan 2004 02:54:18 -0000 1.18 --- DatabaseTableMetaData.java 25 Feb 2004 19:08:15 -0000 1.19 *************** *** 26,29 **** --- 26,31 ---- import org.dbunit.dataset.DataSetException; import org.dbunit.dataset.NoColumnsFoundException; + import org.dbunit.dataset.ITableMetaData; + import org.dbunit.dataset.DefaultTableMetaData; import org.dbunit.dataset.datatype.DataType; import org.dbunit.dataset.datatype.IDataTypeFactory; *************** *** 33,36 **** --- 35,39 ---- import java.sql.ResultSet; import java.sql.SQLException; + import java.sql.ResultSetMetaData; import java.util.ArrayList; import java.util.Arrays; *************** *** 57,60 **** --- 60,95 ---- } + public static ITableMetaData createMetaData(String tableName, + ResultSet resultSet, IDataTypeFactory dataTypeFactory) + throws DataSetException, SQLException + { + ResultSetMetaData metaData = resultSet.getMetaData(); + Column[] columns = new Column[metaData.getColumnCount()]; + for (int i = 0; i < columns.length; i++) + { + int columnType = metaData.getColumnType(i + 1); + String columnTypeName = metaData.getColumnTypeName(i + 1); + DataType dataType = dataTypeFactory.createDataType( + columnType, columnTypeName); + columns[i] = new Column( + metaData.getColumnName(i + 1), + dataType, + columnTypeName, + Column.nullableValue(metaData.isNullable(i + 1))); + } + + return new DefaultTableMetaData(tableName, columns); + } + + public static ITableMetaData createMetaData(String tableName, + ResultSet resultSet, IDatabaseConnection connection) + throws SQLException, DataSetException + { + DatabaseConfig config = connection.getConfig(); + IDataTypeFactory typeFactory = (IDataTypeFactory)config.getProperty( + DatabaseConfig.PROPERTY_DATATYPE_FACTORY); + return createMetaData(tableName, resultSet, typeFactory); + } + private String[] getPrimaryKeyNames() throws SQLException { |
From: <mla...@us...> - 2004-02-24 15:52:05
|
Update of /cvsroot/dbunit/dbunit/src/test/org/dbunit/dataset/datatype In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv8695/src/test/org/dbunit/dataset/datatype Modified Files: BytesDataTypeTest.java Log Message: Added support for external file in BytesDataType; the value can be either a qualified URL or a file path name. Index: BytesDataTypeTest.java =================================================================== RCS file: /cvsroot/dbunit/dbunit/src/test/org/dbunit/dataset/datatype/BytesDataTypeTest.java,v retrieving revision 1.10 retrieving revision 1.11 diff -C2 -d -r1.10 -r1.11 *** BytesDataTypeTest.java 22 Feb 2004 23:27:20 -0000 1.10 --- BytesDataTypeTest.java 24 Feb 2004 15:37:45 -0000 1.11 *************** *** 23,30 **** --- 23,33 ---- import org.dbunit.database.ExtendedMockSingleRowResultSet; + import org.dbunit.util.FileAsserts; import org.dbunit.dataset.ITable; import java.sql.Types; import java.util.Arrays; + import java.io.File; + import java.io.ByteArrayInputStream; /** *************** *** 107,110 **** --- 110,138 ---- } + public void testTypeCastFileName() throws Exception + { + File file = new File("LICENSE.txt"); + + Object[] values = { + file.toString(), + file.getAbsolutePath(), + file.toURL().toString(), + file, + file.toURL(), + }; + + // System.out.println(file.getAbsolutePath()); + assertEquals("exists", true, file.exists()); + + for (int i = 0; i < TYPES.length; i++) + { + for (int j = 0; j < values.length; j++) + { + byte[] actual = (byte[])TYPES[i].typeCast(values[j]); + FileAsserts.assertEquals(new ByteArrayInputStream(actual), file); + } + } + } + public void testTypeCastNone() throws Exception { *************** *** 120,124 **** Object[] values = { new Object(), ! new Integer(1234) }; --- 148,152 ---- Object[] values = { new Object(), ! new Integer(1234), }; *************** *** 130,134 **** { TYPES[i].typeCast(values[j]); ! fail("Should throw TypeCastException"); } catch (TypeCastException e) --- 158,162 ---- { TYPES[i].typeCast(values[j]); ! fail("Should throw TypeCastException: " + values[j]); } catch (TypeCastException e) |
From: <mla...@us...> - 2004-02-24 15:52:04
|
Update of /cvsroot/dbunit/dbunit/src/java/org/dbunit/dataset/datatype In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv8695/src/java/org/dbunit/dataset/datatype Modified Files: BytesDataType.java Log Message: Added support for external file in BytesDataType; the value can be either a qualified URL or a file path name. Index: BytesDataType.java =================================================================== RCS file: /cvsroot/dbunit/dbunit/src/java/org/dbunit/dataset/datatype/BytesDataType.java,v retrieving revision 1.14 retrieving revision 1.15 diff -C2 -d -r1.14 -r1.15 *** BytesDataType.java 22 Feb 2004 23:27:20 -0000 1.14 --- BytesDataType.java 24 Feb 2004 15:37:45 -0000 1.15 *************** *** 29,32 **** --- 29,41 ---- import java.sql.ResultSet; import java.sql.SQLException; + import java.io.ByteArrayOutputStream; + import java.io.IOException; + import java.io.InputStream; + import java.io.FileNotFoundException; + import java.io.FileInputStream; + import java.io.File; + import java.io.BufferedInputStream; + import java.net.MalformedURLException; + import java.net.URL; /** *************** *** 37,40 **** --- 46,51 ---- public class BytesDataType extends AbstractDataType { + private static final int MAX_URI_LENGTH = 256; + BytesDataType(String name, int sqlType) { *************** *** 42,45 **** --- 53,69 ---- } + private byte[] toByteArray(InputStream in, int length) throws IOException + { + ByteArrayOutputStream out = new ByteArrayOutputStream(length); + in = new BufferedInputStream(in); + int i = in.read(); + while (i != -1) + { + out.write(i); + i = in.read(); + } + return out.toByteArray(); + } + //////////////////////////////////////////////////////////////////////////// // DataType class *************** *** 59,65 **** if (value instanceof String) { ! return Base64.decode((String)value); ! } if (value instanceof Blob) --- 83,123 ---- if (value instanceof String) { ! String stringValue = (String)value; ! ! // Assume not an uri if length greater than max uri length ! if (stringValue.length() == 0 || stringValue.length() > MAX_URI_LENGTH) ! { ! return Base64.decode((String)value); ! } + try + { + try + { + // Try value as URL + URL url = new URL(stringValue); + return toByteArray(url.openStream(), 0); + } + catch (MalformedURLException e1) + { + try + { + // Not an URL, try as file name + File file = new File(stringValue); + return toByteArray(new FileInputStream(file), + (int)file.length()); + } + catch (FileNotFoundException e2) + { + // Not a file name either + return Base64.decode((String)value); + } + } + } + catch (IOException e) + { + throw new TypeCastException(e); + } + } if (value instanceof Blob) *************** *** 76,79 **** --- 134,163 ---- } + if (value instanceof URL) + { + try + { + return toByteArray(((URL)value).openStream(), 0); + } + catch (IOException e) + { + throw new TypeCastException(e); + } + } + + if (value instanceof File) + { + try + { + File file = (File)value; + return toByteArray(new FileInputStream(file), + (int)file.length()); + } + catch (IOException e) + { + throw new TypeCastException(e); + } + } + throw new TypeCastException(value.toString()); } |
Update of /cvsroot/dbunit/dbunit/src/test/org/dbunit/dataset/datatype In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv25482/src/test/org/dbunit/dataset/datatype Modified Files: AbstractDataTypeTest.java BooleanDataTypeTest.java BytesDataTypeTest.java DateDataTypeTest.java DoubleDataTypeTest.java FloatDataTypeTest.java IntegerDataTypeTest.java LongDataTypeTest.java NumberDataTypeTest.java StringDataTypeTest.java TimeDataTypeTest.java TimestampDataTypeTest.java Log Message: Added back support for <none/> value in data types and statements. Still need to modify database operations. Index: AbstractDataTypeTest.java =================================================================== RCS file: /cvsroot/dbunit/dbunit/src/test/org/dbunit/dataset/datatype/AbstractDataTypeTest.java,v retrieving revision 1.10 retrieving revision 1.11 diff -C2 -d -r1.10 -r1.11 *** AbstractDataTypeTest.java 22 Jan 2004 02:54:21 -0000 1.10 --- AbstractDataTypeTest.java 22 Feb 2004 23:27:20 -0000 1.11 *************** *** 45,48 **** --- 45,50 ---- public abstract void testTypeCast() throws Exception; + public abstract void testTypeCastNone() throws Exception; + public abstract void testTypeCastInvalid() throws Exception; Index: BooleanDataTypeTest.java =================================================================== RCS file: /cvsroot/dbunit/dbunit/src/test/org/dbunit/dataset/datatype/BooleanDataTypeTest.java,v retrieving revision 1.10 retrieving revision 1.11 diff -C2 -d -r1.10 -r1.11 *** BooleanDataTypeTest.java 22 Jan 2004 02:54:21 -0000 1.10 --- BooleanDataTypeTest.java 22 Feb 2004 23:27:20 -0000 1.11 *************** *** 23,26 **** --- 23,27 ---- import org.dbunit.database.ExtendedMockSingleRowResultSet; + import org.dbunit.dataset.ITable; import java.sql.Types; *************** *** 64,70 **** } - /** - * - */ public void testTypeCast() throws Exception { --- 65,68 ---- *************** *** 103,106 **** --- 101,109 ---- } + public void testTypeCastNone() throws Exception + { + assertEquals("typecast", null, THIS_TYPE.typeCast(ITable.NO_VALUE)); + } + public void testTypeCastInvalid() throws Exception { Index: BytesDataTypeTest.java =================================================================== RCS file: /cvsroot/dbunit/dbunit/src/test/org/dbunit/dataset/datatype/BytesDataTypeTest.java,v retrieving revision 1.9 retrieving revision 1.10 diff -C2 -d -r1.9 -r1.10 *** BytesDataTypeTest.java 22 Jan 2004 02:54:21 -0000 1.9 --- BytesDataTypeTest.java 22 Feb 2004 23:27:20 -0000 1.10 *************** *** 23,26 **** --- 23,27 ---- import org.dbunit.database.ExtendedMockSingleRowResultSet; + import org.dbunit.dataset.ITable; import java.sql.Types; *************** *** 106,109 **** --- 107,119 ---- } + public void testTypeCastNone() throws Exception + { + for (int i = 0; i < TYPES.length; i++) + { + DataType type = TYPES[i]; + assertEquals("typecast " + type, null, type.typeCast(ITable.NO_VALUE)); + } + } + public void testTypeCastInvalid() throws Exception { Index: DateDataTypeTest.java =================================================================== RCS file: /cvsroot/dbunit/dbunit/src/test/org/dbunit/dataset/datatype/DateDataTypeTest.java,v retrieving revision 1.11 retrieving revision 1.12 diff -C2 -d -r1.11 -r1.12 *** DateDataTypeTest.java 22 Jan 2004 02:54:21 -0000 1.11 --- DateDataTypeTest.java 22 Feb 2004 23:27:20 -0000 1.12 *************** *** 23,26 **** --- 23,27 ---- import org.dbunit.database.ExtendedMockSingleRowResultSet; + import org.dbunit.dataset.ITable; import java.sql.Time; *************** *** 98,101 **** --- 99,107 ---- } + public void testTypeCastNone() throws Exception + { + assertEquals("typecast", null, THIS_TYPE.typeCast(ITable.NO_VALUE)); + } + public void testTypeCastInvalid() throws Exception { Index: DoubleDataTypeTest.java =================================================================== RCS file: /cvsroot/dbunit/dbunit/src/test/org/dbunit/dataset/datatype/DoubleDataTypeTest.java,v retrieving revision 1.10 retrieving revision 1.11 diff -C2 -d -r1.10 -r1.11 *** DoubleDataTypeTest.java 22 Jan 2004 02:54:21 -0000 1.10 --- DoubleDataTypeTest.java 22 Feb 2004 23:27:20 -0000 1.11 *************** *** 23,26 **** --- 23,27 ---- import org.dbunit.database.ExtendedMockSingleRowResultSet; + import org.dbunit.dataset.ITable; import java.math.BigDecimal; *************** *** 108,111 **** --- 109,122 ---- } + + public void testTypeCastNone() throws Exception + { + for (int i = 0; i < TYPES.length; i++) + { + DataType type = TYPES[i]; + assertEquals("typecast " + type, null, type.typeCast(ITable.NO_VALUE)); + } + } + public void testTypeCastInvalid() throws Exception { Index: FloatDataTypeTest.java =================================================================== RCS file: /cvsroot/dbunit/dbunit/src/test/org/dbunit/dataset/datatype/FloatDataTypeTest.java,v retrieving revision 1.10 retrieving revision 1.11 diff -C2 -d -r1.10 -r1.11 *** FloatDataTypeTest.java 22 Jan 2004 02:54:21 -0000 1.10 --- FloatDataTypeTest.java 22 Feb 2004 23:27:20 -0000 1.11 *************** *** 23,26 **** --- 23,27 ---- import org.dbunit.database.ExtendedMockSingleRowResultSet; + import org.dbunit.dataset.ITable; import java.math.BigDecimal; *************** *** 93,96 **** --- 94,102 ---- } + public void testTypeCastNone() throws Exception + { + assertEquals("typecast", null, THIS_TYPE.typeCast(ITable.NO_VALUE)); + } + public void testTypeCastInvalid() throws Exception { Index: IntegerDataTypeTest.java =================================================================== RCS file: /cvsroot/dbunit/dbunit/src/test/org/dbunit/dataset/datatype/IntegerDataTypeTest.java,v retrieving revision 1.10 retrieving revision 1.11 diff -C2 -d -r1.10 -r1.11 *** IntegerDataTypeTest.java 22 Jan 2004 02:54:21 -0000 1.10 --- IntegerDataTypeTest.java 22 Feb 2004 23:27:20 -0000 1.11 *************** *** 23,26 **** --- 23,27 ---- import org.dbunit.database.ExtendedMockSingleRowResultSet; + import org.dbunit.dataset.ITable; import java.math.BigDecimal; *************** *** 126,129 **** --- 127,139 ---- } + public void testTypeCastNone() throws Exception + { + for (int i = 0; i < TYPES.length; i++) + { + DataType type = TYPES[i]; + assertEquals("typecast " + type, null, type.typeCast(ITable.NO_VALUE)); + } + } + public void testTypeCastInvalid() throws Exception { Index: LongDataTypeTest.java =================================================================== RCS file: /cvsroot/dbunit/dbunit/src/test/org/dbunit/dataset/datatype/LongDataTypeTest.java,v retrieving revision 1.10 retrieving revision 1.11 diff -C2 -d -r1.10 -r1.11 *** LongDataTypeTest.java 22 Jan 2004 02:54:21 -0000 1.10 --- LongDataTypeTest.java 22 Feb 2004 23:27:20 -0000 1.11 *************** *** 23,26 **** --- 23,27 ---- import org.dbunit.database.ExtendedMockSingleRowResultSet; + import org.dbunit.dataset.ITable; import java.math.BigDecimal; *************** *** 110,113 **** --- 111,119 ---- } + public void testTypeCastNone() throws Exception + { + assertEquals("typecast", null, THIS_TYPE.typeCast(ITable.NO_VALUE)); + } + public void testTypeCastInvalid() throws Exception { Index: NumberDataTypeTest.java =================================================================== RCS file: /cvsroot/dbunit/dbunit/src/test/org/dbunit/dataset/datatype/NumberDataTypeTest.java,v retrieving revision 1.11 retrieving revision 1.12 diff -C2 -d -r1.11 -r1.12 *** NumberDataTypeTest.java 22 Jan 2004 02:54:21 -0000 1.11 --- NumberDataTypeTest.java 22 Feb 2004 23:27:20 -0000 1.12 *************** *** 23,26 **** --- 23,27 ---- import org.dbunit.database.ExtendedMockSingleRowResultSet; + import org.dbunit.dataset.ITable; import java.math.BigDecimal; *************** *** 100,103 **** --- 101,113 ---- } + public void testTypeCastNone() throws Exception + { + for (int i = 0; i < TYPES.length; i++) + { + DataType type = TYPES[i]; + assertEquals("typecast " + type, null, type.typeCast(ITable.NO_VALUE)); + } + } + public void testTypeCastInvalid() throws Exception { Index: StringDataTypeTest.java =================================================================== RCS file: /cvsroot/dbunit/dbunit/src/test/org/dbunit/dataset/datatype/StringDataTypeTest.java,v retrieving revision 1.12 retrieving revision 1.13 diff -C2 -d -r1.12 -r1.13 *** StringDataTypeTest.java 22 Jan 2004 02:54:21 -0000 1.12 --- StringDataTypeTest.java 22 Feb 2004 23:27:20 -0000 1.13 *************** *** 23,26 **** --- 23,27 ---- import org.dbunit.database.ExtendedMockSingleRowResultSet; + import org.dbunit.dataset.ITable; import java.sql.Types; *************** *** 116,119 **** --- 117,129 ---- } + public void testTypeCastNone() throws Exception + { + for (int i = 0; i < TYPES.length; i++) + { + DataType type = TYPES[i]; + assertEquals("typecast " + type, null, type.typeCast(ITable.NO_VALUE)); + } + } + public void testTypeCastInvalid() throws Exception { Index: TimeDataTypeTest.java =================================================================== RCS file: /cvsroot/dbunit/dbunit/src/test/org/dbunit/dataset/datatype/TimeDataTypeTest.java,v retrieving revision 1.10 retrieving revision 1.11 diff -C2 -d -r1.10 -r1.11 *** TimeDataTypeTest.java 22 Jan 2004 02:54:21 -0000 1.10 --- TimeDataTypeTest.java 22 Feb 2004 23:27:20 -0000 1.11 *************** *** 23,26 **** --- 23,27 ---- import org.dbunit.database.ExtendedMockSingleRowResultSet; + import org.dbunit.dataset.ITable; import java.sql.Time; *************** *** 86,89 **** --- 87,95 ---- } + public void testTypeCastNone() throws Exception + { + assertEquals("typecast", null, THIS_TYPE.typeCast(ITable.NO_VALUE)); + } + public void testTypeCastInvalid() throws Exception { Index: TimestampDataTypeTest.java =================================================================== RCS file: /cvsroot/dbunit/dbunit/src/test/org/dbunit/dataset/datatype/TimestampDataTypeTest.java,v retrieving revision 1.11 retrieving revision 1.12 diff -C2 -d -r1.11 -r1.12 *** TimestampDataTypeTest.java 22 Jan 2004 02:54:21 -0000 1.11 --- TimestampDataTypeTest.java 22 Feb 2004 23:27:20 -0000 1.12 *************** *** 23,26 **** --- 23,27 ---- import org.dbunit.database.ExtendedMockSingleRowResultSet; + import org.dbunit.dataset.ITable; import java.sql.Date; *************** *** 95,98 **** --- 96,104 ---- } + public void testTypeCastNone() throws Exception + { + assertEquals("typecast", null, THIS_TYPE.typeCast(ITable.NO_VALUE)); + } + public void testTypeCastInvalid() throws Exception { |
Update of /cvsroot/dbunit/dbunit/src/java/org/dbunit/dataset/datatype In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv25482/src/java/org/dbunit/dataset/datatype Modified Files: BooleanDataType.java BytesDataType.java DateDataType.java DoubleDataType.java FloatDataType.java IntegerDataType.java LongDataType.java NumberDataType.java StringDataType.java TimeDataType.java TimestampDataType.java UnknownDataType.java Log Message: Added back support for <none/> value in data types and statements. Still need to modify database operations. Index: BooleanDataType.java =================================================================== RCS file: /cvsroot/dbunit/dbunit/src/java/org/dbunit/dataset/datatype/BooleanDataType.java,v retrieving revision 1.13 retrieving revision 1.14 diff -C2 -d -r1.13 -r1.14 *** BooleanDataType.java 22 Jan 2004 02:54:18 -0000 1.13 --- BooleanDataType.java 22 Feb 2004 23:27:20 -0000 1.14 *************** *** 22,25 **** --- 22,27 ---- package org.dbunit.dataset.datatype; + import org.dbunit.dataset.ITable; + import java.sql.PreparedStatement; import java.sql.ResultSet; *************** *** 43,47 **** public Object typeCast(Object value) throws TypeCastException { ! if (value == null) { return null; --- 45,49 ---- public Object typeCast(Object value) throws TypeCastException { ! if (value == null || value == ITable.NO_VALUE) { return null; Index: BytesDataType.java =================================================================== RCS file: /cvsroot/dbunit/dbunit/src/java/org/dbunit/dataset/datatype/BytesDataType.java,v retrieving revision 1.13 retrieving revision 1.14 diff -C2 -d -r1.13 -r1.14 *** BytesDataType.java 22 Jan 2004 02:54:18 -0000 1.13 --- BytesDataType.java 22 Feb 2004 23:27:20 -0000 1.14 *************** *** 23,26 **** --- 23,27 ---- import org.dbunit.util.Base64; + import org.dbunit.dataset.ITable; import java.sql.Blob; *************** *** 46,52 **** public Object typeCast(Object value) throws TypeCastException { ! if (value == null) { ! return value; } --- 47,53 ---- public Object typeCast(Object value) throws TypeCastException { ! if (value == null || value == ITable.NO_VALUE) { ! return null; } Index: DateDataType.java =================================================================== RCS file: /cvsroot/dbunit/dbunit/src/java/org/dbunit/dataset/datatype/DateDataType.java,v retrieving revision 1.12 retrieving revision 1.13 diff -C2 -d -r1.12 -r1.13 *** DateDataType.java 22 Jan 2004 02:54:18 -0000 1.12 --- DateDataType.java 22 Feb 2004 23:27:20 -0000 1.13 *************** *** 22,25 **** --- 22,27 ---- package org.dbunit.dataset.datatype; + import org.dbunit.dataset.ITable; + import java.sql.PreparedStatement; import java.sql.ResultSet; *************** *** 44,48 **** public Object typeCast(Object value) throws TypeCastException { ! if (value == null) { return null; --- 46,50 ---- public Object typeCast(Object value) throws TypeCastException { ! if (value == null || value == ITable.NO_VALUE) { return null; Index: DoubleDataType.java =================================================================== RCS file: /cvsroot/dbunit/dbunit/src/java/org/dbunit/dataset/datatype/DoubleDataType.java,v retrieving revision 1.12 retrieving revision 1.13 diff -C2 -d -r1.12 -r1.13 *** DoubleDataType.java 22 Jan 2004 02:54:18 -0000 1.12 --- DoubleDataType.java 22 Feb 2004 23:27:20 -0000 1.13 *************** *** 22,25 **** --- 22,27 ---- package org.dbunit.dataset.datatype; + import org.dbunit.dataset.ITable; + import java.math.BigDecimal; import java.sql.PreparedStatement; *************** *** 43,47 **** public Object typeCast(Object value) throws TypeCastException { ! if (value == null) { return null; --- 45,49 ---- public Object typeCast(Object value) throws TypeCastException { ! if (value == null || value == ITable.NO_VALUE) { return null; Index: FloatDataType.java =================================================================== RCS file: /cvsroot/dbunit/dbunit/src/java/org/dbunit/dataset/datatype/FloatDataType.java,v retrieving revision 1.12 retrieving revision 1.13 diff -C2 -d -r1.12 -r1.13 *** FloatDataType.java 22 Jan 2004 02:54:18 -0000 1.12 --- FloatDataType.java 22 Feb 2004 23:27:20 -0000 1.13 *************** *** 22,25 **** --- 22,27 ---- package org.dbunit.dataset.datatype; + import org.dbunit.dataset.ITable; + import java.math.BigDecimal; import java.sql.PreparedStatement; *************** *** 44,48 **** public Object typeCast(Object value) throws TypeCastException { ! if (value == null) { return null; --- 46,50 ---- public Object typeCast(Object value) throws TypeCastException { ! if (value == null || value == ITable.NO_VALUE) { return null; Index: IntegerDataType.java =================================================================== RCS file: /cvsroot/dbunit/dbunit/src/java/org/dbunit/dataset/datatype/IntegerDataType.java,v retrieving revision 1.12 retrieving revision 1.13 diff -C2 -d -r1.12 -r1.13 *** IntegerDataType.java 22 Jan 2004 02:54:18 -0000 1.12 --- IntegerDataType.java 22 Feb 2004 23:27:20 -0000 1.13 *************** *** 22,25 **** --- 22,27 ---- package org.dbunit.dataset.datatype; + import org.dbunit.dataset.ITable; + import java.math.BigDecimal; import java.sql.PreparedStatement; *************** *** 43,47 **** public Object typeCast(Object value) throws TypeCastException { ! if (value == null) { return null; --- 45,49 ---- public Object typeCast(Object value) throws TypeCastException { ! if (value == null || value == ITable.NO_VALUE) { return null; Index: LongDataType.java =================================================================== RCS file: /cvsroot/dbunit/dbunit/src/java/org/dbunit/dataset/datatype/LongDataType.java,v retrieving revision 1.12 retrieving revision 1.13 diff -C2 -d -r1.12 -r1.13 *** LongDataType.java 22 Jan 2004 02:54:18 -0000 1.12 --- LongDataType.java 22 Feb 2004 23:27:20 -0000 1.13 *************** *** 22,25 **** --- 22,27 ---- package org.dbunit.dataset.datatype; + import org.dbunit.dataset.ITable; + import java.math.BigDecimal; import java.sql.PreparedStatement; *************** *** 44,48 **** public Object typeCast(Object value) throws TypeCastException { ! if (value == null) { return null; --- 46,50 ---- public Object typeCast(Object value) throws TypeCastException { ! if (value == null || value == ITable.NO_VALUE) { return null; Index: NumberDataType.java =================================================================== RCS file: /cvsroot/dbunit/dbunit/src/java/org/dbunit/dataset/datatype/NumberDataType.java,v retrieving revision 1.11 retrieving revision 1.12 diff -C2 -d -r1.11 -r1.12 *** NumberDataType.java 22 Jan 2004 02:54:18 -0000 1.11 --- NumberDataType.java 22 Feb 2004 23:27:20 -0000 1.12 *************** *** 22,25 **** --- 22,27 ---- package org.dbunit.dataset.datatype; + import org.dbunit.dataset.ITable; + import java.math.BigDecimal; import java.sql.PreparedStatement; *************** *** 47,51 **** public Object typeCast(Object value) throws TypeCastException { ! if (value == null) { return null; --- 49,53 ---- public Object typeCast(Object value) throws TypeCastException { ! if (value == null || value == ITable.NO_VALUE) { return null; Index: StringDataType.java =================================================================== RCS file: /cvsroot/dbunit/dbunit/src/java/org/dbunit/dataset/datatype/StringDataType.java,v retrieving revision 1.20 retrieving revision 1.21 diff -C2 -d -r1.20 -r1.21 *** StringDataType.java 22 Jan 2004 02:54:18 -0000 1.20 --- StringDataType.java 22 Feb 2004 23:27:20 -0000 1.21 *************** *** 23,26 **** --- 23,27 ---- import org.dbunit.util.Base64; + import org.dbunit.dataset.ITable; import java.sql.Blob; *************** *** 46,50 **** public Object typeCast(Object value) throws TypeCastException { ! if (value == null) { return null; --- 47,51 ---- public Object typeCast(Object value) throws TypeCastException { ! if (value == null || value == ITable.NO_VALUE) { return null; Index: TimeDataType.java =================================================================== RCS file: /cvsroot/dbunit/dbunit/src/java/org/dbunit/dataset/datatype/TimeDataType.java,v retrieving revision 1.11 retrieving revision 1.12 diff -C2 -d -r1.11 -r1.12 *** TimeDataType.java 22 Jan 2004 02:54:18 -0000 1.11 --- TimeDataType.java 22 Feb 2004 23:27:20 -0000 1.12 *************** *** 22,25 **** --- 22,27 ---- package org.dbunit.dataset.datatype; + import org.dbunit.dataset.ITable; + import java.sql.PreparedStatement; import java.sql.ResultSet; *************** *** 45,49 **** public Object typeCast(Object value) throws TypeCastException { ! if (value == null) { return null; --- 47,51 ---- public Object typeCast(Object value) throws TypeCastException { ! if (value == null || value == ITable.NO_VALUE) { return null; Index: TimestampDataType.java =================================================================== RCS file: /cvsroot/dbunit/dbunit/src/java/org/dbunit/dataset/datatype/TimestampDataType.java,v retrieving revision 1.12 retrieving revision 1.13 diff -C2 -d -r1.12 -r1.13 *** TimestampDataType.java 22 Jan 2004 02:54:18 -0000 1.12 --- TimestampDataType.java 22 Feb 2004 23:27:20 -0000 1.13 *************** *** 22,25 **** --- 22,27 ---- package org.dbunit.dataset.datatype; + import org.dbunit.dataset.ITable; + import java.sql.PreparedStatement; import java.sql.ResultSet; *************** *** 45,49 **** public Object typeCast(Object value) throws TypeCastException { ! if (value == null) { return null; --- 47,51 ---- public Object typeCast(Object value) throws TypeCastException { ! if (value == null || value == ITable.NO_VALUE) { return null; Index: UnknownDataType.java =================================================================== RCS file: /cvsroot/dbunit/dbunit/src/java/org/dbunit/dataset/datatype/UnknownDataType.java,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** UnknownDataType.java 22 Jan 2004 02:54:18 -0000 1.3 --- UnknownDataType.java 22 Feb 2004 23:27:20 -0000 1.4 *************** *** 22,25 **** --- 22,27 ---- package org.dbunit.dataset.datatype; + import org.dbunit.dataset.ITable; + import java.sql.Types; *************** *** 40,43 **** --- 42,50 ---- public Object typeCast(Object value) throws TypeCastException { + if (value == ITable.NO_VALUE) + { + return null; + } + return value; } |
From: <mla...@us...> - 2004-02-22 23:40:23
|
Update of /cvsroot/dbunit/dbunit/src/java/org/dbunit/database/statement In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv25482/src/java/org/dbunit/database/statement Modified Files: PreparedBatchStatement.java SimplePreparedStatement.java Log Message: Added back support for <none/> value in data types and statements. Still need to modify database operations. Index: PreparedBatchStatement.java =================================================================== RCS file: /cvsroot/dbunit/dbunit/src/java/org/dbunit/database/statement/PreparedBatchStatement.java,v retrieving revision 1.11 retrieving revision 1.12 diff -C2 -d -r1.11 -r1.12 *** PreparedBatchStatement.java 22 Jan 2004 02:54:18 -0000 1.11 --- PreparedBatchStatement.java 22 Feb 2004 23:26:59 -0000 1.12 *************** *** 24,27 **** --- 24,28 ---- import org.dbunit.dataset.datatype.DataType; import org.dbunit.dataset.datatype.TypeCastException; + import org.dbunit.dataset.ITable; import java.sql.Connection; *************** *** 51,55 **** { // Special NULL handling ! if (value == null) { _statement.setNull(++_index, dataType.getSqlType()); --- 52,56 ---- { // Special NULL handling ! if (value == null || value == ITable.NO_VALUE) { _statement.setNull(++_index, dataType.getSqlType()); Index: SimplePreparedStatement.java =================================================================== RCS file: /cvsroot/dbunit/dbunit/src/java/org/dbunit/database/statement/SimplePreparedStatement.java,v retrieving revision 1.12 retrieving revision 1.13 diff -C2 -d -r1.12 -r1.13 *** SimplePreparedStatement.java 22 Jan 2004 02:54:18 -0000 1.12 --- SimplePreparedStatement.java 22 Feb 2004 23:27:19 -0000 1.13 *************** *** 24,27 **** --- 24,28 ---- import org.dbunit.dataset.datatype.DataType; import org.dbunit.dataset.datatype.TypeCastException; + import org.dbunit.dataset.ITable; import java.sql.Connection; *************** *** 53,57 **** { // Special NULL handling ! if (value == null) { _statement.setNull(++_index, dataType.getSqlType()); --- 54,58 ---- { // Special NULL handling ! if (value == null || value == ITable.NO_VALUE) { _statement.setNull(++_index, dataType.getSqlType()); |
From: <mla...@us...> - 2004-02-22 23:40:20
|
Update of /cvsroot/dbunit/dbunit/src/java/org/dbunit/dataset In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv25482/src/java/org/dbunit/dataset Modified Files: DataSetUtils.java Log Message: Added back support for <none/> value in data types and statements. Still need to modify database operations. Index: DataSetUtils.java =================================================================== RCS file: /cvsroot/dbunit/dbunit/src/java/org/dbunit/dataset/DataSetUtils.java,v retrieving revision 1.18 retrieving revision 1.19 diff -C2 -d -r1.18 -r1.19 *** DataSetUtils.java 22 Jan 2004 02:54:18 -0000 1.18 --- DataSetUtils.java 22 Feb 2004 23:27:19 -0000 1.19 *************** *** 138,142 **** throws TypeCastException { ! if (value == null) { return "NULL"; --- 138,142 ---- throws TypeCastException { ! if (value == null || value == ITable.NO_VALUE) { return "NULL"; |
From: <mla...@us...> - 2004-02-18 19:46:29
|
Update of /cvsroot/dbunit/dbunit/xdocs In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv16134/xdocs Modified Files: faq.fml Log Message: Fixing overwriten FAQ about views. Index: faq.fml =================================================================== RCS file: /cvsroot/dbunit/dbunit/xdocs/faq.fml,v retrieving revision 1.13 retrieving revision 1.14 diff -C2 -d -r1.13 -r1.14 *** faq.fml 17 Feb 2004 22:52:48 -0000 1.13 --- faq.fml 18 Feb 2004 19:36:44 -0000 1.14 *************** *** 161,169 **** Yes. By default DbUnit is configured to only recognize normal tables. Modify the <a href="properties.html#tabletype">table type property</a> to work with other table types. </p> <p> ! For example, use <code>{"TABLE", "VIEW"}</code> for views. </p> - </answer> </faq> --- 161,171 ---- Yes. By default DbUnit is configured to only recognize normal tables. Modify the <a href="properties.html#tabletype">table type property</a> to work with other table types. + For example, use <code>{"TABLE", "VIEW"}</code> for views. </p> <p> ! Be aware that REFRESH, DELETE and UPDATE operations are not compatible with tables without ! primary keys, thus are not usable with views. CLEAN_INSERT, INSERT and DELETE_ALL ! operations are compatible with views. </p> </answer> </faq> |
From: <mla...@us...> - 2004-02-17 23:01:57
|
Update of /cvsroot/dbunit/dbunit/xdocs In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv11301/xdocs Modified Files: faq.fml Log Message: Updated FAQ about DbUnit performance Index: faq.fml =================================================================== RCS file: /cvsroot/dbunit/dbunit/xdocs/faq.fml,v retrieving revision 1.12 retrieving revision 1.13 diff -C2 -d -r1.12 -r1.13 *** faq.fml 10 Feb 2004 19:55:03 -0000 1.12 --- faq.fml 17 Feb 2004 22:52:48 -0000 1.13 *************** *** 4,8 **** <part id="general"> <title>General</title> - <!-- <faq id="supportedvendors"> --- 4,7 ---- *************** *** 11,18 **** </question> <answer> ! <p>The Dbunit framework is actively developed and tested with Oracle and HypersonicSQL. ! It uses a fairly simple SQL syntax and should be compatible with the other ! database systems. <a href="support.html">Let us know</a> if you find any ! incompatibilities.</p> </answer> </faq> --- 10,14 ---- </question> <answer> ! <p>See the publicly maintained <a href="http://www.dbunit.org/cgi-bin/wiki.pl?SupportedRDBMS">list of compatible RDBMS</a> at the <a href="http://www.dbunit.org/wiki/">DbUnit Wiki.</a></p> </answer> </faq> *************** *** 165,174 **** Yes. By default DbUnit is configured to only recognize normal tables. Modify the <a href="properties.html#tabletype">table type property</a> to work with other table types. - For example, use <code>{"TABLE", "VIEW"}</code> for views. </p> <p> ! Be aware that REFRESH, DELETE and UPDATE operations are not compatible with tables without ! primary keys, thus are not usable with views. CLEAN_INSERT, INSERT and DELETE_ALL ! operations are compatible with views. </p> --- 161,167 ---- Yes. By default DbUnit is configured to only recognize normal tables. Modify the <a href="properties.html#tabletype">table type property</a> to work with other table types. </p> <p> ! For example, use <code>{"TABLE", "VIEW"}</code> for views. </p> *************** *** 300,303 **** --- 293,341 ---- </answer> </faq> + + <faq id="performance"> + <question> + How to improve the performance of my DbUnit tests? + </question> + <answer> + <p> + It is normal that testing with a real database is slower than testing with <a href="http://www.mockobjects.com/">MockObjects</a>. Here are few tricks that will help to speedup your DbUnit tests. + </p> + <h5> + 1. Reuse the same connection thorough your test suite + </h5> + <p> + Creating a new DbUnit connection every time has a cost. The overhead is much more than just creating a new JDBC connection. DbUnit need to fetches tables' metadata to determine columns data types. This information is cached in the DbUnit connection. So this is highly recommended to reuse the same DbUnit connection thorough your test suite; more you have tables greater are the benefits. + </p> + <h5> + 2. Specify the database schema name + </h5> + <p> + If your database server supports multiple schemas, like Oracle, you should always specify the schema name you want to use when + creating the DbUnit connection. DbUnit can potentially fetch the metadata of all tables it have access to. + This include tables from other schemas if you are using a <b>god JDBC connection</b>. So in this situation, + specifying a schema name can dramatically improve DbUnit performance. + </p> + <h5> + 3. Test with little data + </h5> + <p> + Unit testing require relatively little data. So try to <a href="bestpractices.html#smalldatasets">keep your setup datasets as small as possible</a>. There is no necessity to reset the entire database content at the beginning of every test. Try to use only the data you need for a particular test case. + </p> + <h5> + 4. Setup stale data once for the entire test suite + </h5> + <p> + If most of your tests are using the same read-only data, you should consider initializing this data once for an entire test class or test suite. + </p> + <h5> + 5. Enable the batched statement feature + </h5> + <p> + The <a href="properties.html#batchstatement">batched statements</a> feature is disabled by default because there are many JDBC drivers incompatible with it. This is recommended to enable this feature if your driver supports it. The performance gain may not be very significant when testing with <a href="bestpractices.html#smalldatasets">small datasets</a>. + </p> + + </answer> + </faq> </part> |
From: <mla...@us...> - 2004-02-10 19:58:36
|
Update of /cvsroot/dbunit/dbunit/xdocs In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv5220/xdocs Modified Files: faq.fml Log Message: Updated FAQ, REFRESH not usable with views. Index: faq.fml =================================================================== RCS file: /cvsroot/dbunit/dbunit/xdocs/faq.fml,v retrieving revision 1.11 retrieving revision 1.12 diff -C2 -d -r1.11 -r1.12 *** faq.fml 3 Feb 2004 01:18:01 -0000 1.11 --- faq.fml 10 Feb 2004 19:55:03 -0000 1.12 *************** *** 165,171 **** Yes. By default DbUnit is configured to only recognize normal tables. Modify the <a href="properties.html#tabletype">table type property</a> to work with other table types. </p> <p> ! For example, use <code>{"TABLE", "VIEW"}</code> for views. </p> --- 165,174 ---- Yes. By default DbUnit is configured to only recognize normal tables. Modify the <a href="properties.html#tabletype">table type property</a> to work with other table types. + For example, use <code>{"TABLE", "VIEW"}</code> for views. </p> <p> ! Be aware that REFRESH, DELETE and UPDATE operations are not compatible with tables without ! primary keys, thus are not usable with views. CLEAN_INSERT, INSERT and DELETE_ALL ! operations are compatible with views. </p> |
From: <mla...@us...> - 2004-02-10 02:02:18
|
Update of /cvsroot/dbunit/dbunit/src/java/org/dbunit/operation In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv19330/src/java/org/dbunit/operation Modified Files: AbstractBatchOperation.java Log Message: Oups! Also commited other changes that should not be! Index: AbstractBatchOperation.java =================================================================== RCS file: /cvsroot/dbunit/dbunit/src/java/org/dbunit/operation/AbstractBatchOperation.java,v retrieving revision 1.24 retrieving revision 1.25 diff -C2 -d -r1.24 -r1.25 *** AbstractBatchOperation.java 10 Feb 2004 01:50:18 -0000 1.24 --- AbstractBatchOperation.java 10 Feb 2004 01:58:50 -0000 1.25 *************** *** 86,90 **** * a column to ignore. */ ! BigInteger getIgnoreMapping(ITable table, int row) throws DataSetException { --- 86,90 ---- * a column to ignore. */ ! BigInteger getIngnoreMapping(ITable table, int row) throws DataSetException { *************** *** 129,133 **** ITableMetaData metaData = getOperationMetaData(connection, table.getTableMetaData()); ! BigInteger noneMapping = null; OperationData operationData = null; IPreparedBatchStatement statement = null; --- 129,133 ---- ITableMetaData metaData = getOperationMetaData(connection, table.getTableMetaData()); ! BigInteger ignoreMapping = null; OperationData operationData = null; IPreparedBatchStatement statement = null; *************** *** 145,151 **** int row = i; ! // If current row have a diffrent NONE value mapping than // previous one, we generate a new statement ! if (noneMapping == null || !equalsIgnoreMapping(noneMapping, table, row)) { // Execute and close previous statement --- 145,151 ---- int row = i; ! // If current row have a diffrent ignore value mapping than // previous one, we generate a new statement ! if (ignoreMapping == null || !equalsIgnoreMapping(ignoreMapping, table, row)) { // Execute and close previous statement *************** *** 157,162 **** } ! noneMapping = getIgnoreMapping(table, row); ! operationData = getOperationData(metaData, noneMapping, connection); statement = factory.createPreparedBatchStatement( operationData.getSql(), connection); --- 157,162 ---- } ! ignoreMapping = getIngnoreMapping(table, row); ! operationData = getOperationData(metaData, ignoreMapping, connection); statement = factory.createPreparedBatchStatement( operationData.getSql(), connection); *************** *** 169,173 **** { // Bind value only if not in ignore mapping ! if (!noneMapping.testBit(j)) { Column column = columns[j]; --- 169,173 ---- { // Bind value only if not in ignore mapping ! if (!ignoreMapping.testBit(j)) { Column column = columns[j]; *************** *** 189,193 **** finally { ! if (statement != null) { statement.close(); --- 189,193 ---- finally { ! if (statement != null) { statement.close(); |
From: <mla...@us...> - 2004-02-10 01:53:37
|
Update of /cvsroot/dbunit/dbunit/src/java/org/dbunit/operation In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv17650/src/java/org/dbunit/operation Modified Files: AbstractBatchOperation.java Log Message: Fixed NPE when getting metadata throws an exception. Index: AbstractBatchOperation.java =================================================================== RCS file: /cvsroot/dbunit/dbunit/src/java/org/dbunit/operation/AbstractBatchOperation.java,v retrieving revision 1.23 retrieving revision 1.24 diff -C2 -d -r1.23 -r1.24 *** AbstractBatchOperation.java 3 Feb 2004 01:27:11 -0000 1.23 --- AbstractBatchOperation.java 10 Feb 2004 01:50:18 -0000 1.24 *************** *** 86,90 **** * a column to ignore. */ ! BigInteger getIngnoreMapping(ITable table, int row) throws DataSetException { --- 86,90 ---- * a column to ignore. */ ! BigInteger getIgnoreMapping(ITable table, int row) throws DataSetException { *************** *** 129,133 **** ITableMetaData metaData = getOperationMetaData(connection, table.getTableMetaData()); ! BigInteger ignoreMapping = null; OperationData operationData = null; IPreparedBatchStatement statement = null; --- 129,133 ---- ITableMetaData metaData = getOperationMetaData(connection, table.getTableMetaData()); ! BigInteger noneMapping = null; OperationData operationData = null; IPreparedBatchStatement statement = null; *************** *** 145,151 **** int row = i; ! // If current row have a diffrent ignore value mapping than // previous one, we generate a new statement ! if (ignoreMapping == null || !equalsIgnoreMapping(ignoreMapping, table, row)) { // Execute and close previous statement --- 145,151 ---- int row = i; ! // If current row have a diffrent NONE value mapping than // previous one, we generate a new statement ! if (noneMapping == null || !equalsIgnoreMapping(noneMapping, table, row)) { // Execute and close previous statement *************** *** 157,162 **** } ! ignoreMapping = getIngnoreMapping(table, row); ! operationData = getOperationData(metaData, ignoreMapping, connection); statement = factory.createPreparedBatchStatement( operationData.getSql(), connection); --- 157,162 ---- } ! noneMapping = getIgnoreMapping(table, row); ! operationData = getOperationData(metaData, noneMapping, connection); statement = factory.createPreparedBatchStatement( operationData.getSql(), connection); *************** *** 169,173 **** { // Bind value only if not in ignore mapping ! if (!ignoreMapping.testBit(j)) { Column column = columns[j]; --- 169,173 ---- { // Bind value only if not in ignore mapping ! if (!noneMapping.testBit(j)) { Column column = columns[j]; *************** *** 189,193 **** finally { ! statement.close(); } } --- 189,196 ---- finally { ! if (statement != null) ! { ! statement.close(); ! } } } |
From: <mla...@us...> - 2004-02-09 18:16:38
|
Update of /cvsroot/dbunit/dbunit/xdocs In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv2502/xdocs Modified Files: properties.xml Log Message: Added more anchors. Index: properties.xml =================================================================== RCS file: /cvsroot/dbunit/dbunit/xdocs/properties.xml,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** properties.xml 18 Jan 2004 18:26:23 -0000 1.5 --- properties.xml 9 Feb 2004 18:13:22 -0000 1.6 *************** *** 144,147 **** --- 144,148 ---- </tr> </table> + <a name="statementfactory"></a> <h4>Statement factory</h4> <table border="1"> *************** *** 160,163 **** --- 161,165 ---- </tr> </table> + <a name="resultsettablefactory"></a> <h4>ResultSetTable factory</h4> <table border="1"> |
From: <mla...@us...> - 2004-02-09 15:16:35
|
Update of /cvsroot/dbunit/dbunit/xdocs In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv27199/xdocs Modified Files: components.xml Log Message: Added more anchors. Index: components.xml =================================================================== RCS file: /cvsroot/dbunit/dbunit/xdocs/components.xml,v retrieving revision 1.9 retrieving revision 1.10 diff -C2 -d -r1.9 -r1.10 *** components.xml 20 Jan 2004 14:45:41 -0000 1.9 --- components.xml 9 Feb 2004 15:13:20 -0000 1.10 *************** *** 57,61 **** </tr> <tr> ! <td><a name="FlatXmlDataSet" href="apidocs/org/dbunit/dataset/xml/FlatXmlDataSet.html">FlatXmlDataSet</a></td> <td> Reads and writes flat XML dataset document. Each XML element corresponds to a table row. --- 57,61 ---- </tr> <tr> ! <td><a name="flatxmldataset" href="apidocs/org/dbunit/dataset/xml/FlatXmlDataSet.html">FlatXmlDataSet</a></td> <td> Reads and writes flat XML dataset document. Each XML element corresponds to a table row. *************** *** 89,93 **** </tr> <tr> ! <td><a href="apidocs/org/dbunit/dataset/xml/XmlDataSet.html">XmlDataSet</a></td> <td> Reads and writes original XML dataset document. This format --- 89,93 ---- </tr> <tr> ! <td><a name="xmldataset" href="apidocs/org/dbunit/dataset/xml/XmlDataSet.html">XmlDataSet</a></td> <td> Reads and writes original XML dataset document. This format *************** *** 226,230 **** </tr> <tr> ! <td><a href="apidocs/org/dbunit/dataset/excel/XlsDataSet.html">XlsDataSet</a></td> <td>Read and writes MS Excel dataset documents. Each sheet represents a table. The first row of a sheet defines the columns names --- 226,230 ---- </tr> <tr> ! <td><a name="xlsdataset" href="apidocs/org/dbunit/dataset/excel/XlsDataSet.html">XlsDataSet</a></td> <td>Read and writes MS Excel dataset documents. Each sheet represents a table. The first row of a sheet defines the columns names *************** *** 282,286 **** </tr> <tr> ! <td><a href="apidocs/org/dbunit/operation/DeleteOperation.html">DatabaseOperation.DELETE</a></td> <td>This operation deletes only the dataset contents from the database. This operation does not delete the entire table contents but only data that are --- 282,286 ---- </tr> <tr> ! <td><a name="delete" href="apidocs/org/dbunit/operation/DeleteOperation.html">DatabaseOperation.DELETE</a></td> <td>This operation deletes only the dataset contents from the database. This operation does not delete the entire table contents but only data that are *************** *** 292,296 **** </tr> <tr> ! <td><a href="apidocs/org/dbunit/operation/TruncateTableOperation.html">DatabaseOperation.TRUNCATE</a></td> <td>Truncate tables present in the specified dataset. If the dataset does not contains a particular table, but that table exists in the database, the database table is not affected. Table are truncated in reverse sequence. --- 292,296 ---- </tr> <tr> ! <td><a name="truncate" href="apidocs/org/dbunit/operation/TruncateTableOperation.html">DatabaseOperation.TRUNCATE</a></td> <td>Truncate tables present in the specified dataset. If the dataset does not contains a particular table, but that table exists in the database, the database table is not affected. Table are truncated in reverse sequence. *************** *** 298,302 **** </tr> <tr> ! <td><a name="#refresh" href="apidocs/org/dbunit/operation/RefreshOperation.html">DatabaseOperation.REFRESH</a></td> <td>This operation literally refreshes dataset contents into the target database. This means that data of existing rows are updated and non-existing row get --- 298,302 ---- </tr> <tr> ! <td><a name="refresh" href="apidocs/org/dbunit/operation/RefreshOperation.html">DatabaseOperation.REFRESH</a></td> <td>This operation literally refreshes dataset contents into the target database. This means that data of existing rows are updated and non-existing row get *************** *** 308,312 **** </tr> <tr> ! <td><a name="#cleanInsert">DatabaseOperation.CLEAN_INSERT</a></td> <td>This composite operation performs a <a href="#deleteall">DELETE_ALL</a> operation followed by an <a href="#insert">INSERT</a> operation. This is the safest approach to ensure that the database --- 308,312 ---- </tr> <tr> ! <td><a name="cleanInsert">DatabaseOperation.CLEAN_INSERT</a></td> <td>This composite operation performs a <a href="#deleteall">DELETE_ALL</a> operation followed by an <a href="#insert">INSERT</a> operation. This is the safest approach to ensure that the database |
From: <mla...@us...> - 2004-02-03 01:29:20
|
Update of /cvsroot/dbunit/dbunit/src/java/org/dbunit/operation In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv3633/src/java/org/dbunit/operation Modified Files: AbstractBatchOperation.java AbstractOperation.java RefreshOperation.java Log Message: * Added test to verify misnamed column when executing some operations. * Minor operations cleanup. Index: AbstractBatchOperation.java =================================================================== RCS file: /cvsroot/dbunit/dbunit/src/java/org/dbunit/operation/AbstractBatchOperation.java,v retrieving revision 1.22 retrieving revision 1.23 diff -C2 -d -r1.22 -r1.23 *** AbstractBatchOperation.java 22 Jan 2004 02:54:19 -0000 1.22 --- AbstractBatchOperation.java 3 Feb 2004 01:27:11 -0000 1.23 *************** *** 27,36 **** import org.dbunit.database.statement.IPreparedBatchStatement; import org.dbunit.database.statement.IStatementFactory; ! import org.dbunit.dataset.*; import java.math.BigInteger; import java.sql.SQLException; - import java.util.ArrayList; - import java.util.List; /** --- 27,40 ---- import org.dbunit.database.statement.IPreparedBatchStatement; import org.dbunit.database.statement.IStatementFactory; ! import org.dbunit.dataset.Column; ! import org.dbunit.dataset.DataSetException; ! import org.dbunit.dataset.IDataSet; ! import org.dbunit.dataset.ITable; ! import org.dbunit.dataset.ITableIterator; ! import org.dbunit.dataset.ITableMetaData; ! import org.dbunit.dataset.RowOutOfBoundsException; import java.math.BigInteger; import java.sql.SQLException; /** *************** *** 46,83 **** protected boolean _reverseRowOrder = false; - /** - * Returns the metadata to use in this operation. - * - * @param connection the database connection - * @param metaData the xml table metadata - */ - static ITableMetaData getOperationMetaData(IDatabaseConnection connection, - ITableMetaData metaData) throws DatabaseUnitException, SQLException - { - IDataSet databaseDataSet = connection.createDataSet(); - String tableName = metaData.getTableName(); - - ITableMetaData databaseMetaData = databaseDataSet.getTableMetaData(tableName); - Column[] databaseColumns = databaseMetaData.getColumns(); - Column[] columns = metaData.getColumns(); - - List columnList = new ArrayList(); - for (int j = 0; j < columns.length; j++) - { - String columnName = columns[j].getColumnName(); - Column column = DataSetUtils.getColumn( - columnName, databaseColumns); - if (column == null) - { - throw new NoSuchColumnException(tableName + "." + columnName); - } - columnList.add(column); - } - - return new DefaultTableMetaData(databaseMetaData.getTableName(), - (Column[])columnList.toArray(new Column[0]), - databaseMetaData.getPrimaryKeys()); - } - static boolean isEmpty(ITable table) throws DataSetException { --- 50,53 ---- Index: AbstractOperation.java =================================================================== RCS file: /cvsroot/dbunit/dbunit/src/java/org/dbunit/operation/AbstractOperation.java,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** AbstractOperation.java 22 Jan 2004 02:54:19 -0000 1.2 --- AbstractOperation.java 3 Feb 2004 01:27:11 -0000 1.3 *************** *** 24,27 **** --- 24,37 ---- import org.dbunit.database.IDatabaseConnection; import org.dbunit.dataset.DataSetUtils; + import org.dbunit.dataset.ITableMetaData; + import org.dbunit.dataset.IDataSet; + import org.dbunit.dataset.Column; + import org.dbunit.dataset.NoSuchColumnException; + import org.dbunit.dataset.DefaultTableMetaData; + import org.dbunit.DatabaseUnitException; + + import java.sql.SQLException; + import java.util.List; + import java.util.ArrayList; /** *************** *** 40,43 **** --- 50,85 ---- } + /** + * Returns the metadata to use in this operation. + * + * @param connection the database connection + * @param metaData the xml table metadata + */ + static ITableMetaData getOperationMetaData(IDatabaseConnection connection, + ITableMetaData metaData) throws DatabaseUnitException, SQLException + { + IDataSet databaseDataSet = connection.createDataSet(); + String tableName = metaData.getTableName(); + + ITableMetaData databaseMetaData = databaseDataSet.getTableMetaData(tableName); + Column[] databaseColumns = databaseMetaData.getColumns(); + Column[] columns = metaData.getColumns(); + List columnList = new ArrayList(); + for (int j = 0; j < columns.length; j++) + { + String columnName = columns[j].getColumnName(); + Column column = DataSetUtils.getColumn( + columnName, databaseColumns); + if (column == null) + { + throw new NoSuchColumnException(tableName + "." + columnName); + } + columnList.add(column); + } + + return new DefaultTableMetaData(databaseMetaData.getTableName(), + (Column[])columnList.toArray(new Column[0]), + databaseMetaData.getPrimaryKeys()); + } } Index: RefreshOperation.java =================================================================== RCS file: /cvsroot/dbunit/dbunit/src/java/org/dbunit/operation/RefreshOperation.java,v retrieving revision 1.31 retrieving revision 1.32 diff -C2 -d -r1.31 -r1.32 *** RefreshOperation.java 22 Jan 2004 02:54:19 -0000 1.31 --- RefreshOperation.java 3 Feb 2004 01:27:11 -0000 1.32 *************** *** 67,77 **** } - private ITableMetaData getOperationMetaData(IDatabaseConnection connection, - ITableMetaData metaData) throws DatabaseUnitException, SQLException - { - return AbstractBatchOperation.getOperationMetaData( - connection, metaData); - } - //////////////////////////////////////////////////////////////////////////// // DatabaseOperation class --- 67,70 ---- *************** *** 140,144 **** /** ! * This class represents a operation executable on a single table row. */ class RowOperation --- 133,137 ---- /** ! * This class represents a operation executed on a single table row. */ class RowOperation *************** *** 149,153 **** /** ! * Execute this operation on the sepcfied table row. * @return <code>true</code> if operation have been executed on the row. */ --- 142,146 ---- /** ! * Execute this operation on the sepcified table row. * @return <code>true</code> if operation have been executed on the row. */ |
From: <mla...@us...> - 2004-02-03 01:29:20
|
Update of /cvsroot/dbunit/dbunit/src/test/org/dbunit/operation In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv3633/src/test/org/dbunit/operation Modified Files: InsertOperationTest.java RefreshOperationTest.java Log Message: * Added test to verify misnamed column when executing some operations. * Minor operations cleanup. Index: InsertOperationTest.java =================================================================== RCS file: /cvsroot/dbunit/dbunit/src/test/org/dbunit/operation/InsertOperationTest.java,v retrieving revision 1.23 retrieving revision 1.24 diff -C2 -d -r1.23 -r1.24 *** InsertOperationTest.java 22 Jan 2004 02:54:35 -0000 1.23 --- InsertOperationTest.java 3 Feb 2004 01:27:11 -0000 1.24 *************** *** 26,29 **** --- 26,30 ---- import org.dbunit.DatabaseEnvironment; import org.dbunit.TestFeature; + import org.dbunit.DatabaseUnitException; import org.dbunit.database.DatabaseConfig; import org.dbunit.database.MockDatabaseConnection; *************** *** 100,103 **** --- 101,155 ---- } + public void testExecuteUnknownColumn() throws Exception + { + String tableName = "table"; + + // setup table + Column[] columns = new Column[]{ + new Column("column", DataType.VARCHAR), + new Column("unknown", DataType.VARCHAR), + }; + DefaultTable table = new DefaultTable(tableName, columns); + table.addRow(); + table.setValue(0, columns[0].getColumnName(), null); + table.setValue(0, columns[0].getColumnName(), "value"); + IDataSet insertDataset = new DefaultDataSet(table); + + IDataSet databaseDataSet = new DefaultDataSet( + new DefaultTable(tableName, new Column[]{ + new Column("column", DataType.VARCHAR), + })); + + // setup mock objects + MockBatchStatement statement = new MockBatchStatement(); + statement.setExpectedExecuteBatchCalls(0); + statement.setExpectedClearBatchCalls(0); + statement.setExpectedCloseCalls(0); + + MockStatementFactory factory = new MockStatementFactory(); + factory.setExpectedCreatePreparedStatementCalls(0); + factory.setupStatement(statement); + + MockDatabaseConnection connection = new MockDatabaseConnection(); + connection.setupDataSet(databaseDataSet); + connection.setupStatementFactory(factory); + connection.setExpectedCloseCalls(0); + + // execute operation + try + { + new InsertOperation().execute(connection, insertDataset); + fail("Should not be here!"); + } + catch (NoSuchColumnException e) + { + + } + + statement.verify(); + factory.verify(); + connection.verify(); + } + public void testExecuteIgnoreNull() throws Exception { Index: RefreshOperationTest.java =================================================================== RCS file: /cvsroot/dbunit/dbunit/src/test/org/dbunit/operation/RefreshOperationTest.java,v retrieving revision 1.15 retrieving revision 1.16 diff -C2 -d -r1.15 -r1.16 *** RefreshOperationTest.java 22 Jan 2004 02:54:36 -0000 1.15 --- RefreshOperationTest.java 3 Feb 2004 01:27:11 -0000 1.16 *************** *** 26,38 **** import org.dbunit.database.MockDatabaseConnection; import org.dbunit.database.statement.MockStatementFactory; ! import org.dbunit.dataset.Column; ! import org.dbunit.dataset.DefaultDataSet; ! import org.dbunit.dataset.DefaultTable; ! import org.dbunit.dataset.DefaultTableMetaData; ! import org.dbunit.dataset.ForwardOnlyDataSet; ! import org.dbunit.dataset.IDataSet; ! import org.dbunit.dataset.ITable; ! import org.dbunit.dataset.LowerCaseDataSet; ! import org.dbunit.dataset.NoPrimaryKeyException; import org.dbunit.dataset.datatype.DataType; import org.dbunit.dataset.xml.FlatXmlDataSet; --- 26,31 ---- import org.dbunit.database.MockDatabaseConnection; import org.dbunit.database.statement.MockStatementFactory; ! import org.dbunit.database.statement.MockBatchStatement; ! import org.dbunit.dataset.*; import org.dbunit.dataset.datatype.DataType; import org.dbunit.dataset.xml.FlatXmlDataSet; *************** *** 185,188 **** --- 178,231 ---- } + public void testExecuteUnknownColumn() throws Exception + { + String tableName = "table"; + + // setup table + Column[] columns = new Column[]{ + new Column("unknown", DataType.VARCHAR), + }; + DefaultTable table = new DefaultTable(tableName, columns); + table.addRow(); + table.setValue(0, columns[0].getColumnName(), "value"); + IDataSet insertDataset = new DefaultDataSet(table); + + IDataSet databaseDataSet = new DefaultDataSet( + new DefaultTable(tableName, new Column[]{ + new Column("column", DataType.VARCHAR), + })); + + // setup mock objects + MockBatchStatement statement = new MockBatchStatement(); + statement.setExpectedExecuteBatchCalls(0); + statement.setExpectedClearBatchCalls(0); + statement.setExpectedCloseCalls(0); + + MockStatementFactory factory = new MockStatementFactory(); + factory.setExpectedCreatePreparedStatementCalls(0); + factory.setupStatement(statement); + + MockDatabaseConnection connection = new MockDatabaseConnection(); + connection.setupDataSet(databaseDataSet); + connection.setupStatementFactory(factory); + connection.setExpectedCloseCalls(0); + + // execute operation + try + { + new RefreshOperation().execute(connection, insertDataset); + fail("Should not be here!"); + } + catch (NoSuchColumnException e) + { + + } + + statement.verify(); + factory.verify(); + connection.verify(); + } + + } |