forked from Blazemeter/jmeter-bzm-plugins
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fixed sub results labels for JMeter 5.0 (Blazemeter#70)
* Fixed sub results labels for JMeter 5.0 * add test
- Loading branch information
Showing
3 changed files
with
70 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
64 changes: 64 additions & 0 deletions
64
parallel/src/test/java/com/blazemeter/jmeter/controller/ParallelListenerNotifierTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
package com.blazemeter.jmeter.controller; | ||
|
||
import org.apache.jmeter.samplers.SampleEvent; | ||
import org.apache.jmeter.samplers.SampleListener; | ||
import org.apache.jmeter.samplers.SampleResult; | ||
import org.apache.jmeter.testelement.AbstractTestElement; | ||
import org.junit.Test; | ||
|
||
import java.util.ArrayList; | ||
import java.util.List; | ||
|
||
import static org.junit.Assert.assertEquals; | ||
|
||
public class ParallelListenerNotifierTest { | ||
|
||
@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); | ||
} | ||
|
||
private static class SampleListenerExt extends AbstractTestElement implements SampleListener { | ||
int count = 0; | ||
@Override | ||
public void sampleOccurred(SampleEvent sampleEvent) { | ||
assertEquals("label", sampleEvent.getResult().getSampleLabel()); | ||
count++; | ||
} | ||
|
||
@Override | ||
public void sampleStarted(SampleEvent sampleEvent) { | ||
|
||
} | ||
|
||
@Override | ||
public void sampleStopped(SampleEvent sampleEvent) { | ||
|
||
} | ||
} | ||
|
||
|
||
} |