新聞中心
這里有您想知道的互聯(lián)網(wǎng)營銷解決方案
如何通過JAVA代碼創(chuàng)建僅一次控制器和預處理器
本篇內容介紹了“如何通過JAVA代碼創(chuàng)建僅一次控制器和預處理器”的有關知識,在實際案例的操作過程中,不少人都會遇到這樣的困境,接下來就讓小編帶領大家學習一下如何處理這些情況吧!希望大家仔細閱讀,能夠學有所成!
定制網(wǎng)站建設可以根據(jù)自己的需求進行定制,網(wǎng)站設計、做網(wǎng)站構思過程中功能建設理應排到主要部位公司網(wǎng)站設計、做網(wǎng)站的運用實際效果公司網(wǎng)站制作網(wǎng)站建立與制做的實際意義
Jmeter:通過JAVA代碼創(chuàng)建僅一次控制器(OnceOnlyController)
最近在研究通過JAVA動態(tài)創(chuàng)建Jmeter腳本,對于創(chuàng)建OnceOnlyController ,實在沒找到相關資料,就自己研究了下,不是很難,代碼如下:
/** * 創(chuàng)建OnceOnlyController 僅一次控制器 * @param threadGroupHashTree * @param taskId */ public static void createOnceOnlyController(HashTree threadGroupHashTree ,String taskId) { OnceOnlyController onceOnlyController=new OnceOnlyController(); onceOnlyController.setProperty("testname", "test"); onceOnlyController.setProperty("enable", true); HashTree testPlanTree = new HashTree(); testPlanTree.add(createBeanShellPreProcessor(taskId)); BeanShellSampler beanShellSampler = new BeanShellSampler(); beanShellSampler.setName("test" + taskId); beanShellSampler.setProperty("BeanShellSampler.query", ""); testPlanTree.add(beanShellSampler); //將BeanShellPreProcessor和BeanShellSampler 添加到OnceOnlyController下 threadGroupHashTree.add(onceOnlyController,testPlanTree); } /** * 創(chuàng)建BeanShell 預處理器 * @return */ public static BeanShellPreProcessor createBeanShellPreProcessor(String taskId) { BeanShellPreProcessor preProcessor=new BeanShellPreProcessor(); preProcessor.setEnabled(true); preProcessor.setProperty("resetInterpreter", false); String script="System.out.println(\"預處理num:\"+ctx.getThreadNum());"; preProcessor.setProperty("script", script); preProcessor.setProperty(TestElement.ENABLED, true); preProcessor.setProperty(TestElement.NAME,"abcd"); preProcessor.setProperty(TestElement.TEST_CLASS, preProcessor.getClass().getName()); preProcessor.setProperty(TestElement.GUI_CLASS, TestBeanGUI.class.getName()); System.out.println("createBeanShellPreProcessor:"+preProcessor.getPropertyAsString("script")); return preProcessor; }
“如何通過JAVA代碼創(chuàng)建僅一次控制器和預處理器”的內容就介紹到這里了,感謝大家的閱讀。如果想了解更多行業(yè)相關的知識可以關注創(chuàng)新互聯(lián)網(wǎng)站,小編將為大家輸出更多高質量的實用文章!
文章標題:如何通過JAVA代碼創(chuàng)建僅一次控制器和預處理器
網(wǎng)站網(wǎng)址:http://fisionsoft.com.cn/article/ghspoh.html