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, 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, Plugins::ActiveThreadsOverTime, Plugins::CompositeGraph, Plugins::ConsoleStatusLogger, Plugins::DummySampler, Plugins::JsonPathAssertion, Plugins::JsonPathExtractor, Plugins::LatenciesOverTime, Plugins::LoadosophiaUploader, Plugins::PerfmonCollector, Plugins::RedisDataSet, Plugins::ResponseCodesPerSecond, Plugins::ResponseTimesDistribution, Plugins::ResponseTimesOverTime, Plugins::ResponseTimesPercentiles, Plugins::SteppingThreadGroup, Plugins::ThroughputShapingTimer, Plugins::TransactionsPerSecond, Plugins::UltimateThreadGroup, PoissonRandomTimer, RandomController, RandomOrderController, RandomVariable, RecordingController, RegexUserParameters, RegularExpressionExtractor, ResponseAssertion, ResponseTimeGraph, ResultStatusActionHandler, RuntimeController, SaveResponsesToAFile, SetupThreadGroup, SimpleConfigElement, SimpleController, SimpleDataWriter, SmimeAssertion, SmtpSampler, SoapxmlrpcRequest, SplineVisualizer, SummaryReport, SwitchController, SynchronizingTimer, TcpSampler, TcpSamplerConfig, TestAction, TestFragment, 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
- #enabled(params) ⇒ Object
- #enabled_disabled(params) ⇒ Object
- #update(params) ⇒ Object
- #update_at_xpath(params) ⇒ Object
- #update_collection(params) ⇒ Object
Instance Method Details
#enabled(params) ⇒ Object
66 67 68 69 70 71 72 73 |
# File 'lib/ruby-jmeter/helpers/helper.rb', line 66 def enabled(params) #default to true unless explicitly set to false if params.has_key?(:enabled) && params[:enabled] == false 'false' else 'true' end end |
#enabled_disabled(params) ⇒ Object
35 36 37 38 |
# File 'lib/ruby-jmeter/helpers/helper.rb', line 35 def enabled_disabled(params) return unless params.is_a?(Hash) @doc.children.first.attributes['enabled'].value = params[:enabled].to_s.empty? ? 'true' : 'false' end |
#update(params) ⇒ Object
17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 |
# File 'lib/ruby-jmeter/helpers/helper.rb', line 17 def update(params) params.delete(:name) enabled_disabled(params) if params.class == Array update_collection params else params.each do |name, value| node = @doc.children.xpath("//*[contains(@name,\"#{name.to_s}\")]") if value.class == Nokogiri::XML::Builder node.first.children = value.doc.at_xpath('//builder').children else node.first.content = value unless node.empty? end end end end |
#update_at_xpath(params) ⇒ Object
40 41 42 43 44 45 46 47 48 49 50 |
# File 'lib/ruby-jmeter/helpers/helper.rb', line 40 def update_at_xpath(params) params[:update_at_xpath].each do |fragment| if fragment[:xpath] @doc.at_xpath(fragment[:xpath]) << fragment[:value] else fragment.each do |xpath, value| @doc.at_xpath(xpath).content = value end end end end |
#update_collection(params) ⇒ Object
52 53 54 55 56 57 58 59 60 61 62 63 64 |
# File 'lib/ruby-jmeter/helpers/helper.rb', line 52 def update_collection(params) elements = @doc.at_xpath("//collectionProp/elementProp") params.each_with_index do |param, index| param.each do |name, value| next unless elements && elements.element_children element = elements.element_children.xpath("//*[contains(@name,\"#{name}\")]") element.last.content = value end if index != params.size - 1 && elements @doc.at_xpath("//collectionProp") << elements.dup end end end |