|
From: <de...@us...> - 2003-01-29 13:02:46
|
Update of /cvsroot/dbunit/dbunit/src/test/org/dbunit/operation/mssqlserver
In directory sc8-pr-cvs1:/tmp/cvs-serv29571
Modified Files:
InsertIdentityOperationTest.java
Log Message:
Test added to validate the patch from Gaetano Di Gregorio.
Index: InsertIdentityOperationTest.java
===================================================================
RCS file: /cvsroot/dbunit/dbunit/src/test/org/dbunit/operation/mssqlserver/InsertIdentityOperationTest.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -C2 -d -r1.2 -r1.3
*** InsertIdentityOperationTest.java 16 Dec 2002 19:21:19 -0000 1.2
--- InsertIdentityOperationTest.java 29 Jan 2003 13:02:43 -0000 1.3
***************
*** 128,131 ****
--- 128,172 ----
}
+
+ /* test case was added to validate the bug that tables with Identity columns that are not
+ one of the primary keys are able to figure out if an IDENTITY_INSERT is needed.
+ Thanks to Gaetano Di Gregorio for finding the bug.
+ */
+ public void testIdentityInsertNoPK() throws Exception
+ {
+ if (DatabaseEnvironment.getInstance() instanceof MSSQLServerEnvironment){
+ InputStream in = new FileInputStream("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);
+ }
+ }
+ }
+
+ }
}
|