org.apache.jmeter.reporters.ResultCollector Java Examples

The following examples show how to use org.apache.jmeter.reporters.ResultCollector. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: LoadosophiaClientTest.java    From jmeter-bzm-plugins with Apache License 2.0 6 votes vote down vote up
@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);
}
 
Example #2
Source File: LoadosophiaClientTest.java    From jmeter-bzm-plugins with Apache License 2.0 6 votes vote down vote up
@Test
public void testStop() throws Exception {
    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));

    client.teardownTest(null);
    String results = notifierCallback.getBuffer().toString();

    assertTrue(results.contains("Failed to upload results to BM.Sense, see log for detais"));
}
 
Example #3
Source File: DebuggerDialogBase.java    From jmeter-debugger with Apache License 2.0 6 votes vote down vote up
public Component getLastSamplerResultTab() {
    lastSamplerResult = new ViewResultsFullVisualizer() {
        @Override
        public TestElement createTestElement() {
            this.collector = new ResultCollector() {
                @Override
                public void sampleOccurred(SampleEvent event) {
                    lastSamplerResult.clearData();
                    getVisualizer().add(event.getResult());
                }
            };
            this.modifyTestElement(this.collector);
            return collector;
        }
    };
    lastSamplerResult.setName("Last Sampler Result");
    try {
        Field mainSplitField = lastSamplerResult.getClass().getSuperclass().getDeclaredField("mainSplit");
        mainSplitField.setAccessible(true);
        return (Component) mainSplitField.get(lastSamplerResult);
    } catch (Throwable ex) {
        log.warn("Failed to find 'mainSplit' field in visualizer");
        return lastSamplerResult;
    }
}
 
Example #4
Source File: SynthesisReportGuiTest.java    From jmeter-plugins with Apache License 2.0 6 votes vote down vote up
/**
 * Test of add method, of class SynthesisReportGui.
 */
@Test
public void testAdd() throws IOException {
    System.out.println("add");
    SynthesisReportGui instance = new SynthesisReportGui();

    SampleResult res = new SampleResult();
    instance.add(res);

    SampleResult res2 = new SampleResult();
    instance.add(res2);

    ResultCollector rc = new ResultCollector();
    rc.setListener(instance);
    rc.sampleOccurred(new SampleEvent(res, ""));
    rc.sampleOccurred(new SampleEvent(res2, ""));

    File f = File.createTempFile("test", ".csv");
    instance.getGraphPanelChart().saveGraphToCSV(f);
}
 
Example #5
Source File: AggregateReportGuiTest.java    From jmeter-plugins with Apache License 2.0 6 votes vote down vote up
/**
 * Test of add method, of class StatVisualizerAccessorGui.
 */
@Test
public void testAdd() throws IOException {
    System.out.println("add");
    AggregateReportGui instance = new AggregateReportGui();

    SampleResult res = new SampleResult();
    instance.add(res);

    SampleResult res2 = new SampleResult();
    instance.add(res2);

    ResultCollector rc = new ResultCollector();
    rc.setListener(instance);
    rc.sampleOccurred(new SampleEvent(res, ""));
    rc.sampleOccurred(new SampleEvent(res2, ""));

    File f = File.createTempFile("test", ".csv");
    instance.getGraphPanelChart().saveGraphToCSV(f);
}
 
Example #6
Source File: MergeResultsGui.java    From jmeter-plugins with Apache License 2.0 6 votes vote down vote up
/**
 * Modifies a given TestElement to mirror the data in the gui components.
 *
 * @see org.apache.jmeter.gui.JMeterGUIComponent#modifyTestElement(TestElement)
 */
@Override
public void modifyTestElement(TestElement c) {
    super.modifyTestElement(c);
    if (c instanceof ResultCollector) {
        ResultCollector rc = (ResultCollector) c;
        rc.setFilename(getFile());

        rc.setProperty(new StringProperty(
                CorrectedResultCollector.FILENAME, getFile()));
        CollectionProperty rows = JMeterPluginsUtils
                .tableModelRowsToCollectionProperty(tableModel,
                        DATA_PROPERTY);
        rc.setProperty(rows);
        collector = rc;
    }
}
 
Example #7
Source File: ThroughputVsThreadsGuiTest.java    From jmeter-plugins with Apache License 2.0 5 votes vote down vote up
@Test
public void testModifyTestElement() {
    System.out.println("modifyTestElement");
    TestElement c = new ResultCollector();
    ThroughputVsThreadsGui instance = new ThroughputVsThreadsGui();
    instance.modifyTestElement(c);
}
 
Example #8
Source File: FlushingResultCollector.java    From jmeter-plugins with Apache License 2.0 5 votes vote down vote up
@Override
public void testEnded(String host) {
    super.testEnded(host);
    try {
        // hack for JMeter < 2.12 (BUG #56807)
        ResultCollector.class.getDeclaredMethod("flushFile");
        flushFile();
    } catch (NoSuchMethodException e) {
        log.warn("Cannot flush PrintWriter to file");
    }
}
 
Example #9
Source File: PageDataExtractorOverTimeGuiTest.java    From jmeter-plugins with Apache License 2.0 5 votes vote down vote up
/**
 * Test of modifyTestElement method, of class PageDataExtractorOverTimeGui.
 */
@Test
public void testModifyTestElement() {
    System.out.println("modifyTestElement");
    TestElement te = new ResultCollector();
    PageDataExtractorOverTimeGui instance = new PageDataExtractorOverTimeGui();
    instance.modifyTestElement(te);
}
 
Example #10
Source File: PageDataExtractorOverTimeGuiTest.java    From jmeter-plugins with Apache License 2.0 5 votes vote down vote up
/**
 * Test of createTestElement method, of class PageDataExtractorOverTimeGui.
 */
@Test
public void testCreateTestElement() {
    System.out.println("createTestElement");
    PageDataExtractorOverTimeGui instance = new PageDataExtractorOverTimeGui();
    TestElement result = instance.createTestElement();
    assertTrue(result instanceof ResultCollector);
}
 
Example #11
Source File: SynthesisReportGuiTest.java    From jmeter-plugins with Apache License 2.0 5 votes vote down vote up
/**
 * Test of modifyTestElement method, of class SynthesisReportGui.
 */
@Test
public void testModifyTestElement() {
    System.out.println("modifyTestElement");
    TestElement c = new ResultCollector();
    SynthesisReportGui instance = new SynthesisReportGui();
    instance.modifyTestElement(c);
}
 
Example #12
Source File: AggregateReportGuiTest.java    From jmeter-plugins with Apache License 2.0 5 votes vote down vote up
/**
 * Test of configure method, of class StatVisualizerAccessorGui.
 */
@Test
public void testConfigure() {
    System.out.println("configure");
    TestElement c = new ResultCollector();
    AggregateReportGui instance = new AggregateReportGui();
    instance.configure(c);
}
 
Example #13
Source File: AggregateReportGuiTest.java    From jmeter-plugins with Apache License 2.0 5 votes vote down vote up
/**
 * Test of modifyTestElement method, of class StatVisualizerAccessorGui.
 */
@Test
public void testModifyTestElement() {
    System.out.println("modifyTestElement");
    TestElement c = new ResultCollector();
    AggregateReportGui instance = new AggregateReportGui();
    instance.modifyTestElement(c);
}
 
Example #14
Source File: MergeResultsGuiTest.java    From jmeter-plugins with Apache License 2.0 5 votes vote down vote up
@Test
public void testConfigure() {
    System.out.println("configure");
    TestElement el = new ResultCollector();
    el.setProperty(new StringProperty(MergeResultsGui.FILENAME,
            "fusionRes.csv"));
    MergeResultsGui instance = new MergeResultsGui();
    instance.modifyTestElement(el);
    instance.configure(el);
}
 
Example #15
Source File: MergeResultsGuiTest.java    From jmeter-plugins with Apache License 2.0 5 votes vote down vote up
@Test
public void testConfigure_NullProperty() {
    System.out.println("configure");
    TestElement el = new ResultCollector();
    el.setProperty(new StringProperty(MergeResultsGui.FILENAME,
            "fusionRes.csv"));
    MergeResultsGui instance = new MergeResultsGui();
    instance.configure(el);
}
 
Example #16
Source File: MergeResultsGuiTest.java    From jmeter-plugins with Apache License 2.0 5 votes vote down vote up
@Test
public void testModifyTestElement() {
    System.out.println("modifyTestElement");
    TestElement c = new ResultCollector();
    MergeResultsGui instance = new MergeResultsGui();
    instance.modifyTestElement(c);
}
 
Example #17
Source File: ThroughputVsThreadsGuiTest.java    From jmeter-plugins with Apache License 2.0 5 votes vote down vote up
@Test
public void testConfigure() {
    System.out.println("configure");
    TestElement el = new ResultCollector();
    ThroughputVsThreadsGui instance = new ThroughputVsThreadsGui();
    instance.configure(el);
}
 
Example #18
Source File: LoadosophiaUploader.java    From jmeter-bzm-plugins with Apache License 2.0 5 votes vote down vote up
private void setupSaving() throws IOException {
    log.debug("Set up saving with " + this);
    String dir = getStoreDir();
    File tmpFile;
    try {
        if (dir == null || dir.trim().isEmpty()) {
            tmpFile = File.createTempFile("Sense_", ".jtl");
        } else {
            File storeDir = new File(dir);
            storeDir.mkdirs();
            tmpFile = File.createTempFile("Sense_", ".jtl", storeDir);
        }
    } catch (IOException ex) {
        informUser("Unable to create temp file: " + ex.getMessage());
        informUser("Try to set another directory in the above field.");
        throw ex;
    }

    fileName = tmpFile.getAbsolutePath();
    tmpFile.delete(); // IMPORTANT! this is required to have CSV headers
    informUser("Storing results for upload to Sense: " + fileName);
    resultCollector.setFilename(fileName);
    // OMG, I spent 2 days finding that setting properties in testStarted
    // marks them temporary, though they cleared in some places.
    // So we do dirty(?) hack here...
    clearTemporary(getProperty(ResultCollector.FILENAME));

    SampleSaveConfiguration conf = resultCollector.getSaveConfig();
    JMeterPluginsUtils.doBestCSVSetup(conf);

    resultCollector.setSaveConfig(conf);
}
 
Example #19
Source File: TimesVsThreadsGuiTest.java    From jmeter-plugins with Apache License 2.0 5 votes vote down vote up
@Test
public void testConfigure()
{
   System.out.println("configure");
   TestElement el = new ResultCollector();
   TimesVsThreadsGui instance = new TimesVsThreadsGui();
   instance.configure(el);
}
 
Example #20
Source File: TimesVsThreadsGuiTest.java    From jmeter-plugins with Apache License 2.0 5 votes vote down vote up
@Test
public void testModifyTestElement()
{
   System.out.println("modifyTestElement");
   TestElement c = new ResultCollector();
   TimesVsThreadsGui instance = new TimesVsThreadsGui();
   instance.modifyTestElement(c);
}
 
Example #21
Source File: CompositeGraphGui.java    From jmeter-plugins with Apache License 2.0 5 votes vote down vote up
@Override
public TestElement createTestElement() {
    ResultCollector modelNew = getModel();
    if (modelNew == null) {
        modelNew = new CompositeResultCollector();
        ((CompositeResultCollector) modelNew).setCompositeModel(compositeModel);
        setModel(modelNew);
    }
    modifyTestElement(modelNew);
    modelNew.setComment(JMeterPluginsUtils.getWikiLinkText("CompositeGraph"));
    return modelNew;
}
 
Example #22
Source File: AbstractGraphPanelVisualizerTest.java    From jmeter-plugins with Apache License 2.0 5 votes vote down vote up
@Test
public void testConfigure() {
    System.out.println("configure");
    TestElement el = new ResultCollector();
    el.setProperty(new LongProperty(AbstractGraphPanelVisualizer.INTERVAL_PROPERTY, 10000));
    AbstractGraphPanelVisualizer instance = new AbstractGraphPanelVisualizerImpl();
    instance.configure(el);
}
 
Example #23
Source File: AbstractGraphPanelVisualizerTest.java    From jmeter-plugins with Apache License 2.0 5 votes vote down vote up
@Test
public void testModifyTestElement() {
    System.out.println("modifyTestElement");
    TestElement c = new ResultCollector();
    AbstractGraphPanelVisualizer instance = new AbstractGraphPanelVisualizerImpl();
    instance.modifyTestElement(c);
}
 
Example #24
Source File: DebuggerDialog.java    From jmeter-debugger with Apache License 2.0 5 votes vote down vote up
public DebuggerDialog() {
    super();
    start.addActionListener(new StartDebugging());
    stop.addActionListener(new StopDebugging());
    step.addActionListener(new StepOver());
    pauseContinue.addActionListener(new PauseContinue());
    tgCombo.addItemListener(new ThreadGroupChoiceChanged());
    lastResultListener = (ResultCollector) lastSamplerResult.createTestElement();
}
 
Example #25
Source File: LoadosophiaClient.java    From jmeter-bzm-plugins with Apache License 2.0 5 votes vote down vote up
private void flush() {
    // FIXME: trying to handle safe upgrade, needs to be removed in the future
    // @see https://issues.apache.org/bugzilla/show_bug.cgi?id=56807
    try {
        Class<ResultCollector> c = ResultCollector.class;
        Method m = c.getDeclaredMethod("flushFile");
        m.setAccessible(true);
        m.invoke(resultCollector);
        log.info("Successfully flushed results file");
    } catch (NoSuchMethodException ex) {
        log.warn("Cannot flush results file since you are using old version of JMeter, consider upgrading to latest. Currently the results may be incomplete.");
    } catch (InvocationTargetException | IllegalAccessException e) {
        log.error("Failed to flush file", e);
    }
}
 
Example #26
Source File: MergeResultsGui.java    From jmeter-plugins with Apache License 2.0 4 votes vote down vote up
@Override
public void stateChanged(ChangeEvent e) {
    log.debug("getting new collector");
    collector = (ResultCollector) createTestElement();
}
 
Example #27
Source File: LoadosophiaClientTest.java    From jmeter-bzm-plugins with Apache License 2.0 4 votes vote down vote up
@Test
public void testGetAndSet() throws Exception {
    LoadosophiaClient client = new LoadosophiaClient();

    LoadosophiaUploader informer = new LoadosophiaUploader();
    client.setInformer(informer);
    assertEquals(informer, client.getInformer());

    LoadosophiaAPIClient apiClient = new LoadosophiaAPIClient(null, null, null, null, null, null);
    client.setApiClient(apiClient);
    assertEquals(apiClient, client.getApiClient());

    ResultCollector collector = new ResultCollector();
    client.setResultCollector(collector);
    assertEquals(collector, client.getResultCollector());

    String address = "ADDRESS";
    client.setAddress(address);
    assertEquals(address, client.getAddress());

    String fileName = "tmpFile.txt";
    client.setFileName(fileName);
    assertEquals(fileName, client.getFileName());

    String project = "DAFULT_PROJECT";
    client.setProject(project);
    assertEquals(project, client.getProject());

    String title = "DAFULT_TITLE";
    client.setTitle(title);
    assertEquals(title, client.getTitle());

    String color = "red";
    client.setColor(color);
    assertEquals(color, client.getColor());

    client.setOnlineInitiated(true);
    assertTrue(client.isOnlineInitiated());
    client.setOnlineInitiated(false);
    assertFalse(client.isOnlineInitiated());
}
 
Example #28
Source File: LoadosophiaClient.java    From jmeter-bzm-plugins with Apache License 2.0 4 votes vote down vote up
public void setResultCollector(ResultCollector resultCollector) {
    this.resultCollector = resultCollector;
}
 
Example #29
Source File: LoadosophiaClient.java    From jmeter-bzm-plugins with Apache License 2.0 4 votes vote down vote up
public ResultCollector getResultCollector() {
    return resultCollector;
}