org.apache.jmeter.samplers.SampleListener Java Examples

The following examples show how to use org.apache.jmeter.samplers.SampleListener. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: ParallelListenerNotifier.java    From jmeter-bzm-plugins with Apache License 2.0 6 votes vote down vote up
@Override
public void notifyListeners(SampleEvent res, List<SampleListener> listeners) {
    log.debug("Adding subresult " + res.getResult());
    SampleResult result = res.getResult();
    String label = result.getSampleLabel();
    synchronized (this) {
        container.addSubResult(result);
        if (!res.getResult().isSuccessful()) {
            container.setSuccessful(false);
        }
    }
    // because https://bz.apache.org/bugzilla/show_bug.cgi?id=62550 in JMeter 5.0
    result.setSampleLabel(label);
    super.notifyListeners(res, listeners);
    log.debug("Added subresult " + res.getResult());
}
 
Example #2
Source File: ParallelListenerNotifierTest.java    From jmeter-bzm-plugins with Apache License 2.0 5 votes vote down vote up
@Test
public void testSubResultsLabels() {
    ParallelListenerNotifier notifier = new ParallelListenerNotifier();
    SampleResult container = new SampleResult() {
        @Override
        public void addSubResult(SampleResult subResult) {
            // generate JMeter 5.0 behaviour
            // https://bz.apache.org/bugzilla/show_bug.cgi?id=62550
            subResult.setSampleLabel("new Label");
        }
    };


    notifier.setContainer(container);

    SampleResult subSampler = new SampleResult();
    subSampler.setSampleLabel("label");

    SampleListenerExt sampleListenerExt = new SampleListenerExt();
    List<SampleListener> list = new ArrayList<>();
    list.add(sampleListenerExt);


    notifier.notifyListeners(new SampleEvent(subSampler, ""), list);
    assertEquals("label", subSampler.getSampleLabel());
    assertEquals(1, sampleListenerExt.count);
}
 
Example #3
Source File: TreeClonerTG.java    From jmeter-debugger with Apache License 2.0 5 votes vote down vote up
private TestElement getAlteredElement(TestElement cloned) {
    boolean isWrappable = !(cloned instanceof TransactionController) && !(cloned instanceof TestFragmentController) && !(cloned instanceof ReplaceableController);

    TestElement userObject = cloned;
    if (!isWrappable) {
        log.debug("Forcing unwrapped: " + cloned);
    } else if (cloned instanceof AbstractThreadGroup) {
        userObject = new DebuggingThreadGroup();
        userObject.setProperty(TestElement.GUI_CLASS, DebuggingThreadGroupGui.class.getCanonicalName());
    } else if (cloned instanceof Controller) {
        userObject = getController(cloned);
    } else if (cloned instanceof PreProcessor) {
        userObject = new PreProcessorDebug();
    } else if (cloned instanceof Timer) {
        userObject = new TimerDebug();
    } else if (cloned instanceof Sampler) {
        userObject = new SamplerDebug();
    } else if (cloned instanceof PostProcessor) {
        userObject = new PostProcessorDebug();
    } else if (cloned instanceof Assertion) {
        userObject = new AssertionDebug();
    } else if (cloned instanceof SampleListener) {
        userObject = new SampleListenerDebug();
    } else {
        log.debug("Keeping element unwrapped: " + cloned);
    }
    return userObject;
}