我正在尝试模拟其请求输入参数可以是 Name 或 UniqueIdentifier 的服务。两种输入类型返回的响应相同。
所以,我想命名文件<Name>_<UniqueIdentifier>.xml
并从目录中读取模拟响应。
当在模拟上收到请求时,我想使用输入参数(将是目录中文件名的子字符串)搜索文件并发送响应。
为此,我正在尝试使用 FileNameFinder 类,但是我得到了
java.lang.NoClassDefFoundError: org/apache/tools/ant/BuildException
我也尝试过使用 ant.jar 在 C:\Program Files\SmartBear\ReadyAPI-1.8.5\lib
. 但是,我得到同样的错误。
如果您能帮助解决这个问题,将不胜感激。
谢谢。
ReadyAPI 中的调度脚本
def groovyUtils = new com.eviware.soapui.support.GroovyUtils(context);
def holder = groovyUtils.getXmlHolder("externalBnSearch#Request");
import groovy.util.FileNameFinder;
String name = holder.getNodeValue( "//tn.type:name" )
log.info('Request - name: ' + name);
String UNI = holder.getNodeValue( "//tn.type:UNI" )
log.info('Request - number: ' +UNI);
def file = new FileNameFinder().getFileNames("C:/resposne/", '"+name+"*/*.xml')
log.info(txtFiles)
def mockname = "LookUpResponse"
if (file.exists())
{
context.content = file.getText()
return (mockname);
}