alvinalexander.com | career | drupal | java | mac | mysql | perl | scala | uml | unix  

JMeter example source code file (CSVSample.jmx)

This example JMeter source code file (CSVSample.jmx) is included in the DevDaily.com "Java Source Code Warehouse" project. The intent of this project is to help you "Learn Java by Example" TM.

Java - JMeter tags/keywords

action, action, argument, argument, arguments, arguments, javasampler, javasampler, label, ok, responsemessage, sleep_mask, sleep_time, status

The JMeter CSVSample.jmx source code

<?xml version="1.0" encoding="UTF-8"?>
<jmeterTestPlan version="1.2" properties="2.1">
  <hashTree>
    <TestPlan guiclass="TestPlanGui" testclass="TestPlan" testname="CSVSample" enabled="true">
      <stringProp name="TestPlan.comments">Example of using CSV DataSet
      <boolProp name="TestPlan.functional_mode">false
      <boolProp name="TestPlan.serialize_threadgroups">false
      <elementProp name="TestPlan.user_defined_variables" elementType="Arguments" guiclass="ArgumentsPanel" testclass="Arguments" testname="User Defined Variables" enabled="true">
        <collectionProp name="Arguments.arguments"/>
      </elementProp>
      <stringProp name="TestPlan.user_define_classpath">
    </TestPlan>
    <hashTree>
      <ThreadGroup guiclass="ThreadGroupGui" testclass="ThreadGroup" testname="Thread Group" enabled="true">
        <elementProp name="ThreadGroup.main_controller" elementType="LoopController" guiclass="LoopControlPanel" testclass="LoopController" testname="Loop Controller" enabled="true">
          <boolProp name="LoopController.continue_forever">false
          <intProp name="LoopController.loops">-1
        </elementProp>
        <stringProp name="ThreadGroup.num_threads">1
        <stringProp name="ThreadGroup.ramp_time">1
        <longProp name="ThreadGroup.start_time">1226457982000
        <longProp name="ThreadGroup.end_time">1226457982000
        <boolProp name="ThreadGroup.scheduler">false
        <stringProp name="ThreadGroup.on_sample_error">continue
        <stringProp name="ThreadGroup.duration">
        <stringProp name="ThreadGroup.delay">
      </ThreadGroup>
      <hashTree>
        <CSVDataSet guiclass="TestBeanGUI" testclass="CSVDataSet" testname="Get user details" enabled="true">
          <stringProp name="TestPlan.comments">Top level 
          <stringProp name="delimiter">,
          <stringProp name="fileEncoding">
          <stringProp name="filename">CSVSample_user.csv
          <boolProp name="quotedData">false
          <boolProp name="recycle">false
          <stringProp name="shareMode">All threads
          <boolProp name="stopThread">true
          <stringProp name="variableNames">USER,PASS
        </CSVDataSet>
        <hashTree/>
        <JavaSampler guiclass="JavaTestSamplerGui" testclass="JavaSampler" testname="Dummy Login" enabled="true">
          <elementProp name="arguments" elementType="Arguments" guiclass="ArgumentsPanel" testclass="Arguments" enabled="true">
            <collectionProp name="Arguments.arguments">
              <elementProp name="Sleep_Time" elementType="Argument">
                <stringProp name="Argument.name">Sleep_Time
                <stringProp name="Argument.value">100
                <stringProp name="Argument.metadata">=
              </elementProp>
              <elementProp name="Sleep_Mask" elementType="Argument">
                <stringProp name="Argument.name">Sleep_Mask
                <stringProp name="Argument.value">0xFF
                <stringProp name="Argument.metadata">=
              </elementProp>
              <elementProp name="Label" elementType="Argument">
                <stringProp name="Argument.name">Label
                <stringProp name="Argument.value">Login as ${USER}
                <stringProp name="Argument.metadata">=
              </elementProp>
              <elementProp name="ResponseCode" elementType="Argument">
                <stringProp name="Argument.name">ResponseCode
                <stringProp name="Argument.value">200
                <stringProp name="Argument.metadata">=
              </elementProp>
              <elementProp name="ResponseMessage" elementType="Argument">
                <stringProp name="Argument.name">ResponseMessage
                <stringProp name="Argument.value">OK
                <stringProp name="Argument.metadata">=
              </elementProp>
              <elementProp name="Status" elementType="Argument">
                <stringProp name="Argument.name">Status
                <stringProp name="Argument.value">OK
                <stringProp name="Argument.metadata">=
              </elementProp>
              <elementProp name="SamplerData" elementType="Argument">
                <stringProp name="Argument.name">SamplerData
                <stringProp name="Argument.value">Login as ${USER} with password ${PASS}
                <stringProp name="Argument.metadata">=
              </elementProp>
              <elementProp name="ResultData" elementType="Argument">
                <stringProp name="Argument.name">ResultData
                <stringProp name="Argument.value">Login OK for ${USER}
                <stringProp name="Argument.metadata">=
              </elementProp>
            </collectionProp>
          </elementProp>
          <stringProp name="classname">org.apache.jmeter.protocol.java.test.JavaTest
        </JavaSampler>
        <hashTree>
          <UserParameters guiclass="UserParametersGui" testclass="UserParameters" testname="User Parameters" enabled="true">
            <collectionProp name="UserParameters.names">
              <stringProp name="1925345846">ACTION
            </collectionProp>
            <collectionProp name="UserParameters.thread_values">
              <collectionProp name="-149786089">
                <stringProp name="3387192">none
              </collectionProp>
            </collectionProp>
            <boolProp name="UserParameters.per_iteration">false
          </UserParameters>
          <hashTree/>
        </hashTree>
        <JavaSampler guiclass="JavaTestSamplerGui" testclass="JavaSampler" testname="Java Request" enabled="true">
          <elementProp name="arguments" elementType="Arguments" guiclass="ArgumentsPanel" testclass="Arguments" enabled="true">
            <collectionProp name="Arguments.arguments">
              <elementProp name="Sleep_Time" elementType="Argument">
                <stringProp name="Argument.name">Sleep_Time
                <stringProp name="Argument.value">100
                <stringProp name="Argument.metadata">=
              </elementProp>
              <elementProp name="Sleep_Mask" elementType="Argument">
                <stringProp name="Argument.name">Sleep_Mask
                <stringProp name="Argument.value">0xFF
                <stringProp name="Argument.metadata">=
              </elementProp>
              <elementProp name="Label" elementType="Argument">
                <stringProp name="Argument.name">Label
                <stringProp name="Argument.value">Action = ${ACTION}
                <stringProp name="Argument.metadata">=
              </elementProp>
              <elementProp name="ResponseCode" elementType="Argument">
                <stringProp name="Argument.name">ResponseCode
                <stringProp name="Argument.value">200
                <stringProp name="Argument.metadata">=
              </elementProp>
              <elementProp name="ResponseMessage" elementType="Argument">
                <stringProp name="Argument.name">ResponseMessage
                <stringProp name="Argument.value">OK
                <stringProp name="Argument.metadata">=
              </elementProp>
              <elementProp name="Status" elementType="Argument">
                <stringProp name="Argument.name">Status
                <stringProp name="Argument.value">OK
                <stringProp name="Argument.metadata">=
              </elementProp>
              <elementProp name="SamplerData" elementType="Argument">
                <stringProp name="Argument.name">SamplerData
                <stringProp name="Argument.value">
                <stringProp name="Argument.metadata">=
              </elementProp>
              <elementProp name="ResultData" elementType="Argument">
                <stringProp name="Argument.name">ResultData
                <stringProp name="Argument.value">
                <stringProp name="Argument.metadata">=
              </elementProp>
            </collectionProp>
          </elementProp>
          <stringProp name="classname">org.apache.jmeter.protocol.java.test.JavaTest
        </JavaSampler>
        <hashTree/>
        <WhileController guiclass="WhileControllerGui" testclass="WhileController" testname="While Controller" enabled="true">
          <stringProp name="WhileController.condition">${__jexl("${ACTION}" != "<EOF>")}
        </WhileController>
        <hashTree>
          <CSVDataSet guiclass="TestBeanGUI" testclass="CSVDataSet" testname="Get Actions" enabled="true">
            <stringProp name="filename">CSVSample_actions.csv
            <stringProp name="fileEncoding">
            <stringProp name="variableNames">ACTION
            <stringProp name="delimiter">,
            <boolProp name="quotedData">true
            <boolProp name="recycle">false
            <boolProp name="stopThread">false
            <stringProp name="shareMode">All threads
          </CSVDataSet>
          <hashTree/>
          <IfController guiclass="IfControllerPanel" testclass="IfController" testname="If Controller" enabled="true">
            <stringProp name="IfController.condition">"${ACTION}" != "<EOF>"
            <boolProp name="IfController.evaluateAll">false
          </IfController>
          <hashTree>
            <JavaSampler guiclass="JavaTestSamplerGui" testclass="JavaSampler" testname="Action" enabled="true">
              <elementProp name="arguments" elementType="Arguments" guiclass="ArgumentsPanel" testclass="Arguments" enabled="true">
                <collectionProp name="Arguments.arguments">
                  <elementProp name="Sleep_Time" elementType="Argument">
                    <stringProp name="Argument.name">Sleep_Time
                    <stringProp name="Argument.value">100
                    <stringProp name="Argument.metadata">=
                  </elementProp>
                  <elementProp name="Sleep_Mask" elementType="Argument">
                    <stringProp name="Argument.name">Sleep_Mask
                    <stringProp name="Argument.value">0xFF
                    <stringProp name="Argument.metadata">=
                  </elementProp>
                  <elementProp name="Label" elementType="Argument">
                    <stringProp name="Argument.name">Label
                    <stringProp name="Argument.value">Action ${ACTION}
                    <stringProp name="Argument.metadata">=
                  </elementProp>
                  <elementProp name="ResponseCode" elementType="Argument">
                    <stringProp name="Argument.name">ResponseCode
                    <stringProp name="Argument.value">200
                    <stringProp name="Argument.metadata">=
                  </elementProp>
                  <elementProp name="ResponseMessage" elementType="Argument">
                    <stringProp name="Argument.name">ResponseMessage
                    <stringProp name="Argument.value">OK
                    <stringProp name="Argument.metadata">=
                  </elementProp>
                  <elementProp name="Status" elementType="Argument">
                    <stringProp name="Argument.name">Status
                    <stringProp name="Argument.value">OK
                    <stringProp name="Argument.metadata">=
                  </elementProp>
                  <elementProp name="SamplerData" elementType="Argument">
                    <stringProp name="Argument.name">SamplerData
                    <stringProp name="Argument.value">Perform Action ${ACTION}
                    <stringProp name="Argument.metadata">=
                  </elementProp>
                  <elementProp name="ResultData" elementType="Argument">
                    <stringProp name="Argument.name">ResultData
                    <stringProp name="Argument.value">Succeeded  ${ACTION}
                    <stringProp name="Argument.metadata">=
                  </elementProp>
                </collectionProp>
              </elementProp>
              <stringProp name="classname">org.apache.jmeter.protocol.java.test.JavaTest
            </JavaSampler>
            <hashTree/>
          </hashTree>
        </hashTree>
        <JavaSampler guiclass="JavaTestSamplerGui" testclass="JavaSampler" testname="Logout" enabled="true">
          <elementProp name="arguments" elementType="Arguments" guiclass="ArgumentsPanel" testclass="Arguments" enabled="true">
            <collectionProp name="Arguments.arguments">
              <elementProp name="Sleep_Time" elementType="Argument">
                <stringProp name="Argument.name">Sleep_Time
                <stringProp name="Argument.value">100
                <stringProp name="Argument.metadata">=
              </elementProp>
              <elementProp name="Sleep_Mask" elementType="Argument">
                <stringProp name="Argument.name">Sleep_Mask
                <stringProp name="Argument.value">0xFF
                <stringProp name="Argument.metadata">=
              </elementProp>
              <elementProp name="Label" elementType="Argument">
                <stringProp name="Argument.name">Label
                <stringProp name="Argument.value">
                <stringProp name="Argument.metadata">=
              </elementProp>
              <elementProp name="ResponseCode" elementType="Argument">
                <stringProp name="Argument.name">ResponseCode
                <stringProp name="Argument.value">200
                <stringProp name="Argument.metadata">=
              </elementProp>
              <elementProp name="ResponseMessage" elementType="Argument">
                <stringProp name="Argument.name">ResponseMessage
                <stringProp name="Argument.value">OK
                <stringProp name="Argument.metadata">=
              </elementProp>
              <elementProp name="Status" elementType="Argument">
                <stringProp name="Argument.name">Status
                <stringProp name="Argument.value">OK
                <stringProp name="Argument.metadata">=
              </elementProp>
              <elementProp name="SamplerData" elementType="Argument">
                <stringProp name="Argument.name">SamplerData
                <stringProp name="Argument.value">Logout ${USER}
                <stringProp name="Argument.metadata">=
              </elementProp>
              <elementProp name="ResultData" elementType="Argument">
                <stringProp name="Argument.name">ResultData
                <stringProp name="Argument.value">Succeeded  ${USER}
                <stringProp name="Argument.metadata">=
              </elementProp>
            </collectionProp>
          </elementProp>
          <stringProp name="classname">org.apache.jmeter.protocol.java.test.JavaTest
        </JavaSampler>
        <hashTree/>
        <JavaSampler guiclass="JavaTestSamplerGui" testclass="JavaSampler" testname="Java Request" enabled="true">
          <elementProp name="arguments" elementType="Arguments" guiclass="ArgumentsPanel" testclass="Arguments" enabled="true">
            <collectionProp name="Arguments.arguments">
              <elementProp name="Sleep_Time" elementType="Argument">
                <stringProp name="Argument.name">Sleep_Time
                <stringProp name="Argument.value">100
                <stringProp name="Argument.metadata">=
              </elementProp>
              <elementProp name="Sleep_Mask" elementType="Argument">
                <stringProp name="Argument.name">Sleep_Mask
                <stringProp name="Argument.value">0xFF
                <stringProp name="Argument.metadata">=
              </elementProp>
              <elementProp name="Label" elementType="Argument">
                <stringProp name="Argument.name">Label
                <stringProp name="Argument.value">Action = ${ACTION}
                <stringProp name="Argument.metadata">=
              </elementProp>
              <elementProp name="ResponseCode" elementType="Argument">
                <stringProp name="Argument.name">ResponseCode
                <stringProp name="Argument.value">200
                <stringProp name="Argument.metadata">=
              </elementProp>
              <elementProp name="ResponseMessage" elementType="Argument">
                <stringProp name="Argument.name">ResponseMessage
                <stringProp name="Argument.value">OK
                <stringProp name="Argument.metadata">=
              </elementProp>
              <elementProp name="Status" elementType="Argument">
                <stringProp name="Argument.name">Status
                <stringProp name="Argument.value">OK
                <stringProp name="Argument.metadata">=
              </elementProp>
              <elementProp name="SamplerData" elementType="Argument">
                <stringProp name="Argument.name">SamplerData
                <stringProp name="Argument.value">
                <stringProp name="Argument.metadata">=
              </elementProp>
              <elementProp name="ResultData" elementType="Argument">
                <stringProp name="Argument.name">ResultData
                <stringProp name="Argument.value">
                <stringProp name="Argument.metadata">=
              </elementProp>
            </collectionProp>
          </elementProp>
          <stringProp name="classname">org.apache.jmeter.protocol.java.test.JavaTest
        </JavaSampler>
        <hashTree/>
      </hashTree>
      <ResultCollector guiclass="TableVisualizer" testclass="ResultCollector" testname="View Results in Table" enabled="true">
        <boolProp name="ResultCollector.error_logging">false
        <objProp>
          <name>saveConfig
          <value class="SampleSaveConfiguration">
            <time>true
            <latency>true
            <timestamp>true
            <success>true
            <label>true
            <code>true
            <message>true
            <threadName>true
            <dataType>true
            <encoding>false
            <assertions>true
            <subresults>true
            <responseData>false
            <samplerData>false
            <xml>true
            <fieldNames>false
            <responseHeaders>false
            <requestHeaders>false
            <responseDataOnError>false
            <saveAssertionResultsFailureMessage>false
            <assertionsResultsToSave>0
            <bytes>true
          </value>
        </objProp>
        <stringProp name="filename">
      </ResultCollector>
      <hashTree/>
      <ResultCollector guiclass="ViewResultsFullVisualizer" testclass="ResultCollector" testname="View Results Tree" enabled="true">
        <boolProp name="ResultCollector.error_logging">false
        <objProp>
          <name>saveConfig
          <value class="SampleSaveConfiguration">
            <time>true
            <latency>true
            <timestamp>true
            <success>true
            <label>true
            <code>true
            <message>true
            <threadName>true
            <dataType>true
            <encoding>false
            <assertions>true
            <subresults>true
            <responseData>false
            <samplerData>false
            <xml>true
            <fieldNames>false
            <responseHeaders>false
            <requestHeaders>false
            <responseDataOnError>false
            <saveAssertionResultsFailureMessage>false
            <assertionsResultsToSave>0
            <bytes>true
          </value>
        </objProp>
        <stringProp name="filename">
      </ResultCollector>
      <hashTree/>
    </hashTree>
  </hashTree>
</jmeterTestPlan>

Other JMeter examples (source code examples)

Here is a short list of links related to this JMeter CSVSample.jmx source code file:

... this post is sponsored by my books ...

#1 New Release!

FP Best Seller

 

new blog posts

 

Copyright 1998-2024 Alvin Alexander, alvinalexander.com
All Rights Reserved.

A percentage of advertising revenue from
pages under the /java/jwarehouse URI on this website is
paid back to open source projects.