本文整理汇总了Java中org.apache.jmeter.samplers.SampleResult.setDataEncoding方法的典型用法代码示例。如果您正苦于以下问题:Java SampleResult.setDataEncoding方法的具体用法?Java SampleResult.setDataEncoding怎么用?Java SampleResult.setDataEncoding使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.apache.jmeter.samplers.SampleResult
的用法示例。
在下文中一共展示了SampleResult.setDataEncoding方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getMasterList
import org.apache.jmeter.samplers.SampleResult; //导入方法依赖的package包/类
private DataRequest getMasterList(SampleResult masterResult, Parser parser) throws IOException {
masterResult.sampleStart();
DataRequest respond = parser.getBaseUrl(new URL(getURLData()), masterResult, true);
masterResult.sampleEnd();
masterResult.setRequestHeaders(respond.getRequestHeaders() + "\n\n" + getCookieHeader(getURLData()) + "\n\n"
+ getRequestHeader(this.getHeaderManager()));
masterResult.setSuccessful(respond.isSuccess());
masterResult.setResponseMessage(respond.getResponseMessage());
masterResult.setSampleLabel(this.getName());
masterResult.setResponseHeaders(respond.getHeadersAsString());
masterResult.setResponseData(respond.getResponse().getBytes());
masterResult.setResponseCode(respond.getResponseCode());
masterResult.setContentType(respond.getContentType());
masterResult.setBytes(masterResult.getBytesAsLong() + (long) masterResult.getRequestHeaders().length());
int headerBytes = masterResult.getResponseHeaders().length() // condensed
// length
// (without
// \r)
+ respond.getHeaders().size() // Add \r for each header
+ 1 // Add \r for initial header
+ 2; // final \r\n before data
masterResult.setHeadersSize((int) headerBytes);
masterResult.setSentBytes(respond.getSentBytes());
masterResult.setDataEncoding(respond.getContentEncoding());
return respond;
}
示例2: getPlayList
import org.apache.jmeter.samplers.SampleResult; //导入方法依赖的package包/类
private DataRequest getPlayList(SampleResult playListResult, Parser parser) throws IOException {
String lastPath = "";
playListResult.sampleStart();
DataRequest subRespond = parser.getBaseUrl(new URL(playlist), playListResult, true);
playListResult.sampleEnd();
String[] urlArray = playlist.split("/");
lastPath = urlArray[urlArray.length - 1];
playListResult.setRequestHeaders(subRespond.getRequestHeaders() + "\n\n" + getCookieHeader(playlist) + "\n\n"
+ getRequestHeader(this.getHeaderManager()));
playListResult.setSuccessful(subRespond.isSuccess());
playListResult.setResponseMessage(subRespond.getResponseMessage());
playListResult.setSampleLabel(lastPath);
playListResult.setResponseHeaders(subRespond.getHeadersAsString());
playListResult.setResponseData(subRespond.getResponse().getBytes());
playListResult.setResponseCode(subRespond.getResponseCode());
playListResult.setContentType(subRespond.getContentType());
playListResult.setBytes(playListResult.getBytesAsLong() + (long) playListResult.getRequestHeaders().length());
int headerBytes = playListResult.getResponseHeaders().length() // condensed
// length
// (without
// \r)
+ subRespond.getHeaders().size() // Add \r for each header
+ 1 // Add \r for initial header
+ 2; // final \r\n before data
playListResult.setHeadersSize((int) headerBytes);
playListResult.setSentBytes(subRespond.getSentBytes());
playListResult.setDataEncoding(subRespond.getContentEncoding());
return subRespond;
}
示例3: getFragments
import org.apache.jmeter.samplers.SampleResult; //导入方法依赖的package包/类
public List<SampleResult> getFragments(Parser parser, List<DataFragment> uris, String url) {
List<SampleResult> res = new ArrayList<>();
if (!uris.isEmpty()) {
SampleResult result = new SampleResult();
String uriString = uris.get(0).getTsUri();
if ((url != null) && (!uriString.startsWith("http"))) {
uriString = url + uriString;
}
result.sampleStart();
try {
DataRequest respond = parser.getBaseUrl(new URL(uriString), result, false);
result.sampleEnd();
String[] urlArray = uriString.split("/");
String lastPath = urlArray[urlArray.length - 1];
result.setRequestHeaders(respond.getRequestHeaders() + "\n\n" + getCookieHeader(uriString) + "\n\n"
+ getRequestHeader(this.getHeaderManager()));
result.setSuccessful(respond.isSuccess());
result.setResponseMessage(respond.getResponseMessage());
result.setSampleLabel(lastPath);
result.setResponseHeaders("URL: " + uriString + "\n" + respond.getHeadersAsString());
result.setResponseCode(respond.getResponseCode());
result.setContentType(respond.getContentType());
result.setBytes(result.getBytesAsLong() + (long) result.getRequestHeaders().length());
int headerBytes = result.getResponseHeaders().length() // condensed
// length
// (without
// \r)
+ respond.getHeaders().size() // Add \r for each header
+ 1 // Add \r for initial header
+ 2; // final \r\n before data
result.setHeadersSize((int) headerBytes);
result.setSentBytes(respond.getSentBytes());
result.setDataEncoding(respond.getContentEncoding());
res.add(result);
} catch (IOException e1) {
e1.printStackTrace();
result.sampleEnd();
result.setSuccessful(false);
result.setResponseMessage("Exception: " + e1);
res.add(result);
}
uris.remove(0);
List<SampleResult> aux = getFragments(parser, uris, url);
for (SampleResult s : aux) {
if(!res.contains(s))
res.add(s);
}
}
return res;
}