當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。