@Test public void testExecute() throws Exception { System.out.println("execute 1"); SampleResult previousResult = null; Sampler currentSampler = null; Assert.assertNull(JMeterContextService.getContext().getVariables().get("toto")); Collection<CompoundVariable> parameters = new ArrayList<>(); parameters.add(new CompoundVariable(key)); Env instance = new Env(); instance.setParameters(parameters); String result = instance.execute(null, null); Assert.assertEquals(value, result); Assert.assertNull(JMeterContextService.getContext().getVariables().get("toto")); }
@Override public synchronized String execute(SampleResult previousResult, Sampler currentSampler) throws InvalidVariableException { String propertyName = values[0].execute(); String propertyDefault = propertyName; if (values.length > 2) { propertyDefault = values[2].execute(); } String propertyValue = JMeterPluginsUtils.getEnvDefault(propertyName, propertyDefault); if (values.length > 1) { String variableName = values[1].execute(); if (variableName.length() > 0) { final JMeterVariables variables = getVariables(); if (variables != null) { variables.put(variableName, propertyValue); } } } return propertyValue; }
Env extends AbstractFunction { @Override public synchronized String execute(SampleResult previousResult, Sampler currentSampler) throws InvalidVariableException { String propertyName = values[0].execute(); String propertyDefault = propertyName; if (values.length > 2) { propertyDefault = values[2].execute(); } String propertyValue = JMeterPluginsUtils.getEnvDefault(propertyName, propertyDefault); if (values.length > 1) { String variableName = values[1].execute(); if (variableName.length() > 0) { final JMeterVariables variables = getVariables(); if (variables != null) { variables.put(variableName, propertyValue); } } } return propertyValue; } }
Env extends AbstractFunction { @Override public synchronized String execute(SampleResult previousResult, Sampler currentSampler) throws InvalidVariableException { String propertyName = values[0].execute(); String propertyDefault = propertyName; if (values.length > 2) { propertyDefault = values[2].execute(); } String propertyValue = JMeterPluginsUtils.getEnvDefault(propertyName, propertyDefault); if (values.length > 1) { String variableName = values[1].execute(); if (variableName.length() > 0) { final JMeterVariables variables = getVariables(); if (variables != null) { variables.put(variableName, propertyValue); } } } return propertyValue; } Env(); }
Env extends AbstractFunction { @Override public synchronized String execute(SampleResult previousResult, Sampler currentSampler) throws InvalidVariableException { String propertyName = values[0].execute(); String propertyDefault = propertyName; if (values.length > 2) { propertyDefault = values[2].execute(); } String propertyValue = JMeterPluginsUtils.getEnvDefault(propertyName, propertyDefault); if (values.length > 1) { String variableName = values[1].execute(); if (variableName.length() > 0) { final JMeterVariables variables = getVariables(); if (variables != null) { variables.put(variableName, propertyValue); } } } return propertyValue; } Env(); @Override synchronized String execute(SampleResult previousResult, Sampler currentSampler); @Override synchronized void setParameters(Collection<CompoundVariable> parameters); @Override String getReferenceKey(); @Override List<String> getArgumentDesc(); }
Env extends AbstractFunction { @Override public synchronized String execute(SampleResult previousResult, Sampler currentSampler) throws InvalidVariableException { String propertyName = values[0].execute(); String propertyDefault = propertyName; if (values.length > 2) { propertyDefault = values[2].execute(); } String propertyValue = JMeterPluginsUtils.getEnvDefault(propertyName, propertyDefault); if (values.length > 1) { String variableName = values[1].execute(); if (variableName.length() > 0) { final JMeterVariables variables = getVariables(); if (variables != null) { variables.put(variableName, propertyValue); } } } return propertyValue; } Env(); @Override synchronized String execute(SampleResult previousResult, Sampler currentSampler); @Override synchronized void setParameters(Collection<CompoundVariable> parameters); @Override String getReferenceKey(); @Override List<String> getArgumentDesc();  }