Package org.apache.jmeter.junit.stubs

Examples of org.apache.jmeter.junit.stubs.TestSampler


            StringProperty prop = new StringProperty(LoopController.LOOPS,"${__Random(1,12,)}");
            JMeterProperty newProp = transformer.transformValue(prop);
            newProp.setRunningVersion(true);
           
            loop.setProperty(newProp);
            loop.addTestElement(new TestSampler("random run"));
            loop.setRunningVersion(true);
            loop.initialize();
            int loops = loop.getLoops();
            for (int i = 0; i < loops; i++) {
                Sampler s = loop.next();
View Full Code Here


    }

    public void testProcessing() throws Exception {
        GenericController controller = new GenericController();
        GenericController sub_1 = new OnceOnlyController();
        sub_1.addTestElement(new TestSampler("one"));
        sub_1.addTestElement(new TestSampler("two"));
        controller.addTestElement(sub_1);
        controller.addTestElement(new TestSampler("three"));
        LoopController sub_2 = new LoopController();
        sub_2.setLoops(3);
        GenericController sub_3 = new GenericController();
        sub_2.addTestElement(new TestSampler("four"));
        sub_3.addTestElement(new TestSampler("five"));
        sub_3.addTestElement(new TestSampler("six"));
        sub_2.addTestElement(sub_3);
        sub_2.addTestElement(new TestSampler("seven"));
        controller.addTestElement(sub_2);
        String[] interleaveOrder = new String[] { "one", "two" };
        String[] order = new String[] { "", "", "three", "four", "five", "six", "seven", "four", "five", "six",
            "seven", "four", "five", "six", "seven" };
        int counter = 15;
View Full Code Here

    }

    public void testProcessing2() throws Exception {
        GenericController controller = new GenericController();
        GenericController sub_1 = new OnceOnlyController();
        sub_1.addTestElement(new TestSampler("one"));
        sub_1.addTestElement(new TestSampler("two"));
        controller.addTestElement(sub_1);
        controller.addTestElement(new TestSampler("three"));
        LoopController sub_2 = new LoopController();
        sub_2.setLoops(3);
        OnceOnlyController sub_3 = new OnceOnlyController();
        sub_2.addTestElement(new TestSampler("four"));
        sub_3.addTestElement(new TestSampler("five"));
        sub_3.addTestElement(new TestSampler("six"));
        sub_2.addTestElement(sub_3);
        sub_2.addIterationListener(sub_3);
        sub_2.addTestElement(new TestSampler("seven"));
        controller.addTestElement(sub_2);
        String[] interleaveOrder = new String[] { "one", "two" };
        String[] order = new String[] { "", "", "three", "four", "five", "six", "seven", "four", "seven", "four",
            "seven" };
        int counter = 11;
View Full Code Here

        LoopController controller = new LoopController();
        final int outerLoopCount = 4;
        controller.setLoops(outerLoopCount);
        // OnlyOnce samples
        OnceOnlyController sub_1 = new OnceOnlyController();
        sub_1.addTestElement(new TestSampler("one"));
        sub_1.addTestElement(new TestSampler("two"));
        controller.addTestElement(sub_1);
        controller.addIterationListener(sub_1);
        // Outer sample
        controller.addTestElement(new TestSampler("three"));
        // Inner loop
        LoopController sub_2 = new LoopController();
        final int innerLoopCount = 3;
        sub_2.setLoops(innerLoopCount);
        GenericController sub_3 = new GenericController();
        sub_2.addTestElement(new TestSampler("four"));
        sub_3.addTestElement(new TestSampler("five"));
        sub_3.addTestElement(new TestSampler("six"));
        sub_2.addTestElement(sub_3);
        // Sample in inner loop
        sub_2.addTestElement(new TestSampler("seven"));
        controller.addTestElement(sub_2);
       
        // Compute the expected sample names
        String[] onlyOnceOrder = new String[] { "one", "two" };
        String[] order = new String[] { "three", "four", "five", "six", "seven", "four", "five", "six",
View Full Code Here

        LoopController controller = new LoopController();
        final int outerLoopCount = 4;
        controller.setLoops(outerLoopCount);
        // OnlyOnce samples
        OnceOnlyController sub_1 = new OnceOnlyController();
        sub_1.addTestElement(new TestSampler("one"));
        sub_1.addTestElement(new TestSampler("two"));
        controller.addTestElement(sub_1);
        controller.addIterationListener(sub_1);
        // Outer sample
        controller.addTestElement(new TestSampler("three"));
        // Inner loop
        LoopController sub_2 = new LoopController();
        final int innerLoopCount = 3;
        sub_2.setLoops(innerLoopCount);
        // Sample in inner loop
        sub_2.addTestElement(new TestSampler("four"));
        // OnlyOnce inside inner loop
        OnceOnlyController sub_3 = new OnceOnlyController();
        sub_3.addTestElement(new TestSampler("five"));
        sub_3.addTestElement(new TestSampler("six"));
        sub_2.addTestElement(sub_3);
        sub_2.addIterationListener(sub_3);
        // Sample in inner loop
        sub_2.addTestElement(new TestSampler("seven"));
        controller.addTestElement(sub_2);

        // Compute the expected sample names
        String[] onlyOnceOrder = new String[] { "one", "two" };
        String[] order = new String[] { "three", "four", "five", "six", "seven", "four", "seven", "four", "seven" };
View Full Code Here

        final int outerLoopCount = 4;
        controller.setLoops(outerLoopCount);
        // OnlyOnce samples
        OnceOnlyController sub_1 = new OnceOnlyController();
        sub_1.setName("outer OnlyOnce");
        sub_1.addTestElement(new TestSampler("one"));
        sub_1.addTestElement(new TestSampler("two"));
        controller.addTestElement(sub_1);
        controller.addIterationListener(sub_1);
        // Outer sample
        controller.addTestElement(new TestSampler("three"));
        // Inner loop
        LoopController sub_2 = new LoopController();
        final int innerLoopCount = 5;
        sub_2.setLoops(innerLoopCount);
        sub_2.addTestElement(new TestSampler("four"));
        // OnlyOnce inside inner loop
        OnceOnlyController sub_3 = new OnceOnlyController();
        sub_3.setName("In loop OnlyOnce");
        sub_3.addTestElement(new TestSampler("five"));
        sub_3.addTestElement(new TestSampler("six"));
        sub_2.addTestElement(sub_3);
        sub_2.addIterationListener(sub_3);
        // InterleaveController in inner loop
        InterleaveControl sub_4 = new InterleaveControl();
        sub_4.setStyle(InterleaveControl.USE_SUB_CONTROLLERS);
        // OnlyOnce inside InterleaveController
        OnceOnlyController sub_5 = new OnceOnlyController();
        sub_5.addTestElement(new TestSampler("seven"));
        sub_5.addTestElement(new TestSampler("eight"));
        sub_5.setName("Inside InterleaveController OnlyOnce");
        sub_4.addTestElement(sub_5);
        sub_4.addIterationListener(sub_5);
        // Samples inside InterleaveController       
        sub_4.addTestElement(new TestSampler("nine"));
        sub_4.addTestElement(new TestSampler("ten"));
        sub_2.addTestElement(sub_4);
        // Sample in inner loop       
        sub_2.addTestElement(new TestSampler("eleven"));
        controller.addTestElement(sub_2);

        // Compute the expected sample names
        String[] onlyOnceOrder = new String[] { "one", "two" };
        String[] order = new String[] { "three", "four", "five", "six", "seven", "eight", "eleven",
View Full Code Here

        }

        public void testProcessing() throws Exception {
            GenericController controller = new GenericController();
            GenericController sub_1 = new GenericController();
            sub_1.addTestElement(new TestSampler("one"));
            sub_1.addTestElement(new TestSampler("two"));
            controller.addTestElement(sub_1);
            controller.addTestElement(new TestSampler("three"));
            LoopController sub_2 = new LoopController();
            sub_2.setLoops(3);
            GenericController sub_3 = new GenericController();
            sub_2.addTestElement(new TestSampler("four"));
            sub_3.addTestElement(new TestSampler("five"));
            sub_3.addTestElement(new TestSampler("six"));
            sub_2.addTestElement(sub_3);
            sub_2.addTestElement(new TestSampler("seven"));
            controller.addTestElement(sub_2);
            String[] order = new String[] { "one", "two", "three", "four", "five", "six", "seven", "four", "five",
                    "six", "seven", "four", "five", "six", "seven" };
            int counter = 15;
            controller.setRunningVersion(true);
View Full Code Here

        }

        public void testLoopZeroTimes() throws Exception {
            LoopController loop = new LoopController();
            loop.setLoops(0);
            loop.addTestElement(new TestSampler("never run"));
            loop.initialize();
            assertNull(loop.next());
        }
View Full Code Here

        }

        public void testInfiniteLoop() throws Exception {
            LoopController loop = new LoopController();
            loop.setLoops(-1);
            loop.addTestElement(new TestSampler("never run"));
            loop.setRunningVersion(true);
            loop.initialize();
            for (int i = 0; i < 42; i++) {
                assertNotNull(loop.next());
            }
View Full Code Here

        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);
        }
View Full Code Here

TOP

Related Classes of org.apache.jmeter.junit.stubs.TestSampler

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.