Search in sources :

Example 21 with PropertyIterator

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;
}
Also used : BasicAttribute(javax.naming.directory.BasicAttribute) ModificationItem(javax.naming.directory.ModificationItem) Argument(org.apache.jmeter.config.Argument) PropertyIterator(org.apache.jmeter.testelement.property.PropertyIterator)

Example 22 with PropertyIterator

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;
}
Also used : BasicAttribute(javax.naming.directory.BasicAttribute) ModificationItem(javax.naming.directory.ModificationItem) PropertyIterator(org.apache.jmeter.testelement.property.PropertyIterator) LDAPArgument(org.apache.jmeter.protocol.ldap.config.gui.LDAPArgument)

Example 23 with PropertyIterator

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);
}
Also used : JMeterProperty(org.apache.jmeter.testelement.property.JMeterProperty) CollectionProperty(org.apache.jmeter.testelement.property.CollectionProperty) NullProperty(org.apache.jmeter.testelement.property.NullProperty) PropertyIterator(org.apache.jmeter.testelement.property.PropertyIterator) List(java.util.List)

Example 24 with PropertyIterator

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;
}
Also used : CollectionProperty(org.apache.jmeter.testelement.property.CollectionProperty) PropertyIterator(org.apache.jmeter.testelement.property.PropertyIterator)

Example 25 with PropertyIterator

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();
}
Also used : PropertyIterator(org.apache.jmeter.testelement.property.PropertyIterator)

Aggregations

PropertyIterator (org.apache.jmeter.testelement.property.PropertyIterator)36 JMeterProperty (org.apache.jmeter.testelement.property.JMeterProperty)12 CollectionProperty (org.apache.jmeter.testelement.property.CollectionProperty)8 ArrayList (java.util.ArrayList)4 Argument (org.apache.jmeter.config.Argument)4 HTTPArgument (org.apache.jmeter.protocol.http.util.HTTPArgument)3 Test (org.junit.jupiter.api.Test)3 BasicAttribute (javax.naming.directory.BasicAttribute)2 ModificationItem (javax.naming.directory.ModificationItem)2 NameValuePair (org.apache.http.NameValuePair)2 UrlEncodedFormEntity (org.apache.http.client.entity.UrlEncodedFormEntity)2 BasicNameValuePair (org.apache.http.message.BasicNameValuePair)2 Customizer (java.beans.Customizer)1 ByteArrayOutputStream (java.io.ByteArrayOutputStream)1 File (java.io.File)1 UnsupportedEncodingException (java.io.UnsupportedEncodingException)1 MalformedURLException (java.net.MalformedURLException)1 Charset (java.nio.charset.Charset)1 HashMap (java.util.HashMap)1 LinkedHashMap (java.util.LinkedHashMap)1