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

The following examples show how to use org.apache.jmeter.testelement.property.PropertyIterator. 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: 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 #2
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 #3
Source File: CompositeGraphGui.java    From jmeter-plugins with Apache License 2.0 6 votes vote down vote up
private void setConfig(CollectionProperty properties) {
    PropertyIterator iter = properties.iterator();

    CollectionProperty testplans = (CollectionProperty) iter.next();
    CollectionProperty rows = (CollectionProperty) iter.next();

    if (rows.size() > 0) {
        PropertyIterator iterTestplans = testplans.iterator();
        PropertyIterator iterRows = rows.iterator();

        while (iterTestplans.hasNext() && iterRows.hasNext()) {
            String testplan = iterTestplans.next().getStringValue();
            String row = iterRows.next().getStringValue();
            compositeRowsSelectorPanel.addItemsToComposite(testplan, row);
        }

    }
}
 
Example #4
Source File: FreeFormArrivalsThreadStarter.java    From jmeter-plugins with Apache License 2.0 6 votes vote down vote up
@Override
protected double getCurrentRate() {
    CollectionProperty data = arrivalsTG.getData();
    PropertyIterator it = data.iterator();
    int offset = 0;
    while (it.hasNext()) {
        CollectionProperty record = (CollectionProperty) it.next();
        double chunkLen = record.get(2).getDoubleValue() * arrivalsTG.getUnitFactor();
        double timeProgress = this.rollingTime / 1000.0 - startTime;
        double chunkProgress = (timeProgress - offset) / chunkLen;
        offset += chunkLen;
        if (timeProgress <= offset) {
            double chunkStart = record.get(0).getDoubleValue() / arrivalsTG.getUnitFactor();
            double chunkEnd = record.get(1).getDoubleValue() / arrivalsTG.getUnitFactor();
            double chunkHeight = chunkEnd - chunkStart;
            return chunkStart + chunkProgress * chunkHeight;
        }
    }
    log.info("Got no further schedule, can stop now");
    return -1;
}
 
Example #5
Source File: ThreadSafeCookieManager.java    From jmeter-bzm-plugins with Apache License 2.0 5 votes vote down vote up
public ThreadSafeCookieManager(CookieManager manager) {
    PropertyIterator iter = manager.propertyIterator();
    while (iter.hasNext()) {
        setProperty(iter.next().clone());
    }
    setRunningVersion(manager.isRunningVersion());
    testStarted();
}
 
Example #6
Source File: BaseCollectorConfig.java    From jmeter-prometheus-plugin with Apache License 2.0 5 votes vote down vote up
@Override
public String toString() {
	PropertyIterator it = this.propertyIterator();
	StringBuilder sb = new StringBuilder();
	sb.append("[");
	while(it.hasNext()) {
		JMeterProperty prop = it.next();
		sb.append(prop.getName()).append(": ").append(prop.getStringValue()).append(", ");
	}

	sb.append("]");
	return sb.toString();
}
 
Example #7
Source File: AbstractCollectorTable.java    From jmeter-prometheus-plugin with Apache License 2.0 5 votes vote down vote up
public void populateTable(CollectorElement<C> config) {
	
	CollectionProperty collectors = config.getCollectorConfigs();
	log.debug("Configuring table with " + collectors.size() + " collectors.");
	
	this.model.clearData();
	
	PropertyIterator it = collectors.iterator();
	while(it.hasNext()) {
		BaseCollectorConfig cfg = (BaseCollectorConfig) it.next().getObjectValue();			 
		this.model.addRow(cfg);
		log.debug("added row into table: " + cfg.toString());
	}
	
}
 
Example #8
Source File: TreeClonerTG.java    From jmeter-debugger with Apache License 2.0 5 votes vote down vote up
private JMeterTreeNode getClonedNode(JMeterTreeNode node) {
    TestElement orig = getOriginalObject(node);
    TestElement cloned = (TestElement) orig.clone();
    TestElement altered = getAlteredElement(cloned);

    if (altered instanceof Wrapper) {
        Wrapper wrp = (Wrapper) altered;
        //noinspection unchecked
        wrp.setWrappedElement(cloned);
        PropertyIterator iter = cloned.propertyIterator();
        while (iter.hasNext()) {
            JMeterProperty prop = iter.next();
            if (!prop.getName().startsWith("TestElement")) {
                wrp.setProperty(prop.clone());
            }
        }
    }

    if (altered instanceof OriginalLink) {
        OriginalLink link = (OriginalLink) altered;
        //noinspection unchecked
        link.setOriginal(orig);
    } else {
        log.debug("Not linking original: " + altered);
    }

    JMeterTreeNode res = new JMeterTreeNode();
    altered.setName(cloned.getName());
    altered.setEnabled(cloned.isEnabled());
    if (altered.getProperty(TestElement.GUI_CLASS) instanceof NullProperty) {
        altered.setProperty(TestElement.GUI_CLASS, ControllerDebugGui.class.getCanonicalName());
    }
    res.setUserObject(altered);
    return res;
}
 
Example #9
Source File: JMeterRecorder.java    From jsflight with Apache License 2.0 5 votes vote down vote up
private List<TestElement> findAndRemoveHeaderManagers(TestElement element) {
    List<TestElement> descendants = new ArrayList<>();

    for (PropertyIterator iter = element.propertyIterator(); iter.hasNext();)
    {
        JMeterProperty property = iter.next();
        if (property.getObjectValue() instanceof HeaderManager)
        {
            descendants.add((HeaderManager)property.getObjectValue());
            iter.remove();
        }
    }
    return descendants;
}
 
Example #10
Source File: FreeFormArrivalsThreadGroupGui.java    From jmeter-plugins with Apache License 2.0 5 votes vote down vote up
protected void updateChart(AbstractDynamicThreadGroup tg) {
    FreeFormArrivalsThreadGroup atg = (FreeFormArrivalsThreadGroup) tg;
    CollectionProperty data = atg.getData();
    chartModel.clear();
    previewChart.clearErrorMessage();
    AbstractGraphRow row = new GraphRowExactValues();
    row.setColor(getRowColor());
    row.setDrawLine(true);
    row.setMarkerSize(AbstractGraphRow.MARKER_SIZE_NONE);
    row.setDrawThickLines(true);

    row.add(0, 0); // initial value to force min Y

    JMeterVariableEvaluator evaluator = new JMeterVariableEvaluator();
    int offset = 0;
    double totalArrivals = 0;
    PropertyIterator it = data.iterator();
    while (it.hasNext()) {
        CollectionProperty record = (CollectionProperty) it.next();
        double from = evaluator.getDouble(record.get(0));
        double to = evaluator.getDouble(record.get(1));
        double during = evaluator.getDouble(record.get(2));
        row.add(offset * 1000, from);
        offset += during * tg.getUnitFactor();
        row.add(offset * 1000, to);
        totalArrivals += during * from + during * (to - from) / 2;
    }

    previewChart.setxAxisLabelRenderer(new DateTimeRenderer(DateTimeRenderer.HHMMSS, 0));
    chartModel.put(getRowLabel(totalArrivals), row);
}
 
Example #11
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);
}