Пример #1
0
  protected void setUp() throws Exception {
    // NOTE: This will disable the SYS GLOBAL party creation and creation of all the reference
    // entities!!!
    initializeModelData = false;

    super.setUp();
    IDatabaseConnection dbUnitConn = null;
    dbUnitConn = getDbUnitConnection();
    DatabaseOperation.REFRESH.execute(dbUnitConn, getDataSet());
    dbUnitConn.getConnection().commit();
    dbUnitConn.close();
    dbUnitConn.getConnection().close();
  }
  public void executeDataset(String path) throws IOException, SQLException {
    InputStream inputStream = getClass().getResourceAsStream(path);
    ReplacementDataSet replacementDataSet = null;
    try {
      replacementDataSet =
          new ReplacementDataSet(
              new FlatXmlDataSet(new InputStreamReader(inputStream), false, true, false));

      inputStream.close();
    } catch (DataSetException e) {
      throw new IOException(e);
    } finally {
      IOUtils.closeQuietly(inputStream);
    }
    replacementDataSet.addReplacementObject("[NULL]", null);

    try {
      DatabaseOperation.REFRESH.execute(dbUnitConnection, replacementDataSet);

      connection.commit();
    } catch (DatabaseUnitException e) {
      throw new IOException(e);
    }
  }