@Test public void testExecute() throws Exception { JMeterContext context = JMeterContextService.getContext(); context.setVariables(new JMeterVariables()); Collection<CompoundVariable> parameters = new ArrayList<>(); parameters.add(new CompoundVariable("dGVzdCBzdHJpbmc=")); parameters.add(new CompoundVariable("b64dec_res")); Base64Decode instance = new Base64Decode(); instance.setParameters(parameters); String res = instance.execute(null, null); Assert.assertEquals("test string", res); Assert.assertNotNull(context.getVariables().get("b64dec_res")); }
@Override public synchronized String execute(SampleResult previousResult, Sampler currentSampler) throws InvalidVariableException { String sourceString = values[0].execute(); String decodedValue = new String(Base64.decodeBase64(sourceString)); if (values.length > 1) { String variableName = values[1].execute(); if (variableName.length() > 0) { final JMeterVariables variables = getVariables(); if (variables != null) { variables.put(variableName, decodedValue); } } } return decodedValue; }
Base64Decode extends AbstractFunction { @Override public synchronized String execute(SampleResult previousResult, Sampler currentSampler) throws InvalidVariableException { String sourceString = values[0].execute(); String decodedValue = new String(Base64.decodeBase64(sourceString)); if (values.length > 1) { String variableName = values[1].execute(); if (variableName.length() > 0) { final JMeterVariables variables = getVariables(); if (variables != null) { variables.put(variableName, decodedValue); } } } return decodedValue; } }
Base64Decode extends AbstractFunction { @Override public synchronized String execute(SampleResult previousResult, Sampler currentSampler) throws InvalidVariableException { String sourceString = values[0].execute(); String decodedValue = new String(Base64.decodeBase64(sourceString)); if (values.length > 1) { String variableName = values[1].execute(); if (variableName.length() > 0) { final JMeterVariables variables = getVariables(); if (variables != null) { variables.put(variableName, decodedValue); } } } return decodedValue; }  }
Base64Decode extends AbstractFunction { @Override public synchronized String execute(SampleResult previousResult, Sampler currentSampler) throws InvalidVariableException { String sourceString = values[0].execute(); String decodedValue = new String(Base64.decodeBase64(sourceString)); if (values.length > 1) { String variableName = values[1].execute(); if (variableName.length() > 0) { final JMeterVariables variables = getVariables(); if (variables != null) { variables.put(variableName, decodedValue); } } } return decodedValue; }  @Override synchronized String execute(SampleResult previousResult, Sampler currentSampler); @Override synchronized void setParameters(Collection<CompoundVariable> parameters); @Override String getReferenceKey(); @Override List<String> getArgumentDesc(); }
Base64Decode extends AbstractFunction { @Override public synchronized String execute(SampleResult previousResult, Sampler currentSampler) throws InvalidVariableException { String sourceString = values[0].execute(); String decodedValue = new String(Base64.decodeBase64(sourceString)); if (values.length > 1) { String variableName = values[1].execute(); if (variableName.length() > 0) { final JMeterVariables variables = getVariables(); if (variables != null) { variables.put(variableName, decodedValue); } } } return decodedValue; }  @Override synchronized String execute(SampleResult previousResult, Sampler currentSampler); @Override synchronized void setParameters(Collection<CompoundVariable> parameters); @Override String getReferenceKey(); @Override List<String> getArgumentDesc();  }