use of org.apache.jmeter.testelement.property.CollectionProperty in project jmeter-plugins by undera.
the class VariableThroughputTimer method getRPSForSecond.
/**
* @param durationSinceStartOfTestSec 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);
}
use of org.apache.jmeter.testelement.property.CollectionProperty in project jmeter-plugins by undera.
the class VariableThroughputTimerGui method modifyTestElement.
@Override
public void modifyTestElement(TestElement tg) {
// log.info("Modify test element");
super.configureTestElement(tg);
if (grid.isEditing()) {
grid.getCellEditor().stopCellEditing();
}
if (tg instanceof VariableThroughputTimer) {
VariableThroughputTimer utg = (VariableThroughputTimer) tg;
CollectionProperty rows = JMeterPluginsUtils.tableModelRowsToCollectionProperty(tableModel, VariableThroughputTimer.DATA_PROPERTY);
utg.setData(rows);
}
}
use of org.apache.jmeter.testelement.property.CollectionProperty in project jmeter-plugins by undera.
the class VariableThroughputTimerGuiTest method testModifyTestElement.
/**
*/
@Test
public void testModifyTestElement() {
System.out.println("modifyTestElement");
VariableThroughputTimer tg = new VariableThroughputTimer();
VariableThroughputTimerGui instance = new VariableThroughputTimerGui();
// instance.addRowButton.doClick();
instance.modifyTestElement(tg);
CollectionProperty data = (CollectionProperty) tg.getData();
Assert.assertEquals(instance.grid.getModel().getRowCount(), data.size());
}
use of org.apache.jmeter.testelement.property.CollectionProperty in project jmeter-plugins by undera.
the class VariableThroughputTimerTest method testDelay1000.
@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 (// 10 seconds test
(System.currentTimeMillis() - start) < 10 * 1000) {
try {
result = instance.delay();
assertEquals("9", JMeterUtils.getProperty("TEST_totalDuration"));
assertEquals(0, result);
} catch (RuntimeException ex) {
if (!ex.getMessage().equals("Immediate stop")) {
throw ex;
}
}
}
}
use of org.apache.jmeter.testelement.property.CollectionProperty in project jmeter-plugins by undera.
the class FirefoxDriverConfig method setExtensions.
public void setExtensions(PowerTableModel model) {
CollectionProperty prop = JMeterPluginsUtils.tableModelRowsToCollectionProperty(model, EXTENSIONS_TO_LOAD);
setProperty(prop);
}
Aggregations