Sha256: 8c5e50781e0a9d1432c6554b4c5db038c641995b10f6bbde575b4a63cfa5fca8

Contents?: true

Size: 1.34 KB

Versions: 1

Compression:

Stored size: 1.34 KB

Contents

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

  class BeanShellSampler
    attr_accessor :doc
    include Helper

    def initialize(params = {})
      testname = params.is_a?(Array) ? "BeanShellSampler" : (params[:name] || "BeanShellSampler")
      @doc = Nokogiri::XML(<<~EOS.strip_heredoc)
        <BeanShellSampler guiclass="BeanShellSamplerGui" testclass="BeanShellSampler" testname="#{testname}" enabled="true">
          <stringProp name="BeanShellSampler.query"/>
          <stringProp name="BeanShellSampler.filename"/>
          <stringProp name="BeanShellSampler.parameters"/>
          <boolProp name="BeanShellSampler.resetInterpreter">false</boolProp>
        </BeanShellSampler>
      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/bean_shell_sampler.rb