org.apache.jmeter.testelement.property.JMeterProperty Java Examples

The following examples show how to use org.apache.jmeter.testelement.property.JMeterProperty. 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: DbMonCollector.java    From jmeter-plugins with Apache License 2.0 6 votes vote down vote up
private void initiateConnectors() throws SQLException {
    JMeterProperty prop = getSamplerSettings();
    dbMonSamplers.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 connectionPool = ((JMeterProperty) row.get(0)).getStringValue();
        String label = ((JMeterProperty) row.get(1)).getStringValue();
        boolean isDelta = ((JMeterProperty) row.get(2)).getBooleanValue();
        String sql = ((JMeterProperty) row.get(3)).getStringValue();
        initiateConnector(connectionPool, label, isDelta, sql);
    }
}
 
Example #2
Source File: UltimateThreadGroupGui.java    From jmeter-plugins with Apache License 2.0 6 votes vote down vote up
@Override
public void configure(TestElement tg) {
    super.configure(tg);
    UltimateThreadGroup utg = (UltimateThreadGroup) tg;
    JMeterProperty threadValues = utg.getData();
    if (!(threadValues instanceof NullProperty)) {
        CollectionProperty columns = (CollectionProperty) threadValues;

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

    TestElement te = (TestElement) tg.getProperty(AbstractThreadGroup.MAIN_CONTROLLER).getObjectValue();
    if (te != null) {
        loopPanel.configure(te);
    }
    buttons.checkDeleteButtonStatus();
}
 
Example #3
Source File: PrometheusMetricsConfig.java    From jmeter-prometheus-plugin with Apache License 2.0 6 votes vote down vote up
@Override
public boolean equals(Object o) {
	if (o instanceof PrometheusMetricsConfig) {
		PrometheusMetricsConfig other = (PrometheusMetricsConfig) o;
		
		CollectionProperty thisConfig = this.getCollectorConfigs();
		CollectionProperty otherConfig = other.getCollectorConfigs();
		boolean sameSize = thisConfig.size() == otherConfig.size();
		
		for (int i = 0; i < thisConfig.size(); i++) {
			JMeterProperty left = thisConfig.get(i);
			JMeterProperty right = otherConfig.get(i);
			
			if(!left.equals(right)) {
				return false;
			}
		}
		
		return true && sameSize;
	}
	
	return false;
}
 
Example #4
Source File: UltimateThreadGroup.java    From jmeter-plugins with Apache License 2.0 6 votes vote down vote up
@Override
public int getNumThreads() {
    int result = 0;

    JMeterProperty threadValues = getData();
    if (!(threadValues instanceof NullProperty)) {
        CollectionProperty columns = (CollectionProperty) threadValues;
        List<?> rows = (List<?>) columns.getObjectValue();
        for (Object row1 : rows) {
            CollectionProperty prop = (CollectionProperty) row1;
            ArrayList<JMeterProperty> row = (ArrayList<JMeterProperty>) prop.getObjectValue();
            //log.info(prop.getStringValue());
            result += row.get(0).getIntValue();
        }
    }

    return result;
}
 
Example #5
Source File: BaseCollectorConfig.java    From jmeter-prometheus-plugin with Apache License 2.0 6 votes vote down vote up
public String[] getLabels() {
	JMeterProperty prop = this.getProperty(LABELS);
	if(prop == null || prop instanceof NullProperty) {
		return new String[0];
	}

	CollectionProperty colletion = (CollectionProperty) prop;
	String[] retArray = new String[colletion.size()];
	PropertyIterator it = colletion.iterator();

	int i=0;
	while(it.hasNext()) {
		String next = it.next().getStringValue();
		retArray[i] = next;
		i++;
	}

	return retArray;
}
 
Example #6
Source File: UltimateThreadGroup.java    From jmeter-plugins with Apache License 2.0 6 votes vote down vote up
public JMeterProperty getData() {
    JMeterProperty brokenProp = getProperty(EXTERNAL_DATA_PROPERTY);
    JMeterProperty usualProp = getProperty(DATA_PROPERTY);

    if (brokenProp instanceof CollectionProperty) {
        if (usualProp == null || usualProp instanceof NullProperty) {
            log.warn("Copying '" + EXTERNAL_DATA_PROPERTY + "' into '" + DATA_PROPERTY + "'");
            JMeterProperty newProp = brokenProp.clone();
            newProp.setName(DATA_PROPERTY);
            setProperty(newProp);
        }
        log.warn("Removing property '" + EXTERNAL_DATA_PROPERTY + "' as invalid");
        removeProperty(EXTERNAL_DATA_PROPERTY);
    }

    //log.info("getData: "+getProperty(DATA_PROPERTY));
    CollectionProperty overrideProp = getLoadFromExternalProperty();
    if (overrideProp != null) {
        return overrideProp;
    }

    return getProperty(DATA_PROPERTY);
}
 
Example #7
Source File: WebSocketAbstractSampler.java    From jmeter-bzm-plugins with Apache License 2.0 6 votes vote down vote up
protected void setConnectionHeaders(ClientUpgradeRequest request, HeaderManager headerManager, CacheManager cacheManager) {
    if (headerManager != null) {
        CollectionProperty headers = headerManager.getHeaders();
        PropertyIterator p = headers.iterator();
        if (headers != null) {
        	while (p.hasNext()){
        		JMeterProperty jMeterProperty = p.next();
        		org.apache.jmeter.protocol.http.control.Header header
                = (org.apache.jmeter.protocol.http.control.Header)
                        jMeterProperty.getObjectValue();
                String n = header.getName();
                if (! HTTPConstants.HEADER_CONTENT_LENGTH.equalsIgnoreCase(n)){
                    String v = header.getValue();
            		request.setHeader(n, v);
                }
        	}
        }
    }
    if (cacheManager != null){
    }
}
 
Example #8
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 #9
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 #10
Source File: VariableThroughputTimerGui.java    From jmeter-plugins with Apache License 2.0 6 votes vote down vote up
@Override
public void configure(TestElement tg) {
    //log.info("Configure");
    super.configure(tg);
    VariableThroughputTimer utg = (VariableThroughputTimer) 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 #11
Source File: FirefoxDriverConfigGui.java    From jmeter-plugins-webdriver with Apache License 2.0 6 votes vote down vote up
@Override
public void configure(TestElement element) {
    super.configure(element);
    if (element instanceof FirefoxDriverConfig) {
        FirefoxDriverConfig config = (FirefoxDriverConfig) element;
        userAgentOverrideCheckbox.setSelected(config.isUserAgentOverridden());
        userAgentOverrideText.setText(config.getUserAgentOverride());
        userAgentOverrideText.setEnabled(config.isUserAgentOverridden());

        JMeterProperty ext = config.getExtensions();
        if (!(ext instanceof NullProperty)) {
            JMeterPluginsUtils.collectionPropertyToTableModelRows((CollectionProperty) ext, extensions.getModel());
        }

        JMeterProperty pref = config.getPreferences();
        if (!(ext instanceof NullProperty)) {
            JMeterPluginsUtils.collectionPropertyToTableModelRows((CollectionProperty) pref, preferences.getModel());
        }
    }
}
 
Example #12
Source File: FirefoxDriverConfig.java    From jmeter-plugins-webdriver with Apache License 2.0 6 votes vote down vote up
private void setPreferences(FirefoxProfile profile) {
    JMeterProperty property = getProperty(PREFERENCES);
    if (property instanceof NullProperty) {
        return;
    }
    CollectionProperty rows = (CollectionProperty) property;
    for (int i = 0; i < rows.size(); i++) {
        ArrayList row = (ArrayList) rows.get(i).getObjectValue();
        String name = ((JMeterProperty) row.get(0)).getStringValue();
        String value = ((JMeterProperty) row.get(1)).getStringValue();
        switch (value) {
            case "true":
                profile.setPreference(name, true);
                break;
            case "false":
                profile.setPreference(name, false);
                break;
            default:
                profile.setPreference(name, value);
                break;
        }
    }
}
 
Example #13
Source File: DbMonCollectorTest.java    From jmeter-plugins with Apache License 2.0 5 votes vote down vote up
/**
 * Test of getSamplerSettings method, of class DbMonCollector.
 */
@Test
public void testGetSamplerSettings() {
    System.out.println("getSamplerSettings");
    DbMonCollector instance = new DbMonCollector();
    JMeterProperty result = instance.getSamplerSettings();
}
 
Example #14
Source File: UltimateThreadGroupTest.java    From jmeter-plugins with Apache License 2.0 5 votes vote down vote up
@Test
public void testSchedule_Prop() {
    System.out.println("schedule from property");
    String threadsSchedule = "spawn(1,1s,1s,1s,1m) spawn(2,1s,3s,1s,2h)";
    JMeterUtils.setProperty(UltimateThreadGroup.EXTERNAL_DATA_PROPERTY, threadsSchedule);
    UltimateThreadGroup instance = new UltimateThreadGroup();
    JMeterProperty result = instance.getData();
    JMeterUtils.setProperty(UltimateThreadGroup.EXTERNAL_DATA_PROPERTY, ""); // clear!
    assertEquals("[[1, 1, 1, 1, 60], [2, 1, 3, 1, 7200]]", result.toString());
}
 
Example #15
Source File: VariableThroughputTimer.java    From jmeter-plugins with Apache License 2.0 5 votes vote down vote up
/**
 * @param elapsedSinceStartOfTestSec Elapsed time since start of test in seconds
 * @return double RPS at that second or -1 if we're out of schedule
 */
public Pair<Double, Long> getRPSForSecond(final double elapsedSinceStartOfTestSec) {
    JMeterProperty data = getData();
    if (data instanceof NullProperty) {
        return Pair.of(-1.0, 0L);
    }
    CollectionProperty rows = (CollectionProperty) data;
    PropertyIterator scheduleIT = rows.iterator();
    double newSec = elapsedSinceStartOfTestSec;
    double result = -1;
    boolean resultComputed = false;
    long totalDuration = 0;
    while (scheduleIT.hasNext()) {
        @SuppressWarnings("unchecked")
        List<Object> curProp = (List<Object>) scheduleIT.next().getObjectValue();
        int duration = getIntValue(curProp, DURATION_FIELD_NO);
        totalDuration += duration;
        if (!resultComputed) {
            double fromRps = getDoubleValue(curProp, FROM_FIELD_NO);
            double toRps = getDoubleValue(curProp, TO_FIELD_NO);
            if (newSec - duration <= 0) {
                result = fromRps + newSec * (toRps - fromRps) / (double) duration;
                resultComputed = true;
            } else {
                // We're not yet in the slot
                newSec -= duration;
            }
        }
    }
    return Pair.of(result, totalDuration);
}
 
Example #16
Source File: VariableThroughputTimerTest.java    From jmeter-plugins with Apache License 2.0 5 votes vote down vote up
@Test
public void testDelay_Prop() {
    System.out.println("delay from property");
    String load = "const(10,10s) line(10,100,1m) step(5,25,5,1h)";
    JMeterUtils.setProperty(VariableThroughputTimer.DATA_PROPERTY, load);
    VariableThroughputTimer instance = new VariableThroughputTimer();
    JMeterUtils.setProperty(VariableThroughputTimer.DATA_PROPERTY, ""); // clear!
    JMeterProperty result = instance.getData();
    assertEquals("[[10, 10, 10], [10, 100, 60], [5, 5, 3600], [10, 10, 3600], [15, 15, 3600], [20, 20, 3600], [25, 25, 3600]]", result.toString());
}
 
Example #17
Source File: FirefoxDriverConfig.java    From jmeter-plugins-webdriver with Apache License 2.0 5 votes vote down vote up
private void addExtensions(FirefoxProfile profile) {
    JMeterProperty property = getProperty(EXTENSIONS_TO_LOAD);
    if (property instanceof NullProperty) {
        return;
    }
    CollectionProperty rows = (CollectionProperty) property;
    for (int i = 0; i < rows.size(); i++) {
        ArrayList row = (ArrayList) rows.get(i).getObjectValue();
        String filename = ((JMeterProperty) row.get(0)).getStringValue();
        profile.addExtension(new File(filename));
    }
}
 
Example #18
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 #19
Source File: DbMonGui.java    From jmeter-plugins with Apache License 2.0 5 votes vote down vote up
@Override
public void configure(TestElement te) {
    super.configure(te);
    DbMonCollector dmte = (DbMonCollector) te;
    JMeterProperty dbmonValues = dmte.getSamplerSettings();
    if (!(dbmonValues instanceof NullProperty)) {
        JMeterPluginsUtils.collectionPropertyToTableModelRows((CollectionProperty) dbmonValues, tableModel, columnClasses);
    } else {
        log.warn("Received null property instead of collection");
    }
}
 
Example #20
Source File: PerfMonGui.java    From jmeter-plugins with Apache License 2.0 5 votes vote down vote up
@Override
public void configure(TestElement te) {
    super.configure(te);
    PerfMonCollector pmte = (PerfMonCollector) te;
    JMeterProperty perfmonValues = pmte.getMetricSettings();
    if (!(perfmonValues instanceof NullProperty)) {
        JMeterPluginsUtils.collectionPropertyToTableModelRows((CollectionProperty) perfmonValues, tableModel);
    } else {
        log.warn("Received null property instead of collection");
    }
}
 
Example #21
Source File: JMXMonSampler.java    From jmeter-plugins with Apache License 2.0 5 votes vote down vote up
public JMXMonSampler(MBeanServerConnection remote, JMXConnector jmxConnector, JMeterProperty url, String name, String objectName, String attribute, String key, boolean sampleDeltaValue) {
	this.pool = null;
	this.connectionAttributes = null;
	this.remote = remote;
    this.metricName = name;
    this.url = url;
    this.objectName = objectName;
    this.attribute = attribute;
    this.sampleDeltaValue = sampleDeltaValue;
    this.key = key;
    this.canRetry = false;
}
 
Example #22
Source File: JMXMonCollector.java    From jmeter-plugins with Apache License 2.0 5 votes vote down vote up
protected void initiateConnector(Hashtable attributes, JMeterProperty jmxUrl, String name, 
		boolean delta, String objectName, String attribute, String key, boolean canRetry) throws IOException {
    
	if (!canRetry && pool.getConnection(jmxUrl.getStringValue(), attributes, true) == null)
		return;
	
    jmxMonSamplers.add(new JMXMonSampler(this, pool, attributes, jmxUrl,  name, objectName, attribute, key, delta, canRetry));
}
 
Example #23
Source File: JMXMonGui.java    From jmeter-plugins with Apache License 2.0 5 votes vote down vote up
@Override
public void configure(TestElement te) {
    super.configure(te);
    JMXMonCollector dmte = (JMXMonCollector) te;
    JMeterProperty jmxmonValues = dmte.getSamplerSettings();
    if (!(jmxmonValues instanceof NullProperty)) {
        JMeterPluginsUtils.collectionPropertyToTableModelRows((CollectionProperty) jmxmonValues, tableModel, columnClasses);
    } else {
        log.warn("Received null property instead of collection");
    }
}
 
Example #24
Source File: SetVariablesActionTest.java    From jmeter-plugins with Apache License 2.0 5 votes vote down vote up
@Test
public void testGetUserDefinedVariablesAsProperty() {
    System.out.println("getUserDefinedVariablesAsProperty");
    Arguments vars = new Arguments();
    vars.addArgument("key", "value");
    instance.setUserDefinedVariables(vars);
    JMeterProperty result = instance.getUserDefinedVariablesAsProperty();
    assertNotNull(result);
}
 
Example #25
Source File: SetVariablesActionTest.java    From jmeter-plugins with Apache License 2.0 5 votes vote down vote up
@Test
public void testSetUserDefinedVariables() {
    System.out.println("setUserDefinedVariables");
    Arguments vars = new Arguments();
    vars.addArgument("var1", "val0");
    instance.setUserDefinedVariables(vars);
    JMeterProperty property = instance.getUserDefinedVariablesAsProperty();
    Arguments args = (Arguments) property.getObjectValue();
    assertEquals("val0", args.getArgumentsAsMap().get("var1"));
}
 
Example #26
Source File: ParameterizedControllerTest.java    From jmeter-plugins with Apache License 2.0 5 votes vote down vote up
@Test
public void testGetUserDefinedVariablesAsProperty() {
    System.out.println("getUserDefinedVariablesAsProperty");
    Arguments vars = new Arguments();
    vars.addArgument("key", "value");
    instance.setUserDefinedVariables(vars);
    JMeterProperty result = instance.getUserDefinedVariablesAsProperty();
    assertNotNull(result);
}
 
Example #27
Source File: ParameterizedControllerGui.java    From jmeter-plugins with Apache License 2.0 5 votes vote down vote up
@Override
public void configure(TestElement te) {
    super.configure(te);
    ParameterizedController controller = (ParameterizedController) te;
    final JMeterProperty udv = controller.getUserDefinedVariablesAsProperty();
    if (udv != null && !(udv instanceof NullProperty)) {
        argsPanel.configure((Arguments) udv.getObjectValue());
    }
}
 
Example #28
Source File: SetVariablesActionGui.java    From jmeter-plugins with Apache License 2.0 5 votes vote down vote up
@Override
public void configure(TestElement te) {
    super.configure(te);
    SetVariablesAction controller = (SetVariablesAction) te;
    final JMeterProperty udv = controller.getUserDefinedVariablesAsProperty();
    if (udv != null && !(udv instanceof NullProperty)) {
        argsPanel.configure((Arguments) udv.getObjectValue());
    }
}
 
Example #29
Source File: PerfMonCollectorTest.java    From jmeter-plugins with Apache License 2.0 5 votes vote down vote up
/**
 * Test of getMetricSettings method, of class PerfMonCollector.
 */
@Test
public void testGetMetricSettings() {
    System.out.println("getMetricSettings");
    PerfMonCollector instance = new PerfMonCollector();
    JMeterProperty expResult = null;
    JMeterProperty result = instance.getMetricSettings();
}
 
Example #30
Source File: VariableThroughputTimerTest.java    From jmeter-plugins with Apache License 2.0 5 votes vote down vote up
/**
 * Test of getData method, of class VariableThroughputTimer.
 */
@Test
public void testGetData() {
    System.out.println("getData");
    VariableThroughputTimer instance = new VariableThroughputTimer();
    instance.setData(new CollectionProperty(VariableThroughputTimer.DATA_PROPERTY, new LinkedList()));
    JMeterProperty result = instance.getData();
    //System.err.println(result.getClass().getCanonicalName());
    assertTrue(result instanceof CollectionProperty);
}