Search in sources :

Example 81 with CollectionProperty

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

the class ModuleController method setNodePath.

private void setNodePath() {
    List<String> nodePath = new ArrayList<>();
    if (selectedNode != null) {
        TreeNode[] path = selectedNode.getPath();
        for (TreeNode node : path) {
            nodePath.add(((JMeterTreeNode) node).getName());
        }
    }
    setProperty(new CollectionProperty(NODE_PATH, nodePath));
}
Also used : CollectionProperty(org.apache.jmeter.testelement.property.CollectionProperty) JMeterTreeNode(org.apache.jmeter.gui.tree.JMeterTreeNode) TreeNode(javax.swing.tree.TreeNode) ArrayList(java.util.ArrayList)

Example 82 with CollectionProperty

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

the class AuthManager method clear.

/**
 * {@inheritDoc}
 */
@Override
public void clear() {
    super.clear();
    kerberosManager.clearSubjects();
    setProperty(new CollectionProperty(AUTH_LIST, new ArrayList<>()));
}
Also used : CollectionProperty(org.apache.jmeter.testelement.property.CollectionProperty) ArrayList(java.util.ArrayList)

Example 83 with CollectionProperty

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

the class DNSCacheManager method clearServers.

/**
 * Remove all the servers.
 */
private void clearServers() {
    log.debug("Clear all servers from store");
    setProperty(new CollectionProperty(SERVERS, new ArrayList<String>()));
}
Also used : CollectionProperty(org.apache.jmeter.testelement.property.CollectionProperty) ArrayList(java.util.ArrayList)

Example 84 with CollectionProperty

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

the class SendMailCommand method addHeader.

/**
 * Adds a header-part to current HashMap of headers - to be called by
 * SmtpSampler-object
 *
 * @param headerName
 *            Key for current header
 * @param headerValue
 *            Value for current header
 */
public void addHeader(String headerName, String headerValue) {
    if (this.headerFields == null) {
        this.headerFields = new CollectionProperty();
    }
    Argument argument = new Argument(headerName, headerValue);
    this.headerFields.addItem(argument);
}
Also used : CollectionProperty(org.apache.jmeter.testelement.property.CollectionProperty) Argument(org.apache.jmeter.config.Argument)

Example 85 with CollectionProperty

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

the class CookieManager method addFile.

/**
 * Add cookie data from a file.
 *
 * @param cookieFile
 *            name of the file to read the cookies from. If the name is
 *            relative, the system property <code>user.dir</code> will be
 *            prepended
 * @throws IOException
 *             if reading the file fails
 */
public void addFile(String cookieFile) throws IOException {
    File file = new File(cookieFile);
    if (!file.isAbsolute()) {
        file = new File(// $NON-NLS-1$
        System.getProperty("user.dir") + File.separator + cookieFile);
    }
    if (!file.canRead()) {
        throw new IOException("The file you specified cannot be read.");
    }
    // N.B. this must agree with the save() and cookieToString() methods
    String line;
    try (BufferedReader reader = Files.newBufferedReader(file.toPath())) {
        final CollectionProperty cookies = getCookies();
        while ((line = reader.readLine()) != null) {
            try {
                if (line.startsWith("#") || JOrphanUtils.isBlank(line)) {
                    // $NON-NLS-1$
                    continue;
                }
                String[] st = JOrphanUtils.split(line, TAB, false);
                final int _domain = 0;
                // final int _ignored = 1;
                final int _path = 2;
                final int _secure = 3;
                final int _expires = 4;
                final int _name = 5;
                final int _value = 6;
                final int _fields = 7;
                if (st.length != _fields) {
                    throw new IOException("Expected " + _fields + " fields, found " + st.length + " in " + line);
                }
                if (st[_path].length() == 0) {
                    // $NON-NLS-1$
                    st[_path] = "/";
                }
                boolean secure = Boolean.parseBoolean(st[_secure]);
                long expires = Long.parseLong(st[_expires]);
                if (expires == Long.MAX_VALUE) {
                    expires = 0;
                }
                // long max was used to represent a non-expiring cookie, but that caused problems
                Cookie cookie = new Cookie(st[_name], st[_value], st[_domain], st[_path], secure, expires);
                cookies.addItem(cookie);
            } catch (NumberFormatException e) {
                throw new IOException("Error parsing cookie line\n\t'" + line + "'\n\t" + e);
            }
        }
    }
}
Also used : CollectionProperty(org.apache.jmeter.testelement.property.CollectionProperty) BufferedReader(java.io.BufferedReader) IOException(java.io.IOException) File(java.io.File)

Aggregations

CollectionProperty (org.apache.jmeter.testelement.property.CollectionProperty)91 JMeterProperty (org.apache.jmeter.testelement.property.JMeterProperty)29 ArrayList (java.util.ArrayList)19 NullProperty (org.apache.jmeter.testelement.property.NullProperty)13 Test (org.junit.Test)11 PropertyIterator (org.apache.jmeter.testelement.property.PropertyIterator)8 Test (org.junit.jupiter.api.Test)7 IOException (java.io.IOException)5 List (java.util.List)4 StringProperty (org.apache.jmeter.testelement.property.StringProperty)4 File (java.io.File)3 Argument (org.apache.jmeter.config.Argument)3 PowerTableModel (org.apache.jmeter.gui.util.PowerTableModel)3 TestPlan (org.apache.jmeter.testelement.TestPlan)3 UnsupportedEncodingException (java.io.UnsupportedEncodingException)2 Field (java.lang.reflect.Field)2 MalformedURLException (java.net.MalformedURLException)2 URL (java.net.URL)2 UnknownHostException (java.net.UnknownHostException)2 LinkedList (java.util.LinkedList)2