当前位置: 首页>>代码示例>>Java>>正文


Java Sampler.sample方法代码示例

本文整理汇总了Java中org.apache.jmeter.samplers.Sampler.sample方法的典型用法代码示例。如果您正苦于以下问题:Java Sampler.sample方法的具体用法?Java Sampler.sample怎么用?Java Sampler.sample使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.apache.jmeter.samplers.Sampler的用法示例。


在下文中一共展示了Sampler.sample方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: testProcessingTrue

import org.apache.jmeter.samplers.Sampler; //导入方法依赖的package包/类
public void testProcessingTrue() throws Exception {
    LoopController controller = new LoopController();
    controller.setLoops(2);
    controller.addTestElement(new TestSampler("Sample1"));
    IfController ifCont = new IfController("true==true");
    ifCont.setEvaluateAll(true);
    ifCont.addTestElement(new TestSampler("Sample2"));
    TestSampler sample3 = new TestSampler("Sample3");            
    ifCont.addTestElement(sample3);
    controller.addTestElement(ifCont);
                
    String[] order = new String[] { "Sample1", "Sample2", "Sample3", 
            "Sample1", "Sample2", "Sample3" };
    int counter = 0;
    controller.setRunningVersion(true);
    ifCont.setRunningVersion(true);
    
    Sampler sampler = null;
    while ((sampler = controller.next()) != null) {
        sampler.sample(null);
        assertEquals(order[counter], sampler.getName());
        counter++;
    }
    assertEquals(counter, 6);
}
 
开发者ID:botelhojp,项目名称:apache-jmeter-2.10,代码行数:26,代码来源:TestIfController.java

示例2: testProcessing

import org.apache.jmeter.samplers.Sampler; //导入方法依赖的package包/类
public void testProcessing() throws Exception {

            RunTime controller = new RunTime();
            controller.setRuntime(10);
            TestSampler samp1 = new TestSampler("Sample 1", 500);
            TestSampler samp2 = new TestSampler("Sample 2", 490);

            LoopController sub1 = new LoopController();
            sub1.setLoops(2);
            sub1.setContinueForever(false);
            sub1.addTestElement(samp1);

            LoopController sub2 = new LoopController();
            sub2.setLoops(40);
            sub2.setContinueForever(false);
            sub2.addTestElement(samp2);
            controller.addTestElement(sub1);
            controller.addTestElement(sub2);
            controller.setRunningVersion(true);
            sub1.setRunningVersion(true);
            sub2.setRunningVersion(true);
            controller.initialize();
            Sampler sampler = null;
            int loops = 0;
            long now = System.currentTimeMillis();
            while ((sampler = controller.next()) != null) {
                loops++;
                sampler.sample(null);
            }
            long elapsed = System.currentTimeMillis() - now;
            assertTrue("Should be at least 20 loops "+loops, loops >= 20);
            assertTrue("Should be fewer than 30 loops "+loops, loops < 30);
            assertTrue("Should take at least 10 seconds "+elapsed, elapsed >= 10000);
            assertTrue("Should take less than 12 seconds "+elapsed, elapsed <= 12000);
            assertEquals("Sampler 1 should run 2 times", 2, samp1.getSamples());
            assertTrue("Sampler 2 should run >= 18 times", samp2.getSamples() >= 18);
        }
 
开发者ID:botelhojp,项目名称:apache-jmeter-2.10,代码行数:38,代码来源:TestRunTime.java

示例3: testEvaluateAllChildrenWithoutSubController

import org.apache.jmeter.samplers.Sampler; //导入方法依赖的package包/类
/**
 * Test false return on sample3 (sample4 doesn't execute)
 * @throws Exception
 */
public void testEvaluateAllChildrenWithoutSubController() throws Exception {
    LoopController controller = new LoopController();
    controller.setLoops(2);
    controller.addTestElement(new TestSampler("Sample1"));
    IfController ifCont = new IfController("true==true");
    ifCont.setEvaluateAll(true);
    controller.addTestElement(ifCont);
    
    ifCont.addTestElement(new TestSampler("Sample2"));
    TestSampler sample3 = new TestSampler("Sample3");            
    ifCont.addTestElement(sample3);
    TestSampler sample4 = new TestSampler("Sample4");
    ifCont.addTestElement(sample4);
    
    String[] order = new String[] { "Sample1", "Sample2", "Sample3", 
            "Sample1", "Sample2", "Sample3" };
    int counter = 0;
    controller.setRunningVersion(true);
    ifCont.setRunningVersion(true);
    
    Sampler sampler = null;
    while ((sampler = controller.next()) != null) {
        sampler.sample(null);
        if (sampler.getName().equals("Sample3")) {
            ifCont.setCondition("true==false");
        }
        assertEquals(order[counter], sampler.getName());
        counter++;
    }
    assertEquals(counter, 6);
}
 
开发者ID:botelhojp,项目名称:apache-jmeter-2.10,代码行数:36,代码来源:TestIfController.java

示例4: testEvaluateAllChildrenWithSubController

import org.apache.jmeter.samplers.Sampler; //导入方法依赖的package包/类
/**
 * test 2 loops with a sub generic controller (sample4 doesn't execute)
 * @throws Exception
 */
public void testEvaluateAllChildrenWithSubController() throws Exception {
    LoopController controller = new LoopController();
    controller.setLoops(2);
    controller.addTestElement(new TestSampler("Sample1"));
    IfController ifCont = new IfController("true==true");
    ifCont.setEvaluateAll(true);
    controller.addTestElement(ifCont);
    ifCont.addTestElement(new TestSampler("Sample2"));
    
    GenericController genericCont = new GenericController();
    TestSampler sample3 = new TestSampler("Sample3");            
    genericCont.addTestElement(sample3);
    TestSampler sample4 = new TestSampler("Sample4");
    genericCont.addTestElement(sample4);
    ifCont.addTestElement(genericCont);
    
    String[] order = new String[] { "Sample1", "Sample2", "Sample3", 
            "Sample1", "Sample2", "Sample3" };
    int counter = 0;
    controller.setRunningVersion(true);
    ifCont.setRunningVersion(true);
    genericCont.setRunningVersion(true);

    Sampler sampler = null;
    while ((sampler = controller.next()) != null) {
        sampler.sample(null);
        if (sampler.getName().equals("Sample3")) {
            ifCont.setCondition("true==false");
        }
        assertEquals(order[counter], sampler.getName());
        counter++;
    }
    assertEquals(counter, 6); 
}
 
开发者ID:botelhojp,项目名称:apache-jmeter-2.10,代码行数:39,代码来源:TestIfController.java


注:本文中的org.apache.jmeter.samplers.Sampler.sample方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。