本文整理匯總了Java中org.apache.jmeter.samplers.SampleResult.getSubResults方法的典型用法代碼示例。如果您正苦於以下問題:Java SampleResult.getSubResults方法的具體用法?Java SampleResult.getSubResults怎麽用?Java SampleResult.getSubResults使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類org.apache.jmeter.samplers.SampleResult
的用法示例。
在下文中一共展示了SampleResult.getSubResults方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: sample
import org.apache.jmeter.samplers.SampleResult; //導入方法依賴的package包/類
@Test
public void sample() throws Exception {
JMeterThread dummy = new JMeterThread(new HashTree(new GenericController()), null, null);
JMeterContextService.getContext().setThread(dummy);
JMeterThread thr = JMeterContextService.getContext().getThread();
for (int n = 0; n < 1000; n++) {// we're doing good check here because of multi-threads
log.debug("\n\n\nTry #" + n);
EmulSampler.instances = 0;
EmulSampler.count.set(0);
ParallelSampler obj = new ParallelSampler();
obj.threadStarted();
obj.setGenerateParent(true);
obj.addTestElement(getContextedSampler(thr));
obj.addTestElement(getContextedSampler(thr));
obj.addTestElement(getContextedSampler(thr));
obj.addTestElement(getContextedSampler(thr));
obj.addTestElement(getContextedSampler(thr));
SampleResult res = obj.sample(null);
assertEquals(5, EmulSampler.count.get());
if (res.getSubResults().length < 5) {
throw new AssertionError();
}
assertEquals(5, res.getSubResults().length);
}
}
示例2: sampleOccurred
import org.apache.jmeter.samplers.SampleResult; //導入方法依賴的package包/類
/**
* When a test result is received, display it and save it.
*
* @param event
* the sample event that was received
*/
@Override
public void sampleOccurred(SampleEvent event) {
SampleResult result = event.getResult();
// Verify if it's an HTTPSampleResult
if (result instanceof HTTP2SampleResult) {
HTTP2SampleResult http2Result = (HTTP2SampleResult) result;
if (!http2Result.isPendingResponse()) {
SampleResult[] subResults = result.getSubResults();
//Look into childs to get the response of the message and the response of the secondary requests
for (SampleResult child : subResults) {
if (child instanceof HTTP2SampleResult) {
http2Result = (HTTP2SampleResult) child;
if (!http2Result.isSecondaryRequest()) {
SampleEvent evtChild = new SampleEvent(child, event.getThreadGroup());
// The method implements the same logic to save as method SampleOcurred of JMeter.
saveLine(evtChild);
}
}
}
saveLine(event);
}
} else {
// If it's not an HTTP2SampleResult follow the normal flow
saveLine(event);
}
}