@Override
  public Feedback run() {
    isRunning.set(true);

    try {
      String persistenceMode =
          getMapping().getSettingValue(Constants.Misc.SETTING_PERSISTENCE_MODE);
      Database database = DatabaseFactory.createDatabase(persistenceMode);
      EasyTravelConfig cfg = EasyTravelConfig.read();

      boolean randomContent = true;
      // disable random content if disabled by setting
      String value = getMapping().getSettingValue("randomContent");
      if (Boolean.FALSE.toString().equalsIgnoreCase(value)) {
        LOGGER.info(
            "Not creating random content in database because it is disabled via setting 'randomContent=false'");
        randomContent = false;
      }

      try {
        database.createContents(cfg, randomContent);
      } catch (Exception e) {
        LOGGER.log(Level.SEVERE, "Setting up the database content failed.", e);
        return Feedback.Failure;
      } finally {
        database.closeConnection();
      }
    } finally {
      isRunning.set(false);
    }

    return Feedback.Neutral;
  }
예제 #2
0
  @BeforeClass
  public static void setUpClass() throws IOException {
    DtVersionDetector.enforceInstallationType(InstallationType.Classic);

    config = EasyTravelConfig.read();
    proc = new DbmsProcedure(new DefaultProcedureMapping("databasetest"));
    started = false;

    LoggerFactory.initLogging();

    if (config.internalDatabaseEnabled) {
      assertTrue(proc.init());
      if (!proc.isRunning()) { // JLT-44297 don't start Derby twice
        log.info("Starting database procedure");

        started = true;
        assertEquals(Feedback.Success, proc.run());
      }
    }
    database = new SqlDatabase().initialize();

    //		JpaAccessUtils.setProperties(config.databaseDriver, config.databaseUrl, config.databaseUser,
    // config.databasePassword);
  }