本文整理汇总了Java中org.apache.jmeter.samplers.SampleSaveConfiguration.saveResponseData方法的典型用法代码示例。如果您正苦于以下问题:Java SampleSaveConfiguration.saveResponseData方法的具体用法?Java SampleSaveConfiguration.saveResponseData怎么用?Java SampleSaveConfiguration.saveResponseData使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.apache.jmeter.samplers.SampleSaveConfiguration
的用法示例。
在下文中一共展示了SampleSaveConfiguration.saveResponseData方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: saveResponseData
import org.apache.jmeter.samplers.SampleSaveConfiguration; //导入方法依赖的package包/类
/**
* Save the response from the sample result into the stream
*
* @param writer
* stream to save objects into
* @param context
* context for xstream to allow nested objects
* @param res
* sample to be saved
* @param save
* configuration telling us what to save
*/
protected void saveResponseData(HierarchicalStreamWriter writer, MarshallingContext context, SampleResult res,
SampleSaveConfiguration save) {
if (save.saveResponseData(res)) {
writer.startNode(TAG_RESPONSE_DATA);
writer.addAttribute(ATT_CLASS, JAVA_LANG_STRING);
try {
if (SampleResult.TEXT.equals(res.getDataType())){
writer.setValue(new String(res.getResponseData(), res.getDataEncodingWithDefault()));
} else {
writer.setValue("Non-TEXT response data, cannot record: (" + res.getDataType() + ")");
}
// Otherwise don't save anything - no point
} catch (UnsupportedEncodingException e) {
writer.setValue("Unsupported encoding in response data, cannot record: " + e);
}
writer.endNode();
}
if (save.saveFileName()){
writer.startNode(TAG_RESPONSE_FILE);
writer.addAttribute(ATT_CLASS, JAVA_LANG_STRING);
writer.setValue(res.getResultFileName());
writer.endNode();
}
}
示例2: saveResponseData
import org.apache.jmeter.samplers.SampleSaveConfiguration; //导入方法依赖的package包/类
/**
* @param writer
* @param res
* @param save
*/
protected void saveResponseData(HierarchicalStreamWriter writer, MarshallingContext context, SampleResult res,
SampleSaveConfiguration save) {
if (save.saveResponseData(res)) {
writer.startNode(TAG_RESPONSE_DATA);
writer.addAttribute(ATT_CLASS, JAVA_LANG_STRING);
try {
if (SampleResult.TEXT.equals(res.getDataType())){
writer.setValue(new String(res.getResponseData(), res.getDataEncodingWithDefault()));
}
// Otherwise don't save anything - no point
} catch (UnsupportedEncodingException e) {
writer.setValue("Unsupported encoding in response data, can't record.");
}
writer.endNode();
}
if (save.saveFileName()){
writer.startNode(TAG_RESPONSE_FILE);
writer.addAttribute(ATT_CLASS, JAVA_LANG_STRING);
writer.setValue(res.getResultFileName());
writer.endNode();
}
}