本文整理汇总了Java中org.apache.jmeter.testelement.property.PropertyIterator类的典型用法代码示例。如果您正苦于以下问题:Java PropertyIterator类的具体用法?Java PropertyIterator怎么用?Java PropertyIterator使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
PropertyIterator类属于org.apache.jmeter.testelement.property包,在下文中一共展示了PropertyIterator类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: setValues
import org.apache.jmeter.testelement.property.PropertyIterator; //导入依赖的package包/类
private void setValues() {
synchronized (lock) {
if (log.isDebugEnabled()) {
log.debug(Thread.currentThread().getName() + " Running up named: " + getName());//$NON-NLS-1$
}
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()) {
log.debug(Thread.currentThread().getName() + " saving variable: " + name + "=" + value);//$NON-NLS-1$
}
jmvars.put(name, value);
}
}
}
示例2: marshal
import org.apache.jmeter.testelement.property.PropertyIterator; //导入依赖的package包/类
/** {@inheritDoc} */
@Override
public void marshal(Object arg0, HierarchicalStreamWriter writer, MarshallingContext context) {
TestElement el = (TestElement) arg0;
ConversionHelp.saveSpecialProperties(el,writer);
PropertyIterator iter = el.propertyIterator();
while (iter.hasNext()) {
JMeterProperty jmp=iter.next();
// Skip special properties if required
if (!ConversionHelp.isSpecialProperty(jmp.getName())) {
// Don't save empty comments - except for the TestPlan (to maintain compatibility)
if (!(
TestElement.COMMENTS.equals(jmp.getName())
&& jmp.getStringValue().length()==0
&& !el.getClass().equals(TestPlan.class)
))
{
writeItem(jmp, context, writer);
}
}
}
}
示例3: getArgumentsAsMap
import org.apache.jmeter.testelement.property.PropertyIterator; //导入依赖的package包/类
/**
* 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 LinkedHashMap<>();
while (iter.hasNext()) {
Argument arg = (Argument) iter.next().getObjectValue();
// Because CollectionProperty.mergeIn will not prevent adding two
// properties of the same name, we need to select the first value so
// that this element's values prevail over defaults provided by
// configuration
// elements:
if (!argMap.containsKey(arg.getName())) {
argMap.put(arg.getName(), arg.getValue());
}
}
return argMap;
}
示例4: removeMatchingCookies
import org.apache.jmeter.testelement.property.PropertyIterator; //导入依赖的package包/类
void removeMatchingCookies(Cookie newCookie){
// Scan for any matching cookies
PropertyIterator iter = getCookies().iterator();
while (iter.hasNext()) {
Cookie cookie = (Cookie) iter.next().getObjectValue();
if (cookie == null) {// TODO is this possible?
continue;
}
if (match(cookie,newCookie)) {
if (log.isDebugEnabled()) {
log.debug("New Cookie = " + newCookie.toString()
+ " removing matching Cookie " + cookie.toString());
}
iter.remove();
}
}
}
示例5: getSendParameterValuesAsPostBody
import org.apache.jmeter.testelement.property.PropertyIterator; //导入依赖的package包/类
/**
* Determine if none of the parameters have a name, and if that
* is the case, it means that the parameter values should be sent
* as the entity body
*
* @return true if none of the parameters have a name specified
*/
public boolean getSendParameterValuesAsPostBody() {
if (getPostBodyRaw()) {
return true;
} else {
boolean noArgumentsHasName = true;
PropertyIterator args = getArguments().iterator();
while (args.hasNext()) {
HTTPArgument arg = (HTTPArgument) args.next().getObjectValue();
if (arg.getName() != null && arg.getName().length() > 0) {
noArgumentsHasName = false;
break;
}
}
return noArgumentsHasName;
}
}
示例6: toString
import org.apache.jmeter.testelement.property.PropertyIterator; //导入依赖的package包/类
/**
* 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) {
str.append("="); //$NON-NLS$
} else {
str.append(metaData);
}
str.append(arg.getValue());
if (iter.hasNext()) {
str.append("&"); //$NON-NLS$
}
}
return str.toString();
}
示例7: save
import org.apache.jmeter.testelement.property.PropertyIterator; //导入依赖的package包/类
/**
* Save the static cookie data to a file.
* Cookies are only taken from the GUI - runtime cookies are not included.
*/
public void save(String authFile) throws IOException {
File file = new File(authFile);
if (!file.isAbsolute()) {
file = new File(System.getProperty("user.dir") // $NON-NLS-1$
+ File.separator + authFile);
}
PrintWriter writer = new PrintWriter(new FileWriter(file)); // TODO Charset ?
writer.println("# JMeter generated Cookie file");// $NON-NLS-1$
PropertyIterator cookies = getCookies().iterator();
long now = System.currentTimeMillis();
while (cookies.hasNext()) {
Cookie cook = (Cookie) cookies.next().getObjectValue();
final long expiresMillis = cook.getExpiresMillis();
if (expiresMillis == 0 || expiresMillis > now) { // only save unexpired cookies
writer.println(cookieToString(cook));
}
}
writer.flush();
writer.close();
}
示例8: getCookiesForUrl
import org.apache.jmeter.testelement.property.PropertyIterator; //导入依赖的package包/类
/**
* Get array of valid HttpClient cookies for the URL
*
* @param url the target URL
* @return array of HttpClient cookies
*
*/
org.apache.commons.httpclient.Cookie[] getCookiesForUrl(
CollectionProperty cookiesCP,
URL url,
boolean allowVariableCookie){
org.apache.commons.httpclient.Cookie cookies[]=
new org.apache.commons.httpclient.Cookie[cookiesCP.size()];
int i=0;
for (PropertyIterator iter = cookiesCP.iterator(); iter.hasNext();) {
Cookie jmcookie = (Cookie) iter.next().getObjectValue();
// Set to running version, to allow function evaluation for the cookie values (bug 28715)
if (allowVariableCookie) {
jmcookie.setRunningVersion(true);
}
cookies[i++] = makeCookie(jmcookie);
if (allowVariableCookie) {
jmcookie.setRunningVersion(false);
}
}
String host = url.getHost();
String protocol = url.getProtocol();
int port= HTTPSamplerBase.getDefaultPort(protocol,url.getPort());
String path = url.getPath();
boolean secure = HTTPSamplerBase.isSecure(protocol);
return cookieSpec.match(host, port, path, secure, cookies);
}
示例9: matchesPatterns
import org.apache.jmeter.testelement.property.PropertyIterator; //导入依赖的package包/类
private boolean matchesPatterns(String url, CollectionProperty patterns) {
PropertyIterator iter = patterns.iterator();
while (iter.hasNext()) {
String item = iter.next().getStringValue();
Pattern pattern = null;
try {
pattern = JMeterUtils.getPatternCache().getPattern(item, Perl5Compiler.READ_ONLY_MASK | Perl5Compiler.SINGLELINE_MASK);
if (JMeterUtils.getMatcher().matches(url, pattern)) {
return true;
}
} catch (MalformedCachePatternException e) {
log.warn("Skipped invalid pattern: " + item, e);
}
}
return false;
}
示例10: setConnectionHeaders
import org.apache.jmeter.testelement.property.PropertyIterator; //导入依赖的package包/类
/**
* Extracts all the required headers for that particular URL request and
* sets them in the <code>HttpURLConnection</code> passed in
*
* @param conn
* <code>HttpUrlConnection</code> which represents the URL
* request
* @param u
* <code>URL</code> of the URL request
* @param headerManager
* the <code>HeaderManager</code> containing all the cookies
* for this <code>UrlConfig</code>
* @param cacheManager the CacheManager (may be null)
*/
private void setConnectionHeaders(HttpURLConnection conn, URL u, HeaderManager headerManager, CacheManager cacheManager) {
// Add all the headers from the HeaderManager
if (headerManager != null) {
CollectionProperty headers = headerManager.getHeaders();
if (headers != null) {
PropertyIterator i = headers.iterator();
while (i.hasNext()) {
Header header = (Header) i.next().getObjectValue();
String n = header.getName();
String v = header.getValue();
conn.addRequestProperty(n, v);
}
}
}
if (cacheManager != null){
cacheManager.setHeaders(conn, u);
}
}
示例11: getSendParameterValuesAsPostBody
import org.apache.jmeter.testelement.property.PropertyIterator; //导入依赖的package包/类
/**
* Determine if none of the parameters have a name, and if that
* is the case, it means that the parameter values should be sent
* as the entity body
*
* @return true if none of the parameters have a name specified
*/
public boolean getSendParameterValuesAsPostBody() {
if(getPostBodyRaw()) {
return true;
} else {
boolean noArgumentsHasName = true;
PropertyIterator args = getArguments().iterator();
while (args.hasNext()) {
HTTPArgument arg = (HTTPArgument) args.next().getObjectValue();
if(arg.getName() != null && arg.getName().length() > 0) {
noArgumentsHasName = false;
break;
}
}
return noArgumentsHasName;
}
}
示例12: getUserAttributes
import org.apache.jmeter.testelement.property.PropertyIterator; //导入依赖的package包/类
/**
* 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 Add Test.
*
* @return the BasicAttributes
*/
private BasicAttributes getUserAttributes() {
BasicAttribute basicattribute = new BasicAttribute("objectclass"); //$NON-NLS-1$
basicattribute.add("top"); //$NON-NLS-1$
basicattribute.add("person"); //$NON-NLS-1$
basicattribute.add("organizationalPerson"); //$NON-NLS-1$
basicattribute.add("inetOrgPerson"); //$NON-NLS-1$
BasicAttributes attrs = new BasicAttributes(true);
attrs.put(basicattribute);
BasicAttribute attr;
PropertyIterator iter = getArguments().iterator();
while (iter.hasNext()) {
Argument item = (Argument) iter.next().getObjectValue();
attr = getBasicAttribute(item.getName(), item.getValue());
attrs.put(attr);
}
return attrs;
}
示例13: getUserAttributes
import org.apache.jmeter.testelement.property.PropertyIterator; //导入依赖的package包/类
/***************************************************************************
* Collect all the values from the table (Arguments), using this create the
* Attributes, this will create the Attributes for the User
* defined TestCase for Add Test
*
* @return The Attributes
**************************************************************************/
private Attributes getUserAttributes() {
Attributes attrs = new BasicAttributes(true);
Attribute attr;
PropertyIterator iter = getArguments().iterator();
while (iter.hasNext()) {
Argument item = (Argument) iter.next().getObjectValue();
attr = attrs.get(item.getName());
if (attr == null) {
attr = getBasicAttribute(item.getName(), item.getValue());
} else {
attr.add(item.getValue());
}
attrs.put(attr);
}
return attrs;
}
示例14: marshal
import org.apache.jmeter.testelement.property.PropertyIterator; //导入依赖的package包/类
/** {@inheritDoc} */
@Override
public void marshal(Object arg0, HierarchicalStreamWriter writer, MarshallingContext context) {
TestElement el = (TestElement) arg0;
if (SaveService.IS_TESTPLAN_FORMAT_22){
ConversionHelp.saveSpecialProperties(el,writer);
}
PropertyIterator iter = el.propertyIterator();
while (iter.hasNext()) {
JMeterProperty jmp=iter.next();
// Skip special properties if required
if (!SaveService.IS_TESTPLAN_FORMAT_22 || !ConversionHelp.isSpecialProperty(jmp.getName())) {
// Don't save empty comments - except for the TestPlan (to maintain compatibility)
if (!(
TestElement.COMMENTS.equals(jmp.getName())
&& jmp.getStringValue().length()==0
&& !el.getClass().equals(TestPlan.class)
))
{
writeItem(jmp, context, writer);
}
}
}
}
示例15: getArgumentsAsMap
import org.apache.jmeter.testelement.property.PropertyIterator; //导入依赖的package包/类
/**
* 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 LinkedHashMap<String, String>();
while (iter.hasNext()) {
Argument arg = (Argument) iter.next().getObjectValue();
// Because CollectionProperty.mergeIn will not prevent adding two
// properties of the same name, we need to select the first value so
// that this element's values prevail over defaults provided by
// configuration
// elements:
if (!argMap.containsKey(arg.getName())) {
argMap.put(arg.getName(), arg.getValue());
}
}
return argMap;
}