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

The following examples show how to use org.apache.jmeter.testelement.property.NullProperty. 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: 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 #2
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 #3
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 #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: 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 #6
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 #7
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 #8
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 #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: 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 #11
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 #12
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 #13
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 #14
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 #15
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 #16
Source File: UltimateThreadGroupTest.java    From jmeter-plugins with Apache License 2.0 5 votes vote down vote up
@Test
public void testGetData() {
    System.out.println("getSchedule");
    CollectionProperty prop = JMeterPluginsUtils.tableModelRowsToCollectionProperty(dataModel, UltimateThreadGroup.DATA_PROPERTY);
    instance.setData(prop);
    JMeterProperty result = instance.getData();
    assertFalse(result instanceof NullProperty);
    assertEquals(prop.getStringValue(), result.getStringValue());
}
 
Example #17
Source File: UltimateThreadGroup.java    From jmeter-plugins with Apache License 2.0 5 votes vote down vote up
@Override
public void testStarted() {
    JMeterProperty data = getData();
    if (!(data instanceof NullProperty)) {
        scheduleIT = ((CollectionProperty) data).iterator();
    }
    threadsToSchedule = 0;
}
 
Example #18
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 #19
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 #20
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 #21
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 #22
Source File: PageDataExtractorOverTimeGui.java    From jmeter-plugins with Apache License 2.0 5 votes vote down vote up
@Override
public void configure(TestElement te) {
    super.configure(te);
    CorrectedResultCollector rc = (CorrectedResultCollector) te;
    JMeterProperty regexpValues = rc.getProperty(REGEXPS_PROPERTY);
    if (!(regexpValues instanceof NullProperty)) {
        JMeterPluginsUtils.collectionPropertyToTableModelRows((CollectionProperty) regexpValues, tableModel, columnClasses);
        regExps = (CollectionProperty) regexpValues;
    } else {
        log.warn("Received null property instead of collection");
    }
}
 
Example #23
Source File: CompositeGraphGui.java    From jmeter-plugins with Apache License 2.0 5 votes vote down vote up
@Override
public void configure(TestElement te) {
    //log.info("Configure");
    super.configure(te);
    ((CompositeResultCollector) te).setCompositeModel(compositeModel);

    JMeterProperty data = te.getProperty(CONFIG_PROPERTY);

    if (!(data instanceof NullProperty)) {
        setConfig((CollectionProperty) data);
    }
}
 
Example #24
Source File: AbstractMonitoringVisualizer.java    From jmeter-plugins with Apache License 2.0 5 votes vote down vote up
@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 #25
Source File: ParallelHTTPSampler.java    From jmeter-bzm-plugins with Apache License 2.0 4 votes vote down vote up
@Override
protected HTTPSampleResult sample(java.net.URL u, String method, boolean areFollowingRedirect, int depth) {
    if (depth < 1) {
        JMeterProperty data = getData();
        StringBuilder body = new StringBuilder();
        StringBuilder req = new StringBuilder();
        if (!(data instanceof NullProperty)) {
            CollectionProperty rows = (CollectionProperty) data;

            for (JMeterProperty row : rows) {
                ArrayList<Object> curProp = (ArrayList<Object>) row.getObjectValue();
                req.append(curProp.get(0)).append("\n");
                body.append("<iframe src='").append(curProp.get(0)).append("'></iframe>\n");
            }
        }

        HTTPSampleResult res = new HTTPSampleResult();
        res.setSamplerData(req.toString());
        res.setRequestHeaders("\n");
        res.setHTTPMethod("GET");
        try {
            res.setURL(new URL("http://parallel-urls-list"));
        } catch (MalformedURLException e) {
            log.warn("Failed to set empty url", e);
        }

        res.setSuccessful(true);
        res.setResponseData(body.toString(), res.getDataEncodingWithDefault());
        res.setContentType("text/html");
        res.sampleStart();
        downloadPageResources(res, res, depth);
        if (res.getEndTime() == 0L) {
            res.sampleEnd();
        }
        return res;
    } else {
        if (impl == null) {
            impl = HCAccessor.getInstance(this);
        }

        return HCAccessor.sample(impl, u, method, areFollowingRedirect, depth);
    }
}