Search in sources :

Example 1 with CollectionProperty

use of org.apache.jmeter.testelement.property.CollectionProperty in project jmeter-plugins by undera.

the class JMXMonCollector method initiateConnectors.

private void initiateConnectors() {
    JMeterProperty prop = getSamplerSettings();
    jmxMonSamplers.clear();
    if (!(prop instanceof CollectionProperty)) {
        log.warn("Got unexpected property: " + prop);
        return;
    }
    CollectionProperty rows = (CollectionProperty) prop;
    for (int i = 0; i < rows.size(); i++) {
        ArrayList<Object> row = (ArrayList<Object>) rows.get(i).getObjectValue();
        String label = ((JMeterProperty) row.get(0)).getStringValue();
        JMeterProperty jmxUrl = (JMeterProperty) row.get(1);
        String username = ((JMeterProperty) row.get(2)).getStringValue();
        String password = ((JMeterProperty) row.get(3)).getStringValue();
        String objectName = ((JMeterProperty) row.get(4)).getStringValue();
        String attribute = ((JMeterProperty) row.get(5)).getStringValue();
        String key = ((JMeterProperty) row.get(6)).getStringValue();
        boolean isDelta = ((JMeterProperty) row.get(7)).getBooleanValue();
        boolean canRetry = ((JMeterProperty) row.get(8)).getBooleanValue();
        try {
            Hashtable attributes = new Hashtable();
            String[] buffer = { username, password };
            attributes.put("jmx.remote.credentials", (String[]) buffer);
            initiateConnector(attributes, jmxUrl, label, isDelta, objectName, attribute, key, canRetry);
        } catch (MalformedURLException ex) {
            // throw new RuntimeException(ex);
            log.error("Malformed JMX url", ex);
        } catch (IOException ex) {
            log.error("IOException reading JMX", ex);
        }
    }
}
Also used : MalformedURLException(java.net.MalformedURLException) JMeterProperty(org.apache.jmeter.testelement.property.JMeterProperty) CollectionProperty(org.apache.jmeter.testelement.property.CollectionProperty) Hashtable(java.util.Hashtable) ArrayList(java.util.ArrayList) IOException(java.io.IOException)

Example 2 with CollectionProperty

use of org.apache.jmeter.testelement.property.CollectionProperty in project jmeter-plugins by undera.

the class JMXMonGui method modifyTestElement.

@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);
}
Also used : CollectionProperty(org.apache.jmeter.testelement.property.CollectionProperty) JMXMonCollector(kg.apc.jmeter.jmxmon.JMXMonCollector)

Example 3 with CollectionProperty

use of org.apache.jmeter.testelement.property.CollectionProperty in project jmeter-plugins by undera.

the class JMeterPluginsUtils method tableModelRowsToCollectionPropertyEval.

public static CollectionProperty tableModelRowsToCollectionPropertyEval(PowerTableModel model, String propname) {
    CollectionProperty rows = new CollectionProperty(propname, new ArrayList<>());
    for (int row = 0; row < model.getRowCount(); row++) {
        List<Object> item = getArrayListForArrayEval(model.getRowData(row));
        rows.addItem(item);
    }
    return rows;
}
Also used : CollectionProperty(org.apache.jmeter.testelement.property.CollectionProperty)

Example 4 with CollectionProperty

use of org.apache.jmeter.testelement.property.CollectionProperty in project jmeter-plugins by undera.

the class FreeFormArrivalsThreadStarterTest method getRow.

private CollectionProperty getRow(int i, int i1, int i2) {
    CollectionProperty row = new CollectionProperty();
    row.addProperty(new StringProperty("", String.valueOf(i)));
    row.addProperty(new StringProperty("", String.valueOf(i1)));
    row.addProperty(new StringProperty("", String.valueOf(i2)));
    return row;
}
Also used : CollectionProperty(org.apache.jmeter.testelement.property.CollectionProperty) StringProperty(org.apache.jmeter.testelement.property.StringProperty)

Example 5 with CollectionProperty

use of org.apache.jmeter.testelement.property.CollectionProperty in project jmeter-plugins by undera.

the class FreeFormArrivalsThreadStarterTest method testSchedule.

@Test
public void testSchedule() throws Exception {
    CollectionProperty sched = new CollectionProperty(FreeFormArrivalsThreadGroup.SCHEDULE, new LinkedHashSet<>());
    sched.addProperty(getRow(1, 10, 30));
    sched.addProperty(getRow(0, 0, 5));
    sched.addProperty(getRow(10, 1, 15));
    FreeFormArrivalsThreadGroup atg = new FreeFormArrivalsThreadGroup();
    atg.setProperty(sched);
    FreeFormArrivalsThreadStarterEmul obj = new FreeFormArrivalsThreadStarterEmul(atg);
    for (int n = 0; n < 60; n++) {
        log.info("Rate " + n + ": " + obj.getCurrentRate());
        obj.addRollingTime(1000);
    }
}
Also used : CollectionProperty(org.apache.jmeter.testelement.property.CollectionProperty) Test(org.junit.Test)

Aggregations

CollectionProperty (org.apache.jmeter.testelement.property.CollectionProperty)91 JMeterProperty (org.apache.jmeter.testelement.property.JMeterProperty)29 ArrayList (java.util.ArrayList)19 NullProperty (org.apache.jmeter.testelement.property.NullProperty)13 Test (org.junit.Test)11 PropertyIterator (org.apache.jmeter.testelement.property.PropertyIterator)8 Test (org.junit.jupiter.api.Test)7 IOException (java.io.IOException)5 List (java.util.List)4 StringProperty (org.apache.jmeter.testelement.property.StringProperty)4 File (java.io.File)3 Argument (org.apache.jmeter.config.Argument)3 PowerTableModel (org.apache.jmeter.gui.util.PowerTableModel)3 TestPlan (org.apache.jmeter.testelement.TestPlan)3 UnsupportedEncodingException (java.io.UnsupportedEncodingException)2 Field (java.lang.reflect.Field)2 MalformedURLException (java.net.MalformedURLException)2 URL (java.net.URL)2 UnknownHostException (java.net.UnknownHostException)2 LinkedList (java.util.LinkedList)2