SoapUI脚本保存变量,加一BUG

来源:互联网 发布:上色软件 编辑:程序博客网 时间:2024/04/30 08:17

.....看看,好高深....偷笑

保存为全局变量,可以在groovy脚本中,也可以在断言脚本中

        String _url=System.getProperties().getProperty("_url");        _url+="sss"+";"; // 每次重定向就保存一次        System.getProperties().setProperty("_url",_url);//先设置一个键位DBType的属性

主要是好记


BUG,

soapUI自带重定向http,其实是soapUI手动重定向的,不是httpclient自动的

有的服务器会要 header中的HOST值,如 192.168.1.2:8080,那么host也应该一致,返回的Location指令会到8080

看看改以后代码:

package com.eviware.soapui.impl.wsdl.submit.transports.http;
HttpClientRequestTransport

String location = httpResponse.getFirstHeader("Location").getValue();URI uri = new URI(new URI(httpMethod.getURI().toString(), true), location, true);java.net.URI newUri = HttpUtils.createUri(uri.getScheme(), uri.getEscapedUserinfo(), uri.getHost(), uri.getPort(), uri.getEscapedPath(), uri.getEscapedQuery(), uri.getEscapedFragment());((ExtendedHttpMethod)getMethod).setURI(newUri);((ExtendedHttpMethod)getMethod).setHeader("Host", uri.getHost()+":"+uri.getPort());//添加端口!!//  不加端口号是为何,真是受不了,ai,真心麻烦String _url=System.getProperties().getProperty("_url");_url+=uri+";"; // 每次重定向就保存一次System.getProperties().setProperty("_url",_url);//先设置一个键位DBType的属性//System.getProperties().getProperty("_url");//后通过getProperty方法得到DBType的值。//我添加了新内容
由于是测试工具,有时需要拦截中间的url,所以做了一个保存!

修改以后替换回去就好了



0 0
原创粉丝点击