Sha256: 90f02785f0f037bcf18a4cd9749b9c28e7e172184dbd4f5b71bc2dd76a42aae9

Contents?: true

Size: 1.18 KB

Versions: 1

Compression:

Stored size: 1.18 KB

Contents

module JmeterPerf
  class DSL
    # DSL method synonymous with the JMeter Element BSFSampler
    # @see https://github.com/jlurena/jmeter_perf/wiki/1.-DSL-Documentation#bsfsampler
    # @param [Hash] params Parameters for the BSFSampler element (default: `{}`).
    # @yield block to attach to the BSFSampler element
    # @return [JmeterPerf::BSFSampler], a subclass of JmeterPerf::DSL that can be chained with other DSL methods.
    def bsf_sampler(params = {}, &)
      node = JmeterPerf::BSFSampler.new(params)
      attach_node(node, &)
    end
  end

  class BSFSampler
    attr_accessor :doc
    include Helper

    def initialize(params = {})
      testname = params.is_a?(Array) ? "BSFSampler" : (params[:name] || "BSFSampler")
      @doc = Nokogiri::XML(<<~EOS.strip_heredoc)
        <BSFSampler guiclass="TestBeanGUI" testclass="BSFSampler" testname="#{testname}" enabled="true">
          <stringProp name="filename"/>
          <stringProp name="parameters"/>
          <stringProp name="script"/>
          <stringProp name="scriptLanguage"/>
        </BSFSampler>
      EOS
      update params
      update_at_xpath params if params.is_a?(Hash) && params[:update_at_xpath]
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
jmeter_perf-0.0.7 lib/jmeter_perf/dsl/bsf_sampler.rb