@BeforeClass
  public static void init() throws OsmTransferException {
    logger.info("initializing ...");
    JOSMFixture.createFunctionalTestFixture().init();

    // don't use atomic upload, the test API server can't cope with large diff uploads
    Main.pref.put("osm-server.atomic-upload", false);

    File dataSetCacheOutputFile =
        new File(
            System.getProperty("java.io.tmpdir"),
            MultiFetchServerObjectReaderTest.class.getName() + ".dataset");

    String p = System.getProperties().getProperty("useCachedDataset");
    if (p != null && Boolean.parseBoolean(p.trim().toLowerCase())) {
      logger.info(
          MessageFormat.format("property ''{0}'' set, using cached dataset", "useCachedDataset"));
      return;
    }

    logger.info(
        MessageFormat.format(
            "property ''{0}'' not set to true, creating test dataset on the server. property is ''{1}''",
            "useCachedDataset", p));

    // build and upload the test data set
    logger.info("creating test data set ....");
    testDataSet = buildTestDataSet();
    logger.info("uploading test data set ...");
    createDataSetOnServer(testDataSet);

    try (PrintWriter pw =
        new PrintWriter(
            new OutputStreamWriter(
                new FileOutputStream(dataSetCacheOutputFile), StandardCharsets.UTF_8))) {
      logger.info(
          MessageFormat.format(
              "caching test data set in ''{0}'' ...", dataSetCacheOutputFile.toString()));
      try (OsmWriter w = new OsmWriter(pw, false, testDataSet.getVersion())) {
        w.header();
        w.writeDataSources(testDataSet);
        w.writeContent(testDataSet);
        w.footer();
      }
    } catch (IOException e) {
      fail(
          MessageFormat.format(
              "failed to open file ''{0}'' for writing", dataSetCacheOutputFile.toString()));
    }
  }
  @BeforeClass
  public static void init() throws OsmTransferException {
    logger.info("initializing ...");
    testProperties = new Properties();

    // load properties
    //
    try {
      testProperties.load(
          MultiFetchServerObjectReaderTest.class.getResourceAsStream(
              "/test-functional-env.properties"));
    } catch (Exception e) {
      logger.log(
          Level.SEVERE,
          MessageFormat.format(
              "failed to load property file ''{0}''", "test-functional-env.properties"));
      fail(
          MessageFormat.format(
              "failed to load property file ''{0}''", "test-functional-env.properties"));
    }

    // check josm.home
    //
    String josmHome = testProperties.getProperty("josm.home");
    if (josmHome == null) {
      fail(MessageFormat.format("property ''{0}'' not set in test environment", "josm.home"));
    } else {
      File f = new File(josmHome);
      if (!f.exists() || !f.canRead()) {
        fail(
            MessageFormat.format(
                "property ''{0}'' points to ''{1}'' which is either not existing or not readable",
                "josm.home", josmHome));
      }
    }

    // check temp output dir
    //
    String tempOutputDir = testProperties.getProperty("test.functional.tempdir");
    if (tempOutputDir == null) {
      fail(
          MessageFormat.format(
              "property ''{0}'' not set in test environment", "test.functional.tempdir"));
    } else {
      File f = new File(tempOutputDir);
      if (!f.exists() || !f.isDirectory() || !f.canWrite()) {
        fail(
            MessageFormat.format(
                "property ''{0}'' points to ''{1}'' which is either not existing, not a directory, or not writeable",
                "test.functional.tempdir", tempOutputDir));
      }
    }

    // init preferences
    //
    System.setProperty("josm.home", josmHome);
    Main.pref.init(false);
    // don't use atomic upload, the test API server can't cope with large diff uploads
    //
    Main.pref.put("osm-server.atomic-upload", false);
    Main.proj = new Mercator();

    File dataSetCacheOutputFile =
        new File(tempOutputDir, MultiFetchServerObjectReaderTest.class.getName() + ".dataset");

    // make sure we don't upload to production
    //
    String url = OsmApi.getOsmApi().getBaseUrl().toLowerCase().trim();
    if (url.startsWith("http://www.openstreetmap.org")
        || url.startsWith("http://api.openstreetmap.org")) {
      fail(
          MessageFormat.format(
              "configured url ''{0}'' seems to be a productive url, aborting.", url));
    }

    String p = System.getProperties().getProperty("useCachedDataset");
    if (p != null && Boolean.parseBoolean(p.trim().toLowerCase())) {
      logger.info(
          MessageFormat.format("property ''{0}'' set, using cached dataset", "useCachedDataset"));
      return;
    }

    logger.info(
        MessageFormat.format(
            "property ''{0}'' not set to true, creating test dataset on the server. property is ''{1}''",
            "useCachedDataset", p));

    // build and upload the test data set
    //
    logger.info("creating test data set ....");
    testDataSet = buildTestDataSet();
    logger.info("uploading test data set ...");
    createDataSetOnServer(testDataSet);

    try {
      PrintWriter pw = new PrintWriter(new FileWriter(dataSetCacheOutputFile));
      logger.info(
          MessageFormat.format(
              "caching test data set in ''{0}'' ...", dataSetCacheOutputFile.toString()));
      OsmWriter w = new OsmWriter(pw, false, testDataSet.getVersion());
      w.header();
      w.writeDataSources(testDataSet);
      w.writeContent(testDataSet);
      w.footer();
      w.close();
      pw.close();
    } catch (IOException e) {
      fail(
          MessageFormat.format(
              "failed to open file ''{0}'' for writing", dataSetCacheOutputFile.toString()));
    }
  }