Module: RubyJmeter::Helper

Included in:
AccessLogSampler, AggregateGraph, AggregateReport, Ajp13Sampler, AssertionResults, BeanshellAssertion, BeanshellListener, BeanshellPostprocessor, BeanshellPreprocessor, BeanshellSampler, BeanshellTimer, BsfAssertion, BsfListener, BsfPostprocessor, BsfPreprocessor, BsfSampler, BsfTimer, CompareAssertion, ComparisonAssertionVisualizer, ConstantThroughputTimer, ConstantTimer, Counter, CssjqueryExtractor, CsvDataSetConfig, DebugPostprocessor, DebugSampler, DistributionGraphalpha, DurationAssertion, ForeachController, FtpRequest, FtpRequestDefaults, GCConsoleStatusLogger, GCDummySampler, GCLatenciesOverTime, GCResponseCodesPerSecond, GCResponseTimesDistribution, GCResponseTimesOverTime, GCResponseTimesPercentiles, GCThroughputShapingTimer, GCTransactionsPerSecond, GaussianRandomTimer, GenerateSummaryResults, GraphResults, HtmlAssertion, HtmlLinkParser, HtmlParameterMask, HttpAuthorizationManager, HttpCacheManager, HttpCookieManager, HttpHeaderManager, HttpRequest, HttpRequestDefaults, HttpUrlRewritingModifier, IfController, IncludeController, JavaRequest, JavaRequestDefaults, JdbcConnectionConfiguration, JdbcPostprocessor, JdbcPreprocessor, JdbcRequest, JmsPointtopoint, JmsPublisher, JmsSubscriber, Jsr223Assertion, Jsr223Listener, Jsr223Postprocessor, Jsr223Preprocessor, Jsr223Sampler, Jsr223Timer, JunitRequest, KeystoreConfiguration, LdapExtendedRequest, LdapExtendedRequestDefaults, LdapRequest, LdapRequestDefaults, LoginConfigElement, LoopController, MailReaderSampler, MailerVisualizer, Md5hexAssertion, ModuleController, MonitorResults, OnceOnlyController, OsProcessSampler, PoissonRandomTimer, RandomController, RandomOrderController, RandomVariable, RecordingController, RegexUserParameters, RegularExpressionExtractor, ResponseAssertion, ResponseTimeGraph, ResultStatusActionHandler, RuntimeController, SaveResponsesToAFile, SimpleConfigElement, SimpleController, SimpleDataWriter, SmimeAssertion, SmtpSampler, SoapxmlrpcRequest, SplineVisualizer, SummaryReport, SwitchController, SynchronizingTimer, TcpSampler, TcpSamplerConfig, TestAction, TestPlan, ThreadGroup, ThroughputController, TransactionController, UniformRandomTimer, UserDefinedVariables, UserParameters, ViewResultsInTable, ViewResultsTree, WhileController, XmlAssertion, XmlSchemaAssertion, XpathAssertion, XpathExtractor
Defined in:
lib/ruby-jmeter/helpers/helper.rb

Instance Method Summary collapse

Instance Method Details

#enabled(params) ⇒ Object



49
50
51
52
53
54
55
56
# File 'lib/ruby-jmeter/helpers/helper.rb', line 49

def enabled(params)
  #default to true unless explicitly set to false
  if params.has_key?(:enabled) && params[:enabled] == false
    'false'
  else
    'true'
  end
end

#update(params) ⇒ Object



18
19
20
21
22
23
24
25
26
27
28
# File 'lib/ruby-jmeter/helpers/helper.rb', line 18

def update(params)
  params.delete(:name)
  if params.class == Array
    update_collection params
  else
    params.each do |name, value|
      node = @doc.children.xpath("//*[contains(@name,\"#{name.to_s}\")]")
      node.first.content = value unless node.empty?
    end
  end
end

#update_at_xpath(params) ⇒ Object



30
31
32
33
34
# File 'lib/ruby-jmeter/helpers/helper.rb', line 30

def update_at_xpath(params)
  params[:update_at_xpath].each do |fragment|
    @doc.at_xpath(fragment[:xpath]) << fragment[:value]
  end
end

#update_collection(params) ⇒ Object



36
37
38
39
40
41
42
43
44
45
46
47
# File 'lib/ruby-jmeter/helpers/helper.rb', line 36

def update_collection(params)
  elements = @doc.at_xpath("//collectionProp/elementProp")
  params.each_with_index do |param, index|
    param.each do |name, value|
      element = elements.element_children.xpath("//*[contains(@name,\"#{name}\")]")
      element.last.content = value
    end
    if index != params.size - 1
       @doc.at_xpath("//collectionProp") << elements.dup
    end
  end
end