Class DslWeightedSwitchController
- java.lang.Object
-
- us.abstracta.jmeter.javadsl.core.testelements.BaseTestElement
-
- us.abstracta.jmeter.javadsl.core.testelements.TestElementContainer<T,BaseThreadGroup.ThreadGroupChild>
-
- us.abstracta.jmeter.javadsl.core.controllers.BaseController<DslWeightedSwitchController>
-
- us.abstracta.jmeter.javadsl.core.controllers.DslWeightedSwitchController
-
- All Implemented Interfaces:
DslController,DslTestElement,BaseThreadGroup.ThreadGroupChild
public class DslWeightedSwitchController extends BaseController<DslWeightedSwitchController>
Selects a child in each iteration according to specified relative weights.Internally this uses BlazeMeter Weighted Switch Controller plugin.
This controller is handy when you want part of the test plan to act in a probabilistic manner switching between different alternatives.
If you configure for example children weights with (50, child1), (100, child2), (50, child3) and 10 iterations, then you will get this execution: child2, child1, child3, child2, child2, child1, child3, child2, child2, child1.
- Since:
- 0.53
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classDslWeightedSwitchController.CodeBuilder
-
Field Summary
Fields Modifier and Type Field Description static longDEFAULT_WEIGHT-
Fields inherited from class us.abstracta.jmeter.javadsl.core.testelements.TestElementContainer
children
-
Fields inherited from class us.abstracta.jmeter.javadsl.core.testelements.BaseTestElement
guiClass, name
-
-
Constructor Summary
Constructors Constructor Description DslWeightedSwitchController()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description org.apache.jmeter.testelement.TestElementbuildTestElement()org.apache.jorphan.collections.HashTreebuildTreeUnder(org.apache.jorphan.collections.HashTree parent, BuildTreeContext context)Builds the JMeter HashTree for this TestElement under the provided tree node.DslWeightedSwitchControllerchild(long weight, DslController child)Adds a child to the controller with a configured weight for selecting it in iterations.DslWeightedSwitchControllerchild(long weight, DslSampler child)Adds a child to the controller with a configured weight for selecting it in iterations.DslWeightedSwitchControllerchildren(BaseThreadGroup.ThreadGroupChild... children)Allows specifying children test elements which don't have an explicit weight associated.-
Methods inherited from class us.abstracta.jmeter.javadsl.core.testelements.BaseTestElement
buildConfiguredTestElement, buildTestElementGui, configureTestElement, durationToSeconds, loadBeanProperties, showAndWaitFrameWith, showFrameWith, showInGui, showTestElementGui
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface us.abstracta.jmeter.javadsl.core.DslTestElement
showInGui
-
-
-
-
Field Detail
-
DEFAULT_WEIGHT
public static final long DEFAULT_WEIGHT
- See Also:
- Constant Field Values
-
-
Method Detail
-
child
public DslWeightedSwitchController child(long weight, DslController child)
Adds a child to the controller with a configured weight for selecting it in iterations.- Parameters:
weight- is the weight to assign to this particular element for execution in iterations. Keep in mind that if you usechildren(ThreadGroupChild...)to add samplers or controllers, their default assigned weight will be 100.child- is the element to add as controller child that will be selected for execution during iterations according to given weight.- Returns:
- the controller for further configuration and usage.
-
child
public DslWeightedSwitchController child(long weight, DslSampler child)
Adds a child to the controller with a configured weight for selecting it in iterations.- Parameters:
weight- is the weight to assign to this particular element for execution in iterations. Keep in mind that if you usechildren(ThreadGroupChild...)to add samplers or controllers, their default assigned weight will be 100.child- is the element to add as controller child that will be selected for execution during iterations according to given weight.- Returns:
- the controller for further configuration and usage.
-
children
public DslWeightedSwitchController children(BaseThreadGroup.ThreadGroupChild... children)
Allows specifying children test elements which don't have an explicit weight associated.This is method should mainly be used to add elements which weight does not affect like listeners, timers, assertions, pre- and post-processors and config elements.
Note: If a sampler or controller is added with this method, it's weight will default to 100.
- Overrides:
childrenin classBaseController<DslWeightedSwitchController>- Parameters:
children- list of test elements to add as children of this controller.- Returns:
- the controller for further configuration and usage.
-
buildTestElement
public org.apache.jmeter.testelement.TestElement buildTestElement()
- Specified by:
buildTestElementin classBaseTestElement
-
buildTreeUnder
public org.apache.jorphan.collections.HashTree buildTreeUnder(org.apache.jorphan.collections.HashTree parent, BuildTreeContext context)Description copied from interface:DslTestElementBuilds the JMeter HashTree for this TestElement under the provided tree node.- Specified by:
buildTreeUnderin interfaceDslTestElement- Overrides:
buildTreeUnderin classTestElementContainer<DslWeightedSwitchController,BaseThreadGroup.ThreadGroupChild>- Parameters:
parent- the node which will be the parent for the created tree.context- context information which contains information shared by elements while building the test plan tree (eg: adding additional items to test plan when a particular protocol element is added).- Returns:
- The tree created under the parent node.
-
-