|
From: <mla...@us...> - 2003-04-30 02:17:05
|
Update of /cvsroot/dbunit/dbunit/src/test/org/dbunit/dataset
In directory sc8-pr-cvs1:/tmp/cvs-serv8945/src/test/org/dbunit/dataset
Modified Files:
Tag: branch-exml2sax
MockDataSetConsumer.java
Added Files:
Tag: branch-exml2sax
AbstractDataSetProducerTest.java
Log Message:
Added flat DTD producer tests.
--- NEW FILE: AbstractDataSetProducerTest.java ---
/*
*
* 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;
import org.dbunit.dataset.datatype.DataType;
import junit.framework.TestCase;
/**
* @author Manuel Laflamme
* @since Apr 29, 2003
* @version $Revision: 1.1.2.1 $
*/
public abstract class AbstractDataSetProducerTest extends TestCase
{
private static final String[] TABLE_NAMES = {
"DUPLICATE_TABLE",
"SECOND_TABLE",
"TEST_TABLE",
"DUPLICATE_TABLE",
"EMPTY_TABLE",
};
public AbstractDataSetProducerTest(String s)
{
super(s);
}
protected String[] getExpectedNames() throws Exception
{
return (String[])TABLE_NAMES.clone();
}
protected Column[] createExpectedColumns(boolean nullable) throws Exception
{
Column[] columns = new Column[4];
for (int i = 0; i < columns.length; i++)
{
columns[i] = new Column("COLUMN" + i, DataType.UNKNOWN,
Column.nullableValue(nullable));
}
return columns;
}
public abstract void testProduce() throws Exception;
public abstract void testProduceWithoutConsumer() throws Exception;
}
Index: MockDataSetConsumer.java
===================================================================
RCS file: /cvsroot/dbunit/dbunit/src/test/org/dbunit/dataset/Attic/MockDataSetConsumer.java,v
retrieving revision 1.1.2.2
retrieving revision 1.1.2.3
diff -C2 -d -r1.1.2.2 -r1.1.2.3
*** MockDataSetConsumer.java 30 Apr 2003 00:27:48 -0000 1.1.2.2
--- MockDataSetConsumer.java 30 Apr 2003 02:17:01 -0000 1.1.2.3
***************
*** 1,13 ****
package org.dbunit.dataset;
- import com.mockobjects.Verifiable;
import com.mockobjects.ExpectationList;
- import java.util.List;
- import java.util.ArrayList;
import java.util.Arrays;
- import junit.framework.Assert;
-
/**
*
--- 1,9 ----
package org.dbunit.dataset;
import com.mockobjects.ExpectationList;
+ import com.mockobjects.Verifiable;
import java.util.Arrays;
/**
*
***************
*** 39,43 ****
public void addExpectedStartTable(ITableMetaData metaData) throws Exception
{
! _expectedList.addExpected(new StartTableEvent(metaData));
}
--- 35,39 ----
public void addExpectedStartTable(ITableMetaData metaData) throws Exception
{
! _expectedList.addExpected(new StartTableEvent(metaData, false));
}
***************
*** 47,50 ****
--- 43,57 ----
}
+ public void addExpectedStartTableIgnoreColumns(String tableName) throws Exception
+ {
+ _expectedList.addExpected(new StartTableEvent(tableName, true));
+ }
+
+ public void addExpectedEmptyTableIgnoreColumns(String tableName) throws Exception
+ {
+ addExpectedStartTableIgnoreColumns(tableName);
+ addExpectedEndTable(tableName);
+ }
+
public void addExpectedEndTable(String tableName) throws Exception
{
***************
*** 80,84 ****
public void startTable(ITableMetaData metaData) throws DataSetException
{
! _expectedList.addActual(new StartTableEvent(metaData));
_actualTableName = metaData.getTableName();
_actualTableRow = 0;
--- 87,91 ----
public void startTable(ITableMetaData metaData) throws DataSetException
{
! _expectedList.addActual(new StartTableEvent(metaData, false));
_actualTableName = metaData.getTableName();
_actualTableRow = 0;
***************
*** 138,147 ****
private final String _tableName;
private final Column[] _columns;
! public StartTableEvent(ITableMetaData metaData) throws DataSetException
{
super("startTable()");
_tableName = metaData.getTableName();
_columns = metaData.getColumns();
}
--- 145,164 ----
private final String _tableName;
private final Column[] _columns;
+ private final boolean _ignoreColumns;
! public StartTableEvent(ITableMetaData metaData, boolean ignoreColumns) throws DataSetException
{
super("startTable()");
_tableName = metaData.getTableName();
_columns = metaData.getColumns();
+ _ignoreColumns = ignoreColumns;
+ }
+
+ public StartTableEvent(String tableName, boolean ignoreColumns) throws DataSetException
+ {
+ super("startTable()");
+ _tableName = tableName;
+ _columns = new Column[0];
+ _ignoreColumns = ignoreColumns;
}
***************
*** 154,159 ****
final StartTableEvent startTableItem = (StartTableEvent)o;
- if (!Arrays.equals(_columns, startTableItem._columns)) return false;
if (!_tableName.equals(startTableItem._tableName)) return false;
return true;
--- 171,179 ----
final StartTableEvent startTableItem = (StartTableEvent)o;
if (!_tableName.equals(startTableItem._tableName)) return false;
+ if (!_ignoreColumns)
+ {
+ if (!Arrays.equals(_columns, startTableItem._columns)) return false;
+ }
return true;
***************
*** 169,173 ****
public String toString()
{
! return _name + ": table=" + _tableName + ", columns=" + Arrays.asList(_columns);
}
}
--- 189,198 ----
public String toString()
{
! String string = _name + ": table=" + _tableName;
! if (!_ignoreColumns)
! {
! string += ", columns=" + Arrays.asList(_columns);
! }
! return string;
}
}
|