當前位置: 首頁>>代碼示例>>Java>>正文


Java SampleResult.setSuccessful方法代碼示例

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


在下文中一共展示了SampleResult.setSuccessful方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: send

import org.apache.jmeter.samplers.SampleResult; //導入方法依賴的package包/類
@Override
public void send(JMeterContext context, SampleResult result) {
    JMeterVariables variables = context.getVariables();
    ConcurrentHashMap<String, MockLwM2mClient> clients = (ConcurrentHashMap<String, MockLwM2mClient>) variables.getObject("lwm2mClients");
    MockLwM2mClient client = clients.get(endpoint);
    if (client != null) {
        SimpleResource resource = (SimpleResource) client.getObject(objectId).getChild(instanceId).getChild(resourceId);
        result.sampleStart();
        if (resource != null) {
            resource.setResourceValue(Float.toString(rng.nextInt(100)));
            result.setSuccessful(true);
            log.debug("Sent observation for " + objectId + "/" + instanceId + "/" + resourceId);
        } else {
            result.setSuccessful(false);
            log.debug("Could not send observation for " + objectId + "/" + instanceId + "/" + resourceId);
        }
        result.sampleEnd();
    }
}
 
開發者ID:vears91,項目名稱:lwm2m-jmeter,代碼行數:20,代碼來源:NotifyObserversSampler.java

示例2: createLeftPanel

import org.apache.jmeter.samplers.SampleResult; //導入方法依賴的package包/類
private synchronized Component createLeftPanel() {
    SampleResult rootSampleResult = new SampleResult();
    rootSampleResult.setSampleLabel("Root");
    rootSampleResult.setSuccessful(true);
    root = new SearchableTreeNode(rootSampleResult, null);

    treeModel = new DefaultTreeModel(root);
    jTree = new JTree(treeModel);
    jTree.setCellRenderer(new ResultsNodeRenderer());
    jTree.getSelectionModel().setSelectionMode(TreeSelectionModel.SINGLE_TREE_SELECTION);
    jTree.addTreeSelectionListener(this);
    jTree.setRootVisible(false);
    jTree.setShowsRootHandles(true);
    JScrollPane treePane = new JScrollPane(jTree);
    treePane.setPreferredSize(new Dimension(200, 300));

    VerticalPanel leftPane = new VerticalPanel();
    leftPane.add(treePane, BorderLayout.CENTER);
    leftPane.add(createComboRender(), BorderLayout.NORTH);
    autoScrollCB = new JCheckBox(JMeterUtils.getResString("view_results_autoscroll")); // $NON-NLS-1$
    autoScrollCB.setSelected(false);
    autoScrollCB.addItemListener(this);
    leftPane.add(autoScrollCB, BorderLayout.SOUTH);
    return leftPane;
}
 
開發者ID:Blazemeter,項目名稱:jmeter-bzm-plugins,代碼行數:26,代碼來源:ViewResultsFullVisualizer.java

示例3: waitResponse

import org.apache.jmeter.samplers.SampleResult; //導入方法依賴的package包/類
private SampleResult waitResponse(SampleResult res, String recipient) throws InterruptedException, SmackException {
    long time = 0;
    do {
        Iterator<Message> packets = responseMessages.iterator();
        Thread.sleep(conn.getPacketReplyTimeout() / 100); // optimistic
        while (packets.hasNext()) {
            Packet packet = packets.next();
            Message response = (Message) packet;
            if (XmppStringUtils.parseBareAddress(response.getFrom()).equals(recipient)) {
                packets.remove();
                res.setResponseData(response.toXML().toString().getBytes());
                if (response.getError() != null) {
                    res.setSuccessful(false);
                    res.setResponseCode("500");
                    res.setResponseMessage(response.getError().toString());
                }
                return res;
            }
        }
        time += conn.getPacketReplyTimeout() / 10;
        Thread.sleep(conn.getPacketReplyTimeout() / 10);
    } while (time < conn.getPacketReplyTimeout());
    throw new SmackException.NoResponseException();
}
 
開發者ID:Blazemeter,項目名稱:jmeter-bzm-plugins,代碼行數:25,代碼來源:SendMessage.java

示例4: sample

import org.apache.jmeter.samplers.SampleResult; //導入方法依賴的package包/類
public SampleResult sample(Entry arg0) {
	SampleResult res = new SampleResult();
	res.setSampleLabel("函數助手小工具");
	res.sampleStart();
	
	// 輸出GUI界麵所輸入的函數方法返回結果
	JMeterProperty properties = this.getProperty(FUNCTION);
	
	System.out.println(properties);
	
	//
	if (properties != null) {
		res.setResponseData("Function結果是:" + properties.getStringValue(), null);
		res.setDataType(SampleResult.TEXT);
	}
	
	res.sampleEnd();
	res.setSuccessful(true);
	return res;
}
 
開發者ID:mzanthem,項目名稱:Baozun_jmeter,代碼行數:21,代碼來源:TestSampler.java

示例5: runTest

import org.apache.jmeter.samplers.SampleResult; //導入方法依賴的package包/類
/**
 * For each sample request this method is invoked and will return success/failure result
 *
 * @param context
 * @return
 */
@Override
public SampleResult runTest(JavaSamplerContext context) {

    SampleResult sampleResult = new SampleResult();
    sampleResult.sampleStart();
    Object message = JMeterContextService.getContext().getVariables().getObject(placeHolder);

    try {

        ProducerRecord<String, Object> producerRecord = new ProducerRecord<String, Object>(topic, message);
        producer.send(producerRecord);
        sampleResult.setResponseData(message.toString(), StandardCharsets.UTF_8.name());
        sampleResult.setSuccessful(true);
        sampleResult.sampleEnd();

    } catch (Exception e) {
        log.error("Failed to send message", e);
        sampleResult.setResponseData(e.getMessage(), StandardCharsets.UTF_8.name());
        sampleResult.setSuccessful(false);
        sampleResult.sampleEnd();

    }

    return sampleResult;
}
 
開發者ID:GSLabDev,項目名稱:pepper-box,代碼行數:32,代碼來源:PepperBoxKafkaSampler.java

示例6: fillFailedResult

import org.apache.jmeter.samplers.SampleResult; //導入方法依賴的package包/類
private SampleResult fillFailedResult(boolean sampleByTime, SampleResult result, String message) {
	result.setResponseCode("500");
	result.setSuccessful(false);
	result.setResponseMessage(message);
	result.setResponseData(message.getBytes());
	result.setEndTime(result.getStartTime());
	
	if(sampleByTime) {
		try {
			TimeUnit.MILLISECONDS.sleep(Long.parseLong(getSampleElapsedTime()));
		} catch (InterruptedException e) {
			logger.info("Received exception when waiting for notification signal: " + e.getMessage());
		}
	}
	return result;
}
 
開發者ID:emqtt,項目名稱:mqtt-jmeter,代碼行數:17,代碼來源:SubSampler.java

示例7: 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;

	}
 
開發者ID:Blazemeter,項目名稱:jmeter-bzm-plugins,代碼行數:33,代碼來源:HlsSampler.java

示例8: 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;
	}
 
開發者ID:Blazemeter,項目名稱:jmeter-bzm-plugins,代碼行數:36,代碼來源:HlsSampler.java

示例9: 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

示例10: process

import org.apache.jmeter.samplers.SampleResult; //導入方法依賴的package包/類
@Override
public void process() {
    SampleResult prev = getThreadContext().getPreviousResult();
    if (prev == null) return;

    String xml = prev.getResponseDataAsString();
    if (xml == null) return;

    try {
        log.debug("Parsing xml response");
        Document doc = stringToDocument(xml);

        log.debug("Processing WSS header");
        doc = this.process(doc); // Delegate in abstract method

        prev.setResponseData(documentToString(doc), prev.getDataEncodingWithDefault());
    }
    catch (Exception e) {
        log.error("Processing failed! ", e);
        if (e instanceof WSSecurityException && JMeterUtils.getPropDefault(FAIL_ON_WSS_EXCEPTION, true)) {
            AssertionResult assertionResult = new AssertionResult("WSSecurityException").setResultForFailure(e.getMessage());
            assertionResult.setError(true);
            assertionResult.setFailure(true);
            prev.addAssertionResult(assertionResult);
            prev.setSuccessful(false);
        }
    }
}
 
開發者ID:tilln,項目名稱:jmeter-wssecurity,代碼行數:29,代碼來源:AbstractWSSecurityPostProcessor.java

示例11: setUp

import org.apache.jmeter.samplers.SampleResult; //導入方法依賴的package包/類
@Before
public void setUp() throws Exception {
    context = JMeterContextService.getContext();
    mod = new WSSDecryptionPostProcessor();
    mod.setThreadContext(context);
    mod.setKeystoreFile("src/test/resources/keystore.jks");
    mod.setKeystorePassword("changeit");
    mod.setCertPassword("changeit");
    result = new SampleResult();
    result.setSuccessful(true);
}
 
開發者ID:tilln,項目名稱:jmeter-wssecurity,代碼行數:12,代碼來源:TestWSSDecryptionPostProcessor.java

示例12: runTest

import org.apache.jmeter.samplers.SampleResult; //導入方法依賴的package包/類
/**
 * 開始測試,從arg0參數可以獲得參數值;
 */
public SampleResult runTest(JavaSamplerContext arg0) {
	name = arg0.getParameter("name");
	SampleResult sr = new SampleResult();

	sr.setSampleLabel("Java請求--sayHelloToPerson");
	try {
		// jmeter 開始統計響應時間標記
		sr.sampleStart();

		Hello test = new Hello();

		// 通過下麵的操作就可以將被測方法的響應輸出到Jmeter的察看結果樹中的響應數據裏麵了。
		resultData = test.sayHelloToPerson(name);

		if (resultData != null && resultData.length() > 0) {
			sr.setResponseData("結果是:" + resultData, null);
			sr.setDataType(SampleResult.TEXT);
		}
		sr.setSuccessful(true);
	} catch (Throwable e) {
		sr.setSuccessful(false);
		e.printStackTrace();
	} finally {
		// jmeter 結束統計響應時間標記
		sr.sampleEnd();
	}
	return sr;
}
 
開發者ID:mzanthem,項目名稱:Baozun_jmeter,代碼行數:32,代碼來源:HelloTest2.java

示例13: runTest

import org.apache.jmeter.samplers.SampleResult; //導入方法依賴的package包/類
public SampleResult runTest(JavaSamplerContext context) {

		String name = context.getParameter("name");
		getNewLogger().info("dubbo test - {}  start", name);
		SampleResult sr = new SampleResult();
		// 開始測試
		sr.sampleStart();
		start = System.currentTimeMillis();
		sr.setSampleLabel("Dubbo請求--sayHello");
		try {

			String result = this.userService.sayHello();
			if (null != result && result.length() > 0) {
				sr.setResponseData("結果是:" + result, null);
				sr.setDataType(SampleResult.TEXT);
			}

			sr.setSuccessful(true);
		} catch (Exception e) {
			sr.setSuccessful(false);
			e.printStackTrace();
		} finally {
			sr.sampleEnd();
		}

		return sr;
	}
 
開發者ID:mzanthem,項目名稱:Baozun_jmeter,代碼行數:28,代碼來源:DubboTest.java

示例14: runTest

import org.apache.jmeter.samplers.SampleResult; //導入方法依賴的package包/類
@Override
public SampleResult runTest(JavaSamplerContext javaSamplerContext) {
	SampleResult sampleResult = new SampleResult();
	long sampleStart = 0;
	long sampleEnd = 0;

	try {
		assertNotInterrupted();
		executing = true;
		setup();
		setSampleLabel(sampleResult);
		execute();
		assertSuccess();
		sampleResult.setSuccessful(true);
		sampleStart = martiniResult.getStartTimestamp();
		sampleEnd = martiniResult.getEndTimestamp();
		setResponse(sampleResult);
	}
	catch (Exception e) {
		super.getNewLogger().warn("unable to execute Martini", e);
		sampleResult.setSuccessful(false);
		String message = Throwables.getStackTraceAsString(e);
		sampleResult.setResponseMessage(message);
	}
	finally {
		sampleResult.setStampAndTime(sampleStart, sampleEnd);
		teardown();
		executing = false;
	}
	return sampleResult;
}
 
開發者ID:qas-guru,項目名稱:martini-jmeter-extension,代碼行數:32,代碼來源:MartiniSamplerClient.java

示例15: fillOKResult

import org.apache.jmeter.samplers.SampleResult; //導入方法依賴的package包/類
private SampleResult fillOKResult(SampleResult result, int size, String message, String contents) {
	result.setResponseCode("200");
	result.setSuccessful(true);
	result.setResponseMessage(message);
	result.setBodySize(size);
	result.setBytes(size);
	result.setResponseData(contents.getBytes());
	result.sampleEnd();
	return result;
}
 
開發者ID:emqtt,項目名稱:mqtt-jmeter,代碼行數:11,代碼來源:SubSampler.java


注:本文中的org.apache.jmeter.samplers.SampleResult.setSuccessful方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。