本文整理汇总了Java中org.apache.jmeter.control.TransactionController类的典型用法代码示例。如果您正苦于以下问题:Java TransactionController类的具体用法?Java TransactionController怎么用?Java TransactionController使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
TransactionController类属于org.apache.jmeter.control包,在下文中一共展示了TransactionController类的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: next
import org.apache.jmeter.control.TransactionController; //导入依赖的package包/类
@Override
public Sampler next() {
if (chosen) {
Sampler result = super.next();
if (result == null || currentCopy != current ||
(super.getSubControllers().get(current) instanceof TransactionController)) {
reset();
for (TestElement element : super.getSubControllers()) {
if (element instanceof Controller) {
((Controller) element).triggerEndOfLoop();
}
}
return null;
}
return result;
} else {
chosen = true;
choose();
return super.next();
}
}
示例2: saveTransactionControllerConfigs
import org.apache.jmeter.control.TransactionController; //导入依赖的package包/类
private void saveTransactionControllerConfigs(TransactionController tc) {
List<ConfigTestElement> configs = new LinkedList<>();
List<Controller> controllers = new LinkedList<>();
List<SampleListener> listeners = new LinkedList<>();
List<Timer> timers = new LinkedList<>();
List<Assertion> assertions = new LinkedList<>();
LinkedList<PostProcessor> posts = new LinkedList<>();
LinkedList<PreProcessor> pres = new LinkedList<>();
for (int i = stack.size(); i > 0; i--) {
addDirectParentControllers(controllers, stack.get(i - 1));
for (Object item : testTree.list(stack.subList(0, i))) {
if (item instanceof SampleListener) {
listeners.add((SampleListener) item);
}
if (item instanceof Assertion) {
assertions.add((Assertion) item);
}
}
}
SamplePackage pack = new SamplePackage(configs, listeners, timers, assertions,
posts, pres, controllers);
pack.setSampler(new TransactionSampler(tc, tc.getName()));
pack.setRunningVersion(true);
transactionControllerConfigMap.put(tc, pack);
}
示例3: addTransactionController
import org.apache.jmeter.control.TransactionController; //导入依赖的package包/类
/**
* Helper method to add a Transaction Controller to contain the samplers.
* Called from Application Thread that needs to update GUI (JMeterTreeModel)
* @param model
* Test component tree model
* @param node
* Node in the tree where we will add the Controller
* @param name
* A name for the Controller
* @throws InvocationTargetException
* @throws InterruptedException
*/
private void addTransactionController(final JMeterTreeModel model, final JMeterTreeNode node, String name)
throws InterruptedException, InvocationTargetException {
final TransactionController sc = new TransactionController();
sc.setIncludeTimers(false);
sc.setProperty(TestElement.GUI_CLASS, TRANSACTION_CONTROLLER_GUI);
sc.setName(name);
JMeterUtils.runSafe(new Runnable() {
@Override
public void run() {
try {
model.addComponent(sc, node);
} catch (IllegalUserActionException e) {
log.error("Program error", e);
throw new Error(e);
}
}
});
}
示例4: saveTransactionControllerConfigs
import org.apache.jmeter.control.TransactionController; //导入依赖的package包/类
private void saveTransactionControllerConfigs(TransactionController tc) {
List<ConfigTestElement> configs = new LinkedList<ConfigTestElement>();
List<Controller> controllers = new LinkedList<Controller>();
List<SampleListener> listeners = new LinkedList<SampleListener>();
List<Timer> timers = new LinkedList<Timer>();
List<Assertion> assertions = new LinkedList<Assertion>();
LinkedList<PostProcessor> posts = new LinkedList<PostProcessor>();
LinkedList<PreProcessor> pres = new LinkedList<PreProcessor>();
for (int i = stack.size(); i > 0; i--) {
addDirectParentControllers(controllers, stack.get(i - 1));
for (Object item : testTree.list(stack.subList(0, i))) {
if (item instanceof SampleListener) {
listeners.add((SampleListener) item);
}
if (item instanceof Assertion) {
assertions.add((Assertion) item);
}
}
}
SamplePackage pack = new SamplePackage(configs, listeners, timers, assertions,
posts, pres, controllers);
pack.setSampler(new TransactionSampler(tc, tc.getName()));
pack.setRunningVersion(true);
transactionControllerConfigMap.put(tc, pack);
}
示例5: initilizeElement
import org.apache.jmeter.control.TransactionController; //导入依赖的package包/类
@Override
public TestElement initilizeElement() {
TransactionController ele = new TransactionController();
this.baseElement(ele, "Transaction Controller");
ele.setGenerateParentSample(false);
ele.setIncludeTimers(false);
return ele;
}
示例6: configureTransactionSampler
import org.apache.jmeter.control.TransactionController; //导入依赖的package包/类
/**
* Configures Transaction Sampler from SamplePackage extracted from Test plan and returns it
* @param transactionSampler {@link TransactionSampler}
* @return {@link SamplePackage}
*/
public SamplePackage configureTransactionSampler(TransactionSampler transactionSampler) {
TransactionController controller = transactionSampler.getTransactionController();
SamplePackage pack = transactionControllerConfigMap.get(controller);
pack.setSampler(transactionSampler);
return pack;
}
示例7: subtractNode
import org.apache.jmeter.control.TransactionController; //导入依赖的package包/类
/** {@inheritDoc} */
@Override
public void subtractNode() {
LOG.debug("Subtracting node, stack size = " + stack.size());
TestElement child = stack.getLast();
trackIterationListeners(stack);
if (child instanceof Sampler) {
saveSamplerConfigs((Sampler) child);
}
else if(child instanceof TransactionController) {
saveTransactionControllerConfigs((TransactionController) child);
}
stack.removeLast();
if (stack.size() > 0) {
TestElement parent = stack.getLast();
boolean duplicate = false;
// Bug 53750: this condition used to be in ObjectPair#addTestElements()
if (parent instanceof Controller && (child instanceof Sampler || child instanceof Controller)) {
if (parent instanceof TestCompilerHelper) {
TestCompilerHelper te = (TestCompilerHelper) parent;
duplicate = !te.addTestElementOnce(child);
} else { // this is only possible for 3rd party controllers by default
ObjectPair pair = new ObjectPair(child, parent);
synchronized (PAIRING) {// Called from multiple threads
if (!PAIRING.contains(pair)) {
parent.addTestElement(child);
PAIRING.add(pair);
} else {
duplicate = true;
}
}
}
}
if (duplicate) {
LOG.warn("Unexpected duplicate for " + parent.getClass().getName() + " and " + child.getClass().getName());
}
}
}
示例8: findMainNodesAndTrees
import org.apache.jmeter.control.TransactionController; //导入依赖的package包/类
private void findMainNodesAndTrees(HashTree hashTree)
{
hashTree.traverse(new HashTreeTraverser()
{
@Override
public void addNode(Object node, HashTree subTree)
{
System.out.println("Node: " + node.toString());
if (node instanceof Arguments && ((Arguments)node).getName().equalsIgnoreCase("UDV"))
{
vars = (Arguments)node;
}
if (node instanceof TransactionController)
{
transactionControllerSubTree = subTree;
}
}
@Override
public void processPath()
{
}
@Override
public void subtractNode()
{
}
});
}
示例9: modifyTestElement
import org.apache.jmeter.control.TransactionController; //导入依赖的package包/类
@Override
public void modifyTestElement(TestElement el) {
configureTestElement(el);
((TransactionController) el).setParent(parent.isSelected());
TransactionController tc = ((TransactionController) el);
tc.setParent(parent.isSelected());
tc.setIncludeTimers(includeTimers.isSelected());
}
示例10: subtractNode
import org.apache.jmeter.control.TransactionController; //导入依赖的package包/类
/** {@inheritDoc} */
@Override
public void subtractNode() {
LOG.debug("Subtracting node, stack size = " + stack.size());
TestElement child = stack.getLast();
trackIterationListeners(stack);
if (child instanceof Sampler) {
saveSamplerConfigs((Sampler) child);
}
else if(child instanceof TransactionController) {
saveTransactionControllerConfigs((TransactionController) child);
}
stack.removeLast();
if (stack.size() > 0) {
TestElement parent = stack.getLast();
boolean duplicate = false;
// Bug 53750: this condition used to be in ObjectPair#addTestElements()
if (parent instanceof Controller && (child instanceof Sampler || child instanceof Controller)) {
if (!IS_USE_STATIC_SET && parent instanceof TestCompilerHelper) {
TestCompilerHelper te = (TestCompilerHelper) parent;
duplicate = !te.addTestElementOnce(child);
} else { // this is only possible for 3rd party controllers by default
ObjectPair pair = new ObjectPair(child, parent);
synchronized (PAIRING) {// Called from multiple threads
if (!PAIRING.contains(pair)) {
parent.addTestElement(child);
PAIRING.add(pair);
} else {
duplicate = true;
}
}
}
}
if (duplicate) {
LOG.warn("Unexpected duplicate for " + parent.getClass().getName() + " and " + child.getClass().getName());
}
}
}
示例11: testNestedTransactionControllers
import org.apache.jmeter.control.TransactionController; //导入依赖的package包/类
@Test
public void testNestedTransactionControllers() throws Exception {
JMeterContextService.getContext().setVariables(new JMeterVariables());
TestSampleListener listener = new TestSampleListener();
// top WSC
WeightedSwitchController topWSC = new WeightedSwitchController();
PowerTableModel topPTM = new PowerTableModel(new String[]{"name", WeightedSwitchController.WEIGHTS}, new Class[]{String.class, String.class});
topPTM.addRow(new String[]{"ex1", "10"});
topPTM.addRow(new String[]{"ex2", "20"});
topWSC.setData(topPTM);
// first child: transaction controller
TransactionController ex1 = new TransactionController();
ex1.setName("ex1");
DebugSampler example1_1 = new DebugSampler();
example1_1.setName("example1_1");
DebugSampler example1_2 = new DebugSampler();
example1_2.setName("example1_2");
// second child: transaction controller
TransactionController ex2 = new TransactionController();
ex2.setName("ex2");
DebugSampler example2_1 = new DebugSampler();
example2_1.setName("example2_1");
DebugSampler example2_2 = new DebugSampler();
example2_2.setName("example2_2");
// main loop
LoopController loop = new LoopController();
loop.setLoops(60);
loop.setContinueForever(false);
// test tree
ListedHashTree hashTree = new ListedHashTree();
hashTree.add(loop);
hashTree.add(loop, topWSC);
hashTree.add(topWSC, listener);
hashTree.add(topWSC, ex1);
hashTree.add(ex1, example1_1);
hashTree.add(ex1, example1_2);
hashTree.add(ex1, listener);
hashTree.add(topWSC, ex2);
hashTree.add(ex2, example2_1);
hashTree.add(ex2, example2_2);
hashTree.add(ex2, listener);
TestCompiler compiler = new TestCompiler(hashTree);
hashTree.traverse(compiler);
ThreadGroup threadGroup = new ThreadGroup();
threadGroup.setNumThreads(1);
ListenerNotifier notifier = new ListenerNotifier();
JMeterThread thread = new JMeterThread(hashTree, threadGroup, notifier);
thread.setThreadGroup(threadGroup);
thread.setOnErrorStopThread(true);
thread.run();
Map<String, Integer> totalResults = new HashMap<>();
for (SampleEvent event : listener.events) {
String label = event.getResult().getSampleLabel();
if (totalResults.containsKey(label)) {
totalResults.put(label, totalResults.get(label) + 1);
} else {
totalResults.put(label, 1);
}
}
assertEquals(120, listener.events.size());
assertEquals(20, (int) totalResults.get("example1_1"));
assertEquals(40, (int) totalResults.get("example2_1"));
assertEquals(20, (int) totalResults.get("ex1")); // transaction result
assertEquals(40, (int) totalResults.get("ex2")); // transaction result
}
示例12: createTestElement
import org.apache.jmeter.control.TransactionController; //导入依赖的package包/类
@Override
public TestElement createTestElement() {
TransactionController lc = new TransactionController();
configureTestElement(lc);
return lc;
}
示例13: configure
import org.apache.jmeter.control.TransactionController; //导入依赖的package包/类
@Override
public void configure(TestElement el) {
super.configure(el);
parent.setSelected(((TransactionController) el).isParent());
includeTimers.setSelected(((TransactionController) el).isIncludeTimers());
}