当前位置: 首页>>代码示例>>Java>>正文


Java JMeterContext类代码示例

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


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

示例1: process

import org.apache.jmeter.threads.JMeterContext; //导入依赖的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.threads.JMeterContext; //导入依赖的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: send

import org.apache.jmeter.threads.JMeterContext; //导入依赖的package包/类
@Override
public void send(JMeterContext context, SampleResult result) {
    JMeterVariables variables = context.getVariables();
    ConcurrentHashMap<String, MockLwM2mClient> clients = (ConcurrentHashMap<String, MockLwM2mClient>) variables.getObject("lwm2mClients");
    MockLwM2mClient client = clients.get(endpoint);
    if (client != null) {
        SimpleResource resource = (SimpleResource) client.getObject(objectId).getChild(instanceId).getChild(resourceId);
        result.sampleStart();
        if (resource != null) {
            resource.setResourceValue(Float.toString(rng.nextInt(100)));
            result.setSuccessful(true);
            log.debug("Sent observation for " + objectId + "/" + instanceId + "/" + resourceId);
        } else {
            result.setSuccessful(false);
            log.debug("Could not send observation for " + objectId + "/" + instanceId + "/" + resourceId);
        }
        result.sampleEnd();
    }
}
 
开发者ID:vears91,项目名称:lwm2m-jmeter,代码行数:20,代码来源:NotifyObserversSampler.java

示例4: changeVariablesMap

import org.apache.jmeter.threads.JMeterContext; //导入依赖的package包/类
private void changeVariablesMap() {
    try {
        JMeterContext context = this.getThreadContext();
        if (context != null && context.getVariables() != null) {
            JMeterVariables jMeterVariables = context.getVariables();
            Class<JMeterVariables> cls = JMeterVariables.class;
            Field variablesField = cls.getDeclaredField("variables");
            variablesField.setAccessible(true);
            Object obj = variablesField.get(jMeterVariables);
            synchronized (obj) {
                if (obj instanceof Map) {
                    Map variables = (Map) obj;
                    if (!(variables instanceof ConcurrentHashMap)) {
                        variablesField.set(jMeterVariables, new ConcurrentHashMap(variables));
                    }
                } else {
                    log.warn("Unexpected variables map type " + obj.getClass().getName());
                }
            }
        }
    } catch (Throwable ex) {
        log.warn("Cannot change variables map ", ex);
    }
}
 
开发者ID:Blazemeter,项目名称:jmeter-bzm-plugins,代码行数:25,代码来源:ParallelSampler.java

示例5: setup

import org.apache.jmeter.threads.JMeterContext; //导入依赖的package包/类
@Before
public void setup() throws IOException {

    zkServer = new EmbeddedZookeeper();

    String zkConnect = ZKHOST + ":" + zkServer.port();
    zkClient = new ZkClient(zkConnect, 30000, 30000, ZKStringSerializer$.MODULE$);
    ZkUtils zkUtils = ZkUtils.apply(zkClient, false);

    Properties brokerProps = new Properties();
    brokerProps.setProperty("zookeeper.connect", zkConnect);
    brokerProps.setProperty("broker.id", "0");
    brokerProps.setProperty("log.dirs", Files.createTempDirectory("kafka-").toAbsolutePath().toString());
    brokerProps.setProperty("listeners", "PLAINTEXT://" + BROKERHOST +":" + BROKERPORT);
    KafkaConfig config = new KafkaConfig(brokerProps);
    Time mock = new MockTime();
    kafkaServer = TestUtils.createServer(config, mock);
    //AdminUtils.createTopic(zkUtils, TOPIC, 1, 1, new Properties(), RackAwareMode.Disabled$.MODULE$);

    JMeterContext jmcx = JMeterContextService.getContext();
    jmcx.setVariables(new JMeterVariables());

}
 
开发者ID:GSLabDev,项目名称:pepper-box,代码行数:24,代码来源:PepperBoxSamplerTest.java

示例6: iterationStart

import org.apache.jmeter.threads.JMeterContext; //导入依赖的package包/类
@Override
public void iterationStart(LoopIterationEvent event) {
	TestElement source = event.getSource();
	JMeterContext threadContext = source.getThreadContext();
	JMeterVariables variables = threadContext.getVariables();
	iterationStart(variables);
}
 
开发者ID:qas-guru,项目名称:martini-jmeter-extension,代码行数:8,代码来源:SpringPreProcessor.java

示例7: getApplicationContext

import org.apache.jmeter.threads.JMeterContext; //导入依赖的package包/类
public static ApplicationContext getApplicationContext() {
	JMeterContext context = JMeterContextService.getContext();
	JMeterVariables variables = context.getVariables();
	Object o = variables.getObject(VARIABLE);
	checkNotNull(o, "variable %s not found", VARIABLE);
	return ApplicationContext.class.cast(o);
}
 
开发者ID:qas-guru,项目名称:martini-jmeter-extension,代码行数:8,代码来源:SpringPreProcessor.java

示例8: setupTest

import org.apache.jmeter.threads.JMeterContext; //导入依赖的package包/类
/**
 * This is executed once per instantiation of this class. Nothing specific to an
 * individual test run should appear in this method.
 *
 * @param context ignored
 */
@Override
public void setupTest(JavaSamplerContext context) {
	try {
		assertNotInterrupted();
		executing = true;
		super.setupTest(context);

		JMeterContext jmeterContext = JMeterContextService.getContext();
		AbstractThreadGroup threadGroup = jmeterContext.getThreadGroup();
		threadGroupName = threadGroup.getName();

		JMeterThread thread = jmeterContext.getThread();
		threadName = thread.getThreadName();

		String parameter = context.getParameter(PARAMETER, PARAMETER_DEFAULT).trim();
		boolean generatingJson = Boolean.valueOf(parameter);

		assertNotInterrupted();
		if (generatingJson) {
			marshaller = SpringPreProcessor.getBean(MartiniResultMarshaller.class);
		}
		eventManager = SpringPreProcessor.getBean(EventManager.class);
		suiteIdentifier = SpringPreProcessor.getBean(SuiteIdentifier.class);
	}
	finally {
		executing = false;
	}
}
 
开发者ID:qas-guru,项目名称:martini-jmeter-extension,代码行数:35,代码来源:MartiniSamplerClient.java

示例9: makeThread

import org.apache.jmeter.threads.JMeterContext; //导入依赖的package包/类
private DebuggingThread makeThread(int groupCount, ListenerNotifier notifier, ListedHashTree threadGroupTree, StandardJMeterEngine engine, int i, JMeterContext context) {
    // had to copy whole method because of this line
    DebuggingThread jmeterThread = new DebuggingThread(threadGroupTree, this, notifier, context);

    boolean onErrorStopTest = getOnErrorStopTest();
    boolean onErrorStopTestNow = getOnErrorStopTestNow();
    boolean onErrorStopThread = getOnErrorStopThread();
    boolean onErrorStartNextLoop = getOnErrorStartNextLoop();
    String groupName = getName();

    jmeterThread.setThreadNum(i);
    jmeterThread.setThreadGroup(this);
    jmeterThread.setInitialContext(context);
    String threadName = groupName + " " + (groupCount) + "-" + (i + 1);
    jmeterThread.setThreadName(threadName);
    jmeterThread.setEngine(engine);
    jmeterThread.setOnErrorStopTest(onErrorStopTest);
    jmeterThread.setOnErrorStopTestNow(onErrorStopTestNow);
    jmeterThread.setOnErrorStopThread(onErrorStopThread);
    jmeterThread.setOnErrorStartNextLoop(onErrorStartNextLoop);
    return jmeterThread;
}
 
开发者ID:Blazemeter,项目名称:jmeter-debugger,代码行数:23,代码来源:DebuggingThreadGroup.java

示例10: statusRefresh

import org.apache.jmeter.threads.JMeterContext; //导入依赖的package包/类
@Override
public void statusRefresh(JMeterContext context) {
    try {
        refreshVars(context);
        refreshProperties();
    } catch (Throwable e) {
        log.warn("Problem refreshing status pane", e);
    }
    evaluatePanel.refresh(context, debugger.isContinuing());
    SwingUtilities.invokeLater(new Runnable() {
        @Override
        public void run() {
            tree.repaint();
        }
    });
}
 
开发者ID:Blazemeter,项目名称:jmeter-debugger,代码行数:17,代码来源:DebuggerDialog.java

示例11: isDone

import org.apache.jmeter.threads.JMeterContext; //导入依赖的package包/类
/**
 * {@inheritDoc}
 */
@Override
public boolean isDone() {
    if (loopCount >= getEndIndex()) {
        return true;
    }
    JMeterContext context = getThreadContext();
    StringBuilder builder = new StringBuilder(
            getInputVal().length()+getSeparator().length()+3);
    String inputVariable = 
            builder.append(getInputVal())
            .append(getSeparator())
            .append(Integer.toString(loopCount+1)).toString();
    final JMeterVariables variables = context.getVariables();
    final Object currentVariable = variables.getObject(inputVariable);
    if (currentVariable != null) {
        variables.putObject(getReturnVal(), currentVariable);
        if (log.isDebugEnabled()) {
            log.debug("ForEach resultstring isDone=" + variables.get(getReturnVal()));
        }
        return false;
    }
    return super.isDone();
}
 
开发者ID:johrstrom,项目名称:cloud-meter,代码行数:27,代码来源:ForeachController.java

示例12: emptyList

import org.apache.jmeter.threads.JMeterContext; //导入依赖的package包/类
/**
 * Check if there are any matching entries
 *
 * @return whether any entries in the list
 */
private boolean emptyList() {
    JMeterContext context = getThreadContext();

    StringBuilder builder = new StringBuilder(
            getInputVal().length()+getSeparator().length()+3);
    String inputVariable = 
            builder.append(getInputVal())
            .append(getSeparator())
            .append(Integer.toString(loopCount+1)).toString();
    if (context.getVariables().getObject(inputVariable) != null) {
        return false;
    }
    if (log.isDebugEnabled()) {
        log.debug("No entries found - null first entry: " + inputVariable);
    }
    return true;
}
 
开发者ID:johrstrom,项目名称:cloud-meter,代码行数:23,代码来源:ForeachController.java

示例13: process

import org.apache.jmeter.threads.JMeterContext; //导入依赖的package包/类
@Override
public void process() {
    JMeterContext jmctx = JMeterContextService.getContext();

    SampleResult prev = jmctx.getPreviousResult();
    if (prev == null) {
        return; // TODO - should we skip processing here?
    }
    final BeanShellInterpreter bshInterpreter = getBeanShellInterpreter();
    if (bshInterpreter == null) {
        log.error("BeanShell not found");
        return;
    }

    try {
        // Add variables for access to context and variables
        bshInterpreter.set("data", prev.getResponseData());//$NON-NLS-1$
        processFileOrScript(bshInterpreter);
    } catch (JMeterException e) {
        log.warn("Problem in BeanShell script "+e);
    }
}
 
开发者ID:johrstrom,项目名称:cloud-meter,代码行数:23,代码来源:BeanShellPostProcessor.java

示例14: notifyListeners

import org.apache.jmeter.threads.JMeterContext; //导入依赖的package包/类
/**
 * Create additional SampleEvent in NON Parent Mode
 */
protected void notifyListeners() {
    // TODO could these be done earlier (or just once?)
    JMeterContext threadContext = getThreadContext();
    JMeterVariables threadVars = threadContext.getVariables();
    SamplePackage pack = (SamplePackage) threadVars.getObject(JMeterThread.PACKAGE_OBJECT);
    if (pack == null) {
        // If child of TransactionController is a ThroughputController and TPC does
        // not sample its children, then we will have this
        // TODO Should this be at warn level ?
        log.warn("Could not fetch SamplePackage");
    } else {
        SampleEvent event = new SampleEvent(res, threadContext.getThreadGroup().getName(),threadVars, true);
        // We must set res to null now, before sending the event for the transaction,
        // so that we can ignore that event in our sampleOccured method
        res = null;
        lnf.notifyListeners(event, pack.getSampleListeners());
    }
}
 
开发者ID:johrstrom,项目名称:cloud-meter,代码行数:22,代码来源:TransactionController.java

示例15: getStringValue

import org.apache.jmeter.threads.JMeterContext; //导入依赖的package包/类
/**
 * Executes the function (and caches the value for the duration of the test
 * iteration) if the property is a running version. Otherwise, the raw
 * string representation of the function is provided.
 *
 * @see JMeterProperty#getStringValue()
 */
@Override
public String getStringValue() {
    JMeterContext ctx = JMeterContextService.getContext();// Expensive, so
                                                            // do
    // once
    if (!isRunningVersion() /*|| !ctx.isSamplingStarted()*/) {
        log.debug("Not running version, return raw function string");
        return function.getRawParameters();
    }
    if(!ctx.isSamplingStarted()) {
        return function.execute();
    }
    log.debug("Running version, executing function");
    int iter = ctx.getVariables() != null ? ctx.getVariables().getIteration() : -1;
    if (iter < testIteration) {
        testIteration = -1;
    }
    if (iter > testIteration || cacheValue == null) {
        testIteration = iter;
        cacheValue = function.execute();
    }
    return cacheValue;

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


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