예제 #1
0
  /** @throws Exception */
  @BeforeClass(alwaysRun = true)
  protected void prepareDataSet() throws Exception {
    logger.entry();

    if (!prepareSettings()) {
      logger.info("No dataset required");
      return;
    }

    dbUnitConnection = getConnection();

    if (!(testDataHelpers.size() > 0)) throw new RuntimeException("No dataset found");

    for (TestDataHelper helper : testDataHelpers) {
      logger.debug("PREPARING dataset for " + helper.getRawDataFile());
      InputStream input =
          Thread.currentThread()
              .getContextClassLoader()
              .getResourceAsStream(helper.getRawDataFile());
      ReplacementDataSet ds =
          new ReplacementDataSet(
              new FlatXmlDataSetBuilder()
                  .setColumnSensing(true)
                  .setCaseSensitiveTableNames(false)
                  .build(input));
      ds.addReplacementObject("[NULL]", null);
      ds.addReplacementObject("[ne]", "≠");
      ds.addReplacementObject("[NOW]", Calendar.getInstance().getTime());
      helper.setTranslatedDataSet(ds);
    }

    logger.exit();
  }
예제 #2
0
  /** @throws Exception */
  @BeforeMethod(alwaysRun = true)
  protected void beforeTestMethod() throws Exception {
    logger.entry();

    if (dbUnitConnection != null) {
      for (TestDataHelper helper : testDataHelpers) {
        for (DatabaseOperation op : helper.getBeforeTestMethodOperations()) {
          logger.debug("RUNNING DB OPERATIONS FOR: " + helper.getRawDataFile());
          op.execute(dbUnitConnection, helper.getTranslatedDataSet());
        }
      }
    }
    logger.exit();
  }
예제 #3
0
  /** @throws Exception */
  @BeforeClass(
      alwaysRun = true,
      dependsOnMethods = {"prepareDataSet"})
  protected void beforeTestClass() throws Exception {
    logger.entry();

    if (dbUnitConnection != null) {
      for (TestDataHelper helper : testDataHelpers) {
        for (DatabaseOperation op : helper.getBeforeTestClassOperations()) {
          logger.debug("RUNNING DB OPERATIONS FOR: " + helper.getRawDataFile());
          op.execute(dbUnitConnection, helper.getTranslatedDataSet());
        }
      }
    } else {
      logger.error("DB CONNECTION IS NULL, NOT RUNNING beforeTestClass operations");
    }
    logger.exit();
  }