org.apache.jmeter.testelement.property.CollectionProperty Java Examples
The following examples show how to use
org.apache.jmeter.testelement.property.CollectionProperty.
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: UltimateThreadGroupTest.java From jmeter-plugins with Apache License 2.0 | 6 votes |
@Test public void testScheduleThreadAll() { System.out.println("scheduleThreadAll"); HashTree hashtree = new HashTree(); hashtree.add(new LoopController()); CollectionProperty prop = JMeterPluginsUtils.tableModelRowsToCollectionProperty(dataModel, UltimateThreadGroup.DATA_PROPERTY); instance.setData(prop); instance.testStarted(); for (int n = 0; n < instance.getNumThreads(); n++) { JMeterThread thread = new JMeterThread(hashtree, null, null); thread.setThreadNum(n); instance.scheduleThread(thread); } }
Example #2
Source File: DbMonCollector.java From jmeter-plugins with Apache License 2.0 | 6 votes |
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 #3
Source File: ParallelHTTPSamplerGui.java From jmeter-bzm-plugins with Apache License 2.0 | 6 votes |
@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 #4
Source File: FirefoxDriverConfigGui.java From jmeter-plugins-webdriver with Apache License 2.0 | 6 votes |
@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 #5
Source File: WeightedSwitchControllerGui.java From jmeter-bzm-plugins with Apache License 2.0 | 6 votes |
@Override public void configure(TestElement element) { // from model to GUI super.configure(element); log.debug("Props: " + this.isShowing() + " " + isVisible() + " " + isEnabled() + " " + isFocusOwner()); GuiPackage gp = GuiPackage.getInstance(); if (gp != null && element instanceof WeightedSwitchController) { WeightedSwitchController wsc = (WeightedSwitchController) element; CollectionProperty oldData = wsc.getData(); grid.getModel().clearData(); isRandomChoiceCheckBox.setSelected(wsc.isRandomChoice()); if (isShowing()) { fillGridFromTree(wsc, oldData); } else { JMeterPluginsUtils.collectionPropertyToTableModelRows(oldData, grid.getModel()); } } }
Example #6
Source File: BaseCollectorConfig.java From jmeter-prometheus-plugin with Apache License 2.0 | 6 votes |
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 #7
Source File: PrometheusMetricsConfig.java From jmeter-prometheus-plugin with Apache License 2.0 | 6 votes |
@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 #8
Source File: JMeterPluginsUtils.java From jmeter-plugins with Apache License 2.0 | 6 votes |
public static void collectionPropertyToTableModelRows(CollectionProperty prop, PowerTableModel model, Class[] columnClasses) { model.clearData(); for (int rowN = 0; rowN < prop.size(); rowN++) { ArrayList<StringProperty> rowStrings = (ArrayList<StringProperty>) prop.get(rowN).getObjectValue(); ArrayList<Object> rowObject = new ArrayList<>(rowStrings.size()); for (int i = 0; i < columnClasses.length && i < rowStrings.size(); i++) { rowObject.add(convertToClass(rowStrings.get(i), columnClasses[i])); } //for now work only if new fields are added at the end... //needed for retro compatibility if new fields added if (rowObject.size() < columnClasses.length) { for (int i = rowObject.size(); i < columnClasses.length; i++) { rowObject.add(new Object()); } } model.addRow(rowObject.toArray()); } model.fireTableDataChanged(); }
Example #9
Source File: CompositeGraphGui.java From jmeter-plugins with Apache License 2.0 | 6 votes |
private CollectionProperty getConfig() { CollectionProperty ret = new CollectionProperty(); CollectionProperty testplans = new CollectionProperty(); CollectionProperty rows = new CollectionProperty(); ret.setName(CONFIG_PROPERTY); Iterator<String[]> iter = compositeRowsSelectorPanel.getItems(); while (iter.hasNext()) { String[] item = iter.next(); testplans.addItem(item[0]); rows.addItem(item[1]); } ret.addItem(testplans); ret.addItem(rows); return ret; }
Example #10
Source File: CompositeGraphGui.java From jmeter-plugins with Apache License 2.0 | 6 votes |
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 #11
Source File: MergeResultsGui.java From jmeter-plugins with Apache License 2.0 | 6 votes |
@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 #12
Source File: VariableThroughputTimerTest.java From jmeter-plugins with Apache License 2.0 | 6 votes |
@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 #13
Source File: UltimateThreadGroup.java From jmeter-plugins with Apache License 2.0 | 6 votes |
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 #14
Source File: UltimateThreadGroup.java From jmeter-plugins with Apache License 2.0 | 6 votes |
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 #15
Source File: UltimateThreadGroup.java From jmeter-plugins with Apache License 2.0 | 6 votes |
@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 #16
Source File: UltimateThreadGroupGui.java From jmeter-plugins with Apache License 2.0 | 6 votes |
@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 #17
Source File: MergeResultsGui.java From jmeter-plugins with Apache License 2.0 | 6 votes |
/** * 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 #18
Source File: FreeFormArrivalsThreadStarter.java From jmeter-plugins with Apache License 2.0 | 6 votes |
@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 #19
Source File: UltimateThreadGroupTest.java From jmeter-plugins with Apache License 2.0 | 6 votes |
@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 #20
Source File: FirefoxDriverConfig.java From jmeter-plugins-webdriver with Apache License 2.0 | 6 votes |
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 #21
Source File: WeightedSwitchController.java From jmeter-bzm-plugins with Apache License 2.0 | 5 votes |
private double[] getWeights(CollectionProperty data) { long sum = 0; double[] weights = new double[data.size()]; for (int n = 0; n < data.size(); n++) { CollectionProperty row = (CollectionProperty) data.get(n); weights[n] = Long.parseLong(row.get(1).getStringValue()); sum += weights[n]; } for (int n = 0; n < weights.length; n++) { weights[n] /= sum; } //log.info("Weights: " + Arrays.toString(weights)); return weights; }
Example #22
Source File: UltimateThreadGroupGui.java From jmeter-plugins with Apache License 2.0 | 5 votes |
@Override public void modifyTestElement(TestElement tg) { if (grid.isEditing()) { grid.getCellEditor().stopCellEditing(); } if (tg instanceof UltimateThreadGroup) { UltimateThreadGroup utg = (UltimateThreadGroup) tg; CollectionProperty rows = JMeterPluginsUtils.tableModelRowsToCollectionProperty(tableModel, UltimateThreadGroup.DATA_PROPERTY); utg.setData(rows); utg.setSamplerController((LoopController) loopPanel.createTestElement()); } super.configureTestElement(tg); }
Example #23
Source File: PerfMonGui.java From jmeter-plugins with Apache License 2.0 | 5 votes |
@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 #24
Source File: PerfMonCollector.java From jmeter-plugins with Apache License 2.0 | 5 votes |
private void initiateConnectors() { oldValues.clear(); JMeterProperty prop = getMetricSettings(); connectors.clear(); if (!(prop instanceof CollectionProperty)) { log.warn("Got unexpected property: " + prop); return; } CollectionProperty rows = (CollectionProperty) prop; for (int i = 0; i < rows.size(); i++) { Object val = rows.get(i).getObjectValue(); if (val instanceof ArrayList) { ArrayList<JMeterProperty> row = (ArrayList<JMeterProperty>) val; String host = row.get(0).getStringValue(); int port = row.get(1).getIntValue(); String metric = row.get(2).getStringValue(); String params = row.get(3).getStringValue(); initiateConnector(host, port, i, metric, params); } } for (Object key : connectors.keySet()) { try { connectors.get(key).connect(); } catch (IOException ex) { log.error("Error connecting to agent", ex); connectors.put(key, new UnavailableAgentConnector(ex)); } } }
Example #25
Source File: PerfMonGui.java From jmeter-plugins with Apache License 2.0 | 5 votes |
@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 #26
Source File: JMXMonGui.java From jmeter-plugins with Apache License 2.0 | 5 votes |
@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 #27
Source File: JMXMonGui.java From jmeter-plugins with Apache License 2.0 | 5 votes |
@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 #28
Source File: UltimateThreadGroup.java From jmeter-plugins with Apache License 2.0 | 5 votes |
@Override protected void scheduleThread(JMeterThread thread, long tgStartTime) { log.debug("Scheduling thread: " + thread.getThreadName()); if (threadsToSchedule < 1) { if (!scheduleIT.hasNext()) { throw new RuntimeException("Not enough schedule records for thread #" + thread.getThreadName()); } currentRecord = (CollectionProperty) scheduleIT.next(); threadsToSchedule = currentRecord.get(0).getIntValue(); } int numThreads = currentRecord.get(START_THREADS_CNT_FIELD_NO).getIntValue(); int initialDelay = currentRecord.get(INIT_DELAY_FIELD_NO).getIntValue(); int startRampUp = currentRecord.get(STARTUP_TIME_FIELD_NO).getIntValue(); int flightTime = currentRecord.get(HOLD_LOAD_FOR_FIELD_NO).getIntValue(); int endRampUp = currentRecord.get(SHUTDOWN_TIME_FIELD_NO).getIntValue(); long ascentPoint = tgStartTime + 1000 * initialDelay; final int rampUpDelayForThread = (int) Math.floor(1000 * startRampUp * (double) threadsToSchedule / numThreads); long startTime = ascentPoint + rampUpDelayForThread; long descentPoint = startTime + 1000 * flightTime + 1000 * startRampUp - rampUpDelayForThread; thread.setStartTime(startTime); thread.setEndTime(descentPoint + (int) Math.floor(1000 * endRampUp * (double) threadsToSchedule / numThreads)); thread.setScheduled(true); threadsToSchedule--; }
Example #29
Source File: ParallelHTTPSamplerGui.java From jmeter-bzm-plugins with Apache License 2.0 | 5 votes |
@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 #30
Source File: DistributedTestControl.java From jmeter-plugins with Apache License 2.0 | 5 votes |
public CollectionProperty getData() { CollectionProperty data = (CollectionProperty) getProperty(DATA_PROP); LinkedList<String> arr=new LinkedList<String>(); for (int n = 0; n < data.size(); n++) { arr.add(data.get(n).getStringValue()); } String val = StringUtils.join(arr, ","); log.debug("Setting hosts 1: " + val); JMeterUtils.setProperty(PROP_HOSTS, val); return data; }