Package org.apache.jmeter.protocol.http.util

Examples of org.apache.jmeter.protocol.http.util.HTTPArgument


    public void addArgument(String name, String value) {
        this.getArguments().addArgument(new HTTPArgument(name, value));
    }

    public void addArgument(String name, String value, String metadata) {
        this.getArguments().addArgument(new HTTPArgument(name, value, metadata));
    }
View Full Code Here


         }
        StringBuilder buf = new StringBuilder();
        PropertyIterator iter = getArguments().iterator();
        boolean first = true;
        while (iter.hasNext()) {
            HTTPArgument item = null;
            /*
             * N.B. Revision 323346 introduced the ClassCast check, but then used iter.next()
             * to fetch the item to be cast, thus skipping the element that did not cast.
             * Reverted to work more like the original code, but with the check in place.
             * Added a warning message so can track whether it is necessary
             */
            Object objectValue = iter.next().getObjectValue();
            try {
                item = (HTTPArgument) objectValue;
            } catch (ClassCastException e) {
                log.warn("Unexpected argument type: "+objectValue.getClass().getName());
                item = new HTTPArgument((Argument) objectValue);
            }
            final String encodedName = item.getEncodedName();
            if (encodedName.length() == 0) {
                continue; // Skip parameters with a blank name (allows use of optional variables in parameter lists)
            }
            if (!first) {
                buf.append(QRY_SEP);
            } else {
                first = false;
            }
            buf.append(encodedName);
            if (item.getMetaData() == null) {
                buf.append(ARG_VAL_SEP);
            } else {
                buf.append(item.getMetaData());
            }

            // Encode the parameter value in the specified content encoding
            try {
                buf.append(item.getEncodedValue(contentEncoding));
            }
            catch(UnsupportedEncodingException e) {
                log.warn("Unable to encode parameter in encoding " + contentEncoding + ", parameter value not included in query string");
            }
        }
View Full Code Here

     */
    public boolean getSendParameterValuesAsPostBody() {
        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;
View Full Code Here

  public void addEncodedArgument(String name, String value, String metaData, String contentEncoding) {
        if (log.isDebugEnabled()){
        log.debug("adding argument: name: " + name + " value: " + value + " metaData: " + metaData + " contentEncoding: " + contentEncoding);
        }
       
    HTTPArgument arg = null;
        if(contentEncoding != null) {
            arg = new HTTPArgument(name, value, metaData, true, contentEncoding);
        }
        else {
            arg = new HTTPArgument(name, value, metaData, true);
        }

        // Check if there are any difference between name and value and their encoded name and value
        String valueEncoded = null;
        if(contentEncoding != null) {
            try {
                valueEncoded = arg.getEncodedValue(contentEncoding);
            }
            catch (UnsupportedEncodingException e) {
                log.warn("Unable to get encoded value using encoding " + contentEncoding);
                valueEncoded = arg.getEncodedValue();
            }
        }
        else {
            valueEncoded = arg.getEncodedValue();
        }
        // If there is no difference, we mark it as not needing encoding
    if (arg.getName().equals(arg.getEncodedName()) && arg.getValue().equals(valueEncoded)) {
      arg.setAlwaysEncoded(false);
    }
    this.getArguments().addArgument(arg);
  }
View Full Code Here

    public void addEncodedArgument(String name, String value, String metaData) {
        this.addEncodedArgument(name, value, metaData, null);
    }

    public void addNonEncodedArgument(String name, String value, String metadata) {
        HTTPArgument arg = new HTTPArgument(name, value, metadata, false);
        arg.setAlwaysEncoded(false);
        this.getArguments().addArgument(arg);
    }
View Full Code Here

        arg.setAlwaysEncoded(false);
        this.getArguments().addArgument(arg);
    }
   
  public void addArgument(String name, String value) {
    this.getArguments().addArgument(new HTTPArgument(name, value));
  }
View Full Code Here

  public void addArgument(String name, String value) {
    this.getArguments().addArgument(new HTTPArgument(name, value));
  }

  public void addArgument(String name, String value, String metadata) {
    this.getArguments().addArgument(new HTTPArgument(name, value, metadata));
  }
View Full Code Here

     }
    StringBuffer buf = new StringBuffer();
    PropertyIterator iter = getArguments().iterator();
    boolean first = true;
    while (iter.hasNext()) {
      HTTPArgument item = null;
            /*
             * N.B. Revision 323346 introduced the ClassCast check, but then used iter.next()
             * to fetch the item to be cast, thus skipping the element that did not cast.
             * Reverted to work more like the original code, but with the check in place.
             * Added a warning message so can track whether it is necessary
             */
      Object objectValue = iter.next().getObjectValue();
            try {
        item = (HTTPArgument) objectValue;
      } catch (ClassCastException e) {
                log.warn("Unexpected argument type: "+objectValue.getClass().getName());
        item = new HTTPArgument((Argument) objectValue);
      }
      final String encodedName = item.getEncodedName();
      if (encodedName.length() == 0) {
        continue; // Skip parameters with a blank name (allows use of optional variables in parameter lists)
      }
      if (!first) {
        buf.append(QRY_SEP);
      } else {
        first = false;
      }
      buf.append(encodedName);
      if (item.getMetaData() == null) {
        buf.append(ARG_VAL_SEP);
      } else {
        buf.append(item.getMetaData());
      }
           
      // Encode the parameter value in the specified content encoding
      try {
          buf.append(item.getEncodedValue(contentEncoding));
      }
      catch(UnsupportedEncodingException e) {
          log.warn("Unable to encode parameter in encoding " + contentEncoding + ", parameter value not included in query string");
      }
    }
View Full Code Here

    fixSize(table.getColumn(ENCODE_OR_NOT));
    table.setAutoResizeMode(resizeMode);
  }

  protected Object makeNewArgument() {
    HTTPArgument arg = new HTTPArgument("", "");
    arg.setAlwaysEncoded(false);
    arg.setUseEquals(true);
    return arg;
  }
View Full Code Here

  public TestElement createTestElement() {
    stopTableEditing();
    Iterator modelData = tableModel.iterator();
    Arguments args = new Arguments();
    while (modelData.hasNext()) {
      HTTPArgument arg = (HTTPArgument) modelData.next();
      args.addArgument(arg);
    }
    this.configureTestElement(args);
    return (TestElement) args.clone();
  }
View Full Code Here

TOP

Related Classes of org.apache.jmeter.protocol.http.util.HTTPArgument

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.