Sha256: 227d495dabd0cb7d45dffaf29f73c51f0df380e4685d32d25c3272817582baaa

Contents?: true

Size: 1.47 KB

Versions: 1

Compression:

Stored size: 1.47 KB

Contents

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

  class JDBCRequest
    attr_accessor :doc
    include Helper

    def initialize(params = {})
      testname = params.is_a?(Array) ? "JDBCRequest" : (params[:name] || "JDBCRequest")
      @doc = Nokogiri::XML(<<~EOS.strip_heredoc)
        <JDBCSampler guiclass="TestBeanGUI" testclass="JDBCSampler" testname="#{testname}" enabled="true">
          <stringProp name="dataSource"/>
          <stringProp name="query"/>
          <stringProp name="queryArguments"/>
          <stringProp name="queryArgumentsTypes"/>
          <stringProp name="queryType">Select Statement</stringProp>
          <stringProp name="resultVariable"/>
          <stringProp name="variableNames"/>
          <stringProp name="queryTimeout"/>
          <stringProp name="resultSetHandler">Store as String</stringProp>
        </JDBCSampler>
      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/jdbc_request.rb