/** * Add a cookie. * * @param c cookie to be added */ public void add(Cookie c) { String cv = c.getValue(); String cn = c.getName(); removeMatchingCookies(c); // Can't have two matching cookies if (DELETE_NULL_COOKIES && (null == cv || cv.length()==0)) { if (log.isDebugEnabled()) { log.debug("Dropping cookie with null value {}", c.toString()); } } else { if (log.isDebugEnabled()) { log.debug("Add cookie to store {}", c.toString()); } getCookies().addItem(c); if (SAVE_COOKIES) { JMeterContext context = getThreadContext(); if (context.isSamplingStarted()) { context.getVariables().put(COOKIE_NAME_PREFIX+cn, cv); } } } }
/** * 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; }
/** * Update the worker thread jmeter context with the main thread one * @param isInit if true the context a full copy is done, if false only update is done */ private void syncContext(boolean isInit) { // jmeter context synchronisation JMeterContext current = JMeterContextService.getContext(); JMeterContext ctx = this.getThreadContext(); if (isInit) { current.setCurrentSampler(ctx.getCurrentSampler()); current.setEngine(ctx.getEngine()); current.setRestartNextLoop(ctx.isRestartNextLoop()); current.setSamplingStarted(ctx.isSamplingStarted()); current.setThread(ctx.getThread()); current.setThreadGroup(ctx.getThreadGroup()); current.setThreadNum(ctx.getThreadNum()); } current.setVariables(ctx.getVariables()); current.setPreviousResult(ctx.getPreviousResult()); //current.getSamplerContext().putAll(ctx.getSamplerContext()); }
/** * Update the worker thread jmeter context with the main thread one * @param isInit if true the context a full copy is done, if false only update is done */ private void syncContext(boolean isInit) { // jmeter context synchronisation JMeterContext current = JMeterContextService.getContext(); JMeterContext ctx = this.getThreadContext(); if (isInit) { current.setCurrentSampler(ctx.getCurrentSampler()); current.setEngine(ctx.getEngine()); current.setRestartNextLoop(ctx.isRestartNextLoop()); current.setSamplingStarted(ctx.isSamplingStarted()); current.setThread(ctx.getThread()); current.setThreadGroup(ctx.getThreadGroup()); current.setThreadNum(ctx.getThreadNum()); } current.setVariables(ctx.getVariables()); current.setPreviousResult(ctx.getPreviousResult()); //current.getSamplerContext().putAll(ctx.getSamplerContext()); }
/** * Update the worker thread jmeter context with the main thread one * @param isInit if true the context a full copy is done, if false only update is done */ private void syncContext(boolean isInit) { // jmeter context synchronisation JMeterContext current = JMeterContextService.getContext(); JMeterContext ctx = this.getThreadContext(); if (isInit) { current.setCurrentSampler(ctx.getCurrentSampler()); current.setEngine(ctx.getEngine()); current.setRestartNextLoop(ctx.isRestartNextLoop()); current.setSamplingStarted(ctx.isSamplingStarted()); current.setThread(ctx.getThread()); current.setThreadGroup(ctx.getThreadGroup()); current.setThreadNum(ctx.getThreadNum()); } current.setVariables(ctx.getVariables()); current.setPreviousResult(ctx.getPreviousResult()); //current.getSamplerContext().putAll(ctx.getSamplerContext()); } @Override