当前位置: 首页>>代码示例>>Java>>正文


Java SampleResult.addSubResult方法代码示例

本文整理汇总了Java中org.apache.jmeter.samplers.SampleResult.addSubResult方法的典型用法代码示例。如果您正苦于以下问题:Java SampleResult.addSubResult方法的具体用法?Java SampleResult.addSubResult怎么用?Java SampleResult.addSubResult使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.apache.jmeter.samplers.SampleResult的用法示例。


在下文中一共展示了SampleResult.addSubResult方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: perform

import org.apache.jmeter.samplers.SampleResult; //导入方法依赖的package包/类
@Override
public SampleResult perform(JMeterXMPPSampler sampler, SampleResult res) throws Exception {
    long counter = 0;
    for (Packet packet : incomingPackets) {
        incomingPackets.remove(packet);
        SampleResult subRes = new SampleResult();
        subRes.setSuccessful(true);
        subRes.setResponseCode("200");
        subRes.setResponseMessage("OK");
        subRes.setSampleLabel(packet.getClass().getSimpleName().isEmpty() ? packet.getClass().getName() : packet.getClass().getSimpleName());
        subRes.setResponseData(packet.toXML().toString().getBytes());

        if ((packet instanceof Presence) && (((Presence) packet).getType() == Presence.Type.error)) {
            subRes.setSuccessful(false);
            subRes.setResponseCode("500");
            subRes.setResponseMessage(packet.getError().toString());
        } else if ((packet instanceof Message) && (((Message) packet).getType() == Message.Type.error)) {
            subRes.setSuccessful(false);
            subRes.setResponseCode("500");
            subRes.setResponseMessage(packet.getError().toString());
        } else if ((packet instanceof IQ) && (((IQ) packet).getType() == IQ.Type.error)) {
            subRes.setSuccessful(false);
            subRes.setResponseCode("500");
            subRes.setResponseMessage(packet.getError().toString());
        }

        res.addSubResult(subRes);
        counter++;
    }
    res.setResponseData(("Received packets: " + counter).getBytes());
    return counter > 0 ? res : null;
}
 
开发者ID:Blazemeter,项目名称:jmeter-bzm-plugins,代码行数:33,代码来源:NoOp.java

示例2: sample

import org.apache.jmeter.samplers.SampleResult; //导入方法依赖的package包/类
@Override
public SampleResult sample(Entry e) {
	SampleResult masterResult = new SampleResult();
	float currenTimeseconds = 0;
	boolean isVod = getHlsVideoType().equals("vod");
	boolean out = false;
	boolean firstTime = true;
	boolean containNewFragments = false;
	List<String> list = new ArrayList<>();

	try {

		DataRequest respond = getMasterList(masterResult, parser);
		String auxPath = getPlaylistPath(respond, parser);

		int playSeconds = 0;
		if (!getPlAYSecondsData().isEmpty())
			playSeconds = Integer.parseInt(getPlAYSecondsData());


		while ((playSeconds >= currenTimeseconds) && !out) {

			SampleResult playListResult = new SampleResult();
			DataRequest subRespond = getPlayList(playListResult, parser);

			List<DataFragment> videoUri = parser.extractVideoUrl(subRespond.getResponse());
			List<DataFragment> fragmentToDownload = new ArrayList<>();

			if (firstTime) {
				if (!(((getHlsVideoType().equals("live")) && (parser.isLive(subRespond.getResponse())))
						|| ((isVod) && (!parser.isLive(subRespond.getResponse())))
						|| ((getHlsVideoType().equals("event")) && (parser.isLive(subRespond.getResponse()))))) {
				} else {
					firstTime = false;
					out = isVod;
				}

			}

			while ((!videoUri.isEmpty()) && (playSeconds >= currenTimeseconds)) {
				DataFragment frag = videoUri.remove(0);

				boolean isPresent = false;
				int length = fragmentsDownloaded.size();

				if (length != 0) {
					isPresent = fragmentsDownloaded.contains(frag.getTsUri().trim());
				}

				if (!isPresent) {
					fragmentToDownload.add(frag);
					fragmentsDownloaded.add(frag.getTsUri().trim());
					containNewFragments = true;
					if(getVideoDuration()) {
						currenTimeseconds += Float.parseFloat(frag.getDuration());
					}
				}
			}

			List<SampleResult> videoFragment = getFragments(parser, fragmentToDownload, auxPath);
			for (SampleResult sam : videoFragment) {
				playListResult.addSubResult(sam);
			}

			if((!list.contains(playListResult.getSampleLabel())) || (list.contains(playListResult.getSampleLabel()) && containNewFragments))
			{
				masterResult.addSubResult(playListResult);
				list.add(playListResult.getSampleLabel());
				containNewFragments = false;
			}

		}

	} catch (IOException e1) {
		e1.printStackTrace();
		masterResult.sampleEnd();
		masterResult.setSuccessful(false);
		masterResult.setResponseMessage("Exception: " + e1);
	}
	return masterResult;
}
 
开发者ID:Blazemeter,项目名称:jmeter-bzm-plugins,代码行数:82,代码来源:HlsSampler.java


注:本文中的org.apache.jmeter.samplers.SampleResult.addSubResult方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。