Java Code Examples for org.apache.jmeter.samplers.SampleEvent#getResult()
The following examples show how to use
org.apache.jmeter.samplers.SampleEvent#getResult() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: ParallelListenerNotifier.java From jmeter-bzm-plugins with Apache License 2.0 | 6 votes |
@Override public void notifyListeners(SampleEvent res, List<SampleListener> listeners) { log.debug("Adding subresult " + res.getResult()); SampleResult result = res.getResult(); String label = result.getSampleLabel(); synchronized (this) { container.addSubResult(result); if (!res.getResult().isSuccessful()) { container.setSuccessful(false); } } // because https://bz.apache.org/bugzilla/show_bug.cgi?id=62550 in JMeter 5.0 result.setSampleLabel(label); super.notifyListeners(res, listeners); log.debug("Added subresult " + res.getResult()); }
Example 2
Source File: AggregatedTypeUpdater.java From jmeter-prometheus-plugin with Apache License 2.0 | 6 votes |
protected long measure(SampleEvent event) { SampleResult result = event.getResult(); switch(this.config.getMeasuringAsEnum()) { case ResponseSize: return result.getBodySizeAsLong(); case ResponseTime: return result.getTime(); case Latency: return result.getLatency(); case IdleTime: return result.getIdleTime(); case ConnectTime: return result.getConnectTime(); default: return 0; } }
Example 3
Source File: ConsoleStatusLogger.java From jmeter-plugins with Apache License 2.0 | 6 votes |
@Override public synchronized void sampleOccurred(SampleEvent se) { // TODO: make the interval configurable long sec = System.currentTimeMillis() / 1000; if (sec != cur && count > 0) { if (cur == 0) { begin = sec; } log.debug(cur + " " + begin); flush(sec - begin); cur = sec; } SampleResult res = se.getResult(); count++; sumRTime += res.getTime(); sumLatency += res.getLatency(); errors += res.isSuccessful() ? 0 : 1; threads = res.getAllThreads(); }
Example 4
Source File: DebuggerEngineTest.java From jmeter-debugger with Apache License 2.0 | 5 votes |
@Test public void runVariablesDebugEngine() throws Exception { TestProvider prov = new TestProvider("/com/blazemeter/jmeter/debugger/vars.jmx", "vars.jmx"); Debugger sel = new Debugger(prov, new FrontendMock()); AbstractThreadGroup tg = prov.getTG(0); sel.selectThreadGroup(tg); HashTree testTree = sel.getSelectedTree(); TestSampleListener listener = new TestSampleListener(); testTree.add(testTree.getArray()[0], listener); DebuggingThreadGroup tg2 = (DebuggingThreadGroup) getFirstTG(testTree); LoopController samplerController = (LoopController) tg2.getSamplerController(); samplerController.setLoops(1); samplerController.setContinueForever(false); JMeter.convertSubTree(testTree); DebuggerEngine engine = new DebuggerEngine(JMeterContextService.getContext()); StepTriggerCounter hook = new StepTriggerCounter(); engine.setStepper(hook); engine.configure(testTree); engine.runTest(); while (engine.isActive()) { Thread.sleep(1000); } assertEquals(8, hook.cnt); assertEquals(3, listener.events.size()); for (SampleEvent event : listener.events) { SampleResult res = event.getResult(); String label = res.getSampleLabel(); assertTrue("Label: " + label + " must end with '123'", label.endsWith("123")); assertFalse("Variable ${VAR} must be changed to '123' value. label: " + label, label.contains("${VAR}")); assertTrue("label: '" + label + "' response: '" + res.getResponseMessage() +"'", res.isSuccessful()); } }
Example 5
Source File: DebuggerEngineTest.java From jmeter-debugger with Apache License 2.0 | 5 votes |
@Test public void runVariablesInAssertions() throws Exception { TestProvider prov = new TestProvider("/com/blazemeter/jmeter/debugger/debug.jmx", "debug.jmx"); Debugger sel = new Debugger(prov, new FrontendMock()); AbstractThreadGroup tg = prov.getTG(0); sel.selectThreadGroup(tg); HashTree testTree = sel.getSelectedTree(); TestSampleListener listener = new TestSampleListener(); testTree.add(testTree.getArray()[0], listener); DebuggingThreadGroup tg2 = (DebuggingThreadGroup) getFirstTG(testTree); LoopController samplerController = (LoopController) tg2.getSamplerController(); samplerController.setLoops(1); samplerController.setContinueForever(false); JMeter.convertSubTree(testTree); DebuggerEngine engine = new DebuggerEngine(JMeterContextService.getContext()); StepTriggerCounter hook = new StepTriggerCounter(); engine.setStepper(hook); engine.configure(testTree); engine.runTest(); while (engine.isActive()) { Thread.sleep(1000); } assertEquals(4, hook.cnt); assertEquals(1, listener.events.size()); SampleEvent event = listener.events.get(0); SampleResult result = event.getResult(); AssertionResult[] assertionResults = result.getAssertionResults(); assertEquals(1, assertionResults.length); AssertionResult assertionRes = assertionResults[0]; assertNull(assertionRes.getFailureMessage()); }