kg.apc.jmeter.JMeterPluginsUtils Java Examples

The following examples show how to use kg.apc.jmeter.JMeterPluginsUtils. 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: VariableThroughputTimer.java    From jmeter-plugins with Apache License 2.0 6 votes vote down vote up
private void trySettingLoadFromProperty() {
    String loadProp = JMeterUtils.getProperty(DATA_PROPERTY);
    log.debug("Loading property: {}={}", DATA_PROPERTY, loadProp);
    if (!StringUtils.isEmpty(loadProp)) {
        log.info("GUI load profile will be ignored as property {} is defined", DATA_PROPERTY);
        PowerTableModel dataModel = new PowerTableModel(VariableThroughputTimer.columnIdentifiers, VariableThroughputTimer.columnClasses);

        String[] chunks = loadProp.split("\\)");

        for (String chunk : chunks) {
            try {
                parseChunk(chunk, dataModel);
            } catch (RuntimeException e) {
                log.warn("Wrong load chunk {} will be ignored", chunk, e);
            }
        }

        log.info("Setting load profile from property {}: {}", DATA_PROPERTY, loadProp);
        overrideProp = JMeterPluginsUtils.tableModelRowsToCollectionProperty(dataModel, VariableThroughputTimer.DATA_PROPERTY);
    }
}
 
Example #2
Source File: UltimateThreadGroupTest.java    From jmeter-plugins with Apache License 2.0 6 votes vote down vote up
@Test
public void testScheduleThread() {
    System.out.println("scheduleThread");
    HashTree hashtree = new HashTree();
    hashtree.add(new LoopController());
    JMeterThread thread = new JMeterThread(hashtree, null, null);

    CollectionProperty prop = JMeterPluginsUtils.tableModelRowsToCollectionProperty(dataModel, UltimateThreadGroup.DATA_PROPERTY);
    instance.setData(prop);
    instance.testStarted();

    instance.scheduleThread(thread);

    assertTrue(thread.getStartTime() > 0);
    assertTrue(thread.getEndTime() > thread.getStartTime());
}
 
Example #3
Source File: RotatingResultCollectorGui.java    From jmeter-bzm-plugins with Apache License 2.0 6 votes vote down vote up
private void init() {
    setLayout(new BorderLayout(0, 5));
    setBorder(makeBorder());

    Container topPanel = makeTitlePanel();

    add(JMeterPluginsUtils.addHelpLinkToPanel(topPanel, WIKIPAGE), BorderLayout.NORTH);
    add(topPanel, BorderLayout.NORTH);

    JPanel mainPanel = new HorizontalPanel();

    mainPanel.setBorder(BorderFactory.createTitledBorder("File Rotating Rules"));
    mainPanel.add(new JLabel("Limit samples count in file: ", JLabel.RIGHT));
    maxSamplesCount = new JTextField(20);
    mainPanel.add(maxSamplesCount);

    topPanel.add(mainPanel);
}
 
Example #4
Source File: ParallelHTTPSamplerGui.java    From jmeter-bzm-plugins with Apache License 2.0 6 votes vote down vote up
@Override
public void configure(TestElement tg) {
    super.configure(tg);
    ParallelHTTPSampler utg = (ParallelHTTPSampler) tg;
    JMeterProperty threadValues = utg.getData();
    if (threadValues instanceof NullProperty) {
        log.warn("Received null property instead of collection");
        return;
    }

    CollectionProperty columns = (CollectionProperty) threadValues;

    tableModel.removeTableModelListener(this);
    JMeterPluginsUtils.collectionPropertyToTableModelRows(columns, tableModel);
    tableModel.addTableModelListener(this);
    buttons.checkDeleteButtonStatus();
    updateUI();
}
 
Example #5
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 #6
Source File: ParallelControllerGui.java    From jmeter-bzm-plugins with Apache License 2.0 6 votes vote down vote up
private void init() {
    setLayout(new BorderLayout(0, 5));
    setBorder(makeBorder());
    add(JMeterPluginsUtils.addHelpLinkToPanel(makeTitlePanel(), WIKIPAGE), BorderLayout.NORTH);

    Container topPanel = makeTitlePanel();

    add(topPanel, BorderLayout.NORTH);

    JPanel mainPanel = new HorizontalPanel();

    JLabel lbl = new JLabel(MSG, JLabel.CENTER);
    topPanel.add(lbl);

    generateParentSamples = new JCheckBox();
    mainPanel.add(generateParentSamples);
    mainPanel.add(new JLabel("Generate parent sample", JLabel.RIGHT));

    topPanel.add(mainPanel);
}
 
Example #7
Source File: MergeResultsGui.java    From jmeter-plugins with Apache License 2.0 6 votes vote down vote up
@Override
public void configure(TestElement el) {
    super.configure(el);
    setFile(el.getPropertyAsString(CorrectedResultCollector.FILENAME));
    JMeterProperty fileValues = el.getProperty(DATA_PROPERTY);

    if (!(fileValues instanceof NullProperty)) {
        CollectionProperty columns = (CollectionProperty) fileValues;

        tableModel.removeTableModelListener(this);
        JMeterPluginsUtils.collectionPropertyToTableModelRows(columns,
                tableModel, columnClasses);
        tableModel.addTableModelListener(this);
        updateUI();
    } else {
        log.warn("Received null property instead of collection");
    }
    checkDeleteButtonStatus();
    checkMergeButtonStatus();

    startTimeRef = 0;
}
 
Example #8
Source File: UltimateThreadGroupTest.java    From jmeter-plugins with Apache License 2.0 6 votes vote down vote up
@Test
public void testScheduleThreadAll() {
    System.out.println("scheduleThreadAll");
    HashTree hashtree = new HashTree();
    hashtree.add(new LoopController());

    CollectionProperty prop = JMeterPluginsUtils.tableModelRowsToCollectionProperty(dataModel, UltimateThreadGroup.DATA_PROPERTY);
    instance.setData(prop);
    instance.testStarted();

    for (int n = 0; n < instance.getNumThreads(); n++) {
        JMeterThread thread = new JMeterThread(hashtree, null, null);
        thread.setThreadNum(n);
        instance.scheduleThread(thread);
    }
}
 
Example #9
Source File: UltimateThreadGroup.java    From jmeter-plugins with Apache License 2.0 6 votes vote down vote up
private static void parseChunk(String chunk, PowerTableModel model) {
    log.debug("Parsing chunk: " + chunk);
    String[] parts = chunk.split("[(,]");
    String loadVar = parts[0].trim();

    if (loadVar.equalsIgnoreCase("spawn")) {
        Integer[] row = new Integer[5];
        row[START_THREADS_CNT_FIELD_NO] = Integer.parseInt(parts[1].trim());
        row[INIT_DELAY_FIELD_NO] = JMeterPluginsUtils.getSecondsForShortString(parts[2]);
        row[STARTUP_TIME_FIELD_NO] = JMeterPluginsUtils.getSecondsForShortString(parts[3]);
        row[HOLD_LOAD_FOR_FIELD_NO] = JMeterPluginsUtils.getSecondsForShortString(parts[4]);
        row[SHUTDOWN_TIME_FIELD_NO] = JMeterPluginsUtils.getSecondsForShortString(parts[5]);
        model.addRow(row);
    } else {
        throw new RuntimeException("Unknown load type: " + parts[0]);
    }
}
 
Example #10
Source File: WebDriverConfigGui.java    From jmeter-plugins-webdriver with Apache License 2.0 6 votes vote down vote up
private void createGui() {
    setLayout(new BorderLayout(0, 5));

    setBorder(makeBorder());
    add(JMeterPluginsUtils.addHelpLinkToPanel(makeTitlePanel(), getWikiPage()), BorderLayout.NORTH);

    final JTabbedPane tabbedPane = new JTabbedPane();
    if (isProxyEnabled()) {
        tabbedPane.add("Proxy", createProxyPanel());
    }
    tabbedPane.add(browserName(), createBrowserPanel());
    if (isExperimentalEnabled()) {
        tabbedPane.add("Experimental", createExperimentalPanel());
    }

    add(tabbedPane, BorderLayout.CENTER);
}
 
Example #11
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 #12
Source File: VariableThroughputTimerGui.java    From jmeter-plugins with Apache License 2.0 5 votes vote down vote up
@Override
public void updateUI() {
    super.updateUI();

    if (tableModel != null) {
        VariableThroughputTimer utgForPreview = new VariableThroughputTimer();
        utgForPreview.setData(JMeterPluginsUtils.tableModelRowsToCollectionPropertyEval(tableModel, VariableThroughputTimer.DATA_PROPERTY));
        updateChart(utgForPreview);
    }
}
 
Example #13
Source File: UltimateThreadGroupTest.java    From jmeter-plugins with Apache License 2.0 5 votes vote down vote up
@Test
public void testGetData_broken_rename() {
    CollectionProperty prop = JMeterPluginsUtils.tableModelRowsToCollectionProperty(dataModel, UltimateThreadGroup.EXTERNAL_DATA_PROPERTY);
    instance.setProperty(prop);
    JMeterProperty result = instance.getData();
    assertNotNull(instance.getProperty(UltimateThreadGroup.DATA_PROPERTY));
    assertTrue(instance.getProperty(UltimateThreadGroup.EXTERNAL_DATA_PROPERTY) instanceof NullProperty);
    assertFalse(result instanceof NullProperty);
    assertEquals(prop.getStringValue(), result.getStringValue());
}
 
Example #14
Source File: PageDataExtractorOverTimeGui.java    From jmeter-plugins with Apache License 2.0 5 votes vote down vote up
@Override
public void configure(TestElement te) {
    super.configure(te);
    CorrectedResultCollector rc = (CorrectedResultCollector) te;
    JMeterProperty regexpValues = rc.getProperty(REGEXPS_PROPERTY);
    if (!(regexpValues instanceof NullProperty)) {
        JMeterPluginsUtils.collectionPropertyToTableModelRows((CollectionProperty) regexpValues, tableModel, columnClasses);
        regExps = (CollectionProperty) regexpValues;
    } else {
        log.warn("Received null property instead of collection");
    }
}
 
Example #15
Source File: MergeResultsGui.java    From jmeter-plugins with Apache License 2.0 5 votes vote down vote up
@Override
public void updateUI() {
    super.updateUI();

    if (tableModel != null) {
        CorrectedResultCollector crc = new CorrectedResultCollector();
        crc.setProperty(JMeterPluginsUtils
                .tableModelRowsToCollectionPropertyEval(tableModel,
                        DATA_PROPERTY));
    }
}
 
Example #16
Source File: PerfMonGui.java    From jmeter-plugins with Apache License 2.0 5 votes vote down vote up
@Override
public void modifyTestElement(TestElement te) {
    super.modifyTestElement(te);
    if (grid.isEditing()) {
        grid.getCellEditor().stopCellEditing();
    }

    if (te instanceof PerfMonCollector) {
        PerfMonCollector pmte = (PerfMonCollector) te;
        CollectionProperty rows = JMeterPluginsUtils.tableModelRowsToCollectionProperty(tableModel, PerfMonCollector.DATA_PROPERTY);
        pmte.setData(rows);
    }
    super.configureTestElement(te);
}
 
Example #17
Source File: UDPSamplerGui.java    From jmeter-plugins with Apache License 2.0 5 votes vote down vote up
@Override
public TestElement createTestElement() {
    UDPSampler sampler = new UDPSampler();
    modifyTestElement(sampler);
    sampler.setComment(JMeterPluginsUtils.getWikiLinkText(WIKIPAGE));
    return sampler;
}
 
Example #18
Source File: XMLFormatPostProcessorGui.java    From jmeter-plugins with Apache License 2.0 5 votes vote down vote up
@Override
public TestElement createTestElement() {
    XMLFormatPostProcessor te = new XMLFormatPostProcessor();
    modifyTestElement(te);
    te.setComment(JMeterPluginsUtils.getWikiLinkText(WIKIPAGE));
    return te;
}
 
Example #19
Source File: DummySubPostProcessorGui.java    From jmeter-plugins with Apache License 2.0 5 votes vote down vote up
public DummySubPostProcessorGui() {
    setLayout(new BorderLayout(0, 5));
    setBorder(makeBorder());

    add(JMeterPluginsUtils.addHelpLinkToPanel(makeTitlePanel(), WIKIPAGE), BorderLayout.NORTH);

    this.dummyPanel = new DummyPanel();
    add(dummyPanel.init(), BorderLayout.CENTER);
    dummyPanel.initFields();
}
 
Example #20
Source File: PageDataExtractorOverTimeGui.java    From jmeter-plugins with Apache License 2.0 5 votes vote down vote up
@Override
public void modifyTestElement(TestElement te) {
    super.modifyTestElement(te);
    if (grid.isEditing()) {
        grid.getCellEditor().stopCellEditing();
    }

    if (te instanceof CorrectedResultCollector) {
        CorrectedResultCollector rc = (CorrectedResultCollector) te;
        CollectionProperty rows = JMeterPluginsUtils.tableModelRowsToCollectionProperty(tableModel, REGEXPS_PROPERTY);
        rc.setProperty(rows);
    }
}
 
Example #21
Source File: SetVariablesActionGui.java    From jmeter-plugins with Apache License 2.0 5 votes vote down vote up
private void init() {
    setLayout(new BorderLayout());
    setBorder(makeBorder());
    add(JMeterPluginsUtils.addHelpLinkToPanel(makeTitlePanel(), WIKIPAGE), BorderLayout.NORTH);

    add(createVariablePanel(), BorderLayout.CENTER);
}
 
Example #22
Source File: JMXMonTest.java    From jmeter-plugins with Apache License 2.0 5 votes vote down vote up
@Test
public void testRun() throws InterruptedException {
    JMXMonCollector instance = new TestJMXMonCollector(this);
    instance.setData(JMeterPluginsUtils.tableModelRowsToCollectionProperty(dataModel, JMXMonCollector.DATA_PROPERTY));
    instance.testStarted();

    setQueryResult(ATTRIBUTE1, 1);
    setQueryResult(ATTRIBUTE2, 1);
    instance.processConnectors();
    assertLastSample(PROBE1, 1);
    assertEquals(null, latestSamples.get(PROBE2)); // Delta can not produce values at first loop

    setQueryResult(ATTRIBUTE1, -2);
    setQueryResult(ATTRIBUTE2, 2);
    instance.processConnectors();
    assertLastSample(PROBE1, -2);
    assertLastSample(PROBE2, 1);

    setQueryResult(ATTRIBUTE1, 13);
    setQueryResult(ATTRIBUTE2, 1);
    instance.processConnectors();
    assertLastSample(PROBE1, 13);
    assertLastSample(PROBE2, -1);

    instance.testEnded();
    assertSampleGeneratorThreadIsStoped();

}
 
Example #23
Source File: FlexibleFileWriter.java    From jmeter-plugins with Apache License 2.0 5 votes vote down vote up
/**
 * making this once to be efficient and avoid manipulating strings in switch
 * operators
 */
private void compileColumns() {
    log.debug("Compiling columns string: " + getColumns());
    String[] chunks = JMeterPluginsUtils.replaceRNT(getColumns()).split("\\|");
    log.debug("Chunks " + chunks.length);
    compiledFields = new int[chunks.length];
    compiledVars = new int[chunks.length];
    compiledConsts = new ByteBuffer[chunks.length];
    for (int n = 0; n < chunks.length; n++) {
        int fieldID = availableFieldNames.indexOf(chunks[n]);
        if (fieldID >= 0) {
            //log.debug(chunks[n] + " field id: " + fieldID);
            compiledFields[n] = fieldID;
        } else {
            compiledFields[n] = -1;
            compiledVars[n] = -1;
            if (chunks[n].contains(VAR_PREFIX)) {
                log.debug(chunks[n] + " is sample variable");
                String varN = chunks[n].substring(VAR_PREFIX.length());
                try {
                    compiledVars[n] = Integer.parseInt(varN);
                } catch (NumberFormatException e) {
                    log.error("Seems it is not variable spec: " + chunks[n]);
                    compiledConsts[n] = ByteBuffer.wrap(chunks[n].getBytes());
                }
            } else {
                log.debug(chunks[n] + " is const");
                if (chunks[n].length() == 0) {
                    //log.debug("Empty const, treated as |");
                    chunks[n] = "|";
                }

                compiledConsts[n] = ByteBuffer.wrap(chunks[n].getBytes());
            }
        }
    }
}
 
Example #24
Source File: AbstractMonitoringVisualizer.java    From jmeter-plugins with Apache License 2.0 5 votes vote down vote up
@Override
public void configure(TestElement te) {
    super.configure(te);
    MonitoringResultsCollector mrc = (MonitoringResultsCollector) te;
    JMeterProperty samplerValues = mrc.getSamplerSettings();
    if (!(samplerValues instanceof NullProperty)) {
        JMeterPluginsUtils.collectionPropertyToTableModelRows((CollectionProperty) samplerValues, tableModel, getColumnClasses());
    } else {
        log.warn("Received null property instead of collection");
    }
}
 
Example #25
Source File: AbstractMonitoringVisualizer.java    From jmeter-plugins with Apache License 2.0 5 votes vote down vote up
@Override
public void modifyTestElement(TestElement te) {
    super.modifyTestElement(te);
    if (grid.isEditing()) {
        grid.getCellEditor().stopCellEditing();
    }

    if (te instanceof MonitoringResultsCollector) {
        MonitoringResultsCollector mrc = (MonitoringResultsCollector) te;
        CollectionProperty rows = JMeterPluginsUtils.tableModelRowsToCollectionProperty(tableModel, MonitoringResultsCollector.DATA_PROPERTY);
        mrc.setData(rows);
    }
    super.configureTestElement(te);
}
 
Example #26
Source File: AbstractGraphPanelVisualizer.java    From jmeter-plugins with Apache License 2.0 5 votes vote down vote up
private void initGui() {
    setBorder(makeBorder());
    setLayout(new BorderLayout());
    add(JMeterPluginsUtils.addHelpLinkToPanel(makeTitlePanel(), getWikiPage()), BorderLayout.NORTH);
    container = getGraphPanelContainer();
    container.add(createGraphPanel(), BorderLayout.CENTER);
    add(container, BorderLayout.CENTER);
    reloadLabelToColorMapping();
    addMouseClickColorChangeListener();
}
 
Example #27
Source File: UltimateThreadGroupGui.java    From jmeter-plugins with Apache License 2.0 5 votes vote down vote up
@Override
public void modifyTestElement(TestElement tg) {
    if (grid.isEditing()) {
        grid.getCellEditor().stopCellEditing();
    }

    if (tg instanceof UltimateThreadGroup) {
        UltimateThreadGroup utg = (UltimateThreadGroup) tg;
        CollectionProperty rows = JMeterPluginsUtils.tableModelRowsToCollectionProperty(tableModel, UltimateThreadGroup.DATA_PROPERTY);
        utg.setData(rows);
        utg.setSamplerController((LoopController) loopPanel.createTestElement());
    }
    super.configureTestElement(tg);
}
 
Example #28
Source File: AutoStopGui.java    From jmeter-plugins with Apache License 2.0 5 votes vote down vote up
@Override
public TestElement createTestElement() {
    TestElement te = new AutoStop();
    modifyTestElement(te);
    te.setComment(JMeterPluginsUtils.getWikiLinkText(WIKIPAGE));
    return te;
}
 
Example #29
Source File: FlexibleFileWriter.java    From jmeter-plugins with Apache License 2.0 5 votes vote down vote up
protected void openFile() throws IOException {
    String filename = getFilename();
    FileOutputStream fos = new FileOutputStream(filename, !isOverwrite());
    fileChannel = fos.getChannel();

    String header = JMeterPluginsUtils.replaceRNT(getFileHeader());
    if (!header.isEmpty()) {
        syncWrite(ByteBuffer.wrap(header.getBytes()));
    }
}
 
Example #30
Source File: UltimateThreadGroupTest.java    From jmeter-plugins with Apache License 2.0 5 votes vote down vote up
@Test
public void testGetNumThreads() {
    System.out.println("getNumThreads");
    CollectionProperty prop = JMeterPluginsUtils.tableModelRowsToCollectionProperty(dataModel, UltimateThreadGroup.DATA_PROPERTY);
    instance.setData(prop);
    instance.testStarted();

    int expResult = 15;
    int result = instance.getNumThreads();
    assertEquals(expResult, result);
}