本文整理汇总了Java中org.apache.jmeter.functions.InvalidVariableException类的典型用法代码示例。如果您正苦于以下问题:Java InvalidVariableException类的具体用法?Java InvalidVariableException怎么用?Java InvalidVariableException使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
InvalidVariableException类属于org.apache.jmeter.functions包,在下文中一共展示了InvalidVariableException类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: setParameters
import org.apache.jmeter.functions.InvalidVariableException; //导入依赖的package包/类
public void setParameters(String parameters) throws InvalidVariableException {
this.rawParameters = parameters;
if (parameters == null || parameters.length() == 0) {
return;
}
compiledComponents = functionParser.compileString(parameters);
if (compiledComponents.size() > 1 || !(compiledComponents.get(0) instanceof String)) {
hasFunction = true;
}
permanentResults = null; // To be calculated and cached on first execution
isDynamic = false;
for (Object item : compiledComponents) {
if (item instanceof Function || item instanceof SimpleVariable) {
isDynamic = true;
break;
}
}
}
示例2: execute
import org.apache.jmeter.functions.InvalidVariableException; //导入依赖的package包/类
@Override
public String execute(SampleResult previousResult, Sampler currentSampler) throws InvalidVariableException {
String numberString = ((CompoundVariable) values[0]).execute().trim();
int num;
try{
num = Integer.valueOf(numberString);
} catch (Exception e){
return null;
}
return String.valueOf(factorial(num));
}
示例3: setParameters
import org.apache.jmeter.functions.InvalidVariableException; //导入依赖的package包/类
@Override
public void setParameters(Collection<CompoundVariable> parameters) throws InvalidVariableException {
//可以检查参数数量,主要包括以下两种方法
checkMinParameterCount(parameters, 1);
checkParameterCount(parameters, 1, 1);
values = parameters.toArray();
}
示例4: execute
import org.apache.jmeter.functions.InvalidVariableException; //导入依赖的package包/类
@Override
public String execute(SampleResult arg0, Sampler arg1) throws InvalidVariableException {
StringBuffer res = new StringBuffer();
for(int i = 0; i < 1024; i++) {
res.append(seeds[random.nextInt(seeds.length - 1)]);
}
return res.toString();
}
示例5: transformValue
import org.apache.jmeter.functions.InvalidVariableException; //导入依赖的package包/类
@Override
public JMeterProperty transformValue(JMeterProperty prop) throws InvalidVariableException {
String input = prop.getStringValue();
for (Map.Entry<String, String> entry : getVariables().entrySet()) {
String key = entry.getKey();
String value = entry.getValue();
input = StringUtilities.substitute(input, "${" + key + "}", value);
}
return new StringProperty(prop.getName(), input);
}
示例6: transformValue
import org.apache.jmeter.functions.InvalidVariableException; //导入依赖的package包/类
@Override
public JMeterProperty transformValue(JMeterProperty prop) throws InvalidVariableException {
PatternMatcher pm = JMeterUtils.getMatcher();
Pattern pattern = null;
PatternCompiler compiler = new Perl5Compiler();
String input = prop.getStringValue();
if(input == null) {
return prop;
}
for(Entry<String, String> entry : getVariables().entrySet()){
String key = entry.getKey();
String value = entry.getValue();
if (regexMatch) {
try {
pattern = compiler.compile(constructPattern(value));
input = Util.substitute(pm, pattern,
new StringSubstitution(FUNCTION_REF_PREFIX + key + FUNCTION_REF_SUFFIX),
input, Util.SUBSTITUTE_ALL);
} catch (MalformedPatternException e) {
log.warn("Malformed pattern " + value);
}
} else {
input = StringUtilities.substitute(input, value, FUNCTION_REF_PREFIX + key + FUNCTION_REF_SUFFIX);
}
}
return new StringProperty(prop.getName(), input);
}
示例7: CompoundVariable
import org.apache.jmeter.functions.InvalidVariableException; //导入依赖的package包/类
public CompoundVariable(String parameters) {
this();
try {
setParameters(parameters);
} catch (InvalidVariableException e) {
// TODO should level be more than debug ?
if(log.isDebugEnabled()) {
log.debug("Invalid variable:"+ parameters, e);
}
}
}
示例8: execute
import org.apache.jmeter.functions.InvalidVariableException; //导入依赖的package包/类
/** {@inheritDoc} */
@Override
public String execute(SampleResult previousResult, Sampler currentSampler) {
if (compiledComponents == null || compiledComponents.size() == 0) {
return ""; // $NON-NLS-1$
}
StringBuilder results = new StringBuilder();
for (Object item : compiledComponents) {
if (item instanceof Function) {
try {
results.append(((Function) item).execute(previousResult, currentSampler));
} catch (InvalidVariableException e) {
// TODO should level be more than debug ?
if(log.isDebugEnabled()) {
log.debug("Invalid variable:"+item, e);
}
}
} else if (item instanceof SimpleVariable) {
results.append(((SimpleVariable) item).toString());
} else {
results.append(item);
}
}
if (!isDynamic) {
permanentResults = results.toString();
}
return results.toString();
}
示例9: getNamedFunction
import org.apache.jmeter.functions.InvalidVariableException; //导入依赖的package包/类
static Object getNamedFunction(String functionName) throws InvalidVariableException {
if (functions.containsKey(functionName)) {
try {
return ((Class<?>) functions.get(functionName)).newInstance();
} catch (Exception e) {
log.error("", e); // $NON-NLS-1$
throw new InvalidVariableException(e);
}
}
return new SimpleVariable(functionName);
}
示例10: transformValue
import org.apache.jmeter.functions.InvalidVariableException; //导入依赖的package包/类
@Override
public JMeterProperty transformValue(JMeterProperty prop) throws InvalidVariableException {
JMeterProperty newValue = prop;
getMasterFunction().clear();
getMasterFunction().setParameters(prop.getStringValue());
if (getMasterFunction().hasFunction()) {
newValue = new FunctionProperty(prop.getName(), getMasterFunction().getFunction());
}
return newValue;
}
示例11: replaceValues
import org.apache.jmeter.functions.InvalidVariableException; //导入依赖的package包/类
/**
* Scan all test elements passed in for values matching the value of any of
* the variables in any of the variable-holding elements in the collection.
*
* @param sampler A TestElement to replace values on
* @param configs More TestElements to replace values on
* @param variables Collection of Arguments to use to do the replacement, ordered
* by ascending priority.
*/
private void replaceValues(TestElement sampler, TestElement[] configs, Collection<Arguments> variables)
{
// Build the replacer from all the variables in the collection:
ValueReplacer replacer = new ValueReplacer();
for (Arguments variable : variables)
{
final Map<String, String> map = variable.getArgumentsAsMap();
for (Iterator<String> vals = map.values().iterator(); vals.hasNext();)
{
final Object next = vals.next();
if ("".equals(next))
{// Drop any empty values (Bug 45199)
vals.remove();
}
}
replacer.addVariables(map);
}
try
{
boolean cachedRegexpMatch = regexMatch;
replacer.reverseReplace(sampler, cachedRegexpMatch);
for (TestElement config : configs)
{
if (config != null)
{
replacer.reverseReplace(config, cachedRegexpMatch);
}
}
}
catch (InvalidVariableException e)
{
LOG.warn("Invalid variables included for replacement into recorded " + "sample", e);
}
}
示例12: setParameters
import org.apache.jmeter.functions.InvalidVariableException; //导入依赖的package包/类
/** {@inheritDoc} */
@Override
public synchronized void setParameters(
final Collection<CompoundVariable> parameters)
throws InvalidVariableException {
checkMinParameterCount(parameters, 2);
values = parameters.toArray();
}
示例13: replaceValues
import org.apache.jmeter.functions.InvalidVariableException; //导入依赖的package包/类
/**
* @throws InvalidVariableException not thrown currently
*/
public void replaceValues(TestElement el) throws InvalidVariableException {
/**
Collection newProps = replaceValues(el.propertyIterator(), new ReplaceStringWithFunctions(masterFunction,
variables));
setProperties(el, newProps);
**/
}
示例14: reverseReplace
import org.apache.jmeter.functions.InvalidVariableException; //导入依赖的package包/类
/**
* @throws InvalidVariableException not thrown currently
*/
public void reverseReplace(TestElement el) throws InvalidVariableException {
/**
Collection newProps = replaceValues(el.propertyIterator(), new ReplaceFunctionsWithStrings(masterFunction,
variables));
setProperties(el, newProps);
**/
}
示例15: undoReverseReplace
import org.apache.jmeter.functions.InvalidVariableException; //导入依赖的package包/类
/**
* @throws InvalidVariableException not thrown currently
*/
public void undoReverseReplace(TestElement el) throws InvalidVariableException {
/**
Collection newProps = replaceValues(el.propertyIterator(), new UndoVariableReplacement(masterFunction,
variables));
setProperties(el, newProps);
**/
}