• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Java Sampler类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Java中org.apache.jmeter.samplers.Sampler的典型用法代码示例。如果您正苦于以下问题:Java Sampler类的具体用法?Java Sampler怎么用?Java Sampler使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



Sampler类属于org.apache.jmeter.samplers包,在下文中一共展示了Sampler类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: process

import org.apache.jmeter.samplers.Sampler; //导入依赖的package包/类
@Override
public void process(){
    final BeanShellInterpreter bshInterpreter = getBeanShellInterpreter();
    if (bshInterpreter == null) {
        log.error("BeanShell not found");
        return;
    }
    JMeterContext jmctx = JMeterContextService.getContext();
    Sampler sam = jmctx.getCurrentSampler();
    try {
        // Add variables for access to context and variables
        bshInterpreter.set("sampler", sam);//$NON-NLS-1$
        processFileOrScript(bshInterpreter);
    } catch (JMeterException e) {
        log.warn("Problem in BeanShell script "+e);
    }
}
 
开发者ID:botelhojp,项目名称:apache-jmeter-2.10,代码行数:18,代码来源:BeanShellPreProcessor.java


示例2: testBug54467

import org.apache.jmeter.samplers.Sampler; //导入依赖的package包/类
public void testBug54467() throws Exception {
    JMeterContext jmctx = JMeterContextService.getContext();
    LoopController loop = new LoopController();
    Map<String, String> variables = new HashMap<String, String>();
    ReplaceStringWithFunctions transformer = new ReplaceStringWithFunctions(new CompoundVariable(), variables);
    jmctx.setVariables(new JMeterVariables());

    StringProperty prop = new StringProperty(LoopController.LOOPS,"${__Random(1,12,)}");
    JMeterProperty newProp = transformer.transformValue(prop);
    newProp.setRunningVersion(true);
    
    loop.setProperty(newProp);
    loop.addTestElement(new TestSampler("random run"));
    loop.setRunningVersion(true);
    loop.initialize();
    int loops = loop.getLoops();
    for (int i = 0; i < loops; i++) {
        Sampler s = loop.next();
        assertNotNull(s);
    }
    assertNull(loop.next());    
}
 
开发者ID:botelhojp,项目名称:apache-jmeter-2.10,代码行数:23,代码来源:TestLoopController.java


示例3: next

import org.apache.jmeter.samplers.Sampler; //导入依赖的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();
    }
}
 
开发者ID:Blazemeter,项目名称:jmeter-bzm-plugins,代码行数:23,代码来源:WeightedSwitchController.java


示例4: getChildItems

import org.apache.jmeter.samplers.Sampler; //导入依赖的package包/类
private Map<JMeterTreeNode, Boolean> getChildItems(JMeterTreeNode root, WeightedSwitchController element) {
    Map<JMeterTreeNode, Boolean> result = new LinkedHashMap<>();
    for (int i = 0; i < root.getChildCount(); i++) {
        JMeterTreeNode child = (JMeterTreeNode) root.getChildAt(i);

        TestElement te = child.getTestElement();
        if (element != root.getTestElement()) {
            result.putAll(getChildItems(child, element));
        } else {
            if (te instanceof Sampler || te instanceof Controller) {
                result.put(child, te.isEnabled());
            }
        }
    }
    return result;
}
 
开发者ID:Blazemeter,项目名称:jmeter-bzm-plugins,代码行数:17,代码来源:WeightedSwitchControllerGui.java


示例5: testGeneric

import org.apache.jmeter.samplers.Sampler; //导入依赖的package包/类
@Test
public void testGeneric() {
    WeightedSwitchController obj = new WeightedSwitchController();
    obj.addTestElement(getSampler("0"));
    obj.addTestElement(getSampler("1"));
    obj.addTestElement(getSampler("2"));
    obj.addTestElement(getSampler("5"));
    PowerTableModel mdl = new PowerTableModel(new String[]{"name", WeightedSwitchController.WEIGHTS}, new Class[]{String.class, String.class});
    mdl.addRow(new String[]{"0", "0"});
    mdl.addRow(new String[]{"1", "1"});
    mdl.addRow(new String[]{"2", "2"});
    mdl.addRow(new String[]{"5", "5"});
    obj.setData(mdl);

    for (int n = 0; n < 800; n++) {
        Sampler s = obj.next();
        log.info("Sampler: " + s.getName());
        Assert.assertNotNull(s);
        Assert.assertNull(obj.next());
        Assert.assertNotEquals(s.getName(), "0");
    }
}
 
开发者ID:Blazemeter,项目名称:jmeter-bzm-plugins,代码行数:23,代码来源:WeightedSwitchControllerTest.java


示例6: actionPerformed

import org.apache.jmeter.samplers.Sampler; //导入依赖的package包/类
@Override
public void actionPerformed(ActionEvent actionEvent) {
    result.clear();
    if (exprField.getText().isEmpty()) {
        return;
    }

    CompoundVariable masterFunction = new CompoundVariable(exprField.getText());
    SampleResult previousResult = context.getPreviousResult();
    Sampler currentSampler = context.getCurrentSampler();
    try {
        result.setText(masterFunction.execute(previousResult, currentSampler));
    } catch (Throwable e) {
        ByteArrayOutputStream text = new ByteArrayOutputStream(1024);
        e.printStackTrace(new PrintStream(text));
        result.setText(text.toString());
        result.scrollToTop();
    }
}
 
开发者ID:Blazemeter,项目名称:jmeter-debugger,代码行数:20,代码来源:EvaluatePanel.java


示例7: next

import org.apache.jmeter.samplers.Sampler; //导入依赖的package包/类
/**
 * @see org.apache.jmeter.control.Controller#next()
 */
@Override
public Sampler next() {
    // We should only evalute the condition if it is the first
    // time ( first "iteration" ) we are called.
    // For subsequent calls, we are inside the IfControllerGroup,
    // so then we just pass the control to the next item inside the if control
    boolean result = true;
    if(isEvaluateAll() || isFirst()) {
        result = isUseExpression() ? 
                evaluateExpression(getCondition())
                :
                evaluateCondition(getCondition());
    }

    if (result) {
        return super.next();
    }
    // If-test is false, need to re-initialize indexes
    try {
        initializeSubControllers();
        return nextIsNull();
    } catch (NextIsNullException e1) {
        return null;
    }
}
 
开发者ID:johrstrom,项目名称:cloud-meter,代码行数:29,代码来源:IfController.java


示例8: nextIsAController

import org.apache.jmeter.samplers.Sampler; //导入依赖的package包/类
/**
 * {@inheritDoc}
 */
@Override
protected Sampler nextIsAController(Controller controller) throws NextIsNullException {
    Sampler sampler = controller.next();
    if (sampler == null) {
        currentReturnedNull(controller);
        return next();
    }
    currentReturnedAtLeastOne = true;
    if (getStyle() == IGNORE_SUB_CONTROLLERS) {
        incrementCurrent();
        skipNext = true;
    } else {
        searchStart = null;
    }
    return sampler;
}
 
开发者ID:johrstrom,项目名称:cloud-meter,代码行数:20,代码来源:InterleaveControl.java


示例9: next

import org.apache.jmeter.samplers.Sampler; //导入依赖的package包/类
/**
 * @see org.apache.jmeter.control.Controller#next()
 */
@Override
public Sampler next() {
    if (StringUtils.isEmpty(getLockName())) {
        log.warn("Empty lock name in Critical Section Controller:"
                + getName());
        return super.next();
    }
    if (isFirst()) {
        // Take the lock for first child element
        long startTime = System.currentTimeMillis();
        if (this.currentLock == null) {
            this.currentLock = getOrCreateLock();
        }
        this.currentLock.lock();
        long endTime = System.currentTimeMillis();
        if (log.isDebugEnabled()) {
            log.debug(Thread.currentThread().getName()
                    + " acquired lock:'" + getLockName()
                    + "' in Critical Section Controller " + getName()
                    + " in:" + (endTime - startTime) + " ms");
        }
    }
    return super.next();
}
 
开发者ID:johrstrom,项目名称:cloud-meter,代码行数:28,代码来源:CriticalSectionController.java


示例10: nextIsAController

import org.apache.jmeter.samplers.Sampler; //导入依赖的package包/类
@Override
protected Sampler nextIsAController(Controller controller) throws NextIsNullException {
    if (!isGenerateParentSample()) {
        return super.nextIsAController(controller);
    }
    Sampler returnValue;
    Sampler sampler = controller.next();
    if (sampler == null) {
        currentReturnedNull(controller);
        // We need to call the super.next, instead of this.next, which is done in GenericController,
        // because if we call this.next(), it will return the TransactionSampler, and we do not want that.
        // We need to get the next real sampler or controller
        returnValue = super.next();
    } else {
        returnValue = sampler;
    }
    return returnValue;
}
 
开发者ID:johrstrom,项目名称:cloud-meter,代码行数:19,代码来源:TransactionController.java


示例11: doEndTransactionSampler

import org.apache.jmeter.samplers.Sampler; //导入依赖的package包/类
private SampleResult doEndTransactionSampler(
                        TransactionSampler transactionSampler, 
                        Sampler parent,
                        SamplePackage transactionPack,
                        JMeterContext threadContext) {
    SampleResult transactionResult;
    // Get the transaction sample result
    transactionResult = transactionSampler.getTransactionResult();
    transactionResult.setThreadName(threadName);
    transactionResult.setGroupThreads(threadGroup.getNumberOfThreads());
    transactionResult.setAllThreads(JMeterContextService.getNumberOfThreads());

    // Check assertions for the transaction sample
    checkAssertions(transactionPack.getAssertions(), transactionResult, threadContext);
    // Notify listeners with the transaction sample result
    if (!(parent instanceof TransactionSampler)) {
        notifyListeners(transactionPack.getSampleListeners(), transactionResult);
    }
    compiler.done(transactionPack);
    return transactionResult;
}
 
开发者ID:johrstrom,项目名称:cloud-meter,代码行数:22,代码来源:JMeterThread.java


示例12: interrupt

import org.apache.jmeter.samplers.Sampler; //导入依赖的package包/类
/** {@inheritDoc} */
@Override
public boolean interrupt(){
    try {
        interruptLock.lock();
        Sampler samp = currentSampler; // fetch once; must be done under lock
        if (samp instanceof Interruptible){ // (also protects against null)
            log.warn("Interrupting: " + threadName + " sampler: " +samp.getName());
            try {
                boolean found = ((Interruptible)samp).interrupt();
                if (!found) {
                    log.warn("No operation pending");
                }
                return found;
            } catch (Exception e) {
                log.warn("Caught Exception interrupting sampler: "+e.toString());
            }
        } else if (samp != null){
            log.warn("Sampler is not Interruptible: "+samp.getName());
        }
    } finally {
        interruptLock.unlock();            
    }
    return false;
}
 
开发者ID:johrstrom,项目名称:cloud-meter,代码行数:26,代码来源:JMeterThread.java


示例13: configureWithConfigElements

import org.apache.jmeter.samplers.Sampler; //导入依赖的package包/类
private void configureWithConfigElements(Sampler sam, List<ConfigTestElement> configs) {
    sam.clearTestElementChildren();
    for (ConfigTestElement config  : configs) {
        if (!(config instanceof NoConfigMerge)) 
        {
            if(sam instanceof ConfigMergabilityIndicator) {
                if(((ConfigMergabilityIndicator)sam).applies(config)) {
                    sam.addTestElement(config);
                }
            } else {
                // Backward compatibility
                sam.addTestElement(config);
            }
        }
    }
}
 
开发者ID:johrstrom,项目名称:cloud-meter,代码行数:17,代码来源:TestCompiler.java


示例14: execute

import org.apache.jmeter.samplers.Sampler; //导入依赖的package包/类
/** {@inheritDoc} */
@Override
public String execute(SampleResult previousResult, Sampler currentSampler)
        throws InvalidVariableException {
    // return JMeterContextService.getContext().getCurrentSampler().getName();
    String name = "";
    if (currentSampler != null) { // will be null if function is used on TestPlan
        name = currentSampler.getName();
    }
    if (values.length > 0){
        JMeterVariables vars = getVariables();
        if (vars != null) {// May be null if function is used on TestPlan
            String varName = ((CompoundVariable) values[0]).execute().trim();
            if (varName.length() > 0) {
                vars.put(varName, name);
            }
        }
    }
    return name;
}
 
开发者ID:johrstrom,项目名称:cloud-meter,代码行数:21,代码来源:SamplerName.java


示例15: execute

import org.apache.jmeter.samplers.Sampler; //导入依赖的package包/类
/** {@inheritDoc} */
@Override
public String execute(SampleResult previousResult, Sampler currentSampler)
        throws InvalidVariableException {
    String stringToLog = ((CompoundVariable) values[0]).execute();

    String priorityString;
    if (values.length > 1) { // We have a default
        priorityString = ((CompoundVariable) values[1]).execute();
        if (priorityString.length() == 0) {
            priorityString = DEFAULT_PRIORITY;
        }
    } else {
        priorityString = DEFAULT_PRIORITY;
    }

    Throwable t = null;
    if (values.length > 2) { // Throwable wanted
        t = new Throwable(((CompoundVariable) values[2]).execute());
    }

    LogFunction.logDetails(log, stringToLog, priorityString, t, "");

    return "";

}
 
开发者ID:johrstrom,项目名称:cloud-meter,代码行数:27,代码来源:LogFunction2.java


示例16: execute

import org.apache.jmeter.samplers.Sampler; //导入依赖的package包/类
/** {@inheritDoc} */
@Override
public String execute(SampleResult previousResult, Sampler currentSampler)
        throws InvalidVariableException {

    StringBuilder sb = new StringBuilder(values.length);
    for (Object val : values) {
        String numberString = ((CompoundVariable) val).execute().trim();
        try {
            long value = Long.decode(numberString).longValue();
            char ch = (char) value;
            sb.append(ch);
        } catch (NumberFormatException e) {
            log.warn("Could not parse " + numberString + " : " + e);
        }
    }
    return sb.toString();

}
 
开发者ID:johrstrom,项目名称:cloud-meter,代码行数:20,代码来源:CharFunction.java


示例17: execute

import org.apache.jmeter.samplers.Sampler; //导入依赖的package包/类
/** {@inheritDoc} */
@Override
public String execute(SampleResult previousResult, Sampler currentSampler)
        throws InvalidVariableException {
    String propertyName = ((CompoundVariable) values[0]).execute();
    String propertyDefault = propertyName;
    if (values.length > 2) { // We have a 3rd parameter
        propertyDefault = ((CompoundVariable) values[2]).execute();
    }
    String propertyValue = JMeterUtils.getPropDefault(propertyName, propertyDefault);
    if (values.length > 1) {
        String variableName = ((CompoundVariable) values[1]).execute();
        if (variableName.length() > 0) {// Allow for empty name
            final JMeterVariables variables = getVariables();
            if (variables != null) {
                variables.put(variableName, propertyValue);
            }
        }
    }
    return propertyValue;

}
 
开发者ID:johrstrom,项目名称:cloud-meter,代码行数:23,代码来源:Property.java


示例18: execute

import org.apache.jmeter.samplers.Sampler; //导入依赖的package包/类
/** {@inheritDoc} */
@Override
public String execute(SampleResult previousResult, Sampler currentSampler)
        throws InvalidVariableException {

    /*
     * boolean fullHostName = false; if (((CompoundFunction) values[0])
     * .execute() .toLowerCase() .equals("true")) { fullHostName = true; }
     */

    String value = compute();

    if (values.length >= 1){// we have a variable name
        JMeterVariables vars = getVariables();
        if (vars != null) {// May be null if function is used on TestPlan
            String varName = ((CompoundVariable) values[0]).execute().trim();
            if (varName.length() > 0) {
                vars.put(varName, value);
            }
        }
    }
    return value;

}
 
开发者ID:johrstrom,项目名称:cloud-meter,代码行数:25,代码来源:AbstractHostIPName.java


示例19: execute

import org.apache.jmeter.samplers.Sampler; //导入依赖的package包/类
/** {@inheritDoc} */
@Override
public String execute(SampleResult previousResult, Sampler currentSampler)
        throws InvalidVariableException {


    long min = Long.parseLong(minimum.execute().trim());
    long max = Long.parseLong(maximum.execute().trim());

    long rand = ThreadLocalRandom.current().nextLong(min, max+1);

    String randString = Long.toString(rand);

    if (varName != null) {
        JMeterVariables vars = getVariables();
        final String varTrim = varName.execute().trim();
        if (vars != null && varTrim.length() > 0){// vars will be null on TestPlan
            vars.put(varTrim, randString);
        }
    }

    return randString;

}
 
开发者ID:johrstrom,项目名称:cloud-meter,代码行数:25,代码来源:Random.java


示例20: execute

import org.apache.jmeter.samplers.Sampler; //导入依赖的package包/类
/** {@inheritDoc} */
@Override
public String execute(SampleResult previousResult, Sampler currentSampler)
        throws InvalidVariableException {

    JMeterContext jmctx = JMeterContextService.getContext();
    JMeterVariables vars = jmctx.getVariables();

    String script = ((CompoundVariable) values[0]).execute();
    // Allow variable to be omitted
    String varName = values.length < 2 ? null : ((CompoundVariable) values[1]).execute().trim();
    String resultStr = "";

    if(USE_RHINO_ENGINE) {
        resultStr = executeWithRhino(previousResult, currentSampler, jmctx,
            vars, script, varName);
    } else {
        resultStr = executeWithNashorn(previousResult, currentSampler, jmctx,
                vars, script, varName);
    }

    return resultStr;

}
 
开发者ID:johrstrom,项目名称:cloud-meter,代码行数:25,代码来源:JavaScript.java



注:本文中的org.apache.jmeter.samplers.Sampler类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java VangavException类代码示例发布时间:2022-05-22
下一篇:
Java TextSymbolizer类代码示例发布时间:2022-05-22
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap