• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Java EncoderCache类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Java中org.apache.jmeter.protocol.http.util.EncoderCache的典型用法代码示例。如果您正苦于以下问题:Java EncoderCache类的具体用法?Java EncoderCache怎么用?Java EncoderCache使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



EncoderCache类属于org.apache.jmeter.protocol.http.util包,在下文中一共展示了EncoderCache类的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: getDecodedProperty

import org.apache.jmeter.protocol.http.util.EncoderCache; //导入依赖的package包/类
/**
   * Get property as string. If "Encode?" is not checked,
   * the property is decoded to prevent double-encoding.
   * 
   * @param name Parameter name
   * @return
   */
  private String getDecodedProperty(String name) {

  	String raw = getPropertyAsString(name);
  	
  	if (getPropertyAsBoolean(URL_ENCODE))
  		return raw;
  	
  	/* 
  	 * If the parameters doesn't need URL encode, which means
  	 * it's already encoded. It should be decoded.
  	 */
		
      String urlContentEncoding = getContentEncoding();
      if(urlContentEncoding == null || urlContentEncoding.length() == 0) {
              // Use the default encoding for urls 
              urlContentEncoding = EncoderCache.URL_ARGUMENT_ENCODING;
      }
	
      try {
	return URLDecoder.decode(raw, urlContentEncoding);
} catch (UnsupportedEncodingException e) {
	log.error("Unsupported encoding: " + e.getMessage()); //$NON-NLS-1$
	// Just return raw string
	return raw;
}
  }
 
开发者ID:groovenauts,项目名称:jmeter_oauth_plugin,代码行数:34,代码来源:OAuthSampler.java


示例2: checkGetRequest

import org.apache.jmeter.protocol.http.util.EncoderCache; //导入依赖的package包/类
private void checkGetRequest(
        HTTPSamplerBase sampler,
        HTTPSampleResult res
        ) throws IOException {
    // Check URL
    assertEquals(sampler.getUrl(), res.getURL());
    // Check method
    assertEquals(sampler.getMethod(), res.getHTTPMethod());
    // Check that the query string is empty
    assertEquals(0, res.getQueryString().length());

    // Find the data sent to the mirror server, which the mirror server is sending back to us
    String dataSentToMirrorServer = new String(res.getResponseData(), EncoderCache.URL_ARGUMENT_ENCODING);
    int posDividerHeadersAndBody = getPositionOfBody(dataSentToMirrorServer);
    String headersSent = null;
    String bodySent = "";
    if(posDividerHeadersAndBody >= 0) {
        headersSent = dataSentToMirrorServer.substring(0, posDividerHeadersAndBody);
        // Skip the blank line with crlf dividing headers and body
        bodySent = dataSentToMirrorServer.substring(posDividerHeadersAndBody+2);
    }
    else {
        fail("No header and body section found");
    }
    // No body should have been sent
    assertEquals(bodySent.length(), 0);
    // Check method, path and query sent
    checkMethodPathQuery(headersSent, sampler.getMethod(), sampler.getPath(), (String) null, res);
}
 
开发者ID:botelhojp,项目名称:apache-jmeter-2.10,代码行数:30,代码来源:TestHTTPSamplersAgainstHttpMirrorServer.java


示例3: checkGetRequest_Parameters

import org.apache.jmeter.protocol.http.util.EncoderCache; //导入依赖的package包/类
private void checkGetRequest_Parameters(
        HTTPSamplerBase sampler,
        HTTPSampleResult res,
        String contentEncoding,
        URL executedUrl,
        String titleField,
        String titleValue,
        String descriptionField,
        String descriptionValue,
        boolean valuesAlreadyUrlEncoded) throws IOException {
    if(contentEncoding == null || contentEncoding.length() == 0) {
        contentEncoding = EncoderCache.URL_ARGUMENT_ENCODING;
    }
    // Check URL
    assertEquals(executedUrl, res.getURL());
    // Check method
    assertEquals(sampler.getMethod(), res.getHTTPMethod());
    // Cannot check the query string of the result, because the mirror server
    // replies without including query string in URL
    
    String expectedQueryString = null;
    if(!valuesAlreadyUrlEncoded) {
        String expectedTitle = URLEncoder.encode(titleValue, contentEncoding);
        String expectedDescription = URLEncoder.encode(descriptionValue, contentEncoding);
        expectedQueryString = titleField + "=" + expectedTitle + "&" + descriptionField + "=" + expectedDescription;
    }
    else {
        expectedQueryString = titleField + "=" + titleValue + "&" + descriptionField + "=" + descriptionValue;
    }

    // Find the data sent to the mirror server, which the mirror server is sending back to us
    String dataSentToMirrorServer = new String(res.getResponseData(), EncoderCache.URL_ARGUMENT_ENCODING);
    int posDividerHeadersAndBody = getPositionOfBody(dataSentToMirrorServer);
    String headersSent = null;
    String bodySent = "";
    if(posDividerHeadersAndBody >= 0) {
        headersSent = dataSentToMirrorServer.substring(0, posDividerHeadersAndBody);
        // Skip the blank line with crlf dividing headers and body
        bodySent = dataSentToMirrorServer.substring(posDividerHeadersAndBody+2);
    }
    else {
        fail("No header and body section found in: ["+dataSentToMirrorServer+"]");
    }
    // No body should have been sent
    assertEquals(bodySent.length(), 0);
    // Check method, path and query sent
    checkMethodPathQuery(headersSent, sampler.getMethod(), sampler.getPath(), expectedQueryString, res);
}
 
开发者ID:botelhojp,项目名称:apache-jmeter-2.10,代码行数:49,代码来源:TestHTTPSamplersAgainstHttpMirrorServer.java


示例4: checkMethodPathQuery

import org.apache.jmeter.protocol.http.util.EncoderCache; //导入依赖的package包/类
private void checkMethodPathQuery(
        String headersSent,
        String expectedMethod,
        String expectedPath,
        String expectedQueryString,
        HTTPSampleResult res
        )
        throws IOException {
    // Check the Request URI sent to the mirror server, and
    // sent back by the mirror server
    int indexFirstSpace = headersSent.indexOf(' ');
    int indexSecondSpace = headersSent.indexOf(' ', headersSent.length() > indexFirstSpace ? indexFirstSpace + 1 : indexFirstSpace);
    if(indexFirstSpace <= 0 && indexSecondSpace <= 0 || indexFirstSpace == indexSecondSpace) {
        fail("Could not find method and URI sent");
    }
    String methodSent = headersSent.substring(0, indexFirstSpace);
    assertEquals(expectedMethod, methodSent);
    String uriSent = headersSent.substring(indexFirstSpace + 1, indexSecondSpace);
    int indexQueryStart = uriSent.indexOf('?');
    if(expectedQueryString != null && expectedQueryString.length() > 0) {
        // We should have a query string part
        if(indexQueryStart <= 0 || (indexQueryStart == uriSent.length() - 1)) {
            fail("Could not find query string in URI");
        }
    }
    else {
        if(indexQueryStart > 0) {
            // We should not have a query string part
            fail("Query string present in URI");
        }
        else {
            indexQueryStart = uriSent.length();
        }
    }
    // Check path
    String pathSent = uriSent.substring(0, indexQueryStart);
    assertEquals(expectedPath, pathSent);
    // Check query
    if(expectedQueryString != null && expectedQueryString.length() > 0) {
        String queryStringSent = uriSent.substring(indexQueryStart + 1);
        // Is it only the parameter values which are encoded in the specified
        // content encoding, the rest of the query is encoded in UTF-8
        // Therefore we compare the whole query using UTF-8
        checkArraysHaveSameContent(expectedQueryString.getBytes(EncoderCache.URL_ARGUMENT_ENCODING), queryStringSent.getBytes(EncoderCache.URL_ARGUMENT_ENCODING), EncoderCache.URL_ARGUMENT_ENCODING, res);
    }
}
 
开发者ID:botelhojp,项目名称:apache-jmeter-2.10,代码行数:47,代码来源:TestHTTPSamplersAgainstHttpMirrorServer.java


示例5: setPath

import org.apache.jmeter.protocol.http.util.EncoderCache; //导入依赖的package包/类
/**
 * Sets the Path attribute of the UrlConfig object Also calls parseArguments
 * to extract and store any query arguments
 *
 * @param path
 *            The new Path value
 */
public void setPath(String path) {
    // We know that URL arguments should always be encoded in UTF-8 according to spec
    setPath(path, EncoderCache.URL_ARGUMENT_ENCODING);
}
 
开发者ID:johrstrom,项目名称:cloud-meter,代码行数:12,代码来源:HTTPSamplerBase.java


示例6: getQueryString

import org.apache.jmeter.protocol.http.util.EncoderCache; //导入依赖的package包/类
/**
 * Gets the QueryString attribute of the UrlConfig object, using
 * UTF-8 to encode the URL
 *
 * @return the QueryString value
 */
public String getQueryString() {
    // We use the encoding which should be used according to the HTTP spec, which is UTF-8
    return getQueryString(EncoderCache.URL_ARGUMENT_ENCODING);
}
 
开发者ID:johrstrom,项目名称:cloud-meter,代码行数:11,代码来源:HTTPSamplerBase.java



注:本文中的org.apache.jmeter.protocol.http.util.EncoderCache类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java PayloadStreamReaderMessage类代码示例发布时间:2022-05-23
下一篇:
Java CompositeCell类代码示例发布时间:2022-05-23
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap