/** * {@inheritDoc} */ @Override public long delay() { String ret="0"; final BeanShellInterpreter bshInterpreter = getBeanShellInterpreter(); if (bshInterpreter == null) { log.error("BeanShell not found"); return 0; } try { Object o = processFileOrScript(bshInterpreter); if (o != null) { ret=o.toString(); } } catch (JMeterException e) { if (log.isWarnEnabled()) { log.warn("Problem in BeanShell script. {}", e.toString()); } } try { return Long.decode(ret).longValue(); } catch (NumberFormatException e){ log.warn("Number format exception while decoding number: '{}'", ret); return 0; } }
@Override public void sampleOccurred(SampleEvent se) { final BeanShellInterpreter bshInterpreter = getBeanShellInterpreter(); if (bshInterpreter == null) { log.error("BeanShell not found"); return; } SampleResult samp=se.getResult(); try { bshInterpreter.set("sampleEvent", se);//$NON-NLS-1$ bshInterpreter.set("sampleResult", samp);//$NON-NLS-1$ processFileOrScript(bshInterpreter); } catch (JMeterException e) { if (log.isWarnEnabled()) { log.warn("Problem in BeanShell script. {}", e.toString()); } } }
@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) { if (log.isWarnEnabled()) { log.warn("Problem in BeanShell script. {}", e.toString()); } } }
@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) { if (log.isWarnEnabled()) { log.warn("Problem in BeanShell script: {}", e.toString()); } } }