use of org.apache.jmeter.testelement.property.PropertyIterator in project jmeter by apache.
the class LDAPSampler method getUserModAttributes.
/**
* Collect all the value from the table (Arguments), using this create the
* basicAttributes. This will create the Basic Attributes for the User
* defined TestCase for Modify test.
*
* @return the BasicAttributes
*/
private ModificationItem[] getUserModAttributes() {
ModificationItem[] mods = new ModificationItem[getArguments().getArguments().size()];
BasicAttribute attr;
PropertyIterator iter = getArguments().iterator();
int count = 0;
while (iter.hasNext()) {
Argument item = (Argument) iter.next().getObjectValue();
attr = getBasicAttribute(item.getName(), item.getValue());
mods[count] = new ModificationItem(DirContext.REPLACE_ATTRIBUTE, attr);
count = +1;
}
return mods;
}
use of org.apache.jmeter.testelement.property.PropertyIterator in project jmeter by apache.
the class LDAPExtSampler method getUserModAttributes.
/**
*************************************************************************
* Collect all the value from the table (Arguments), using this create the
* basicAttributes This will create the Basic Attributes for the User
* defined TestCase for Modify test
*
* @return The BasicAttributes
*************************************************************************
*/
private ModificationItem[] getUserModAttributes() {
ModificationItem[] mods = new ModificationItem[getLDAPArguments().getArguments().size()];
PropertyIterator iter = getLDAPArguments().iterator();
int count = 0;
while (iter.hasNext()) {
BasicAttribute attr;
LDAPArgument item = (LDAPArgument) iter.next().getObjectValue();
if (item.getValue().length() == 0) {
attr = new BasicAttribute(item.getName());
} else {
attr = getBasicAttribute(item.getName(), item.getValue());
}
final String opcode = item.getOpcode();
if ("add".equals(opcode)) {
// $NON-NLS-1$
mods[count++] = new ModificationItem(DirContext.ADD_ATTRIBUTE, attr);
} else if (// $NON-NLS-1$
"delete".equals(opcode) || "remove".equals(opcode)) {
// $NON-NLS-1$
mods[count++] = new ModificationItem(DirContext.REMOVE_ATTRIBUTE, attr);
} else if ("replace".equals(opcode)) {
// $NON-NLS-1$
mods[count++] = new ModificationItem(DirContext.REPLACE_ATTRIBUTE, attr);
} else {
log.warn("Invalid opCode: {}", opcode);
}
}
return mods;
}
use of org.apache.jmeter.testelement.property.PropertyIterator 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.PropertyIterator in project jmeter-plugins by undera.
the class FreeFormArrivalsThreadStarter method getCurrentRate.
@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;
}
use of org.apache.jmeter.testelement.property.PropertyIterator in project jmeter by apache.
the class Arguments method toString.
/**
* Create a string representation of the arguments.
*
* @return the string representation of the arguments
*/
@Override
public String toString() {
StringBuilder str = new StringBuilder();
PropertyIterator iter = getArguments().iterator();
while (iter.hasNext()) {
Argument arg = (Argument) iter.next().getObjectValue();
final String metaData = arg.getMetaData();
str.append(arg.getName());
if (metaData == null) {
// $NON-NLS-1$
str.append("=");
} else {
str.append(metaData);
}
str.append(arg.getValue());
final String desc = arg.getDescription();
if (desc != null) {
str.append("(");
str.append(desc);
str.append(")");
}
if (iter.hasNext()) {
// $NON-NLS-1$
str.append("&");
}
}
return str.toString();
}
Aggregations