Sha256: d101e07d07ff54412f2951c05803c29fafefc4dc04c445128d8d2fea5f99db36

Contents?: true

Size: 1.51 KB

Versions: 3

Compression:

Stored size: 1.51 KB

Contents

module JmeterPerf
  class ExtendedDSL < DSL
    def http_request_defaults(params = {}, &)
      params[:image_parser] = true if params.key? :download_resources
      params[:concurrentDwn] = true if params.key? :use_concurrent_pool
      params[:concurrentPool] = params[:use_concurrent_pool] if params.key? :use_concurrent_pool

      node = JmeterPerf::HTTPRequestDefaults.new(params).tap do |node|
        if params[:urls_must_match]
          node.doc.children.first.add_child(
            Nokogiri::XML(<<-EOS.strip_heredoc).children
              <stringProp name="HTTPSampler.embedded_url_re">#{params[:urls_must_match]}</stringProp>
            EOS
          )
        end

        if params[:md5]
          node.doc.children.first.add_child(
            Nokogiri::XML(<<-EOS.strip_heredoc).children
              <boolProp name="HTTPSampler.md5">true</stringProp>
            EOS
          )
        end

        if params[:proxy_host]
          node.doc.children.first.add_child(
            Nokogiri::XML(<<-EOS.strip_heredoc).children
              <stringProp name="HTTPSampler.proxyHost">#{params[:proxy_host]}</stringProp>
            EOS
          )
        end

        if params[:proxy_port]
          node.doc.children.first.add_child(
            Nokogiri::XML(<<-EOS.strip_heredoc).children
              <stringProp name="HTTPSampler.proxyPort">#{params[:proxy_port]}</stringProp>
            EOS
          )
        end
      end

      attach_node(node, &)
    end

    alias_method :defaults, :http_request_defaults
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
jmeter_perf-0.0.7 lib/jmeter_perf/extend/config_elements/http_request_defaults.rb
jmeter_perf-0.0.6 lib/jmeter_perf/extend/config_elements/http_request_defaults.rb
jmeter_perf-0.0.2 lib/jmeter_perf/extend/config_elements/http_request_defaults.rb