Java Code Examples for kg.apc.jmeter.JMeterPluginsUtils#tableModelRowsToCollectionProperty()

The following examples show how to use kg.apc.jmeter.JMeterPluginsUtils#tableModelRowsToCollectionProperty() . 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: VariableThroughputTimerTest.java    From jmeter-plugins with Apache License 2.0 6 votes vote down vote up
@Test
public void testDelay1000() throws InterruptedException {
    System.out.println("delay 1000");
    VariableThroughputTimer instance = new VariableThroughputTimerEmul();
    instance.setName("TEST");
    CollectionProperty prop = JMeterPluginsUtils.tableModelRowsToCollectionProperty(dataModel, VariableThroughputTimer.DATA_PROPERTY);
    instance.setData(prop);
    long start = System.currentTimeMillis();
    long result = 0;
    while ((System.currentTimeMillis() - start) < 10 * 1000) // 10 seconds test
    {
        try {
            result = instance.delay();
            assertEquals("9", JMeterUtils.getProperty("TEST_totalDuration"));
            assertEquals(0, result);
        } catch (RuntimeException ex) {
            if (!ex.getMessage().equals("Immediate stop")) {
                throw ex;
            }
        }
    }
}
 
Example 4
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 5
Source File: UltimateThreadGroup.java    From jmeter-plugins with Apache License 2.0 6 votes vote down vote up
private CollectionProperty getLoadFromExternalProperty() {
    String loadProp = JMeterUtils.getProperty(EXTERNAL_DATA_PROPERTY);
    log.debug("Profile prop: " + loadProp);
    if (loadProp != null && loadProp.length() > 0) {
        //expected format : threads_schedule="spawn(1,1s,1s,1s,1s) spawn(2,1s,3s,1s,2s)"
        log.info("GUI threads profile will be ignored");
        PowerTableModel dataModel = new PowerTableModel(UltimateThreadGroupGui.columnIdentifiers, UltimateThreadGroupGui.columnClasses);
        String[] chunks = loadProp.split("\\)");

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

        log.info("Setting threads profile from property " + EXTERNAL_DATA_PROPERTY + ": " + loadProp);
        return JMeterPluginsUtils.tableModelRowsToCollectionProperty(dataModel, UltimateThreadGroup.DATA_PROPERTY);
    }
    return null;
}
 
Example 6
Source File: UltimateThreadGroupTest.java    From jmeter-plugins with Apache License 2.0 5 votes vote down vote up
@Test
public void testGetData_broken_del() {
    CollectionProperty prop = JMeterPluginsUtils.tableModelRowsToCollectionProperty(dataModel, UltimateThreadGroup.EXTERNAL_DATA_PROPERTY);
    instance.setProperty(prop);
    CollectionProperty prop2 = JMeterPluginsUtils.tableModelRowsToCollectionProperty(dataModel, UltimateThreadGroup.DATA_PROPERTY);
    instance.setProperty(prop2);

    JMeterProperty result = instance.getData();
    assertEquals(prop2, instance.getProperty(UltimateThreadGroup.DATA_PROPERTY));
    assertTrue(instance.getProperty(UltimateThreadGroup.EXTERNAL_DATA_PROPERTY) instanceof NullProperty);
    assertFalse(result instanceof NullProperty);
    assertEquals(prop.getStringValue(), result.getStringValue());
}
 
Example 7
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 8
Source File: DbMonGui.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 DbMonCollector) {
        DbMonCollector dmte = (DbMonCollector) te;
        CollectionProperty rows = JMeterPluginsUtils.tableModelRowsToCollectionProperty(tableModel, DbMonCollector.DATA_PROPERTY);
        dmte.setData(rows);
    }
    super.configureTestElement(te);
}
 
Example 9
Source File: VariableThroughputTimerGui.java    From jmeter-plugins with Apache License 2.0 5 votes vote down vote up
@Override
public void modifyTestElement(TestElement tg) {
    //log.info("Modify test element");
    super.configureTestElement(tg);

    if (grid.isEditing()) {
        grid.getCellEditor().stopCellEditing();
    }

    if (tg instanceof VariableThroughputTimer) {
        VariableThroughputTimer utg = (VariableThroughputTimer) tg;
        CollectionProperty rows = JMeterPluginsUtils.tableModelRowsToCollectionProperty(tableModel, VariableThroughputTimer.DATA_PROPERTY);
        utg.setData(rows);
    }
}
 
Example 10
Source File: JMXMonGui.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 JMXMonCollector) {
        JMXMonCollector dmte = (JMXMonCollector) te;
        CollectionProperty rows = JMeterPluginsUtils.tableModelRowsToCollectionProperty(tableModel, JMXMonCollector.DATA_PROPERTY);
        dmte.setData(rows);
    }
    super.configureTestElement(te);
}
 
Example 11
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 12
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);
}
 
Example 13
Source File: ParallelHTTPSamplerTest.java    From jmeter-bzm-plugins with Apache License 2.0 5 votes vote down vote up
@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 14
Source File: ParallelHTTPSamplerGui.java    From jmeter-bzm-plugins with Apache License 2.0 5 votes vote down vote up
@Override
public void modifyTestElement(TestElement tg) {
    super.configureTestElement(tg);

    if (grid.isEditing()) {
        grid.getCellEditor().stopCellEditing();
    }

    if (tg instanceof ParallelHTTPSampler) {
        ParallelHTTPSampler utg = (ParallelHTTPSampler) tg;
        CollectionProperty rows = JMeterPluginsUtils.tableModelRowsToCollectionProperty(tableModel, ParallelHTTPSampler.DATA_PROPERTY);
        utg.setData(rows);
    }
}
 
Example 15
Source File: FreeFormArrivalsThreadGroup.java    From jmeter-plugins with Apache License 2.0 4 votes vote down vote up
public void setData(PowerTableModel model) {
    CollectionProperty prop = JMeterPluginsUtils.tableModelRowsToCollectionProperty(model, SCHEDULE);
    setProperty(prop);
}
 
Example 16
Source File: UltimateThreadGroupGuiTest.java    From jmeter-plugins with Apache License 2.0 4 votes vote down vote up
private CollectionProperty getTestData() {
    PowerTableModel model = UltimateThreadGroupTest.getTestModel();
    CollectionProperty data = JMeterPluginsUtils.tableModelRowsToCollectionProperty(model, UltimateThreadGroup.DATA_PROPERTY);
    return data;
}
 
Example 17
Source File: WeightedSwitchController.java    From jmeter-bzm-plugins with Apache License 2.0 4 votes vote down vote up
public void setData(PowerTableModel model) {
    CollectionProperty prop = JMeterPluginsUtils.tableModelRowsToCollectionProperty(model, WEIGHTS);
    // log.warn("Set prop from model: " + prop);
    setProperty(prop);
}
 
Example 18
Source File: UltimateThreadGroupTest.java    From jmeter-plugins with Apache License 2.0 4 votes vote down vote up
@Test
public void testSetData() {
    System.out.println("setSchedule");
    CollectionProperty prop = JMeterPluginsUtils.tableModelRowsToCollectionProperty(dataModel, UltimateThreadGroup.DATA_PROPERTY);
    instance.setData(prop);
}
 
Example 19
Source File: FirefoxDriverConfig.java    From jmeter-plugins-webdriver with Apache License 2.0 4 votes vote down vote up
public void setPreferences(PowerTableModel model) {
    CollectionProperty prop = JMeterPluginsUtils.tableModelRowsToCollectionProperty(model, PREFERENCES);
    setProperty(prop);
}
 
Example 20
Source File: FirefoxDriverConfig.java    From jmeter-plugins-webdriver with Apache License 2.0 4 votes vote down vote up
public void setExtensions(PowerTableModel model) {
    CollectionProperty prop = JMeterPluginsUtils.tableModelRowsToCollectionProperty(model, EXTENSIONS_TO_LOAD);
    setProperty(prop);
}