本文整理匯總了Java中org.apache.jmeter.samplers.SampleResult.setContentType方法的典型用法代碼示例。如果您正苦於以下問題:Java SampleResult.setContentType方法的具體用法?Java SampleResult.setContentType怎麽用?Java SampleResult.setContentType使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類org.apache.jmeter.samplers.SampleResult
的用法示例。
在下文中一共展示了SampleResult.setContentType方法的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;
}