当前位置: 首页>>代码示例>>Java>>正文


Java HTTPSamplerBase.getArguments方法代码示例

本文整理汇总了Java中org.apache.jmeter.protocol.http.sampler.HTTPSamplerBase.getArguments方法的典型用法代码示例。如果您正苦于以下问题:Java HTTPSamplerBase.getArguments方法的具体用法?Java HTTPSamplerBase.getArguments怎么用?Java HTTPSamplerBase.getArguments使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.apache.jmeter.protocol.http.sampler.HTTPSamplerBase的用法示例。


在下文中一共展示了HTTPSamplerBase.getArguments方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: populateSampler

import org.apache.jmeter.protocol.http.sampler.HTTPSamplerBase; //导入方法依赖的package包/类
/**
 * @see org.apache.jmeter.protocol.http.proxy.SamplerCreator#populateSampler(org.apache.jmeter.protocol.http.sampler.HTTPSamplerBase, org.apache.jmeter.protocol.http.proxy.HttpRequestHdr, java.util.Map, java.util.Map)
 */
@Override
public final void populateSampler(HTTPSamplerBase sampler,
        HttpRequestHdr request, Map<String, String> pageEncodings,
        Map<String, String> formEncodings) throws Exception{
    computeFromHeader(sampler, request, pageEncodings, formEncodings);

    computeFromPostBody(sampler, request);
    if (log.isDebugEnabled()) {
        log.debug("sampler path = " + sampler.getPath());
    }
    Arguments arguments = sampler.getArguments();
    if(arguments.getArgumentCount() == 1 && arguments.getArgument(0).getName().length()==0) {
        sampler.setPostBodyRaw(true);
    }
}
 
开发者ID:botelhojp,项目名称:apache-jmeter-2.10,代码行数:19,代码来源:DefaultSamplerCreator.java

示例2: testGrabSessionIdFromForm

import org.apache.jmeter.protocol.http.sampler.HTTPSamplerBase; //导入方法依赖的package包/类
public void testGrabSessionIdFromForm() throws Exception {
    String[] html = new String[] { 
            "<input name=\"sid\" value=\"myId\">", 
            "<input name='sid' value='myId'>",
            "<input value=\"myId\" NAME='sid'>",
            "<input VALUE='myId' name=\"sid\">",
            "<input blah blah value=\"myId\" yoda yoda NAME='sid'>",
            "<input type=\"HIDDEN\" name=\"sid\"      value=\"myId\">",
            "<input type=\"HIDDEN\" name=\"sid\"\tvalue=\"myId\">",
            };
    for (int i = 0; i < html.length; i++) {
        response = new SampleResult();
        response.setResponseData(html[i], null);
        URLRewritingModifier newMod = new URLRewritingModifier();
        newMod.setThreadContext(context);
        newMod.setArgumentName("sid");
        newMod.setPathExtension(false);
        HTTPSamplerBase sampler = createSampler();
        context.setCurrentSampler(sampler);
        context.setPreviousResult(response);
        newMod.process();
        Arguments args = sampler.getArguments();
        assertEquals("For case i=" + i, "myId", 
                ((Argument) args.getArguments().get(0).getObjectValue()).getValue());
    }
}
 
开发者ID:botelhojp,项目名称:apache-jmeter-2.10,代码行数:27,代码来源:TestURLRewritingModifier.java

示例3: testCache

import org.apache.jmeter.protocol.http.sampler.HTTPSamplerBase; //导入方法依赖的package包/类
public void testCache() throws Exception {
    String[] html = new String[] { 
            "<input name=\"sid\" value=\"myId\">", 
            "<html></html>", // No entry; check it is still present
            };
    URLRewritingModifier newMod = new URLRewritingModifier();
    newMod.setShouldCache(true);
    newMod.setThreadContext(context);
    newMod.setArgumentName("sid");
    newMod.setPathExtension(false);
    for (int i = 0; i < html.length; i++) {
        response = new SampleResult();
        response.setResponseData(html[i], null);
        HTTPSamplerBase sampler = createSampler();
        context.setCurrentSampler(sampler);
        context.setPreviousResult(response);
        newMod.process();
        Arguments args = sampler.getArguments();
        assertEquals("For case i=" + i, "myId", 
                ((Argument) args.getArguments().get(0).getObjectValue()).getValue());
    }
}
 
开发者ID:botelhojp,项目名称:apache-jmeter-2.10,代码行数:23,代码来源:TestURLRewritingModifier.java

示例4: testNoCache

import org.apache.jmeter.protocol.http.sampler.HTTPSamplerBase; //导入方法依赖的package包/类
public void testNoCache() throws Exception {
    String[] html = new String[] { 
            "<input name=\"sid\" value=\"myId\">",  "myId",
            "<html></html>", "",
            };
    URLRewritingModifier newMod = new URLRewritingModifier();
    newMod.setThreadContext(context);
    newMod.setArgumentName("sid");
    newMod.setPathExtension(false);
    newMod.setShouldCache(false);
    for (int i = 0; i < html.length/2; i++) {
        response = new SampleResult();
        response.setResponseData(html[i*2], null);
        HTTPSamplerBase sampler = createSampler();
        context.setCurrentSampler(sampler);
        context.setPreviousResult(response);
        newMod.process();
        Arguments args = sampler.getArguments();
        assertEquals("For case i=" + i, html[i*2+1], 
                ((Argument) args.getArguments().get(0).getObjectValue()).getValue());
    }
}
 
开发者ID:botelhojp,项目名称:apache-jmeter-2.10,代码行数:23,代码来源:TestURLRewritingModifier.java

示例5: process

import org.apache.jmeter.protocol.http.sampler.HTTPSamplerBase; //导入方法依赖的package包/类
@Override
public void process() {
    if (log.isDebugEnabled()) {
        log.debug(Thread.currentThread().getName() + " Running up named: " + getName());//$NON-NLS-1$
    }
    Sampler entry = getThreadContext().getCurrentSampler();
    if (!(entry instanceof HTTPSamplerBase)) {
        return;
    }

    Map<String, String> paramMap = buildParamsMap();
    if(paramMap == null || paramMap.isEmpty()){
        log.info("RegExUserParameters element:"+getName()+" => Referenced RegExp was not found, no parameter will be changed");
        return;
    }

    HTTPSamplerBase sampler = (HTTPSamplerBase) entry;
    for (JMeterProperty jMeterProperty : sampler.getArguments()) {
        Argument arg = (Argument) jMeterProperty.getObjectValue();
        String oldValue = arg.getValue();
        // if parameter name exists in http request
        // then change its value with value obtained with regular expression
        String val = paramMap.get(arg.getName());
        if (val != null) {
            arg.setValue(val);
        }
        if (log.isDebugEnabled()) {
            log.debug("RegExUserParameters element:" + getName() + " => changed parameter: " + arg.getName() + " = " + arg.getValue() + ", was:" + oldValue);
        }
    }
}
 
开发者ID:johrstrom,项目名称:cloud-meter,代码行数:32,代码来源:RegExUserParameters.java

示例6: testGrabSessionId

import org.apache.jmeter.protocol.http.sampler.HTTPSamplerBase; //导入方法依赖的package包/类
public void testGrabSessionId() throws Exception {
    String html = "location: http://server.com/index.html" + "?session_id=jfdkjdkf%20jddkfdfjkdjfdf%22;";
    response = new SampleResult();
    response.setResponseData(html, null);
    mod.setArgumentName("session_id");
    HTTPSamplerBase sampler = createSampler();
    sampler.addArgument("session_id", "adfasdfdsafasdfasd");
    context.setCurrentSampler(sampler);
    context.setPreviousResult(response);
    mod.process();
    Arguments args = sampler.getArguments();
    assertEquals("jfdkjdkf jddkfdfjkdjfdf\"", ((Argument) args.getArguments().get(0).getObjectValue())
            .getValue());
    assertEquals("http://server.com/index.html?" + "session_id=jfdkjdkf+jddkfdfjkdjfdf%22", sampler.toString());
}
 
开发者ID:botelhojp,项目名称:apache-jmeter-2.10,代码行数:16,代码来源:TestURLRewritingModifier.java

示例7: testGrabSessionId2

import org.apache.jmeter.protocol.http.sampler.HTTPSamplerBase; //导入方法依赖的package包/类
public void testGrabSessionId2() throws Exception {
    String html = "<a href=\"http://server.com/index.html?" + "session_id=jfdkjdkfjddkfdfjkdjfdf\">";
    response = new SampleResult();
    response.setResponseData(html, null);
    mod.setArgumentName("session_id");
    HTTPSamplerBase sampler = createSampler();
    context.setCurrentSampler(sampler);
    context.setPreviousResult(response);
    mod.process();
    Arguments args = sampler.getArguments();
    assertEquals("jfdkjdkfjddkfdfjkdjfdf", ((Argument) args.getArguments().get(0).getObjectValue()).getValue());
}
 
开发者ID:botelhojp,项目名称:apache-jmeter-2.10,代码行数:13,代码来源:TestURLRewritingModifier.java

示例8: testGrabSessionId3

import org.apache.jmeter.protocol.http.sampler.HTTPSamplerBase; //导入方法依赖的package包/类
public void testGrabSessionId3() throws Exception {
    String html = "href='index.html?session_id=jfdkjdkfjddkfdfjkdjfdf'";
    response = new SampleResult();
    response.setResponseData(html, null);
    mod.setArgumentName("session_id");
    HTTPSamplerBase sampler = createSampler();
    context.setCurrentSampler(sampler);
    context.setPreviousResult(response);
    mod.process();
    Arguments args = sampler.getArguments();
    assertEquals("jfdkjdkfjddkfdfjkdjfdf", ((Argument) args.getArguments().get(0).getObjectValue()).getValue());
}
 
开发者ID:botelhojp,项目名称:apache-jmeter-2.10,代码行数:13,代码来源:TestURLRewritingModifier.java

示例9: testGrabSessionIdFromXMLNonPatExtension

import org.apache.jmeter.protocol.http.sampler.HTTPSamplerBase; //导入方法依赖的package包/类
public void testGrabSessionIdFromXMLNonPatExtension() throws Exception { // Bug 50286
    String html = "<url>/some/path;jsessionid=123456789</url>";
    response = new SampleResult();
    response.setResponseData(html, null);
    mod.setArgumentName("jsessionid");
    HTTPSamplerBase sampler = createSampler();
    context.setCurrentSampler(sampler);
    context.setPreviousResult(response);
    mod.process();
    Arguments args = sampler.getArguments();
    assertEquals("123456789", ((Argument) args.getArguments().get(0).getObjectValue()).getValue());
}
 
开发者ID:botelhojp,项目名称:apache-jmeter-2.10,代码行数:13,代码来源:TestURLRewritingModifier.java

示例10: testGrabSessionIdEndedInTab

import org.apache.jmeter.protocol.http.sampler.HTTPSamplerBase; //导入方法依赖的package包/类
public void testGrabSessionIdEndedInTab() throws Exception {
    String html = "href='index.html?session_id=jfdkjdkfjddkfdfjkdjfdf\t";
    response = new SampleResult();
    response.setResponseData(html, null);
    mod.setArgumentName("session_id");
    HTTPSamplerBase sampler = createSampler();
    context.setCurrentSampler(sampler);
    context.setPreviousResult(response);
    mod.process();
    Arguments args = sampler.getArguments();
    assertEquals("jfdkjdkfjddkfdfjkdjfdf", ((Argument) args.getArguments().get(0).getObjectValue()).getValue());
}
 
开发者ID:botelhojp,项目名称:apache-jmeter-2.10,代码行数:13,代码来源:TestURLRewritingModifier.java

示例11: testGrabSessionId5

import org.apache.jmeter.protocol.http.sampler.HTTPSamplerBase; //导入方法依赖的package包/类
public void testGrabSessionId5() throws Exception {
    String html = "location: http://server.com/index.html" + "?session[33]=jfdkjdkf%20jddkfdfjkdjfdf%22;";
    response = new SampleResult();
    response.setResponseData(html, null);
    mod.setArgumentName("session[33]");
    HTTPSamplerBase sampler = createSampler();
    sampler.addArgument("session[33]", "adfasdfdsafasdfasd");
    context.setCurrentSampler(sampler);
    context.setPreviousResult(response);
    mod.process();
    Arguments args = sampler.getArguments();
    assertEquals("jfdkjdkf jddkfdfjkdjfdf\"", ((Argument) args.getArguments().get(0).getObjectValue())
            .getValue());
    assertEquals("http://server.com/index.html?session%5B33%5D=jfdkjdkf+jddkfdfjkdjfdf%22", sampler.toString());
}
 
开发者ID:botelhojp,项目名称:apache-jmeter-2.10,代码行数:16,代码来源:TestURLRewritingModifier.java

示例12: testGrabSessionIdURLinJSON

import org.apache.jmeter.protocol.http.sampler.HTTPSamplerBase; //导入方法依赖的package包/类
public void testGrabSessionIdURLinJSON() throws Exception {
    String html = 
        "<a href=\"#\" onclick=\"$(\'frame\').src=\'/index?param1=bla&sessionid=xyzxyzxyz\\'";
    response = new SampleResult();
    response.setResponseData(html, null);
    mod.setArgumentName("sessionid");
    HTTPSamplerBase sampler = createSampler();
    sampler.addArgument("sessionid", "xyzxyzxyz");
    context.setCurrentSampler(sampler);
    context.setPreviousResult(response);
    mod.process();
    Arguments args = sampler.getArguments();
    assertEquals("xyzxyzxyz", ((Argument) args.getArguments().get(0).getObjectValue())
            .getValue());
}
 
开发者ID:botelhojp,项目名称:apache-jmeter-2.10,代码行数:16,代码来源:TestURLRewritingModifier.java

示例13: testPostMultipartFileUpload

import org.apache.jmeter.protocol.http.sampler.HTTPSamplerBase; //导入方法依赖的package包/类
public void testPostMultipartFileUpload() throws Exception {
    String url = "http://localhost/matrix.html";
    // A HTTP POST request, multipart/form-data, simple values,
    String contentEncoding = "UTF-8";
    String boundary = "xf8SqlDNvmn6mFYwrioJaeUR2_Z4cLRXOSmB";
    String endOfLine = "\r\n";
    String fileFieldValue = "test_file";
    String fileName = "somefilename.txt";
    String mimeType = "text/plain";
    String fileContent = "somedummycontent\n\ndfgdfg\r\nfgdgdg\nContent-type:dfsfsfds";
    String postBody = createMultipartFileUploadBody(fileFieldValue, fileName, mimeType, fileContent, boundary, endOfLine);
    String testPostRequest = createMultipartFormRequest(url, postBody, contentEncoding, boundary, endOfLine);
    
    HTTPSamplerBase s = getSamplerForRequest(url, testPostRequest, contentEncoding);
    assertEquals(HTTPConstants.POST, s.getMethod());
    assertEquals(contentEncoding, s.getContentEncoding());
    assertEquals("", s.getQueryString());
    assertTrue(s.getDoMultipartPost());

    // Check arguments
    Arguments arguments = s.getArguments();
    assertEquals(0, arguments.getArgumentCount());
    HTTPFileArg hfa = s.getHTTPFiles()[0]; // Assume there's at least one file
    assertEquals(fileFieldValue, hfa.getParamName());
    assertEquals(fileName, hfa.getPath());
    assertEquals(mimeType, hfa.getMimeType());
}
 
开发者ID:botelhojp,项目名称:apache-jmeter-2.10,代码行数:28,代码来源:TestHttpRequestHdr.java

示例14: isAnchorMatched

import org.apache.jmeter.protocol.http.sampler.HTTPSamplerBase; //导入方法依赖的package包/类
/**
 * Check if anchor matches by checking against:
 * - protocol
 * - domain
 * - path
 * - parameter names
 *
 * @param newLink target to match
 * @param config pattern to match against
 *
 * @return true if target URL matches pattern URL
 */
public static boolean isAnchorMatched(HTTPSamplerBase newLink, HTTPSamplerBase config)
{
    String query = null;
    try {
        query = URLDecoder.decode(newLink.getQueryString(), "UTF-8"); // $NON-NLS-1$
    } catch (UnsupportedEncodingException e) {
        // UTF-8 unsupported? You must be joking!
        log.error("UTF-8 encoding not supported!");
        throw new Error("Should not happen: " + e.toString(), e);
    }

    final Arguments arguments = config.getArguments();

    final Perl5Matcher matcher = JMeterUtils.getMatcher();
    final PatternCacheLRU patternCache = JMeterUtils.getPatternCache();

    if (!isEqualOrMatches(newLink.getProtocol(), config.getProtocol(), matcher, patternCache)){
        return false;
    }

    final String domain = config.getDomain();
    if (domain != null && domain.length() > 0) {
        if (!isEqualOrMatches(newLink.getDomain(), domain, matcher, patternCache)){
            return false;
        }
    }

    final String path = config.getPath();
    if (!newLink.getPath().equals(path)
            && !matcher.matches(newLink.getPath(), patternCache.getPattern("[/]*" + path, // $NON-NLS-1$
                    Perl5Compiler.READ_ONLY_MASK))) {
        return false;
    }

    for (JMeterProperty argument : arguments) {
        Argument item = (Argument) argument.getObjectValue();
        final String name = item.getName();
        if (!query.contains(name + "=")) { // $NON-NLS-1$
            if (!(matcher.contains(query, patternCache.getPattern(name, Perl5Compiler.READ_ONLY_MASK)))) {
                return false;
            }
        }
    }

    return true;
}
 
开发者ID:johrstrom,项目名称:cloud-meter,代码行数:59,代码来源:HtmlParsingUtils.java

示例15: isAnchorMatched

import org.apache.jmeter.protocol.http.sampler.HTTPSamplerBase; //导入方法依赖的package包/类
/**
 * Check if anchor matches by checking against:
 * - protocol
 * - domain
 * - path
 * - parameter names
 *
 * @param newLink target to match
 * @param config pattern to match against
 *
 * @return true if target URL matches pattern URL
 */
public static boolean isAnchorMatched(HTTPSamplerBase newLink, HTTPSamplerBase config)
{
    String query = null;
    try {
        query = URLDecoder.decode(newLink.getQueryString(), "UTF-8"); // $NON-NLS-1$
    } catch (UnsupportedEncodingException e) {
        // UTF-8 unsupported? You must be joking!
        log.error("UTF-8 encoding not supported!");
        throw new Error("Should not happen: " + e.toString(), e);
    }

    final Arguments arguments = config.getArguments();

    final Perl5Matcher matcher = JMeterUtils.getMatcher();
    final PatternCacheLRU patternCache = JMeterUtils.getPatternCache();

    if (!isEqualOrMatches(newLink.getProtocol(), config.getProtocol(), matcher, patternCache)){
        return false;
    }

    final String domain = config.getDomain();
    if (domain != null && domain.length() > 0) {
        if (!isEqualOrMatches(newLink.getDomain(), domain, matcher, patternCache)){
            return false;
        }
    }

    final String path = config.getPath();
    if (!newLink.getPath().equals(path)
            && !matcher.matches(newLink.getPath(), patternCache.getPattern("[/]*" + path, // $NON-NLS-1$
                    Perl5Compiler.READ_ONLY_MASK))) {
        return false;
    }

    PropertyIterator iter = arguments.iterator();
    while (iter.hasNext()) {
        Argument item = (Argument) iter.next().getObjectValue();
        final String name = item.getName();
        if (query.indexOf(name + "=") == -1) { // $NON-NLS-1$
            if (!(matcher.contains(query, patternCache.getPattern(name, Perl5Compiler.READ_ONLY_MASK)))) {
                return false;
            }
        }
    }

    return true;
}
 
开发者ID:botelhojp,项目名称:apache-jmeter-2.10,代码行数:60,代码来源:HtmlParsingUtils.java


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