/* 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 {
    Reader in = TestUtils.getFileReader("xml/insertIdentityOperationTestNoPK.xml");
    IDataSet xmlDataSet = new FlatXmlDataSetBuilder().build(in);

    ITable[] tablesBefore = DataSetUtils.getTables(_connection.createDataSet());
    InsertIdentityOperation.CLEAN_INSERT.execute(_connection, xmlDataSet);
    ITable[] tablesAfter = DataSetUtils.getTables(_connection.createDataSet());

    // Verify tables after
    for (int i = 0; i < tablesAfter.length; i++) {
      ITable tableBefore = tablesBefore[i];
      ITable tableAfter = tablesAfter[i];

      String name = tableAfter.getTableMetaData().getTableName();
      if (name.equals("TEST_IDENTITY_NOT_PK")) {
        assertEquals("row count before: " + name, 0, tableBefore.getRowCount());
        Assertion.assertEquals(xmlDataSet.getTable(name), tableAfter);
      } else {
        // Other tables should have not been affected
        Assertion.assertEquals(tableBefore, tableAfter);
      }
    }
  }
  public void testExecuteForwardOnly() throws Exception {
    Reader in = TestUtils.getFileReader("xml/insertIdentityOperationTestFlat.xml");
    IDataSet dataSet = new ForwardOnlyDataSet(new FlatXmlDataSetBuilder().build(in));

    testExecute(dataSet);
  }
  public void testExecuteXML() throws Exception {
    Reader in = TestUtils.getFileReader("xml/insertIdentityOperationTest.xml");
    IDataSet dataSet = new XmlDataSet(in);

    testExecute(dataSet);
  }