Package org.apache.jmeter.protocol.http.sampler

Examples of org.apache.jmeter.protocol.http.sampler.HTTPSampleResult


            HTTPSamplerBase config = makeUrlConfig("/index\\.html");
            HTTPSamplerBase context = makeContext("http://www.apache.org/subdir/previous.html");
            String responseText = "<html><head><title>Test page</title></head><body>"
                    + "<a href=\"/index.html\">Goto index page</a>" + "hfdfjiudfjdfjkjfkdjf"
                    + "<b>bold text</b><a href=lowerdir/index.html>lower</a>" + "</body></html>";
            HTTPSampleResult result = new HTTPSampleResult();
            result.setResponseData(responseText.getBytes());
            result.setSampleLabel(context.toString());
            result.setURL(context.getUrl());
            jmctx.setCurrentSampler(context);
            jmctx.setCurrentSampler(config);
            jmctx.setPreviousResult(result);
            parser.process();
            String newUrl = config.getUrl().toString();
View Full Code Here


            HTTPSamplerBase config = makeUrlConfig(".*index.*");
            config.getArguments().addArgument("param1", "value1");
            HTTPSamplerBase context = makeContext("http://www.apache.org/subdir/previous.html");
            String responseText = "<html><head><title>Test page</title></head><body>"
                    + "<a href=\"/home/index.html?param1=value1\">" + "Goto index page</a></body></html>";
            HTTPSampleResult result = new HTTPSampleResult();
            result.setResponseData(responseText.getBytes());
            result.setSampleLabel(context.toString());
            result.setURL(context.getUrl());
            jmctx.setCurrentSampler(context);
            jmctx.setCurrentSampler(config);
            jmctx.setPreviousResult(result);
            parser.process();
            String newUrl = config.getUrl().toString();
View Full Code Here

     * @see com.thoughtworks.xstream.converters.Converter#marshal(java.lang.Object,
     *      com.thoughtworks.xstream.io.HierarchicalStreamWriter,
     *      com.thoughtworks.xstream.converters.MarshallingContext)
     */
    public void marshal(Object obj, HierarchicalStreamWriter writer, MarshallingContext context) {
        HTTPSampleResult res = (HTTPSampleResult) obj;
        SampleSaveConfiguration save = res.getSaveConfig();
        setAttributes(writer, context, res, save);
        saveAssertions(writer, context, res, save);
        saveSubResults(writer, context, res, save);
        saveResponseHeaders(writer, context, res, save);
        saveRequestHeaders(writer, context, res, save);
View Full Code Here

     *
     * @see com.thoughtworks.xstream.converters.Converter#unmarshal(com.thoughtworks.xstream.io.HierarchicalStreamReader,
     *      com.thoughtworks.xstream.converters.UnmarshallingContext)
     */
    public Object unmarshal(HierarchicalStreamReader reader, UnmarshallingContext context) {
        HTTPSampleResult res = (HTTPSampleResult) createCollection(context.getRequiredType());
        retrieveAttributes(reader, context, res);
        while (reader.hasMoreChildren()) {
            reader.moveDown();
            Object subItem = readItem(reader, context, res);
            if (!retrieveItem(reader, context, res, subItem)) {
                retrieveHTTPItem(reader, context, res, subItem);
            }
            reader.moveUp();
        }

        // If we have a file, but no data, then read the file
        String resultFileName = res.getResultFileName();
        if (resultFileName.length()>0
        &&  res.getResponseData().length == 0) {
            readFile(resultFileName,res);
        }
        return res;
    }
View Full Code Here

    {
      JMeterContext context = getThreadContext();
        Sampler sam = context.getCurrentSampler();
        SampleResult res = context.getPreviousResult();
        HTTPSamplerBase sampler = null;
        HTTPSampleResult result = null;
        if (res == null
            || !(sam instanceof HTTPSamplerBase)
            || !(res instanceof HTTPSampleResult))
        {
            log.info("Can't apply HTML Link Parser when the previous"
                     +" sampler run is not an HTTP Request.");
            return;
        }
        else
        {
            sampler = (HTTPSamplerBase) sam;
            result = (HTTPSampleResult) res;
        }
        List potentialLinks = new ArrayList();
        String responseText = "";
        try
        {
            responseText = new String(result.getResponseData(), "8859_1");
        }
        catch (UnsupportedEncodingException e)
        {}
        Document html;
        try
View Full Code Here

                        new FileInputStream(
                            System.getProperty("user.dir")
                                + "/testfiles/load_bug_list.jmx"))
                    .getArray()[0];
            config.setRunningVersion(true);
            HTTPSampleResult result = new HTTPSampleResult();
            HTTPSamplerBase context =
                (HTTPSamplerBase) SaveService
                    .loadSubTree(
                        new FileInputStream(
                            System.getProperty("user.dir")
                                + "/testfiles/Load_JMeter_Page.jmx"))
                    .getArray()[0];
            jmctx.setCurrentSampler(context);
            jmctx.setCurrentSampler(config);
            result.setResponseData(
                new TextFile(
                    System.getProperty("user.dir")
                        + HTMLFileName)
                    .getText()
                    .getBytes());
            result.setSampleLabel(context.toString());
            result.setSamplerData(context.toString());
            result.setURL(new URL("http://issues.apache.org/fakepage.html"));
            jmctx.setPreviousResult(result);
            AnchorModifier modifier = new AnchorModifier();
            modifier.setThreadContext(jmctx);
            modifier.process();
            assertEquals(
View Full Code Here

  public void process() {
    JMeterContext context = getThreadContext();
    Sampler sam = context.getCurrentSampler();
    SampleResult res = context.getPreviousResult();
    HTTPSamplerBase sampler = null;
    HTTPSampleResult result = null;
    if (res == null || !(sam instanceof HTTPSamplerBase) || !(res instanceof HTTPSampleResult)) {
      log.info("Can't apply HTML Link Parser when the previous" + " sampler run is not an HTTP Request.");
      return;
    } else {
      sampler = (HTTPSamplerBase) sam;
      result = (HTTPSampleResult) res;
    }
    List potentialLinks = new ArrayList();
    String responseText = ""; // $NON-NLS-1$
    try {
      responseText = new String(result.getResponseData(), result.getDataEncoding());
    } catch (UnsupportedEncodingException e) {
    }
    Document html;
    int index = responseText.indexOf("<"); // $NON-NLS-1$
    if (index == -1) {
View Full Code Here

    public void testProcess() throws MalformedURLException {
        System.out.println("process");
        AnchorModifier instance = new AnchorModifier();
        JMeterContext context = JMeterContextService.getContext();
        Sampler s = new HTTPSampler();
        HTTPSampleResult res = new HTTPSampleResult();
        res.setURL(new URL("http://test/"));
        String data = "<a href='http://test'/><a href='http://test/2'/><a href='http://test'/>";
        data += "<a href='testsub'/><a href='http://test/2'/><a href='http://test'/>";
        res.setResponseData(data.getBytes());
        context.setPreviousResult(res);
        context.setCurrentSampler(s);
        instance.process();
        instance.process();
        instance.process();
View Full Code Here

    httpMethod.addRequestHeader("Authorization", authorization);
  }

  protected HttpClient setupConnection(URL u, HttpMethodBase httpMethod)
      throws IOException {
    HTTPSampleResult temp = new HTTPSampleResult();
    return super.setupConnection(u, httpMethod, temp);
  }
View Full Code Here

        }
    }
   
    protected HttpClient setupConnection(URL u, HttpMethodBase httpMethod) throws IOException
    {
      HTTPSampleResult temp = new HTTPSampleResult();
      return super.setupConnection(u, httpMethod, temp);
    }
View Full Code Here

TOP

Related Classes of org.apache.jmeter.protocol.http.sampler.HTTPSampleResult

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.