use of org.apache.jmeter.testelement.property.JMeterProperty in project jmeter by apache.
the class PackageTest method testParseExample3.
@Test
public void testParseExample3() throws Exception {
StringProperty prop = new StringProperty("html", "${__regexFunction(<html>(.*)</html>,$1$)}" + "${__regexFunction(<html>(.*o)(.*o)(.*)</html>," + "$1$$3$)}");
JMeterProperty newProp = transformer.transformValue(prop);
newProp.setRunningVersion(true);
assertEquals("org.apache.jmeter.testelement.property.FunctionProperty", newProp.getClass().getName());
assertEquals("hello worldhellorld", newProp.getStringValue());
}
use of org.apache.jmeter.testelement.property.JMeterProperty in project jmeter by apache.
the class PackageTest method testParseExample2.
@Test
public void testParseExample2() throws Exception {
StringProperty prop = new StringProperty("html", "It should say:\\${${__regexFunction(<html>(.*)</html>,$1$)}}");
JMeterProperty newProp = transformer.transformValue(prop);
newProp.setRunningVersion(true);
assertEquals("org.apache.jmeter.testelement.property.FunctionProperty", newProp.getClass().getName());
assertEquals("It should say:${hello world}", newProp.getStringValue());
}
use of org.apache.jmeter.testelement.property.JMeterProperty in project jmeter by apache.
the class PackageTest method testFunctionParse1.
@Test
public void testFunctionParse1() throws Exception {
StringProperty prop = new StringProperty("date", "${__javaScript((new Date().getDate() / 100).toString()." + "substr(${__javaScript(1+1,d\\,ay)}\\,2),heute)}");
JMeterProperty newProp = transformer.transformValue(prop);
newProp.setRunningVersion(true);
assertEquals("org.apache.jmeter.testelement.property.FunctionProperty", newProp.getClass().getName());
newProp.recoverRunningVersion(null);
assertTrue(Integer.parseInt(newProp.getStringValue()) > -1);
assertEquals("2", jmctx.getVariables().getObject("d,ay"));
}
use of org.apache.jmeter.testelement.property.JMeterProperty in project jmeter by apache.
the class PackageTest method testParseExample11.
// Escaped dollar commma and backslash with no variable reference
@Test
public void testParseExample11() throws Exception {
StringProperty prop = new StringProperty("html", "\\$a \\, \\\\ \\x \\ jakarta.apache.org");
JMeterProperty newProp = transformer.transformValue(prop);
newProp.setRunningVersion(true);
assertEquals("org.apache.jmeter.testelement.property.StringProperty", newProp.getClass().getName());
assertEquals("\\$a \\, \\\\ \\x \\ jakarta.apache.org", newProp.getStringValue());
}
use of org.apache.jmeter.testelement.property.JMeterProperty in project jmeter by apache.
the class GuiPackage method getTestElementCheckSum.
/**
* Compute checksum of TestElement to detect changes
* the method calculates properties checksum to detect testelement
* modifications
* TODO would be better to override hashCode for TestElement, but I decided not to touch it
*
* @param el {@link TestElement}
* @return int checksum
*/
private int getTestElementCheckSum(TestElement el) {
int ret = el.getClass().hashCode();
PropertyIterator it = el.propertyIterator();
while (it.hasNext()) {
JMeterProperty obj = it.next();
if (obj instanceof TestElementProperty) {
ret ^= getTestElementCheckSum(((TestElementProperty) obj).getElement());
} else {
ret ^= obj.getName().hashCode();
String stringValue = obj.getStringValue();
if (stringValue != null) {
ret ^= stringValue.hashCode();
} else {
if (log.isDebugEnabled()) {
log.debug("obj.getStringValue() returned null for test element:" + el.getName() + " at property:" + obj.getName());
}
}
}
}
return ret;
}
Aggregations