kamahade
15 years agoRegular Contributor
Script problem...
Pro support team ...
I have a script
Which is running fine if I call within my script step by
compareFunction("getAsset#Response" , "//se:getAssetResponse/getAssetResponse/AssetInfo/text/*");
However, if I place the same function within a class and place it in /bin/script folder, when I compile, its throwing many errors.
What one should do take care while placing scripts in script library folder ?
Can't I use "Context" with that script ?
my Groovy class looking like this ..
I have a script
def compareFunction(String testResponseName, String xpathQuery ) {
def MATCHES="False";
def groovyUtils = new com.eviware.soapui.support.GroovyUtils(context);
def functionholder = groovyUtils.getXmlHolder("getAsset#Response");
functionholder.namespaces["se"] = "http://"
for ( value in functionholder.getNodeValues(xpathQuery))
{
//log.info "from response:"+value
for(prp in testRunner.testCase.getPropertyNames())
{
if(value == testRunner.testCase.getPropertyValue(prp)){
log.info "Property matches " + value +"=="+testRunner.testCase.getPropertyValue(prp);
// log.info "Testproperty:" + testRunner.testCase.getPropertyValue(prp)
MATCHES = "True";
break;
}
}
}
assert MATCHES == "True"
}
Which is running fine if I call within my script step by
compareFunction("getAsset#Response" , "//se:getAssetResponse/getAssetResponse/AssetInfo/text/*");
However, if I place the same function within a class and place it in /bin/script folder, when I compile, its throwing many errors.
What one should do take care while placing scripts in script library folder ?
Can't I use "Context" with that script ?
my Groovy class looking like this ..
package soapui.em3.releb;
import com.eviware.soapui.support.*;
import com.eviware.soapui.model.testsuite.*;
import com.eviware.soapui.support.XmlHolder;
import com.eviware.soapui.impl.wsdl.teststeps.*;
import com.eviware.soapui.model.testsuite.TestRunContext;
import com.eviware.soapui.impl.wsdl.testcase.*;
public class getOperation {
def compareFunction(String testResponseName, String xpathQuery ) {
def MATCHES="False";
def groovyUtils = new com.eviware.soapui.support.GroovyUtils(context);
def functionholder = groovyUtils.getXmlHolder("getAsset#Response");
functionholder.namespaces["se"] = "http://"
for ( value in functionholder.getNodeValues(xpathQuery))
{
//log.info "from response:"+value
for(prp in testRunner.testCase.getPropertyNames())
{
if(value == testRunner.testCase.getPropertyValue(prp)){
log.info "Property matches " + value +"=="+testRunner.testCase.getPropertyValue(prp);
// log.info "Testproperty:" + testRunner.testCase.getPropertyValue(prp)
MATCHES = "True";
break;
}
}
}
assert MATCHES == "True"
}
}