Search in sources :

Example 51 with CollectionProperty

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

the class HeaderManager method clear.

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

Example 52 with CollectionProperty

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

the class HeaderManager method save.

/**
 * Save the header data to a file.
 *
 * @param headFile
 *            name of the file to store headers into. If name is relative
 *            the system property <code>user.dir</code> will be prepended
 * @throws IOException
 *             if writing the headers fails
 */
public void save(String headFile) throws IOException {
    File file = new File(headFile);
    if (!file.isAbsolute()) {
        file = new File(// $NON-NLS-1$
        System.getProperty("user.dir") + File.separator + headFile);
    }
    try (BufferedWriter fw = Files.newBufferedWriter(file.toPath());
        PrintWriter writer = new PrintWriter(fw)) {
        // TODO Charset ?
        // $NON-NLS-1$
        writer.println("# JMeter generated Header file");
        final CollectionProperty hdrs = getHeaders();
        for (int i = 0; i < hdrs.size(); i++) {
            final JMeterProperty hdr = hdrs.get(i);
            Header head = (Header) hdr.getObjectValue();
            writer.println(head.toString());
        }
    }
}
Also used : CollectionProperty(org.apache.jmeter.testelement.property.CollectionProperty) JMeterProperty(org.apache.jmeter.testelement.property.JMeterProperty) File(java.io.File) BufferedWriter(java.io.BufferedWriter) PrintWriter(java.io.PrintWriter)

Example 53 with CollectionProperty

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

the class HeaderManager method getFirstHeaderNamed.

/**
 * Get the first header from Headers by the header name, or {@code null} if not found.
 * @param name header name
 * @return the first header from Headers by the header name, or {@code null} if not found
 */
public Header getFirstHeaderNamed(final String name) {
    final CollectionProperty headers = getHeaders();
    final int size = headers.size();
    for (int i = 0; i < size; i++) {
        Header header = (Header) headers.get(i).getObjectValue();
        if (header == null) {
            continue;
        }
        if (header.getName().equalsIgnoreCase(name)) {
            return header;
        }
    }
    return null;
}
Also used : CollectionProperty(org.apache.jmeter.testelement.property.CollectionProperty)

Example 54 with CollectionProperty

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

the class Arguments method clear.

/**
 * Clear the arguments.
 */
@Override
public void clear() {
    super.clear();
    setProperty(new CollectionProperty(ARGUMENTS, new ArrayList<Argument>()));
}
Also used : CollectionProperty(org.apache.jmeter.testelement.property.CollectionProperty) ArrayList(java.util.ArrayList)

Example 55 with CollectionProperty

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

the class JMXMonCollectorTest method testSetData.

/**
 * Test of setData method, of class JMXMonCollector.
 */
@Test
public void testSetData() {
    System.out.println("setData");
    CollectionProperty rows = new CollectionProperty();
    JMXMonCollector instance = new JMXMonCollector();
    instance.setData(rows);
}
Also used : CollectionProperty(org.apache.jmeter.testelement.property.CollectionProperty) Test(org.junit.Test)

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