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));
}
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<>()));
}
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>()));
}
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);
}
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);
}
}
}
}
Aggregations