jmeter多用户登录跨线程组操作传值
项目需求:
需要登录两个用户A、B,用户A操作完后会通知B,然后B再操作,B操作完结束或者再通知A。
实现思路:
1. 设置两个线程组Ⅰ、Ⅱ,组Ⅰ添加cookie管理器,里面添加用户A的操作;组Ⅱ添加cookie管理,里面添加用户B的操作,组Ⅰ和组Ⅱ的请求参数传递交互使用${__setProperty(newstatus,${result_zhxj},)} 这个方法设置,然后${__P(newstatus,)}获取。达到线程组之间的值传递。
2. 组Ⅱ添加while循环,一直等组Ⅰ传值,如果传过来了,就结束循环,往下走。
界面图如下:
脚本如下:
<?xml version="1.0" encoding="UTF-8"?> <jmeterTestPlan version="1.2" properties="3.2" jmeter="3.2 r1790748"> <hashTree> <TestPlan guiclass="TestPlanGui" testclass="TestPlan" testname="综合接续_工号-内部求助_正常_208-1" enabled="true"> <stringProp name="TestPlan.comments"></stringProp> <boolProp name="TestPlan.functional_mode">false</boolProp> <boolProp name="TestPlan.serialize_threadgroups">false</boolProp> <elementProp name="TestPlan.user_defined_variables" elementType="Arguments" guiclass="ArgumentsPanel" testclass="Arguments" testname="用户定义的变量" enabled="true"> <collectionProp name="Arguments.arguments"/> </elementProp> <stringProp name="TestPlan.user_define_classpath"></stringProp> </TestPlan> <hashTree> <HeaderManager guiclass="HeaderPanel" testclass="HeaderManager" testname="HTTP信息头管理器" enabled="true"> <collectionProp name="HeaderManager.headers"> <elementProp name="" elementType="Header"> <stringProp name="Header.name">Content-Type</stringProp> <stringProp name="Header.value">application/json; charset=UTF-8</stringProp> </elementProp> </collectionProp> </HeaderManager> <hashTree/> <kg.apc.jmeter.config.VariablesFromCSV guiclass="kg.apc.jmeter.config.VariablesFromCSVGui" testclass="kg.apc.jmeter.config.VariablesFromCSV" testname="从文本获取自定义变量值" enabled="true"> <collectionProp name="Arguments.arguments"/> <stringProp name="filename">C:\interfaceauto\a.csv</stringProp> <stringProp name="variablesPrefix">MyVar_</stringProp> <stringProp name="delimiter">,</stringProp> <intProp name="skipLines">0</intProp> <boolProp name="storeSysProp">false</boolProp> </kg.apc.jmeter.config.VariablesFromCSV> <hashTree/> <Arguments guiclass="ArgumentsPanel" testclass="Arguments" testname="用户定义的变量" enabled="true"> <collectionProp name="Arguments.arguments"> <elementProp name="ip" elementType="Argument"> <stringProp name="Argument.name">ip</stringProp> <stringProp name="Argument.value">${MyVar_ip}</stringProp> <stringProp name="Argument.metadata">=</stringProp> </elementProp> <elementProp name="port" elementType="Argument"> <stringProp name="Argument.name">port</stringProp> <stringProp name="Argument.value">${MyVar_port}</stringProp> <stringProp name="Argument.metadata">=</stringProp> </elementProp> <elementProp name="protocol" elementType="Argument"> <stringProp name="Argument.name">protocol</stringProp> <stringProp name="Argument.value">${MyVar_protocol}</stringProp> <stringProp name="Argument.metadata">=</stringProp> </elementProp> <elementProp name="agentId" elementType="Argument"> <stringProp name="Argument.name">agentId</stringProp> <stringProp name="Argument.value">${MyVar_agentId}</stringProp> <stringProp name="Argument.metadata">=</stringProp> <stringProp name="Argument.desc">第一视角坐席,自动接听</stringProp> </elementProp> <elementProp name="phoneNum" elementType="Argument"> <stringProp name="Argument.name">phoneNum</stringProp> <stringProp name="Argument.value">${MyVar_phoneNum}</stringProp> <stringProp name="Argument.metadata">=</stringProp> <stringProp name="Argument.desc">第一视角坐席,自动接听</stringProp> </elementProp> <elementProp name="callerDigits" elementType="Argument"> <stringProp name="Argument.name">callerDigits</stringProp> <stringProp name="Argument.value">${MyVar_callerDigits}</stringProp> <stringProp name="Argument.metadata">=</stringProp> </elementProp> <elementProp name="calledDigits" elementType="Argument"> <stringProp name="Argument.name">calledDigits</stringProp> <stringProp name="Argument.value">${MyVar_calledDigits}</stringProp> <stringProp name="Argument.metadata">=</stringProp> <stringProp name="Argument.desc">设置自动接听,micsip</stringProp> </elementProp> <elementProp name="skillIds1" elementType="Argument"> <stringProp name="Argument.name">skillIds1</stringProp> <stringProp name="Argument.value">${MyVar_skillIds1}</stringProp> <stringProp name="Argument.metadata">=</stringProp> </elementProp> <elementProp name="skillIds2" elementType="Argument"> <stringProp name="Argument.name">skillIds2</stringProp> <stringProp name="Argument.value">${MyVar_skillIds2}</stringProp> <stringProp name="Argument.metadata">=</stringProp> </elementProp> <elementProp name="sleepLogin" elementType="Argument"> <stringProp name="Argument.name">sleepLogin</stringProp> <stringProp name="Argument.value">${MyVar_sleepLogin}</stringProp> <stringProp name="Argument.metadata">=</stringProp> </elementProp> <elementProp name="sleepLogout" elementType="Argument"> <stringProp name="Argument.name">sleepLogout</stringProp> <stringProp name="Argument.value">${MyVar_sleepLogout}</stringProp> <stringProp name="Argument.metadata">=</stringProp> </elementProp> <elementProp name="sleepPoll" elementType="Argument"> <stringProp name="Argument.name">sleepPoll</stringProp> <stringProp name="Argument.value">${MyVar_sleepPoll}</stringProp> <stringProp name="Argument.metadata">=</stringProp> </elementProp> <elementProp name="sleepPollagin" elementType="Argument"> <stringProp name="Argument.name">sleepPollagin</stringProp> <stringProp name="Argument.value">${MyVar_sleepPollagin}</stringProp> <stringProp name="Argument.metadata">=</stringProp> </elementProp> <elementProp name="sleepNormal" elementType="Argument"> <stringProp name="Argument.name">sleepNormal</stringProp> <stringProp name="Argument.value">${MyVar_sleepNormal}</stringProp> <stringProp name="Argument.metadata">=</stringProp> </elementProp> <elementProp name="agentId_1" elementType="Argument"> <stringProp name="Argument.name">agentId_1</stringProp> <stringProp name="Argument.value">${MyVar_agentId_1}</stringProp> <stringProp name="Argument.metadata">=</stringProp> <stringProp name="Argument.desc">需要设置手动接听</stringProp> </elementProp> <elementProp name="phoneNum_1" elementType="Argument"> <stringProp name="Argument.name">phoneNum_1</stringProp> <stringProp name="Argument.value">${MyVar_phoneNum_1}</stringProp> <stringProp name="Argument.metadata">=</stringProp> <stringProp name="Argument.desc">需要设置手动接听</stringProp> </elementProp> <elementProp name="calledDigits_1" elementType="Argument"> <stringProp name="Argument.name">calledDigits_1</stringProp> <stringProp name="Argument.value">${MyVar_calledDigits_1}</stringProp> <stringProp name="Argument.metadata">=</stringProp> <stringProp name="Argument.desc">需要设置手动接听,sip</stringProp> </elementProp> <elementProp name="agentId_2" elementType="Argument"> <stringProp name="Argument.name">agentId_2</stringProp> <stringProp name="Argument.value">${MyVar_agentId_2}</stringProp> <stringProp name="Argument.metadata">=</stringProp> <stringProp name="Argument.desc">备用,自动接听</stringProp> </elementProp> <elementProp name="phoneNum_2" elementType="Argument"> <stringProp name="Argument.name">phoneNum_2</stringProp> <stringProp name="Argument.value">${MyVar_phoneNum_2}</stringProp> <stringProp name="Argument.metadata">=</stringProp> <stringProp name="Argument.desc">备用,自动接听</stringProp> </elementProp> <elementProp name="calledDigits_2" elementType="Argument"> <stringProp name="Argument.name">calledDigits_2</stringProp> <stringProp name="Argument.value">${MyVar_calledDigits_2}</stringProp> <stringProp name="Argument.metadata">=</stringProp> <stringProp name="Argument.desc">备用,自动接听</stringProp> </elementProp> <elementProp name="calloutpath" elementType="Argument"> <stringProp name="Argument.name">calloutpath</stringProp> <stringProp name="Argument.value">${MyVar_calloutpath}</stringProp> <stringProp name="Argument.metadata">=</stringProp> <stringProp name="Argument.desc">用户呼入exe路径</stringProp> </elementProp> <elementProp name="calldownpath" elementType="Argument"> <stringProp name="Argument.name">calldownpath</stringProp> <stringProp name="Argument.value">${MyVar_calldownpath}</stringProp> <stringProp name="Argument.metadata">=</stringProp> <stringProp name="Argument.desc">用户挂机exe路径</stringProp> </elementProp> </collectionProp> </Arguments> <hashTree/> <ThreadGroup guiclass="ThreadGroupGui" testclass="ThreadGroup" testname="综合接续_工号-内部求助_正常_208-1_A坐席" enabled="true"> <stringProp name="ThreadGroup.on_sample_error">continue</stringProp> <elementProp name="ThreadGroup.main_controller" elementType="LoopController" guiclass="LoopControlPanel" testclass="LoopController" testname="循环控制器" enabled="true"> <boolProp name="LoopController.continue_forever">false</boolProp> <stringProp name="LoopController.loops">1</stringProp> </elementProp> <stringProp name="ThreadGroup.num_threads">1</stringProp> <stringProp name="ThreadGroup.ramp_time">0</stringProp> <longProp name="ThreadGroup.start_time">1496284305000</longProp> <longProp name="ThreadGroup.end_time">1496284305000</longProp> <boolProp name="ThreadGroup.scheduler">false</boolProp> <stringProp name="ThreadGroup.duration"></stringProp> <stringProp name="ThreadGroup.delay"></stringProp> </ThreadGroup> <hashTree> <CookieManager guiclass="CookiePanel" testclass="CookieManager" testname="HTTP Cookie 管理器" enabled="true"> <collectionProp name="CookieManager.cookies"/> <boolProp name="CookieManager.clearEachIteration">false</boolProp> <stringProp name="CookieManager.policy">standard</stringProp> <stringProp name="CookieManager.implementation">org.apache.jmeter.protocol.http.control.HC4CookieHandler</stringProp> </CookieManager> <hashTree/> <HTTPSamplerProxy guiclass="HttpTestSampleGui" testclass="HTTPSamplerProxy" testname="A坐席签入" enabled="true"> <boolProp name="HTTPSampler.postBodyRaw">true</boolProp> <elementProp name="HTTPsampler.Arguments" elementType="Arguments"> <collectionProp name="Arguments.arguments"> <elementProp name="" elementType="HTTPArgument"> <boolProp name="HTTPArgument.always_encode">false</boolProp> <stringProp name="Argument.value">{
 "ccId": "1",
 "agentId": "${agentId_2}",
 "agentState": "4",
 "skillIds": [
 "${skillIds1}",
 "${skillIds2}"
 ],
 "isAutoAnswer": true,
 "opserialNo": 1,
 "phoneNum": "${phoneNum_2}"
 }</stringProp> <stringProp name="Argument.metadata">=</stringProp> </elementProp> </collectionProp> </elementProp> <stringProp name="HTTPSampler.domain">${ip}</stringProp> <stringProp name="HTTPSampler.port">${port}</stringProp> <stringProp name="HTTPSampler.protocol">${protocol}</stringProp> <stringProp name="HTTPSampler.contentEncoding">UTF-8</stringProp> <stringProp name="HTTPSampler.path">/ccacs/ws/agent/login</stringProp> <stringProp name="HTTPSampler.method">POST</stringProp> <boolProp name="HTTPSampler.follow_redirects">true</boolProp> <boolProp name="HTTPSampler.auto_redirects">false</boolProp> <boolProp name="HTTPSampler.use_keepalive">true</boolProp> <boolProp name="HTTPSampler.DO_MULTIPART_POST">false</boolProp> <stringProp name="HTTPSampler.embedded_url_re"></stringProp> <stringProp name="HTTPSampler.connect_timeout"></stringProp> <stringProp name="HTTPSampler.response_timeout"></stringProp> </HTTPSamplerProxy> <hashTree> <RegexExtractor guiclass="RegexExtractorGui" testclass="RegexExtractor" testname="正则表达式提取器" enabled="true"> <stringProp name="RegexExtractor.useHeaders">true</stringProp> <stringProp name="RegexExtractor.refname">sessionid1</stringProp> <stringProp name="RegexExtractor.regex">JSESSIONID=(.*);</stringProp> <stringProp name="RegexExtractor.template">$1$</stringProp> <stringProp name="RegexExtractor.default"></stringProp> <stringProp name="RegexExtractor.match_number">0</stringProp> </RegexExtractor> <hashTree/> <com.atlantbh.jmeter.plugins.jsonutils.jsonpathassertion.JSONPathAssertion guiclass="com.atlantbh.jmeter.plugins.jsonutils.jsonpathassertion.gui.JSONPathAssertionGui" testclass="com.atlantbh.jmeter.plugins.jsonutils.jsonpathassertion.JSONPathAssertion" testname="jp@gc - JSON Path Assertion" enabled="true"> <stringProp name="JSON_PATH">$.result</stringProp> <stringProp name="EXPECTED_VALUE">0</stringProp> <boolProp name="JSONVALIDATION">true</boolProp> <boolProp name="EXPECT_NULL">false</boolProp> <boolProp name="INVERT">false</boolProp> <boolProp name="ISREGEX">false</boolProp> </com.atlantbh.jmeter.plugins.jsonutils.jsonpathassertion.JSONPathAssertion> <hashTree/> <ConstantTimer guiclass="ConstantTimerGui" testclass="ConstantTimer" testname="固定定时器" enabled="true"> <stringProp name="ConstantTimer.delay">${sleepLogin}</stringProp> </ConstantTimer> <hashTree/> </hashTree> <HTTPSamplerProxy guiclass="HttpTestSampleGui" testclass="HTTPSamplerProxy" testname="A坐席外呼" enabled="true"> <boolProp name="HTTPSampler.postBodyRaw">true</boolProp> <elementProp name="HTTPsampler.Arguments" elementType="Arguments"> <collectionProp name="Arguments.arguments"> <elementProp name="" elementType="HTTPArgument"> <boolProp name="HTTPArgument.always_encode">false</boolProp> <stringProp name="Argument.value">{
 "callerDigits":"10086",
 "calledDigits":"${calledDigits_2}"
 }</stringProp> <stringProp name="Argument.metadata">=</stringProp> </elementProp> </collectionProp> </elementProp> <stringProp name="HTTPSampler.domain">${ip}</stringProp> <stringProp name="HTTPSampler.port">${port}</stringProp> <stringProp name="HTTPSampler.protocol">${protocol}</stringProp> <stringProp name="HTTPSampler.contentEncoding"></stringProp> <stringProp name="HTTPSampler.path">/ccacs/ws/call/callout</stringProp> <stringProp name="HTTPSampler.method">POST</stringProp> <boolProp name="HTTPSampler.follow_redirects">true</boolProp> <boolProp name="HTTPSampler.auto_redirects">false</boolProp> <boolProp name="HTTPSampler.use_keepalive">true</boolProp> <boolProp name="HTTPSampler.DO_MULTIPART_POST">false</boolProp> <stringProp name="HTTPSampler.embedded_url_re"></stringProp> <stringProp name="HTTPSampler.connect_timeout"></stringProp> <stringProp name="HTTPSampler.response_timeout"></stringProp> </HTTPSamplerProxy> <hashTree> <com.atlantbh.jmeter.plugins.jsonutils.jsonpathextractor.JSONPathExtractor guiclass="com.atlantbh.jmeter.plugins.jsonutils.jsonpathextractor.gui.JSONPathExtractorGui" testclass="com.atlantbh.jmeter.plugins.jsonutils.jsonpathextractor.JSONPathExtractor" testname="jp@gc - JSON Path Extractor" enabled="true"> <stringProp name="VAR">callId</stringProp> <stringProp name="JSONPATH">$.callId</stringProp> <stringProp name="DEFAULT"></stringProp> <stringProp name="VARIABLE"></stringProp> <stringProp name="SUBJECT">BODY</stringProp> </com.atlantbh.jmeter.plugins.jsonutils.jsonpathextractor.JSONPathExtractor> <hashTree/> <BeanShellPostProcessor guiclass="TestBeanGUI" testclass="BeanShellPostProcessor" testname="BeanShell PostProcessor" enabled="true"> <boolProp name="resetInterpreter">false</boolProp> <stringProp name="parameters"></stringProp> <stringProp name="filename"></stringProp> <stringProp name="script">//String callId = bsh.args[0]; //print (callId); //System.out.println("userPhone=" + callId); ${__setProperty(newcallId,${callId},)}</stringProp> </BeanShellPostProcessor> <hashTree/> <com.atlantbh.jmeter.plugins.jsonutils.jsonpathassertion.JSONPathAssertion guiclass="com.atlantbh.jmeter.plugins.jsonutils.jsonpathassertion.gui.JSONPathAssertionGui" testclass="com.atlantbh.jmeter.plugins.jsonutils.jsonpathassertion.JSONPathAssertion" testname="jp@gc - JSON Path Assertion" enabled="true"> <stringProp name="JSON_PATH">$.result</stringProp> <stringProp name="EXPECTED_VALUE">0</stringProp> <boolProp name="JSONVALIDATION">true</boolProp> <boolProp name="EXPECT_NULL">false</boolProp> <boolProp name="INVERT">false</boolProp> <boolProp name="ISREGEX">false</boolProp> </com.atlantbh.jmeter.plugins.jsonutils.jsonpathassertion.JSONPathAssertion> <hashTree/> <ConstantTimer guiclass="ConstantTimerGui" testclass="ConstantTimer" testname="固定定时器" enabled="true"> <stringProp name="ConstantTimer.delay">1000</stringProp> </ConstantTimer> <hashTree/> </hashTree> <WhileController guiclass="WhileControllerGui" testclass="WhileController" testname="While间隔3秒判断有没跨线程传值,没有就继续循环,有就结束" enabled="true"> <stringProp name="TestPlan.comments">当另一线程传过来的值 ${__javaScript("${__P(newstatus,)}"!="1")}时结束循环</stringProp> <stringProp name="WhileController.condition">${__javaScript(${__P(newstatus,)}==1)}</stringProp> </WhileController> <hashTree> <ConstantTimer guiclass="ConstantTimerGui" testclass="ConstantTimer" testname="固定定时器" enabled="true"> <stringProp name="ConstantTimer.delay">3000</stringProp> </ConstantTimer> <hashTree/> <DebugSampler guiclass="TestBeanGUI" testclass="DebugSampler" testname="A坐席间隔3秒等待内部求助" enabled="false"> <boolProp name="displayJMeterProperties">false</boolProp> <boolProp name="displayJMeterVariables">true</boolProp> <boolProp name="displaySystemProperties">false</boolProp> </DebugSampler> <hashTree> <BeanShellPostProcessor guiclass="TestBeanGUI" testclass="BeanShellPostProcessor" testname="BeanShell PostProcessor" enabled="true"> <boolProp name="resetInterpreter">false</boolProp> <stringProp name="parameters"></stringProp> <stringProp name="filename"></stringProp> <stringProp name="script">System.out.println("userPhone=等待应答result" + "${__P(newstatus,)}"); //System.out.println("userPhone=222" + "${__P(newcallId,)}"); </stringProp> </BeanShellPostProcessor> <hashTree/> </hashTree> <CounterConfig guiclass="CounterConfigGui" testclass="CounterConfig" testname="计数器" enabled="true"> <stringProp name="CounterConfig.start">1</stringProp> <stringProp name="CounterConfig.end">20</stringProp> <stringProp name="CounterConfig.incr">1</stringProp> <stringProp name="CounterConfig.name">count</stringProp> <stringProp name="CounterConfig.format"></stringProp> <boolProp name="CounterConfig.per_user">false</boolProp> </CounterConfig> <hashTree/> <IfController guiclass="IfControllerPanel" testclass="IfController" testname="强制结束循环" enabled="true"> <stringProp name="IfController.condition">${count}==20</stringProp> <boolProp name="IfController.evaluateAll">false</boolProp> </IfController> <hashTree> <BeanShellSampler guiclass="BeanShellSamplerGui" testclass="BeanShellSampler" testname="强制结束循环" enabled="true"> <stringProp name="BeanShellSampler.query">${__setProperty(newstatus,0,)}</stringProp> <stringProp name="BeanShellSampler.filename"></stringProp> <stringProp name="BeanShellSampler.parameters"></stringProp> <boolProp name="BeanShellSampler.resetInterpreter">false</boolProp> </BeanShellSampler> <hashTree/> </hashTree> </hashTree> <HTTPSamplerProxy guiclass="HttpTestSampleGui" testclass="HTTPSamplerProxy" testname="A坐席应答" enabled="false"> <boolProp name="HTTPSampler.postBodyRaw">true</boolProp> <elementProp name="HTTPsampler.Arguments" elementType="Arguments"> <collectionProp name="Arguments.arguments"> <elementProp name="" elementType="HTTPArgument"> <boolProp name="HTTPArgument.always_encode">false</boolProp> <stringProp name="Argument.value">{
 "callId":${__P(newcallId,)}}
 }</stringProp> <stringProp name="Argument.metadata">=</stringProp> </elementProp> </collectionProp> </elementProp> <stringProp name="HTTPSampler.domain">${ip}</stringProp> <stringProp name="HTTPSampler.port">${port}</stringProp> <stringProp name="HTTPSampler.protocol">${protocol}</stringProp> <stringProp name="HTTPSampler.contentEncoding"></stringProp> <stringProp name="HTTPSampler.path">/ccacs/ws/call/answer</stringProp> <stringProp name="HTTPSampler.method">POST</stringProp> <boolProp name="HTTPSampler.follow_redirects">true</boolProp> <boolProp name="HTTPSampler.auto_redirects">false</boolProp> <boolProp name="HTTPSampler.use_keepalive">true</boolProp> <boolProp name="HTTPSampler.DO_MULTIPART_POST">false</boolProp> <stringProp name="HTTPSampler.embedded_url_re"></stringProp> <stringProp name="HTTPSampler.connect_timeout"></stringProp> <stringProp name="HTTPSampler.response_timeout"></stringProp> </HTTPSamplerProxy> <hashTree> <com.atlantbh.jmeter.plugins.jsonutils.jsonpathassertion.JSONPathAssertion guiclass="com.atlantbh.jmeter.plugins.jsonutils.jsonpathassertion.gui.JSONPathAssertionGui" testclass="com.atlantbh.jmeter.plugins.jsonutils.jsonpathassertion.JSONPathAssertion" testname="jp@gc - JSON Path Assertion" enabled="true"> <stringProp name="JSON_PATH">$.result</stringProp> <stringProp name="EXPECTED_VALUE">0</stringProp> <boolProp name="JSONVALIDATION">true</boolProp> <boolProp name="EXPECT_NULL">false</boolProp> <boolProp name="INVERT">false</boolProp> <boolProp name="ISREGEX">false</boolProp> </com.atlantbh.jmeter.plugins.jsonutils.jsonpathassertion.JSONPathAssertion> <hashTree/> </hashTree> <HTTPSamplerProxy guiclass="HttpTestSampleGui" testclass="HTTPSamplerProxy" testname="A坐席释放" enabled="true"> <boolProp name="HTTPSampler.postBodyRaw">true</boolProp> <elementProp name="HTTPsampler.Arguments" elementType="Arguments"> <collectionProp name="Arguments.arguments"> <elementProp name="" elementType="HTTPArgument"> <boolProp name="HTTPArgument.always_encode">false</boolProp> <stringProp name="Argument.value">{ 
 "callId":${callId}
 }</stringProp> <stringProp name="Argument.metadata">=</stringProp> </elementProp> </collectionProp> </elementProp> <stringProp name="HTTPSampler.domain">${ip}</stringProp> <stringProp name="HTTPSampler.port">${port}</stringProp> <stringProp name="HTTPSampler.protocol">${protocol}</stringProp> <stringProp name="HTTPSampler.contentEncoding"></stringProp> <stringProp name="HTTPSampler.path">/ccacs/ws/call/releasecall</stringProp> <stringProp name="HTTPSampler.method">POST</stringProp> <boolProp name="HTTPSampler.follow_redirects">true</boolProp> <boolProp name="HTTPSampler.auto_redirects">false</boolProp> <boolProp name="HTTPSampler.use_keepalive">true</boolProp> <boolProp name="HTTPSampler.DO_MULTIPART_POST">false</boolProp> <stringProp name="HTTPSampler.embedded_url_re"></stringProp> <stringProp name="HTTPSampler.connect_timeout"></stringProp> <stringProp name="HTTPSampler.response_timeout"></stringProp> </HTTPSamplerProxy> <hashTree> <ConstantTimer guiclass="ConstantTimerGui" testclass="ConstantTimer" testname="固定定时器" enabled="true"> <stringProp name="ConstantTimer.delay">${sleepNormal}</stringProp> </ConstantTimer> <hashTree/> <com.atlantbh.jmeter.plugins.jsonutils.jsonpathassertion.JSONPathAssertion guiclass="com.atlantbh.jmeter.plugins.jsonutils.jsonpathassertion.gui.JSONPathAssertionGui" testclass="com.atlantbh.jmeter.plugins.jsonutils.jsonpathassertion.JSONPathAssertion" testname="jp@gc - JSON Path Assertion" enabled="true"> <stringProp name="JSON_PATH">$.result</stringProp> <stringProp name="EXPECTED_VALUE">0</stringProp> <boolProp name="JSONVALIDATION">true</boolProp> <boolProp name="EXPECT_NULL">false</boolProp> <boolProp name="INVERT">false</boolProp> <boolProp name="ISREGEX">false</boolProp> </com.atlantbh.jmeter.plugins.jsonutils.jsonpathassertion.JSONPathAssertion> <hashTree/> </hashTree> <HTTPSamplerProxy guiclass="HttpTestSampleGui" testclass="HTTPSamplerProxy" testname="A坐席事件轮询" enabled="true"> <boolProp name="HTTPSampler.postBodyRaw">true</boolProp> <elementProp name="HTTPsampler.Arguments" elementType="Arguments"> <collectionProp name="Arguments.arguments"> <elementProp name="" elementType="HTTPArgument"> <boolProp name="HTTPArgument.always_encode">false</boolProp> <stringProp name="Argument.value"></stringProp> <stringProp name="Argument.metadata">=</stringProp> </elementProp> </collectionProp> </elementProp> <stringProp name="HTTPSampler.domain">${ip}</stringProp> <stringProp name="HTTPSampler.port">${port}</stringProp> <stringProp name="HTTPSampler.protocol">${protocol}</stringProp> <stringProp name="HTTPSampler.contentEncoding"></stringProp> <stringProp name="HTTPSampler.path">/ccacs/ws/event/poll</stringProp> <stringProp name="HTTPSampler.method">POST</stringProp> <boolProp name="HTTPSampler.follow_redirects">true</boolProp> <boolProp name="HTTPSampler.auto_redirects">false</boolProp> <boolProp name="HTTPSampler.use_keepalive">true</boolProp> <boolProp name="HTTPSampler.DO_MULTIPART_POST">false</boolProp> <stringProp name="HTTPSampler.embedded_url_re"></stringProp> <stringProp name="HTTPSampler.connect_timeout"></stringProp> <stringProp name="HTTPSampler.response_timeout"></stringProp> </HTTPSamplerProxy> <hashTree> <ConstantTimer guiclass="ConstantTimerGui" testclass="ConstantTimer" testname="固定定时器" enabled="true"> <stringProp name="ConstantTimer.delay">${sleepPoll}</stringProp> </ConstantTimer> <hashTree/> <BeanShellAssertion guiclass="BeanShellAssertionGui" testclass="BeanShellAssertion" testname="BeanShell断言" enabled="true"> <stringProp name="BeanShellAssertion.query">import java.util.ArrayList; import java.util.List; import com.alibaba.fastjson.*; import com.jmeter.*; listexc = new ArrayList(); listexc.add(351); listexc.add(301); listexc.add(302); listexc.add(304); listexc.add(305); listexc.add(306); list = new ArrayList(); flag = "false"; if ((prev.getResponseCode() != null) && (prev.getResponseCode().equals("200") == true)) { String json = prev.getResponseDataAsString(); JSONObject jo = JSON.parseObject(json); if(jo.containsKey("events")) { JSONArray ja = jo.getJSONArray("events"); if(ja.size()>0) { flag = "true"; for(int i = 0;i<ja.size();i++) { System.out.println(ja.get(i)); JSONObject joe = ja.getJSONObject(i); System.out.println(joe.get("eventId")); list.add(joe.get("eventId")); } System.out.println(list.size()); System.out.println(new EventCompare().compare(listexc,list)); if(!new EventCompare().compare(listexc,list)){ Failure = true; FailureMessage = "事件校验失败,预期结果和实际结果不一致,预期事件:"+listexc+" ,实际事件:"+list; } }else{ flag = "false"; Failure = true; FailureMessage = "事件校验失败,轮询接口返回没有eventId"; } vars.put("result",flag); System.out.println(list.size()); /* System.out.println(listexc.containsAll(list)); if(listexc.containsAll(list)) { Failure = true; FailureMessage = "事件校验失败"; } */ }else { Failure = true; FailureMessage = "事件校验失败,轮询接口返回没有events"; } }else { Failure = true; FailureMessage = "事件校验失败,轮询接口返回空"; } </stringProp> <stringProp name="BeanShellAssertion.filename"></stringProp> <stringProp name="BeanShellAssertion.parameters"></stringProp> <boolProp name="BeanShellAssertion.resetInterpreter">false</boolProp> </BeanShellAssertion> <hashTree/> </hashTree> <IfController guiclass="IfControllerPanel" testclass="IfController" testname="如果(If)控制器" enabled="true"> <stringProp name="IfController.condition">"${result}"=="false"</stringProp> <boolProp name="IfController.evaluateAll">false</boolProp> </IfController> <hashTree> <HTTPSamplerProxy guiclass="HttpTestSampleGui" testclass="HTTPSamplerProxy" testname="A坐席事件轮询" enabled="true"> <boolProp name="HTTPSampler.postBodyRaw">true</boolProp> <elementProp name="HTTPsampler.Arguments" elementType="Arguments"> <collectionProp name="Arguments.arguments"> <elementProp name="" elementType="HTTPArgument"> <boolProp name="HTTPArgument.always_encode">false</boolProp> <stringProp name="Argument.value"></stringProp> <stringProp name="Argument.metadata">=</stringProp> </elementProp> </collectionProp> </elementProp> <stringProp name="HTTPSampler.domain">${ip}</stringProp> <stringProp name="HTTPSampler.port">${port}</stringProp> <stringProp name="HTTPSampler.protocol">${protocol}</stringProp> <stringProp name="HTTPSampler.contentEncoding"></stringProp> <stringProp name="HTTPSampler.path">/ccacs/ws/event/poll</stringProp> <stringProp name="HTTPSampler.method">POST</stringProp> <boolProp name="HTTPSampler.follow_redirects">true</boolProp> <boolProp name="HTTPSampler.auto_redirects">false</boolProp> <boolProp name="HTTPSampler.use_keepalive">true</boolProp> <boolProp name="HTTPSampler.DO_MULTIPART_POST">false</boolProp> <stringProp name="HTTPSampler.embedded_url_re"></stringProp> <stringProp name="HTTPSampler.connect_timeout"></stringProp> <stringProp name="HTTPSampler.response_timeout"></stringProp> </HTTPSamplerProxy> <hashTree> <ConstantTimer guiclass="ConstantTimerGui" testclass="ConstantTimer" testname="固定定时器" enabled="true"> <stringProp name="ConstantTimer.delay">${sleepPollagin}</stringProp> </ConstantTimer> <hashTree/> <BeanShellAssertion guiclass="BeanShellAssertionGui" testclass="BeanShellAssertion" testname="BeanShell断言" enabled="true"> <stringProp name="BeanShellAssertion.query">import java.util.ArrayList; import java.util.List; import com.alibaba.fastjson.*; import com.jmeter.*; listexc = new ArrayList(); listexc.add(351); listexc.add(301); listexc.add(302); listexc.add(304); listexc.add(305); listexc.add(306); list = new ArrayList(); flag = "false"; if ((prev.getResponseCode() != null) && (prev.getResponseCode().equals("200") == true)) { String json = prev.getResponseDataAsString(); JSONObject jo = JSON.parseObject(json); if(jo.containsKey("events")) { JSONArray ja = jo.getJSONArray("events"); if(ja.size()>0) { flag = "true"; for(int i = 0;i<ja.size();i++) { System.out.println(ja.get(i)); JSONObject joe = ja.getJSONObject(i); System.out.println(joe.get("eventId")); list.add(joe.get("eventId")); } System.out.println(list.size()); System.out.println(new EventCompare().compare(listexc,list)); if(!new EventCompare().compare(listexc,list)){ Failure = true; FailureMessage = "事件校验失败,预期结果和实际结果不一致,预期事件:"+listexc+" ,实际事件:"+list; } }else{ flag = "false"; Failure = true; FailureMessage = "事件校验失败,轮询接口返回没有eventId"; } //vars.put("result",flag); System.out.println(list.size()); /* System.out.println(listexc.containsAll(list)); if(listexc.containsAll(list)) { Failure = true; FailureMessage = "事件校验失败"; } */ }else { Failure = true; FailureMessage = "事件校验失败,轮询接口返回没有events"; } }else { Failure = true; FailureMessage = "事件校验失败,轮询接口返回空"; } </stringProp> <stringProp name="BeanShellAssertion.filename"></stringProp> <stringProp name="BeanShellAssertion.parameters"></stringProp> <boolProp name="BeanShellAssertion.resetInterpreter">false</boolProp> </BeanShellAssertion> <hashTree/> </hashTree> </hashTree> <HTTPSamplerProxy guiclass="HttpTestSampleGui" testclass="HTTPSamplerProxy" testname="A坐席签出" enabled="true"> <boolProp name="HTTPSampler.postBodyRaw">true</boolProp> <elementProp name="HTTPsampler.Arguments" elementType="Arguments"> <collectionProp name="Arguments.arguments"> <elementProp name="" elementType="HTTPArgument"> <boolProp name="HTTPArgument.always_encode">false</boolProp> <stringProp name="Argument.value">{"reasonCode": "0"}</stringProp> <stringProp name="Argument.metadata">=</stringProp> </elementProp> </collectionProp> </elementProp> <stringProp name="HTTPSampler.domain">${ip}</stringProp> <stringProp name="HTTPSampler.port">${port}</stringProp> <stringProp name="HTTPSampler.protocol">${protocol}</stringProp> <stringProp name="HTTPSampler.contentEncoding">UTF-8</stringProp> <stringProp name="HTTPSampler.path">/ccacs/ws/agent/logout</stringProp> <stringProp name="HTTPSampler.method">POST</stringProp> <boolProp name="HTTPSampler.follow_redirects">true</boolProp> <boolProp name="HTTPSampler.auto_redirects">false</boolProp> <boolProp name="HTTPSampler.use_keepalive">true</boolProp> <boolProp name="HTTPSampler.DO_MULTIPART_POST">false</boolProp> <stringProp name="HTTPSampler.embedded_url_re"></stringProp> <stringProp name="HTTPSampler.connect_timeout"></stringProp> <stringProp name="HTTPSampler.response_timeout"></stringProp> </HTTPSamplerProxy> <hashTree> <com.atlantbh.jmeter.plugins.jsonutils.jsonpathassertion.JSONPathAssertion guiclass="com.atlantbh.jmeter.plugins.jsonutils.jsonpathassertion.gui.JSONPathAssertionGui" testclass="com.atlantbh.jmeter.plugins.jsonutils.jsonpathassertion.JSONPathAssertion" testname="jp@gc - JSON Path Assertion" enabled="true"> <stringProp name="JSON_PATH">$.result</stringProp> <stringProp name="EXPECTED_VALUE">0</stringProp> <boolProp name="JSONVALIDATION">true</boolProp> <boolProp name="EXPECT_NULL">false</boolProp> <boolProp name="INVERT">false</boolProp> <boolProp name="ISREGEX">false</boolProp> </com.atlantbh.jmeter.plugins.jsonutils.jsonpathassertion.JSONPathAssertion> <hashTree/> <ConstantTimer guiclass="ConstantTimerGui" testclass="ConstantTimer" testname="固定定时器" enabled="true"> <stringProp name="ConstantTimer.delay">${sleepLogout}</stringProp> </ConstantTimer> <hashTree/> </hashTree> </hashTree> <ThreadGroup guiclass="ThreadGroupGui" testclass="ThreadGroup" testname="综合接续_工号-内部求助_正常_208-1_B坐席" enabled="true"> <stringProp name="ThreadGroup.on_sample_error">continue</stringProp> <elementProp name="ThreadGroup.main_controller" elementType="LoopController" guiclass="LoopControlPanel" testclass="LoopController" testname="循环控制器" enabled="true"> <boolProp name="LoopController.continue_forever">false</boolProp> <stringProp name="LoopController.loops">1</stringProp> </elementProp> <stringProp name="ThreadGroup.num_threads">1</stringProp> <stringProp name="ThreadGroup.ramp_time">1</stringProp> <longProp name="ThreadGroup.start_time">4084391880000</longProp> <longProp name="ThreadGroup.end_time">4084391880000</longProp> <boolProp name="ThreadGroup.scheduler">false</boolProp> <stringProp name="ThreadGroup.duration"></stringProp> <stringProp name="ThreadGroup.delay">3</stringProp> </ThreadGroup> <hashTree> <CookieManager guiclass="CookiePanel" testclass="CookieManager" testname="HTTP Cookie 管理器" enabled="true"> <collectionProp name="CookieManager.cookies"/> <boolProp name="CookieManager.clearEachIteration">false</boolProp> <stringProp name="CookieManager.policy">standard</stringProp> <stringProp name="CookieManager.implementation">org.apache.jmeter.protocol.http.control.HC4CookieHandler</stringProp> </CookieManager> <hashTree/> <Arguments guiclass="ArgumentsPanel" testclass="Arguments" testname="用户定义的变量" enabled="true"> <collectionProp name="Arguments.arguments"> <elementProp name="result_zhxj" elementType="Argument"> <stringProp name="Argument.name">result_zhxj</stringProp> <stringProp name="Argument.value">1</stringProp> <stringProp name="Argument.metadata">=</stringProp> <stringProp name="Argument.desc">赋初始值,后续会有新值</stringProp> </elementProp> </collectionProp> </Arguments> <hashTree/> <HTTPSamplerProxy guiclass="HttpTestSampleGui" testclass="HTTPSamplerProxy" testname="B坐席签入" enabled="true"> <boolProp name="HTTPSampler.postBodyRaw">true</boolProp> <elementProp name="HTTPsampler.Arguments" elementType="Arguments"> <collectionProp name="Arguments.arguments"> <elementProp name="" elementType="HTTPArgument"> <boolProp name="HTTPArgument.always_encode">false</boolProp> <stringProp name="Argument.value">{
 "ccId": "1",
 "agentId": "${agentId}",
 "agentState": "4",
 "skillIds": [
 "${skillIds1}",
 "${skillIds2}"
 ],
 "isAutoAnswer": true,
 "opserialNo": 1,
 "phoneNum": "${phoneNum}"
 }</stringProp> <stringProp name="Argument.metadata">=</stringProp> </elementProp> </collectionProp> </elementProp> <stringProp name="HTTPSampler.domain">${ip}</stringProp> <stringProp name="HTTPSampler.port">${port}</stringProp> <stringProp name="HTTPSampler.protocol">${protocol}</stringProp> <stringProp name="HTTPSampler.contentEncoding">UTF-8</stringProp> <stringProp name="HTTPSampler.path">/ccacs/ws/agent/login</stringProp> <stringProp name="HTTPSampler.method">POST</stringProp> <boolProp name="HTTPSampler.follow_redirects">true</boolProp> <boolProp name="HTTPSampler.auto_redirects">false</boolProp> <boolProp name="HTTPSampler.use_keepalive">true</boolProp> <boolProp name="HTTPSampler.DO_MULTIPART_POST">false</boolProp> <stringProp name="HTTPSampler.embedded_url_re"></stringProp> <stringProp name="HTTPSampler.connect_timeout"></stringProp> <stringProp name="HTTPSampler.response_timeout"></stringProp> </HTTPSamplerProxy> <hashTree> <RegexExtractor guiclass="RegexExtractorGui" testclass="RegexExtractor" testname="正则表达式提取器" enabled="true"> <stringProp name="RegexExtractor.useHeaders">true</stringProp> <stringProp name="RegexExtractor.refname">sessionid1</stringProp> <stringProp name="RegexExtractor.regex">JSESSIONID=(.*);</stringProp> <stringProp name="RegexExtractor.template">$1$</stringProp> <stringProp name="RegexExtractor.default"></stringProp> <stringProp name="RegexExtractor.match_number">0</stringProp> </RegexExtractor> <hashTree/> <com.atlantbh.jmeter.plugins.jsonutils.jsonpathassertion.JSONPathAssertion guiclass="com.atlantbh.jmeter.plugins.jsonutils.jsonpathassertion.gui.JSONPathAssertionGui" testclass="com.atlantbh.jmeter.plugins.jsonutils.jsonpathassertion.JSONPathAssertion" testname="jp@gc - JSON Path Assertion" enabled="true"> <stringProp name="JSON_PATH">$.result</stringProp> <stringProp name="EXPECTED_VALUE">0</stringProp> <boolProp name="JSONVALIDATION">true</boolProp> <boolProp name="EXPECT_NULL">false</boolProp> <boolProp name="INVERT">false</boolProp> <boolProp name="ISREGEX">false</boolProp> </com.atlantbh.jmeter.plugins.jsonutils.jsonpathassertion.JSONPathAssertion> <hashTree/> <ConstantTimer guiclass="ConstantTimerGui" testclass="ConstantTimer" testname="固定定时器" enabled="true"> <stringProp name="ConstantTimer.delay">${sleepLogin}</stringProp> </ConstantTimer> <hashTree/> <BeanShellPostProcessor guiclass="TestBeanGUI" testclass="BeanShellPostProcessor" testname="BeanShell PostProcessor" enabled="true"> <boolProp name="resetInterpreter">false</boolProp> <stringProp name="parameters">${__setProperty(newstatus,${result4internalhelp},)}</stringProp> <stringProp name="filename"></stringProp> <stringProp name="script">//String callId = bsh.args[0]; //print (callId); //System.out.println("userPhone=" + callId); ${__setProperty(newstatus,${result_zhxj},)}</stringProp> </BeanShellPostProcessor> <hashTree/> </hashTree> <HTTPSamplerProxy guiclass="HttpTestSampleGui" testclass="HTTPSamplerProxy" testname="B坐席外呼" enabled="true"> <boolProp name="HTTPSampler.postBodyRaw">true</boolProp> <elementProp name="HTTPsampler.Arguments" elementType="Arguments"> <collectionProp name="Arguments.arguments"> <elementProp name="" elementType="HTTPArgument"> <boolProp name="HTTPArgument.always_encode">false</boolProp> <stringProp name="Argument.value">{
 "callerDigits":"10086",
 "calledDigits":"${calledDigits}"
 }</stringProp> <stringProp name="Argument.metadata">=</stringProp> </elementProp> </collectionProp> </elementProp> <stringProp name="HTTPSampler.domain">${ip}</stringProp> <stringProp name="HTTPSampler.port">${port}</stringProp> <stringProp name="HTTPSampler.protocol">${protocol}</stringProp> <stringProp name="HTTPSampler.contentEncoding"></stringProp> <stringProp name="HTTPSampler.path">/ccacs/ws/call/callout</stringProp> <stringProp name="HTTPSampler.method">POST</stringProp> <boolProp name="HTTPSampler.follow_redirects">true</boolProp> <boolProp name="HTTPSampler.auto_redirects">false</boolProp> <boolProp name="HTTPSampler.use_keepalive">true</boolProp> <boolProp name="HTTPSampler.DO_MULTIPART_POST">false</boolProp> <stringProp name="HTTPSampler.embedded_url_re"></stringProp> <stringProp name="HTTPSampler.connect_timeout"></stringProp> <stringProp name="HTTPSampler.response_timeout"></stringProp> </HTTPSamplerProxy> <hashTree> <ConstantTimer guiclass="ConstantTimerGui" testclass="ConstantTimer" testname="固定定时器" enabled="true"> <stringProp name="ConstantTimer.delay">${sleepPoll}</stringProp> </ConstantTimer> <hashTree/> <com.atlantbh.jmeter.plugins.jsonutils.jsonpathextractor.JSONPathExtractor guiclass="com.atlantbh.jmeter.plugins.jsonutils.jsonpathextractor.gui.JSONPathExtractorGui" testclass="com.atlantbh.jmeter.plugins.jsonutils.jsonpathextractor.JSONPathExtractor" testname="jp@gc - JSON Path Extractor" enabled="true"> <stringProp name="VAR">callId</stringProp> <stringProp name="JSONPATH">$.callId</stringProp> <stringProp name="DEFAULT"></stringProp> <stringProp name="VARIABLE"></stringProp> <stringProp name="SUBJECT">BODY</stringProp> </com.atlantbh.jmeter.plugins.jsonutils.jsonpathextractor.JSONPathExtractor> <hashTree/> <BeanShellPostProcessor guiclass="TestBeanGUI" testclass="BeanShellPostProcessor" testname="BeanShell PostProcessor" enabled="true"> <boolProp name="resetInterpreter">false</boolProp> <stringProp name="parameters"></stringProp> <stringProp name="filename"></stringProp> <stringProp name="script">//String callId = bsh.args[0]; //print (callId); //System.out.println("userPhone=" + callId); ${__setProperty(newcallId,${callId},)}</stringProp> </BeanShellPostProcessor> <hashTree/> <com.atlantbh.jmeter.plugins.jsonutils.jsonpathassertion.JSONPathAssertion guiclass="com.atlantbh.jmeter.plugins.jsonutils.jsonpathassertion.gui.JSONPathAssertionGui" testclass="com.atlantbh.jmeter.plugins.jsonutils.jsonpathassertion.JSONPathAssertion" testname="jp@gc - JSON Path Assertion" enabled="true"> <stringProp name="JSON_PATH">$.result</stringProp> <stringProp name="EXPECTED_VALUE">0</stringProp> <boolProp name="JSONVALIDATION">true</boolProp> <boolProp name="EXPECT_NULL">false</boolProp> <boolProp name="INVERT">false</boolProp> <boolProp name="ISREGEX">false</boolProp> </com.atlantbh.jmeter.plugins.jsonutils.jsonpathassertion.JSONPathAssertion> <hashTree/> </hashTree> <HTTPSamplerProxy guiclass="HttpTestSampleGui" testclass="HTTPSamplerProxy" testname="B坐席内部求助A坐席" enabled="true"> <boolProp name="HTTPSampler.postBodyRaw">true</boolProp> <elementProp name="HTTPsampler.Arguments" elementType="Arguments"> <collectionProp name="Arguments.arguments"> <elementProp name="" elementType="HTTPArgument"> <boolProp name="HTTPArgument.always_encode">false</boolProp> <stringProp name="Argument.value">{
 "deviceType":"2",
 "dialedDigits":"${agentId_2}",
 "consultMode":"1"
 }</stringProp> <stringProp name="Argument.metadata">=</stringProp> </elementProp> </collectionProp> </elementProp> <stringProp name="HTTPSampler.domain">${ip}</stringProp> <stringProp name="HTTPSampler.port">${port}</stringProp> <stringProp name="HTTPSampler.protocol">${protocol}</stringProp> <stringProp name="HTTPSampler.contentEncoding"></stringProp> <stringProp name="HTTPSampler.path">/ccacs/ws/call/internalhelp</stringProp> <stringProp name="HTTPSampler.method">POST</stringProp> <boolProp name="HTTPSampler.follow_redirects">true</boolProp> <boolProp name="HTTPSampler.auto_redirects">false</boolProp> <boolProp name="HTTPSampler.use_keepalive">true</boolProp> <boolProp name="HTTPSampler.DO_MULTIPART_POST">false</boolProp> <stringProp name="HTTPSampler.embedded_url_re"></stringProp> <stringProp name="HTTPSampler.connect_timeout"></stringProp> <stringProp name="HTTPSampler.response_timeout"></stringProp> </HTTPSamplerProxy> <hashTree> <com.atlantbh.jmeter.plugins.jsonutils.jsonpathassertion.JSONPathAssertion guiclass="com.atlantbh.jmeter.plugins.jsonutils.jsonpathassertion.gui.JSONPathAssertionGui" testclass="com.atlantbh.jmeter.plugins.jsonutils.jsonpathassertion.JSONPathAssertion" testname="jp@gc - JSON Path Assertion" enabled="true"> <stringProp name="JSON_PATH">$.result</stringProp> <stringProp name="EXPECTED_VALUE">-1</stringProp> <boolProp name="JSONVALIDATION">true</boolProp> <boolProp name="EXPECT_NULL">false</boolProp> <boolProp name="INVERT">false</boolProp> <boolProp name="ISREGEX">false</boolProp> </com.atlantbh.jmeter.plugins.jsonutils.jsonpathassertion.JSONPathAssertion> <hashTree/> <com.atlantbh.jmeter.plugins.jsonutils.jsonpathextractor.JSONPathExtractor guiclass="com.atlantbh.jmeter.plugins.jsonutils.jsonpathextractor.gui.JSONPathExtractorGui" testclass="com.atlantbh.jmeter.plugins.jsonutils.jsonpathextractor.JSONPathExtractor" testname="result提取器" enabled="true"> <stringProp name="VAR">result_zhxj</stringProp> <stringProp name="JSONPATH">$.result</stringProp> <stringProp name="DEFAULT">555</stringProp> <stringProp name="VARIABLE"></stringProp> <stringProp name="SUBJECT">BODY</stringProp> </com.atlantbh.jmeter.plugins.jsonutils.jsonpathextractor.JSONPathExtractor> <hashTree/> <BeanShellPostProcessor guiclass="TestBeanGUI" testclass="BeanShellPostProcessor" testname="BeanShell PostProcessor" enabled="true"> <boolProp name="resetInterpreter">false</boolProp> <stringProp name="parameters">${__setProperty(newstatus,${result4internalhelp},)}</stringProp> <stringProp name="filename"></stringProp> <stringProp name="script">//String callId = bsh.args[0]; //print (callId); //System.out.println("userPhone=" + callId); ${__setProperty(newstatus,${result_zhxj},)}</stringProp> </BeanShellPostProcessor> <hashTree/> <ConstantTimer guiclass="ConstantTimerGui" testclass="ConstantTimer" testname="固定定时器" enabled="true"> <stringProp name="ConstantTimer.delay">1000</stringProp> </ConstantTimer> <hashTree/> </hashTree> <HTTPSamplerProxy guiclass="HttpTestSampleGui" testclass="HTTPSamplerProxy" testname="B坐席事件轮询" enabled="true"> <boolProp name="HTTPSampler.postBodyRaw">true</boolProp> <elementProp name="HTTPsampler.Arguments" elementType="Arguments"> <collectionProp name="Arguments.arguments"> <elementProp name="" elementType="HTTPArgument"> <boolProp name="HTTPArgument.always_encode">false</boolProp> <stringProp name="Argument.value"></stringProp> <stringProp name="Argument.metadata">=</stringProp> </elementProp> </collectionProp> </elementProp> <stringProp name="HTTPSampler.domain">${ip}</stringProp> <stringProp name="HTTPSampler.port">${port}</stringProp> <stringProp name="HTTPSampler.protocol">${protocol}</stringProp> <stringProp name="HTTPSampler.contentEncoding"></stringProp> <stringProp name="HTTPSampler.path">/ccacs/ws/event/poll</stringProp> <stringProp name="HTTPSampler.method">POST</stringProp> <boolProp name="HTTPSampler.follow_redirects">true</boolProp> <boolProp name="HTTPSampler.auto_redirects">false</boolProp> <boolProp name="HTTPSampler.use_keepalive">true</boolProp> <boolProp name="HTTPSampler.DO_MULTIPART_POST">false</boolProp> <stringProp name="HTTPSampler.embedded_url_re"></stringProp> <stringProp name="HTTPSampler.connect_timeout"></stringProp> <stringProp name="HTTPSampler.response_timeout"></stringProp> </HTTPSamplerProxy> <hashTree> <ConstantTimer guiclass="ConstantTimerGui" testclass="ConstantTimer" testname="固定定时器" enabled="true"> <stringProp name="ConstantTimer.delay">${sleepPoll}</stringProp> </ConstantTimer> <hashTree/> <BeanShellAssertion guiclass="BeanShellAssertionGui" testclass="BeanShellAssertion" testname="BeanShell断言" enabled="true"> <stringProp name="BeanShellAssertion.query">import java.util.ArrayList; import java.util.List; import com.alibaba.fastjson.*; import com.jmeter.*; listexc = new ArrayList(); listexc.add(351); listexc.add(302); listexc.add(304); list = new ArrayList(); flag = "false"; if ((prev.getResponseCode() != null) && (prev.getResponseCode().equals("200") == true)) { String json = prev.getResponseDataAsString(); JSONObject jo = JSON.parseObject(json); if(jo.containsKey("events")) { JSONArray ja = jo.getJSONArray("events"); if(ja.size()>0) { flag = "true"; for(int i = 0;i<ja.size();i++) { System.out.println(ja.get(i)); JSONObject joe = ja.getJSONObject(i); System.out.println(joe.get("eventId")); list.add(joe.get("eventId")); } System.out.println(list.size()); System.out.println(new EventCompare().compare(listexc,list)); if(!new EventCompare().compare(listexc,list)){ Failure = true; FailureMessage = "事件校验失败,预期结果和实际结果不一致,预期事件:"+listexc+" ,实际事件:"+list; } }else{ flag = "false"; Failure = true; FailureMessage = "事件校验失败,轮询接口返回没有eventId"; } vars.put("result",flag); System.out.println(list.size()); /* System.out.println(listexc.containsAll(list)); if(listexc.containsAll(list)) { Failure = true; FailureMessage = "事件校验失败"; } */ }else { Failure = true; FailureMessage = "事件校验失败,轮询接口返回没有events"; } }else { Failure = true; FailureMessage = "事件校验失败,轮询接口返回空"; } </stringProp> <stringProp name="BeanShellAssertion.filename"></stringProp> <stringProp name="BeanShellAssertion.parameters"></stringProp> <boolProp name="BeanShellAssertion.resetInterpreter">false</boolProp> </BeanShellAssertion> <hashTree/> </hashTree> <IfController guiclass="IfControllerPanel" testclass="IfController" testname="如果(If)控制器" enabled="true"> <stringProp name="IfController.condition">"${result}"=="false"</stringProp> <boolProp name="IfController.evaluateAll">false</boolProp> </IfController> <hashTree> <HTTPSamplerProxy guiclass="HttpTestSampleGui" testclass="HTTPSamplerProxy" testname="B坐席事件轮询" enabled="true"> <boolProp name="HTTPSampler.postBodyRaw">true</boolProp> <elementProp name="HTTPsampler.Arguments" elementType="Arguments"> <collectionProp name="Arguments.arguments"> <elementProp name="" elementType="HTTPArgument"> <boolProp name="HTTPArgument.always_encode">false</boolProp> <stringProp name="Argument.value"></stringProp> <stringProp name="Argument.metadata">=</stringProp> </elementProp> </collectionProp> </elementProp> <stringProp name="HTTPSampler.domain">${ip}</stringProp> <stringProp name="HTTPSampler.port">${port}</stringProp> <stringProp name="HTTPSampler.protocol">${protocol}</stringProp> <stringProp name="HTTPSampler.contentEncoding"></stringProp> <stringProp name="HTTPSampler.path">/ccacs/ws/event/poll</stringProp> <stringProp name="HTTPSampler.method">POST</stringProp> <boolProp name="HTTPSampler.follow_redirects">true</boolProp> <boolProp name="HTTPSampler.auto_redirects">false</boolProp> <boolProp name="HTTPSampler.use_keepalive">true</boolProp> <boolProp name="HTTPSampler.DO_MULTIPART_POST">false</boolProp> <stringProp name="HTTPSampler.embedded_url_re"></stringProp> <stringProp name="HTTPSampler.connect_timeout"></stringProp> <stringProp name="HTTPSampler.response_timeout"></stringProp> </HTTPSamplerProxy> <hashTree> <ConstantTimer guiclass="ConstantTimerGui" testclass="ConstantTimer" testname="固定定时器" enabled="true"> <stringProp name="ConstantTimer.delay">${sleepPollagin}</stringProp> </ConstantTimer> <hashTree/> <BeanShellAssertion guiclass="BeanShellAssertionGui" testclass="BeanShellAssertion" testname="BeanShell断言" enabled="true"> <stringProp name="BeanShellAssertion.query">import java.util.ArrayList; import java.util.List; import com.alibaba.fastjson.*; import com.jmeter.*; listexc = new ArrayList(); listexc.add(351); listexc.add(302); listexc.add(304); list = new ArrayList(); flag = "false"; if ((prev.getResponseCode() != null) && (prev.getResponseCode().equals("200") == true)) { String json = prev.getResponseDataAsString(); JSONObject jo = JSON.parseObject(json); if(jo.containsKey("events")) { JSONArray ja = jo.getJSONArray("events"); if(ja.size()>0) { flag = "true"; for(int i = 0;i<ja.size();i++) { System.out.println(ja.get(i)); JSONObject joe = ja.getJSONObject(i); System.out.println(joe.get("eventId")); list.add(joe.get("eventId")); } System.out.println(list.size()); System.out.println(new EventCompare().compare(listexc,list)); if(!new EventCompare().compare(listexc,list)){ Failure = true; FailureMessage = "事件校验失败,预期结果和实际结果不一致,预期事件:"+listexc+" ,实际事件:"+list; } }else{ flag = "false"; Failure = true; FailureMessage = "事件校验失败,轮询接口返回没有eventId"; } //vars.put("result",flag); System.out.println(list.size()); /* System.out.println(listexc.containsAll(list)); if(listexc.containsAll(list)) { Failure = true; FailureMessage = "事件校验失败"; } */ }else { Failure = true; FailureMessage = "事件校验失败,轮询接口返回没有events"; } }else { Failure = true; FailureMessage = "事件校验失败,轮询接口返回空"; } </stringProp> <stringProp name="BeanShellAssertion.filename"></stringProp> <stringProp name="BeanShellAssertion.parameters"></stringProp> <boolProp name="BeanShellAssertion.resetInterpreter">false</boolProp> </BeanShellAssertion> <hashTree/> </hashTree> </hashTree> <HTTPSamplerProxy guiclass="HttpTestSampleGui" testclass="HTTPSamplerProxy" testname="B坐席释放" enabled="true"> <boolProp name="HTTPSampler.postBodyRaw">true</boolProp> <elementProp name="HTTPsampler.Arguments" elementType="Arguments"> <collectionProp name="Arguments.arguments"> <elementProp name="" elementType="HTTPArgument"> <boolProp name="HTTPArgument.always_encode">false</boolProp> <stringProp name="Argument.value">{ 
 "callId":${callId}
 }</stringProp> <stringProp name="Argument.metadata">=</stringProp> </elementProp> </collectionProp> </elementProp> <stringProp name="HTTPSampler.domain">${ip}</stringProp> <stringProp name="HTTPSampler.port">${port}</stringProp> <stringProp name="HTTPSampler.protocol">${protocol}</stringProp> <stringProp name="HTTPSampler.contentEncoding"></stringProp> <stringProp name="HTTPSampler.path">/ccacs/ws/call/releasecall</stringProp> <stringProp name="HTTPSampler.method">POST</stringProp> <boolProp name="HTTPSampler.follow_redirects">true</boolProp> <boolProp name="HTTPSampler.auto_redirects">false</boolProp> <boolProp name="HTTPSampler.use_keepalive">true</boolProp> <boolProp name="HTTPSampler.DO_MULTIPART_POST">false</boolProp> <stringProp name="HTTPSampler.embedded_url_re"></stringProp> <stringProp name="HTTPSampler.connect_timeout"></stringProp> <stringProp name="HTTPSampler.response_timeout"></stringProp> </HTTPSamplerProxy> <hashTree> <ConstantTimer guiclass="ConstantTimerGui" testclass="ConstantTimer" testname="固定定时器" enabled="true"> <stringProp name="ConstantTimer.delay">${sleepPollagin}</stringProp> </ConstantTimer> <hashTree/> <com.atlantbh.jmeter.plugins.jsonutils.jsonpathassertion.JSONPathAssertion guiclass="com.atlantbh.jmeter.plugins.jsonutils.jsonpathassertion.gui.JSONPathAssertionGui" testclass="com.atlantbh.jmeter.plugins.jsonutils.jsonpathassertion.JSONPathAssertion" testname="jp@gc - JSON Path Assertion" enabled="true"> <stringProp name="JSON_PATH">$.result</stringProp> <stringProp name="EXPECTED_VALUE">0</stringProp> <boolProp name="JSONVALIDATION">true</boolProp> <boolProp name="EXPECT_NULL">false</boolProp> <boolProp name="INVERT">false</boolProp> <boolProp name="ISREGEX">false</boolProp> </com.atlantbh.jmeter.plugins.jsonutils.jsonpathassertion.JSONPathAssertion> <hashTree/> </hashTree> <HTTPSamplerProxy guiclass="HttpTestSampleGui" testclass="HTTPSamplerProxy" testname="B坐席第二次释放(挂机)" enabled="false"> <boolProp name="HTTPSampler.postBodyRaw">true</boolProp> <elementProp name="HTTPsampler.Arguments" elementType="Arguments"> <collectionProp name="Arguments.arguments"> <elementProp name="" elementType="HTTPArgument"> <boolProp name="HTTPArgument.always_encode">false</boolProp> <stringProp name="Argument.value">{ 
 "callId":${callId}
 }</stringProp> <stringProp name="Argument.metadata">=</stringProp> </elementProp> </collectionProp> </elementProp> <stringProp name="HTTPSampler.domain">${ip}</stringProp> <stringProp name="HTTPSampler.port">${port}</stringProp> <stringProp name="HTTPSampler.protocol">${protocol}</stringProp> <stringProp name="HTTPSampler.contentEncoding"></stringProp> <stringProp name="HTTPSampler.path">/ccacs/ws/call/releasecall</stringProp> <stringProp name="HTTPSampler.method">POST</stringProp> <boolProp name="HTTPSampler.follow_redirects">true</boolProp> <boolProp name="HTTPSampler.auto_redirects">false</boolProp> <boolProp name="HTTPSampler.use_keepalive">true</boolProp> <boolProp name="HTTPSampler.DO_MULTIPART_POST">false</boolProp> <stringProp name="HTTPSampler.embedded_url_re"></stringProp> <stringProp name="HTTPSampler.connect_timeout"></stringProp> <stringProp name="HTTPSampler.response_timeout"></stringProp> <stringProp name="TestPlan.comments">"time":"", "dsn":874951945, "handle":"", "server":""</stringProp> </HTTPSamplerProxy> <hashTree> <ConstantTimer guiclass="ConstantTimerGui" testclass="ConstantTimer" testname="固定定时器" enabled="true"> <stringProp name="ConstantTimer.delay">${sleepPollagin}</stringProp> </ConstantTimer> <hashTree/> <com.atlantbh.jmeter.plugins.jsonutils.jsonpathassertion.JSONPathAssertion guiclass="com.atlantbh.jmeter.plugins.jsonutils.jsonpathassertion.gui.JSONPathAssertionGui" testclass="com.atlantbh.jmeter.plugins.jsonutils.jsonpathassertion.JSONPathAssertion" testname="jp@gc - JSON Path Assertion" enabled="true"> <stringProp name="JSON_PATH">$.result</stringProp> <stringProp name="EXPECTED_VALUE">0</stringProp> <boolProp name="JSONVALIDATION">true</boolProp> <boolProp name="EXPECT_NULL">false</boolProp> <boolProp name="INVERT">false</boolProp> <boolProp name="ISREGEX">false</boolProp> </com.atlantbh.jmeter.plugins.jsonutils.jsonpathassertion.JSONPathAssertion> <hashTree/> </hashTree> <HTTPSamplerProxy guiclass="HttpTestSampleGui" testclass="HTTPSamplerProxy" testname="B坐席签出" enabled="true"> <boolProp name="HTTPSampler.postBodyRaw">true</boolProp> <elementProp name="HTTPsampler.Arguments" elementType="Arguments"> <collectionProp name="Arguments.arguments"> <elementProp name="" elementType="HTTPArgument"> <boolProp name="HTTPArgument.always_encode">false</boolProp> <stringProp name="Argument.value">{"reasonCode": "0"}</stringProp> <stringProp name="Argument.metadata">=</stringProp> </elementProp> </collectionProp> </elementProp> <stringProp name="HTTPSampler.domain">${ip}</stringProp> <stringProp name="HTTPSampler.port">${port}</stringProp> <stringProp name="HTTPSampler.protocol">${protocol}</stringProp> <stringProp name="HTTPSampler.contentEncoding">UTF-8</stringProp> <stringProp name="HTTPSampler.path">/ccacs/ws/agent/logout</stringProp> <stringProp name="HTTPSampler.method">POST</stringProp> <boolProp name="HTTPSampler.follow_redirects">true</boolProp> <boolProp name="HTTPSampler.auto_redirects">false</boolProp> <boolProp name="HTTPSampler.use_keepalive">true</boolProp> <boolProp name="HTTPSampler.DO_MULTIPART_POST">false</boolProp> <stringProp name="HTTPSampler.embedded_url_re"></stringProp> <stringProp name="HTTPSampler.connect_timeout"></stringProp> <stringProp name="HTTPSampler.response_timeout"></stringProp> </HTTPSamplerProxy> <hashTree> <com.atlantbh.jmeter.plugins.jsonutils.jsonpathassertion.JSONPathAssertion guiclass="com.atlantbh.jmeter.plugins.jsonutils.jsonpathassertion.gui.JSONPathAssertionGui" testclass="com.atlantbh.jmeter.plugins.jsonutils.jsonpathassertion.JSONPathAssertion" testname="jp@gc - JSON Path Assertion" enabled="true"> <stringProp name="JSON_PATH">$.result</stringProp> <stringProp name="EXPECTED_VALUE">0</stringProp> <boolProp name="JSONVALIDATION">true</boolProp> <boolProp name="EXPECT_NULL">false</boolProp> <boolProp name="INVERT">false</boolProp> <boolProp name="ISREGEX">false</boolProp> </com.atlantbh.jmeter.plugins.jsonutils.jsonpathassertion.JSONPathAssertion> <hashTree/> <ConstantTimer guiclass="ConstantTimerGui" testclass="ConstantTimer" testname="固定定时器" enabled="true"> <stringProp name="ConstantTimer.delay">${sleepLogout}</stringProp> </ConstantTimer> <hashTree/> </hashTree> </hashTree> <ResultCollector guiclass="ViewResultsFullVisualizer" testclass="ResultCollector" testname="察看结果树" enabled="true"> <boolProp name="ResultCollector.error_logging">false</boolProp> <objProp> <name>saveConfig</name> <value class="SampleSaveConfiguration"> <time>true</time> <latency>true</latency> <timestamp>true</timestamp> <success>true</success> <label>true</label> <code>true</code> <message>true</message> <threadName>true</threadName> <dataType>true</dataType> <encoding>false</encoding> <assertions>true</assertions> <subresults>true</subresults> <responseData>false</responseData> <samplerData>false</samplerData> <xml>false</xml> <fieldNames>true</fieldNames> <responseHeaders>false</responseHeaders> <requestHeaders>false</requestHeaders> <responseDataOnError>false</responseDataOnError> <saveAssertionResultsFailureMessage>true</saveAssertionResultsFailureMessage> <assertionsResultsToSave>0</assertionsResultsToSave> <bytes>true</bytes> <sentBytes>true</sentBytes> <threadCounts>true</threadCounts> <idleTime>true</idleTime> <connectTime>true</connectTime> </value> </objProp> <stringProp name="filename"></stringProp> </ResultCollector> <hashTree/> <ResultCollector guiclass="AssertionVisualizer" testclass="ResultCollector" testname="断言结果" enabled="true"> <boolProp name="ResultCollector.error_logging">false</boolProp> <objProp> <name>saveConfig</name> <value class="SampleSaveConfiguration"> <time>true</time> <latency>true</latency> <timestamp>true</timestamp> <success>true</success> <label>true</label> <code>true</code> <message>true</message> <threadName>true</threadName> <dataType>true</dataType> <encoding>false</encoding> <assertions>true</assertions> <subresults>true</subresults> <responseData>true</responseData> <samplerData>true</samplerData> <xml>true</xml> <fieldNames>true</fieldNames> <responseHeaders>true</responseHeaders> <requestHeaders>true</requestHeaders> <responseDataOnError>false</responseDataOnError> <saveAssertionResultsFailureMessage>true</saveAssertionResultsFailureMessage> <assertionsResultsToSave>0</assertionsResultsToSave> <bytes>true</bytes> <sentBytes>true</sentBytes> <url>true</url> <fileName>true</fileName> <hostname>true</hostname> <threadCounts>true</threadCounts> <sampleCount>true</sampleCount> <idleTime>true</idleTime> <connectTime>true</connectTime> </value> </objProp> <stringProp name="filename"></stringProp> </ResultCollector> <hashTree/> </hashTree> <WorkBench guiclass="WorkBenchGui" testclass="WorkBench" testname="工作台" enabled="true"> <boolProp name="WorkBench.save">true</boolProp> </WorkBench> <hashTree/> </hashTree> </jmeterTestPlan>
******************************************************************************************************************************************
作者:乔叶叶
博客地址:http://www.cnblogs.com/qiaoyeye/
本文版权归作者和博客园共有,欢迎转载,但未经作者同意必须保留此段声明,且在文章页面明显位置给出原文连接,否则保留追究法律责任的权利。
******************************************************************************************************************************************
作者:乔叶叶
博客地址:http://www.cnblogs.com/qiaoyeye/
本文版权归作者和博客园共有,欢迎转载,但未经作者同意必须保留此段声明,且在文章页面明显位置给出原文连接,否则保留追究法律责任的权利。
******************************************************************************************************************************************