|
From: <mla...@us...> - 2003-04-13 02:40:15
|
Update of /cvsroot/dbunit/dbunit/src/test/org/dbunit/operation/mssqlserver
In directory sc8-pr-cvs1:/tmp/cvs-serv1956/dbunit/src/test/org/dbunit/operation/mssqlserver
Modified Files:
InsertIdentityOperationTest.java
Added Files:
AllTests.java
Log Message:
* Test suite cleanup. Added new "unsupportedFeatures" property in
profile.properties file. Used to exclude tests of unsupported database
features. No more instanceof in tests.
* New ForwardOnlyResultSetTable class. Renamed ResultSetTable to
ScrollableResultSetTable. Another step toward support of very large
datasets; remains to implement buffered XML datasets.
* New ForwardOnlyDataSet and ForwardOnlyTable classes. Will be used
in test suite only to ensure that insert and export works with buffered
dataset/table implementations.
--- NEW FILE: AllTests.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.operation.mssqlserver;
import org.dbunit.DatabaseEnvironment;
import org.dbunit.TestFeature;
import junit.framework.Test;
import junit.framework.TestSuite;
/**
* @author Manuel Laflamme
* @since Apr 11, 2003
* @version $Revision: 1.1 $
*/
public class AllTests
{
public static Test suite() throws Exception
{
TestSuite suite = new TestSuite();
DatabaseEnvironment environment = DatabaseEnvironment.getInstance();
if (environment.support(TestFeature.INSERT_IDENTITY))
{
suite.addTest(new TestSuite(InsertIdentityOperationTest.class));
}
return suite;
}
}
Index: InsertIdentityOperationTest.java
===================================================================
RCS file: /cvsroot/dbunit/dbunit/src/test/org/dbunit/operation/mssqlserver/InsertIdentityOperationTest.java,v
retrieving revision 1.5
retrieving revision 1.6
diff -C2 -d -r1.5 -r1.6
*** InsertIdentityOperationTest.java 18 Feb 2003 21:49:37 -0000 1.5
--- InsertIdentityOperationTest.java 13 Apr 2003 02:40:12 -0000 1.6
***************
*** 23,39 ****
package org.dbunit.operation.mssqlserver;
! import org.dbunit.operation.*;
! import org.dbunit.*;
! import org.dbunit.database.MockDatabaseConnection;
! import org.dbunit.database.statement.MockBatchStatement;
! import org.dbunit.database.statement.MockStatementFactory;
! import org.dbunit.dataset.*;
! import org.dbunit.dataset.datatype.DataType;
import org.dbunit.dataset.xml.FlatXmlDataSet;
import org.dbunit.dataset.xml.XmlDataSet;
! import java.io.*;
! import java.util.ArrayList;
! import java.util.List;
/**
--- 23,36 ----
package org.dbunit.operation.mssqlserver;
! import org.dbunit.AbstractDatabaseTest;
! import org.dbunit.Assertion;
! import org.dbunit.dataset.DataSetUtils;
! import org.dbunit.dataset.IDataSet;
! import org.dbunit.dataset.ITable;
import org.dbunit.dataset.xml.FlatXmlDataSet;
import org.dbunit.dataset.xml.XmlDataSet;
! import java.io.FileReader;
! import java.io.Reader;
/**
***************
*** 58,132 ****
public void testExecuteXML() throws Exception
{
! if (DatabaseEnvironment.getInstance() instanceof MSSQLServerEnvironment){
! System.out.println("mssql");
! Reader in = new FileReader("src/xml/insertIdentityOperationTest.xml");
! IDataSet xmlDataSet = new XmlDataSet(in);
! ITable[] tablesBefore = DataSetUtils.getTables(_connection.createDataSet());
! InsertIdentityOperation.CLEAN_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("IDENTITY"))
! {
! assertTrue("Should have either 0 or 6", table.getRowCount()==0 | table.getRowCount()==6);
! }
}
! for (int i = 0; i < tablesAfter.length; i++)
{
! ITable table = tablesAfter[i];
! String name = table.getTableMetaData().getTableName();
! if (name.startsWith("IDENTITY"))
! {
! Assertion.assertEquals(xmlDataSet.getTable(name), table);
! }
}
}
-
}
public void testExecuteFlatXML() throws Exception
{
! if (DatabaseEnvironment.getInstance() instanceof MSSQLServerEnvironment){
! Reader in = new FileReader("src/xml/insertIdentityOperationTestFlat.xml");
! IDataSet xmlDataSet = new FlatXmlDataSet(in);
! ITable[] tablesBefore = DataSetUtils.getTables(_connection.createDataSet());
! InsertIdentityOperation.CLEAN_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("IDENTITY"))
! {
! assertTrue("Should have either 0 or 6", table.getRowCount()==0 | table.getRowCount()==6);
! }
}
! for (int i = 0; i < tablesAfter.length; i++)
{
! ITable table = tablesAfter[i];
! String name = table.getTableMetaData().getTableName();
! if (name.startsWith("IDENTITY"))
! {
! Assertion.assertEquals(xmlDataSet.getTable(name), table);
! }
}
}
-
}
--- 55,123 ----
public void testExecuteXML() throws Exception
{
! // System.out.println("mssql");
! Reader in = new FileReader("src/xml/insertIdentityOperationTest.xml");
! IDataSet xmlDataSet = new XmlDataSet(in);
! ITable[] tablesBefore = DataSetUtils.getTables(_connection.createDataSet());
! InsertIdentityOperation.CLEAN_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("IDENTITY"))
! {
! assertTrue("Should have either 0 or 6", table.getRowCount() == 0 | table.getRowCount() == 6);
}
+ }
! for (int i = 0; i < tablesAfter.length; i++)
! {
! ITable table = tablesAfter[i];
! String name = table.getTableMetaData().getTableName();
! if (name.startsWith("IDENTITY"))
{
! Assertion.assertEquals(xmlDataSet.getTable(name), table);
}
}
}
public void testExecuteFlatXML() throws Exception
{
! Reader in = new FileReader("src/xml/insertIdentityOperationTestFlat.xml");
! IDataSet xmlDataSet = new FlatXmlDataSet(in);
! ITable[] tablesBefore = DataSetUtils.getTables(_connection.createDataSet());
! InsertIdentityOperation.CLEAN_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("IDENTITY"))
! {
! assertTrue("Should have either 0 or 6", table.getRowCount() == 0 | table.getRowCount() == 6);
}
+ }
! for (int i = 0; i < tablesAfter.length; i++)
! {
! ITable table = tablesAfter[i];
! String name = table.getTableMetaData().getTableName();
! if (name.startsWith("IDENTITY"))
{
! Assertion.assertEquals(xmlDataSet.getTable(name), table);
}
}
}
***************
*** 135,173 ****
Thanks to Gaetano Di Gregorio for finding the bug.
*/
! public void testIdentityInsertNoPK() throws Exception
{
! if (DatabaseEnvironment.getInstance() instanceof MSSQLServerEnvironment){
! Reader in = new FileReader("src/xml/insertIdentityOperationTestNoPK.xml");
! IDataSet xmlDataSet = new FlatXmlDataSet(in);
! ITable[] tablesBefore = DataSetUtils.getTables(_connection.createDataSet());
! InsertIdentityOperation.CLEAN_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.equals("TEST_IDENTITY_NOT_PK"))
! {
! assertTrue("Should have either 0 or 6", table.getRowCount()==0 | table.getRowCount()==6);
! }
}
! for (int i = 0; i < tablesAfter.length; i++)
{
! ITable table = tablesAfter[i];
! String name = table.getTableMetaData().getTableName();
! if (name.equals("TEST_IDENTITY_NOT_PK"))
! {
! Assertion.assertEquals(xmlDataSet.getTable(name), table);
! }
}
}
-
}
}
--- 126,161 ----
Thanks to Gaetano Di Gregorio for finding the bug.
*/
! public void testIdentityInsertNoPK() throws Exception
{
! Reader in = new FileReader("src/xml/insertIdentityOperationTestNoPK.xml");
! IDataSet xmlDataSet = new FlatXmlDataSet(in);
! ITable[] tablesBefore = DataSetUtils.getTables(_connection.createDataSet());
! InsertIdentityOperation.CLEAN_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.equals("TEST_IDENTITY_NOT_PK"))
! {
! assertTrue("Should have either 0 or 6", table.getRowCount() == 0 | table.getRowCount() == 6);
}
+ }
! for (int i = 0; i < tablesAfter.length; i++)
! {
! ITable table = tablesAfter[i];
! String name = table.getTableMetaData().getTableName();
! if (name.equals("TEST_IDENTITY_NOT_PK"))
{
! Assertion.assertEquals(xmlDataSet.getTable(name), table);
}
}
}
}
|