コード例 #1
0
ファイル: DbUnitModule.java プロジェクト: lkustb/sprProjects
 /**
  * Loads the given multi schema dataset into the database, using the given loadstrategy
  *
  * @param multiSchemaDataSet The multi schema dataset that is inserted in the database
  * @param dataSetLoadStrategy The load strategy that is used
  */
 protected void insertDataSet(
     MultiSchemaDataSet multiSchemaDataSet, DataSetLoadStrategy dataSetLoadStrategy) {
   try {
     for (String schemaName : multiSchemaDataSet.getSchemaNames()) {
       IDataSet schemaDataSet = multiSchemaDataSet.getDataSetForSchema(schemaName);
       dataSetLoadStrategy.execute(getDbUnitDatabaseConnection(schemaName), schemaDataSet);
     }
   } finally {
     closeJdbcConnection();
   }
 }
コード例 #2
0
ファイル: DbUnitModule.java プロジェクト: lkustb/sprProjects
  /**
   * Compares the contents of the expected DbUnitDataSet with the contents of the database. Only the
   * tables and columns that occur in the expected DbUnitDataSet are compared with the database
   * contents.
   *
   * @param testMethod The test method, not null
   * @param testObject The test object, not null
   */
  public void assertDbContentAsExpected(Method testMethod, Object testObject) {
    try {
      // get the expected dataset
      MultiSchemaDataSet multiSchemaExpectedDataSet = getExpectedDataSet(testMethod, testObject);
      if (multiSchemaExpectedDataSet == null) {
        // no data set should be compared
        return;
      }
      // first make sure every database update is flushed to the database
      getDatabaseModule().flushDatabaseUpdates(testObject);

      DataSetAssert dataSetAssert = new DataSetAssert();
      for (String schemaName : multiSchemaExpectedDataSet.getSchemaNames()) {
        IDataSet expectedDataSet = multiSchemaExpectedDataSet.getDataSetForSchema(schemaName);
        IDataSet actualDataSet = getActualDataSet(schemaName);

        dataSetAssert.assertEqualDbUnitDataSets(schemaName, expectedDataSet, actualDataSet);
      }
    } finally {
      closeJdbcConnection();
    }
  }