Search in sources :

Example 26 with PropertyIterator

use of org.apache.jmeter.testelement.property.PropertyIterator in project jmeter by apache.

the class TestHTTPFileArgs method testAdding.

@Test
public void testAdding() throws Exception {
    HTTPFileArgs files = new HTTPFileArgs();
    assertEquals(0, files.getHTTPFileArgCount());
    files.addHTTPFileArg("hede");
    assertEquals(1, files.getHTTPFileArgCount());
    assertEquals("hede", ((HTTPFileArg) files.iterator().next().getObjectValue()).getPath());
    HTTPFileArg file = new HTTPFileArg("hodo");
    files.addHTTPFileArg(file);
    assertEquals(2, files.getHTTPFileArgCount());
    PropertyIterator iter = files.iterator();
    assertEquals("hede", ((HTTPFileArg) iter.next().getObjectValue()).getPath());
    assertEquals("hodo", ((HTTPFileArg) iter.next().getObjectValue()).getPath());
    files.addEmptyHTTPFileArg();
    assertEquals(3, files.getHTTPFileArgCount());
    iter = files.iterator();
    assertEquals("hede", ((HTTPFileArg) iter.next().getObjectValue()).getPath());
    assertEquals("hodo", ((HTTPFileArg) iter.next().getObjectValue()).getPath());
    assertEquals("", ((HTTPFileArg) iter.next().getObjectValue()).getPath());
}
Also used : PropertyIterator(org.apache.jmeter.testelement.property.PropertyIterator) Test(org.junit.jupiter.api.Test)

Example 27 with PropertyIterator

use of org.apache.jmeter.testelement.property.PropertyIterator in project jmeter by apache.

the class LDAPArguments 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()) {
        LDAPArgument arg = (LDAPArgument) iter.next().getObjectValue();
        final String metaData = arg.getMetaData();
        str.append(arg.getName());
        if (metaData == null) {
            // $NON-NLS$
            str.append("=");
        } else {
            str.append(metaData);
        }
        str.append(arg.getValue());
        if (iter.hasNext()) {
            // $NON-NLS$
            str.append("&");
        }
    }
    return str.toString();
}
Also used : PropertyIterator(org.apache.jmeter.testelement.property.PropertyIterator)

Example 28 with PropertyIterator

use of org.apache.jmeter.testelement.property.PropertyIterator in project jmeter by apache.

the class LDAPArguments method getArgumentsAsMap.

/**
 * Get the arguments as a Map. Each argument name is used as the key, and
 * its value as the value.
 *
 * @return a new Map with String keys and values containing the arguments
 */
public Map<String, String> getArgumentsAsMap() {
    PropertyIterator iter = getArguments().iterator();
    Map<String, String> argMap = new HashMap<>();
    while (iter.hasNext()) {
        LDAPArgument arg = (LDAPArgument) iter.next().getObjectValue();
        argMap.put(arg.getName(), arg.getValue());
    }
    return argMap;
}
Also used : HashMap(java.util.HashMap) PropertyIterator(org.apache.jmeter.testelement.property.PropertyIterator)

Example 29 with PropertyIterator

use of org.apache.jmeter.testelement.property.PropertyIterator in project jmeter by apache.

the class LDAPArgumentsPanel method configure.

/**
 * A newly created component can be initialized with the contents of a Test
 * Element object by calling this method. The component is responsible for
 * querying the Test Element object for the relevant information to display
 * in its GUI.
 *
 * @param el
 *            the TestElement to configure
 */
@Override
public void configure(TestElement el) {
    super.configure(el);
    if (el instanceof LDAPArguments) {
        tableModel.clearData();
        PropertyIterator iter = ((LDAPArguments) el).iterator();
        while (iter.hasNext()) {
            LDAPArgument arg = (LDAPArgument) iter.next().getObjectValue();
            tableModel.addRow(arg);
        }
    }
    checkDeleteStatus();
}
Also used : PropertyIterator(org.apache.jmeter.testelement.property.PropertyIterator)

Example 30 with PropertyIterator

use of org.apache.jmeter.testelement.property.PropertyIterator in project jmeter by apache.

the class UserParameters method setValues.

@SuppressWarnings("SynchronizeOnNonFinalField")
private void setValues() {
    synchronized (lock) {
        if (log.isDebugEnabled()) {
            // $NON-NLS-1$
            log.debug("{} Running up named: {}", Thread.currentThread().getName(), getName());
        }
        PropertyIterator namesIter = getNames().iterator();
        PropertyIterator valueIter = getValues().iterator();
        JMeterVariables jmvars = getThreadContext().getVariables();
        while (namesIter.hasNext() && valueIter.hasNext()) {
            String name = namesIter.next().getStringValue();
            String value = valueIter.next().getStringValue();
            if (log.isDebugEnabled()) {
                // $NON-NLS-1$
                log.debug("{} saving variable: {}={}", Thread.currentThread().getName(), name, value);
            }
            jmvars.put(name, value);
        }
    }
}
Also used : JMeterVariables(org.apache.jmeter.threads.JMeterVariables) 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