Java Code Examples for kg.apc.jmeter.JMeterPluginsUtils

The following examples show how to use kg.apc.jmeter.JMeterPluginsUtils. These examples are extracted from open source projects. 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 Project: jmeter-plugins   Source File: UltimateThreadGroup.java    License: 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 2
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 3
Source Project: jmeter-bzm-plugins   Source File: ParallelControllerGui.java    License: 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 4
Source Project: jmeter-bzm-plugins   Source File: ParallelHTTPSamplerGui.java    License: 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
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 6
Source Project: jmeter-plugins   Source File: UltimateThreadGroupTest.java    License: 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 7
Source Project: jmeter-plugins   Source File: VariableThroughputTimer.java    License: 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 8
Source Project: jmeter-plugins   Source File: MergeResultsGui.java    License: 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 9
Source Project: jmeter-plugins   Source File: MergeResultsGui.java    License: 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 10
Source Project: jmeter-plugins   Source File: UltimateThreadGroupTest.java    License: 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 11
Source Project: jmeter-plugins   Source File: DbMonGui.java    License: Apache License 2.0 5 votes vote down vote up
@Override
public TestElement createTestElement() {
    TestElement te = new DbMonCollector();
    modifyTestElement(te);
    te.setComment(JMeterPluginsUtils.getWikiLinkText(getWikiPage()));
    return te;
}
 
Example 12
Source Project: jmeter-plugins   Source File: JMXMonCollector.java    License: Apache License 2.0 5 votes vote down vote up
private void setupSaving(String fileName) {
    SampleSaveConfiguration config = getSaveConfig();
    JMeterPluginsUtils.doBestCSVSetup(config);
    setSaveConfig(config);
    setFilename(fileName);
    log.info("JMXMon metrics will be stored in " + new File(fileName).getAbsolutePath());
}
 
Example 13
Source Project: jmeter-plugins   Source File: VariableThroughputTimerGui.java    License: Apache License 2.0 5 votes vote down vote up
/**
 *
 */
protected final void init() {
    setBorder(makeBorder());
    setLayout(new BorderLayout());
    add(JMeterPluginsUtils.addHelpLinkToPanel(makeTitlePanel(), WIKIPAGE), BorderLayout.NORTH);
    JPanel containerPanel = new VerticalPanel();

    containerPanel.add(createParamsPanel(), BorderLayout.NORTH);
    containerPanel.add(GuiBuilderHelper.getComponentWithMargin(createChart(), 2, 2, 0, 2), BorderLayout.CENTER);
    add(containerPanel, BorderLayout.CENTER);
}
 
Example 14
Source Project: jmeter-plugins   Source File: LockFileGui.java    License: Apache License 2.0 5 votes vote down vote up
@Override
public TestElement createTestElement() {
    log.debug("[Lockfile plugin] createTestElement");
    LockFile lockFile = new LockFile();
    modifyTestElement(lockFile);
    lockFile.setComment(JMeterPluginsUtils.getWikiLinkText(WIKIPAGE));
    return lockFile;
}
 
Example 15
Source Project: jmeter-bzm-plugins   Source File: ParallelHTTPSamplerGui.java    License: Apache License 2.0 5 votes vote down vote up
protected final void init() {
    setBorder(makeBorder());
    setLayout(new BorderLayout());
    add(JMeterPluginsUtils.addHelpLinkToPanel(makeTitlePanel(), WIKIPAGE), BorderLayout.NORTH);
    JPanel containerPanel = new VerticalPanel();

    containerPanel.add(createParamsPanel(), BorderLayout.CENTER);
    add(containerPanel, BorderLayout.CENTER);
}
 
Example 16
Source Project: jmeter-plugins   Source File: JSONToXMLConverterGui.java    License: 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);

    VerticalPanel panel = new VerticalPanel();
    panel.setBorder(BorderFactory.createEtchedBorder());
    jsonInputTextField = new JLabeledTextField("JSON input");
    panel.add(jsonInputTextField);
    add(panel, BorderLayout.CENTER);
}
 
Example 17
@Test
public void sample() throws Exception {
    ParallelHTTPSampler obj = new ParallelHTTPSamplerMock();
    obj.setName("parent");
    //obj.setConcurrentDwn(false); //FIXME: remove or comment this
    PowerTableModel dataModel = new PowerTableModel(ParallelHTTPSampler.columnIdentifiers, ParallelHTTPSampler.columnClasses);
    dataModel.addRow(new String[]{"http://localhost:8000/rtimes/const?delay=1"});
    dataModel.addRow(new String[]{"http://localhost:8000/rtimes/const?delay=2"});
    CollectionProperty prop = JMeterPluginsUtils.tableModelRowsToCollectionProperty(dataModel, ParallelHTTPSampler.DATA_PROPERTY);
    obj.setData(prop);
    SampleResult res = obj.sample();
    assertTrue(res.isSuccessful());
    assertEquals(2, res.getSubResults().length);
}
 
Example 18
Source Project: jmeter-plugins   Source File: ParameterizedControllerGui.java    License: 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 19
Source Project: jmeter-bzm-plugins   Source File: LoadosophiaUploader.java    License: 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 20
Source Project: jmeter-bzm-plugins   Source File: BlazeMeterUploaderGui.java    License: Apache License 2.0 5 votes vote down vote up
@Override
public TestElement createTestElement() {
    TestElement te = new BlazeMeterUploader();
    modifyTestElement(te);
    te.setComment(JMeterPluginsUtils.getWikiLinkText(WIKIPAGE));
    return te;
}
 
Example 21
Source Project: jmeter-bzm-plugins   Source File: JMeterXMPPSamplerGui.java    License: Apache License 2.0 5 votes vote down vote up
private void init() {
    setLayout(new BorderLayout(0, 5));
    setBorder(makeBorder());

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

    JPanel mainPanel = new JPanel();
    mainPanel.setLayout(new BoxLayout(mainPanel, BoxLayout.Y_AXIS));
    mainPanel.setBorder(BorderFactory.createEmptyBorder());

    addActionBlocks(mainPanel);

    add(mainPanel, BorderLayout.CENTER);
}
 
Example 22
Source Project: jmeter-plugins   Source File: AutoStopGui.java    License: 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 23
Source Project: jmeter-plugins   Source File: UltimateThreadGroupGui.java    License: 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 24
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 25
@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
@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 27
Source Project: jmeter-plugins   Source File: JMXMonTest.java    License: 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 28
Source Project: jmeter-plugins   Source File: SetVariablesActionGui.java    License: 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 29
Source Project: jmeter-plugins   Source File: CompositeGraphGui.java    License: 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 30
Source Project: jmeter-plugins   Source File: UltimateThreadGroupTest.java    License: 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);
}