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


Java SampleResult类代码示例

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


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

示例1: getResponseAsString

import org.apache.jmeter.samplers.SampleResult; //导入依赖的package包/类
public static String getResponseAsString(SampleResult res) {
    String response = null;
    if (isTextDataType(res)) {
        // Showing large strings can be VERY costly, so we will avoid
        // doing so if the response
        // data is larger than 200K. TODO: instead, we could delay doing
        // the result.setText
        // call until the user chooses the "Response data" tab. Plus we
        // could warn the user
        // if this happens and revert the choice if he doesn't confirm
        // he's ready to wait.
        int len = res.getResponseDataAsString().length();
        if (MAX_DISPLAY_SIZE > 0 && len > MAX_DISPLAY_SIZE) {
            StringBuilder builder = new StringBuilder(MAX_DISPLAY_SIZE+100);
            builder.append(JMeterUtils.getResString("view_results_response_too_large_message")) //$NON-NLS-1$
                .append(len).append(" > Max: ").append(MAX_DISPLAY_SIZE)
                .append(", ").append(JMeterUtils.getResString("view_results_response_partial_message")) // $NON-NLS-1$
                .append("\n").append(res.getResponseDataAsString().substring(0, MAX_DISPLAY_SIZE)).append("\n...");
            response = builder.toString();
        } else {
            response = res.getResponseDataAsString();
        }
    }
    return response;
}
 
开发者ID:Blazemeter,项目名称:jmeter-bzm-plugins,代码行数:26,代码来源:ViewResultsFullVisualizer.java

示例2: caclucateMetrics

import org.apache.jmeter.samplers.SampleResult; //导入依赖的package包/类
private static JSONObject caclucateMetrics(List<SampleResult> accumulatedValues, List<SampleResult> intervalValues, String label) {
    final JSONObject res = new JSONObject();

    res.put("n", accumulatedValues.size());                              // total count of samples
    res.put("name", label);                                 // label
    res.put("interval", 1);                                 // not used
    res.put("samplesNotCounted", 0);                        // not used
    res.put("assertionsNotCounted", 0);                     // not used
    res.put("failedEmbeddedResources", "[]");               // not used
    res.put("failedEmbeddedResourcesSpilloverCount", 0);    // not used
    res.put("otherErrorsCount", 0);                         // not used
    res.put("percentileHistogram", "[]");                   // not used
    res.put("percentileHistogramLatency", "[]");            // not used
    res.put("percentileHistogramBytes", "[]");              // not used
    res.put("empty", "[]");                                 // not used

    res.put("summary", generateSummary(accumulatedValues));              // summary info
    res.put("intervals", calculateIntervals(intervalValues));         // list of intervals

    addErrors(res, accumulatedValues);

    return res;
}
 
开发者ID:Blazemeter,项目名称:jmeter-bzm-plugins,代码行数:24,代码来源:JSONConverter.java

示例3: testHandleSamples

import org.apache.jmeter.samplers.SampleResult; //导入依赖的package包/类
@Test
public void testHandleSamples() throws Exception {
    JMeterUtils.setProperty("sense.delay", "10000");
    LoadosophiaClient client = new LoadosophiaClient();
    client.setOnlineInitiated(true);
    client.setResultCollector(new ResultCollector());
    client.setFileName("");

    StatusNotifierCallbackTest.StatusNotifierCallbackImpl  notifierCallback = new StatusNotifierCallbackTest.StatusNotifierCallbackImpl();
    client.setInformer(notifierCallback);
    client.setApiClient(new LoadosophiaAPIClientEmul(notifierCallback));

    List<SampleResult> list = new LinkedList<>();
    list.add(new SampleResult(System.currentTimeMillis(), 1));
    list.add(new SampleResult(System.currentTimeMillis() + 1000, 1));
    list.add(new SampleResult(System.currentTimeMillis() + 2000, 1));

    long start = System.currentTimeMillis();
    client.handleSampleResults(list, null);
    long end = System.currentTimeMillis();
    assertTrue((end - start) > 9999);
}
 
开发者ID:Blazemeter,项目名称:jmeter-bzm-plugins,代码行数:23,代码来源:LoadosophiaClientTest.java

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

示例5: flowDefault

import org.apache.jmeter.samplers.SampleResult; //导入依赖的package包/类
@Test
public void flowDefault() throws Exception {
    RotatingResultCollector te = new RotatingResultCollector();
    te.setMaxSamplesCount("ZXC");
    assertEquals(Integer.MAX_VALUE, te.getMaxSamplesCountAsInt());

    File f = File.createTempFile("rotating", ".jtl");
    f.deleteOnExit();
    te.setFilename(f.getAbsolutePath());
    te.setMaxSamplesCount("3");
    te.testStarted();

    for (int n = 0; n < 10; n++) {
        SampleResult result = new SampleResult();
        result.setSampleLabel("#" + n);
        te.sampleOccurred(new SampleEvent(result, ""));
    }

    te.testEnded();
    assertTrue(te.filename.endsWith(".3.jtl"));
}
 
开发者ID:Blazemeter,项目名称:jmeter-bzm-plugins,代码行数:22,代码来源:RotatingResultCollectorTest.java

示例6: testFlowWithoutExtension

import org.apache.jmeter.samplers.SampleResult; //导入依赖的package包/类
@Test
public void testFlowWithoutExtension() throws Exception {
    RotatingResultCollector te = new RotatingResultCollector();
    te.setMaxSamplesCount("ZXC");
    assertEquals(Integer.MAX_VALUE, te.getMaxSamplesCountAsInt());

    File f = File.createTempFile("rotating", "");
    f.deleteOnExit();
    te.setFilename(f.getAbsolutePath());
    te.setMaxSamplesCount("3");
    te.testStarted();

    for (int n = 0; n < 10; n++) {
        SampleResult result = new SampleResult();
        result.setSampleLabel("#" + n);
        te.sampleOccurred(new SampleEvent(result, ""));
    }

    te.testEnded();
    assertTrue(te.filename, te.filename.endsWith(".3"));
}
 
开发者ID:Blazemeter,项目名称:jmeter-bzm-plugins,代码行数:22,代码来源:RotatingResultCollectorTest.java

示例7: testFlowWithNumberExtension

import org.apache.jmeter.samplers.SampleResult; //导入依赖的package包/类
@Test
public void testFlowWithNumberExtension() throws Exception {
    RotatingResultCollector te = new RotatingResultCollector();
    te.setMaxSamplesCount("ZXC");
    assertEquals(Integer.MAX_VALUE, te.getMaxSamplesCountAsInt());

    File f = File.createTempFile("rotating", ".9");
    f.deleteOnExit();
    te.setFilename(f.getAbsolutePath());
    te.setMaxSamplesCount("3");
    te.testStarted();

    for (int n = 0; n < 10; n++) {
        SampleResult result = new SampleResult();
        result.setSampleLabel("#" + n);
        te.sampleOccurred(new SampleEvent(result, ""));
    }

    te.testEnded();
    assertTrue(te.filename, te.filename.endsWith(".3.9"));
}
 
开发者ID:Blazemeter,项目名称:jmeter-bzm-plugins,代码行数:22,代码来源:RotatingResultCollectorTest.java

示例8: updateGui

import org.apache.jmeter.samplers.SampleResult; //导入依赖的package包/类
/**
 * Update the visualizer with new data.
 */
private synchronized void updateGui(SampleResult res) {
    // Add sample
    DefaultMutableTreeNode currNode = new SearchableTreeNode(res, treeModel);
    treeModel.insertNodeInto(currNode, root, root.getChildCount());
    addSubResults(currNode, res);
    // Add any assertion that failed as children of the sample node
    AssertionResult[] assertionResults = res.getAssertionResults();
    int assertionIndex = currNode.getChildCount();
    for (AssertionResult assertionResult : assertionResults) {
        if (assertionResult.isFailure() || assertionResult.isError()) {
            DefaultMutableTreeNode assertionNode = new SearchableTreeNode(assertionResult, treeModel);
            treeModel.insertNodeInto(assertionNode, currNode, assertionIndex++);
        }
    }

    if (root.getChildCount() == 1) {
        jTree.expandPath(new TreePath(root));
    }
    if (autoScrollCB.isSelected() && root.getChildCount() > 1) {
        jTree.scrollPathToVisible(new TreePath(new Object[] { root,
                treeModel.getChild(root, root.getChildCount() - 1) }));
    }
}
 
开发者ID:Blazemeter,项目名称:jmeter-bzm-plugins,代码行数:27,代码来源:ViewResultsFullVisualizer.java

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

示例10: setParentSampleSuccess

import org.apache.jmeter.samplers.SampleResult; //导入依赖的package包/类
/**
 * Set parent successful attribute based on IGNORE_FAILED_EMBEDDED_RESOURCES
 * parameter
 * 
 * @param res
 *            {@link HTTP2SampleResult}
 * @param initialValue
 *            boolean
 */
private void setParentSampleSuccess(HTTP2SampleResult res, boolean initialValue) {
	if (!IGNORE_FAILED_EMBEDDED_RESOURCES) {
		res.setSuccessful(initialValue);
		if (!initialValue) {
			StringBuilder detailedMessage = new StringBuilder(80);
			detailedMessage.append("Embedded resource download error:"); //$NON-NLS-1$
			for (SampleResult subResult : res.getSubResults()) {
				HTTP2SampleResult httpSampleResult = (HTTP2SampleResult) subResult;
				if (!httpSampleResult.isSuccessful()) {
					detailedMessage.append(httpSampleResult.getURL()).append(" code:") //$NON-NLS-1$
							.append(httpSampleResult.getResponseCode()).append(" message:") //$NON-NLS-1$
							.append(httpSampleResult.getResponseMessage()).append(", "); //$NON-NLS-1$
				}
			}
			res.setResponseMessage(detailedMessage.toString()); // $NON-NLS-1$
		}
	}
}
 
开发者ID:Blazemeter,项目名称:jmeter-bzm-plugins,代码行数:28,代码来源:HTTP2StreamHandler.java

示例11: setUp

import org.apache.jmeter.samplers.SampleResult; //导入依赖的package包/类
@Before
public void setUp() throws Exception {
    sampler = HTTPSamplerFactory.newInstance();
    sampler.setProtocol("http");
    sampler.setDomain("dummy.net");
    sampler.setPath("/base/form");
    sampler.setMethod("POST");
    
    prev = SampleResult.createTestSample(0);
    prev.setURL(new URL("http://dummy.net/base/form"));
    prev.setContentType("text/html");
    prev.setResponseData(html, "UTF-8");
     
    context = JMeterContextService.getContext();
    context.setCurrentSampler(sampler);
    context.setPreviousResult(prev);
    
    instance = new HTTPFormManager();
    instance.setThreadContext(context);
}
 
开发者ID:tilln,项目名称:jmeter-formman,代码行数:21,代码来源:TestHTTPFormManager.java

示例12: sample

import org.apache.jmeter.samplers.SampleResult; //导入依赖的package包/类
/**
 * Perform a sample, and return the results
 *
 * @return results of the sampling
 */
public SampleResult sample() {
    SampleResult res = null;
    try {
    	URL url= getUrl();
    	// Create Sample Result
    	HTTP2SampleResult sampleResult =new HTTP2SampleResult(url, getMethod());
    	setConnection(url, sampleResult);
        res = sample(url, getMethod(), false, 0, getConnection(), sampleResult);
        if (res != null) {
            res.setSampleLabel(getName());
        }
        return res;
    } catch (Exception e) {
    	return res;
    }
}
 
开发者ID:Blazemeter,项目名称:jmeter-bzm-plugins,代码行数:22,代码来源:HTTP2Request.java

示例13: sampleOccurredTest

import org.apache.jmeter.samplers.SampleResult; //导入依赖的package包/类
@Test
public void sampleOccurredTest() throws Exception {
 HTTP2SampleResult result = new HTTP2SampleResult();
 HTTP2SampleResult child1 = new HTTP2SampleResult();
 HTTP2SampleResult child2 = new HTTP2SampleResult();
 child1.sampleStart();
 child2.sampleStart();
 result.sampleStart();
 result.addSubResult(child1);
 result.addSubResult(child2);
 SampleEvent event = new SampleEvent((SampleResult) result, "threadGroup", "");
 http2ResultCollector.setFilename("datawriter");
 http2ResultCollector.testStarted();
 http2ResultCollector.sampleOccurred(event);
 http2ResultCollector.testEnded();
}
 
开发者ID:Blazemeter,项目名称:jmeter-bzm-plugins,代码行数:17,代码来源:ResultCollectorTest.java

示例14: getResponseAsStringTest

import org.apache.jmeter.samplers.SampleResult; //导入依赖的package包/类
@Test
public void getResponseAsStringTest() {
 HTTP2SampleResult http2SampleRes= new HTTP2SampleResult();
 http2SampleRes.setDataType(SampleResult.TEXT);
 String textExp = "Convert Java String";
 byte[] bytes = textExp.getBytes();
 http2SampleRes.setResponseData(bytes);
 String textRes = http2ViewResTree.getResponseAsString(http2SampleRes);
 
 assertEquals(textExp, textRes);
 
 
 HTTP2SampleResult http2SampleRes2= new HTTP2SampleResult();
 textExp = "Convert Java String and more text";
 bytes = textExp.getBytes();
 http2SampleRes2.setResponseData(bytes);
 textRes = http2ViewResTree.getResponseAsString(http2SampleRes2);
 
 assertTrue(textRes.contains("Response too large to be displayed."));
 
 
}
 
开发者ID:Blazemeter,项目名称:jmeter-bzm-plugins,代码行数:23,代码来源:ViewResultFullVisualizerTest.java

示例15: handleSampleResults

import org.apache.jmeter.samplers.SampleResult; //导入依赖的package包/类
@Override
public void handleSampleResults(List<SampleResult> list, BackendListenerContext backendListenerContext) {
    if (list != null && isOnlineInitiated) {
        try {
            JSONArray array = getDataToSend(list);
            log.info(array.toString());
            apiClient.sendOnlineData(array);
        } catch (IOException ex) {
            log.warn("Failed to send active test data", ex);
        }
        try {
            Thread.sleep(delay);
        } catch (InterruptedException e) {
            log.warn("Backend listener client thread was interrupted");
        }
    }
}
 
开发者ID:Blazemeter,项目名称:jmeter-bzm-plugins,代码行数:18,代码来源:LoadosophiaClient.java


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