Search in sources :

Example 46 with SampleEvent

use of org.apache.jmeter.samplers.SampleEvent in project jmeter-plugins by undera.

the class JMXMonCollectorTest method testJMXMonSampleOccurred.

/**
 * Test of JMXMonSampleOccurred method, of class JMXMonCollector.
 */
@Test
public void testJMXMonSampleOccurred() {
    System.out.println("JMXMonSampleOccurred");
    SampleEvent event = new SampleEvent(new SampleResult(), "test");
    JMXMonCollector instance = new JMXMonCollector();
    instance.jmxMonSampleOccurred(event);
// TODO review the generated test code and remove the default call to fail.
}
Also used : SampleResult(org.apache.jmeter.samplers.SampleResult) SampleEvent(org.apache.jmeter.samplers.SampleEvent) Test(org.junit.Test)

Example 47 with SampleEvent

use of org.apache.jmeter.samplers.SampleEvent in project jmeter-plugins by undera.

the class JMXMonCollectorTest method testSampleOccurred.

/**
 * Test of sampleOccurred method, of class JMXMonCollector.
 */
@Test
public void testSampleOccurred() {
    System.out.println("sampleOccurred");
    SampleEvent event = null;
    JMXMonCollector instance = new JMXMonCollector();
    instance.sampleOccurred(event);
// TODO review the generated test code and remove the default call to fail.
}
Also used : SampleEvent(org.apache.jmeter.samplers.SampleEvent) Test(org.junit.Test)

Example 48 with SampleEvent

use of org.apache.jmeter.samplers.SampleEvent in project jmeter-plugins by undera.

the class PerfMonCollector method generateSample.

// need floating point precision for memory and cpu
@Override
public void generateSample(double value, String label) {
    PerfMonSampleResult res = new PerfMonSampleResult();
    res.setSampleLabel(label);
    res.setValue(value);
    res.setSuccessful(true);
    SampleEvent e = new SampleEvent(res, PERFMON);
    super.sampleOccurred(e);
}
Also used : SampleEvent(org.apache.jmeter.samplers.SampleEvent)

Example 49 with SampleEvent

use of org.apache.jmeter.samplers.SampleEvent in project jmeter-plugins by undera.

the class ConcurrencyThreadGroupTest method testStartNextLoop.

@Test
public void testStartNextLoop() throws Exception {
    JMeterContextService.getContext().setVariables(new JMeterVariables());
    TestSampleListener listener = new TestSampleListener();
    DebugSampler beforeSampler = new DebugSamplerExt();
    beforeSampler.setName("Before Test Action sampler");
    TestAction testAction = new TestAction();
    testAction.setAction(TestAction.RESTART_NEXT_LOOP);
    DebugSampler afterSampler = new DebugSamplerExt();
    afterSampler.setName("After Test Action sampler");
    ConcurrencyThreadGroup ctg = new ConcurrencyThreadGroup();
    ctg.setProperty(new StringProperty(AbstractThreadGroup.ON_SAMPLE_ERROR, AbstractThreadGroup.ON_SAMPLE_ERROR_CONTINUE));
    ctg.setRampUp("0");
    ctg.setTargetLevel("1");
    ctg.setSteps("0");
    // TODO: increase this value for debugging
    ctg.setHold("5");
    ctg.setIterationsLimit("10");
    ctg.setUnit("S");
    ListedHashTree hashTree = new ListedHashTree();
    hashTree.add(ctg);
    hashTree.add(ctg, beforeSampler);
    hashTree.add(ctg, testAction);
    hashTree.add(ctg, afterSampler);
    hashTree.add(ctg, listener);
    TestCompiler compiler = new TestCompiler(hashTree);
    hashTree.traverse(compiler);
    ListenerNotifier notifier = new ListenerNotifier();
    ctg.start(1, notifier, hashTree, new StandardJMeterEngine());
    ctg.waitThreadsStopped();
    for (SampleEvent event : listener.events) {
        assertEquals("Before Test Action sampler", event.getResult().getSampleLabel());
    }
}
Also used : JMeterVariables(org.apache.jmeter.threads.JMeterVariables) ListedHashTree(org.apache.jorphan.collections.ListedHashTree) DebugSampler(org.apache.jmeter.sampler.DebugSampler) TestCompiler(org.apache.jmeter.threads.TestCompiler) StandardJMeterEngine(org.apache.jmeter.engine.StandardJMeterEngine) StringProperty(org.apache.jmeter.testelement.property.StringProperty) ListenerNotifier(org.apache.jmeter.threads.ListenerNotifier) SampleEvent(org.apache.jmeter.samplers.SampleEvent) TestAction(org.apache.jmeter.sampler.TestAction) ArrivalsThreadGroupTest(com.blazemeter.jmeter.threads.arrivals.ArrivalsThreadGroupTest) Test(org.junit.Test)

Example 50 with SampleEvent

use of org.apache.jmeter.samplers.SampleEvent in project jmeter-plugins by undera.

the class ConsoleStatusLoggerTest method testSampleOccurred.

/**
 * Test of sampleOccurred method, of class ConsoleStatusLogger.
 */
@Test
public void testSampleOccurred() throws InterruptedException {
    System.out.println("sampleOccurred");
    SampleResult res = new SampleResult();
    res.setResponseCode("200");
    SampleEvent se = new SampleEvent(res, "testTG");
    ConsoleStatusLogger instance = new ConsoleStatusLogger();
    instance.testStarted();
    instance.sampleOccurred(se);
    instance.sampleOccurred(se);
    Thread.sleep(1020);
    instance.sampleOccurred(se);
    instance.sampleOccurred(se);
    Thread.sleep(1020);
    instance.sampleOccurred(se);
    instance.sampleOccurred(se);
}
Also used : SampleResult(org.apache.jmeter.samplers.SampleResult) SampleEvent(org.apache.jmeter.samplers.SampleEvent)

Aggregations

SampleEvent (org.apache.jmeter.samplers.SampleEvent)58 SampleResult (org.apache.jmeter.samplers.SampleResult)30 Test (org.junit.Test)17 CorrectedResultCollector (kg.apc.jmeter.vizualizers.CorrectedResultCollector)12 Test (org.junit.jupiter.api.Test)10 File (java.io.File)5 JMeterSerialTest (org.apache.jorphan.test.JMeterSerialTest)4 SampleSaveConfiguration (org.apache.jmeter.samplers.SampleSaveConfiguration)3 JMeterVariables (org.apache.jmeter.threads.JMeterVariables)3 IOException (java.io.IOException)2 ResultCollector (org.apache.jmeter.reporters.ResultCollector)2 StatisticalSampleResult (org.apache.jmeter.samplers.StatisticalSampleResult)2 ArrivalsThreadGroupTest (com.blazemeter.jmeter.threads.arrivals.ArrivalsThreadGroupTest)1 BufferedReader (java.io.BufferedReader)1 FileInputStream (java.io.FileInputStream)1 FileNotFoundException (java.io.FileNotFoundException)1 InputStream (java.io.InputStream)1 InputStreamReader (java.io.InputStreamReader)1 Reader (java.io.Reader)1 StringReader (java.io.StringReader)1