<commit_before>/**
 * Copyright 2011-2014 eBusiness Information, Groupe Excilys (www.ebusinessinformation.fr)
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * 		http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package io.gatling.core.config

import java.nio.charset.Charset

import scala.collection.JavaConversions.mapAsJavaMap
import scala.collection.mutable
import scala.io.Codec

import com.typesafe.config.{ Config, ConfigFactory }

import io.gatling.core.ConfigurationConstants._
import io.gatling.core.util.StringHelper.RichString

/**
 * Configuration loader of Gatling
 */
object GatlingConfiguration {

  // FIXME
  var configuration: GatlingConfiguration = _

  implicit class ConfigStringSeq(val string: String) extends AnyVal {
    def toStringList: List[String] = string.trim match {
      case "" => Nil
      case s  => s.split(",").map(_.trim).toList
    }
  }

  def setUp(props: mutable.Map[String, _ <: Any] = mutable.Map.empty) {
    val classLoader = getClass.getClassLoader

    val defaultsConfig = ConfigFactory.parseResources(classLoader, "gatling-defaults.conf")
    val customConfig = ConfigFactory.parseResources(classLoader, "gatling.conf")
    val propertiesConfig = ConfigFactory.parseMap(props)

    val config = ConfigFactory.systemProperties.withFallback(propertiesConfig).withFallback(customConfig).withFallback(defaultsConfig)

    configuration = GatlingConfiguration(
      core = CoreConfiguration(
        outputDirectoryBaseName = config.getString(CONF_CORE_OUTPUT_DIRECTORY_BASE_NAME).trimToOption,
        runDescription = config.getString(CONF_CORE_RUN_DESCRIPTION).trimToOption,<commit_msg>Add warnings on removed configuration options, close #1764<commit_after>/**
 * Copyright 2011-2014 eBusiness Information, Groupe Excilys (www.ebusinessinformation.fr)
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * 		http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package io.gatling.core.config

import java.nio.charset.Charset

import scala.collection.JavaConversions.mapAsJavaMap
import scala.collection.mutable
import scala.io.Codec

import com.typesafe.config.{ Config, ConfigFactory }

import io.gatling.core.ConfigurationConstants._
import io.gatling.core.util.StringHelper.RichString
import com.typesafe.scalalogging.slf4j.StrictLogging

/**
 * Configuration loader of Gatling
 */
object GatlingConfiguration extends StrictLogging {

  // FIXME
  var configuration: GatlingConfiguration = _

  implicit class ConfigStringSeq(val string: String) extends AnyVal {
    def toStringList: List[String] = string.trim match {
      case "" => Nil
      case s  => s.split(",").map(_.trim).toList
    }
  }

  def setUp(props: mutable.Map[String, _ <: Any] = mutable.Map.empty) {

    def warnAboutRemovedProperties(config: Config) {

      def warnAboutRemovedProperty(path: String) {
        if (config.hasPath(path))
          logger.warn(s"Beware, property $path is still defined but it was removed")
      }

      Vector("gatling.core.extract.xpath.saxParserFactory",
        "gatling.core.extract.xpath.domParserFactory",
        "gatling.core.extract.xpath.expandEntityReferences",
        "gatling.core.extract.xpath.namespaceAware",
        "gatling.core.extract.css.engine",
        "gatling.core.timeOut.actor",
        "gatling.http.baseUrls",
        "gatling.http.proxy.host",
        "gatling.http.proxy.port",
        "gatling.http.proxy.securedPort",
        "gatling.http.proxy.username",
        "gatling.http.proxy.password",
        "gatling.http.followRedirect",
        "gatling.http.autoReferer",
        "gatling.http.cache",
        "gatling.http.discardResponseChunks",
        "gatling.http.shareConnections",
        "gatling.http.basicAuth.username",
        "gatling.http.basicAuth.password",
        "gatling.http.ahc.provider",
        "gatling.http.ahc.requestCompressionLevel",
        "gatling.http.ahc.userAgent",
        "gatling.http.ahc.rfc6265CookieEncoding").foreach(warnAboutRemovedProperty)
    }

    val classLoader = getClass.getClassLoader

    val defaultsConfig = ConfigFactory.parseResources(classLoader, "gatling-defaults.conf")
    val customConfig = ConfigFactory.parseResources(classLoader, "gatling.conf")
    val propertiesConfig = ConfigFactory.parseMap(props)

    val config = ConfigFactory.systemProperties.withFallback(propertiesConfig).withFallback(customConfig).withFallback(defaultsConfig)

    warnAboutRemovedProperties(config)

    configuration = GatlingConfiguration(
      core = CoreConfiguration(
        outputDirectoryBaseName = config.getString(CONF_CORE_OUTPUT_DIRECTORY_BASE_NAME).trimToOption,
        runDescription = config.getString(CONF_CORE_RUN_DESCRIPTION).trimToOption,
{'fraction_non_alphanumeric': 0.09531444860146089, 'fraction_numerical': 0.005879208979155532, 'mean_word_length': 4.021466905187835, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 7, 'https://': 0, 'lorem ipsum': 0, 'www.': 4, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6819049', 'n_tokens_mistral': 1643, 'n_tokens_neox': 1604, 'n_words': 374}