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

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


        }
        public void setUp(){
      control = new ProxyControl();
      control.addIncludedPattern(".*\\.jsp");
      control.addExcludedPattern(".*apache.org.*");
      sampler = new HTTPSampler();
        }
View Full Code Here


    {
        HttpRequestHdr request = new HttpRequestHdr();
        SampleResult result = null;
        HeaderManager headers = null;

        HTTPSampler sampler = new HTTPSampler();
        try
        {
           request.parse(new BufferedInputStream(clientSocket.getInputStream()));

            sampler = request.getSampler();
           
            /*
             * Create a Header Manager to ensure that the browsers headers
             * are captured and sent to the server
            */
            headers = request.getHeaderManager();
            sampler.setHeaderManager(headers);
            result = sampler.sample();
            writeToClient(
                result,
                new BufferedOutputStream(clientSocket.getOutputStream()));
            /*
             * We don't want to store any cookies in the generated test plan
View Full Code Here

        {
            log.debug("Creating URL from Anchor: "+parsedUrlString
                +", base: "+context);
        }
        URL url= new URL(context, parsedUrlString);
        HTTPSampler sampler = new HTTPSampler();
        sampler.setDomain(url.getHost());
        sampler.setProtocol(url.getProtocol());
        sampler.setPort(url.getPort());
        sampler.setPath(url.getPath());
        sampler.parseArguments(url.getQuery());

        return sampler;
    }
View Full Code Here

        String tag = tempNode.getNodeName();
        try
        {
            if (inForm)
            {
                HTTPSampler url = (HTTPSampler) urlConfigs.getLast();
                if (tag.equalsIgnoreCase("form"))
                {
                    try
                    {
                        urlConfigs.add(createFormUrlConfig(tempNode, context));
                    }
                    catch (MalformedURLException e)
                    {
                        inForm = false;
                    }
                }
                else if (tag.equalsIgnoreCase("input"))
                {
                    url.addArgument(
                        getAttributeValue(nodeAtts, "name"),
                        getAttributeValue(nodeAtts, "value"));
                }
                else if (tag.equalsIgnoreCase("textarea"))
                {
                    try
                    {
                        url.addArgument(
                            getAttributeValue(nodeAtts, "name"),
                            tempNode.getFirstChild().getNodeValue());
                    }
                    catch (NullPointerException e)
                    {
                        url.addArgument(
                            getAttributeValue(nodeAtts, "name"),
                            "");
                    }
                }
                else if (tag.equalsIgnoreCase("select"))
                {
                    selectName = getAttributeValue(nodeAtts, "name");
                }
                else if (tag.equalsIgnoreCase("option"))
                {
                    String value = getAttributeValue(nodeAtts, "value");
                    if (value == null)
                    {
                        try
                        {
                            value = tempNode.getFirstChild().getNodeValue();
                        }
                        catch (NullPointerException e)
                        {
                            value = "";
                        }
                    }
                    url.addArgument(selectName, value);
                }
            }
            else if (tag.equalsIgnoreCase("form"))
            {
                try
View Full Code Here

        if (atts.getNamedItem("action") == null)
        {
            throw new MalformedURLException();
        }
        String action = atts.getNamedItem("action").getNodeValue();
        HTTPSampler url = createUrlFromAnchor(action, context);
        return url;
    }
View Full Code Here

    /**
     * A unit test for JUnit.
     */
    public void testSimpleParse() throws Exception
    {
        HTTPSampler config = makeUrlConfig(".*/index\\.html");
        HTTPSampler 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></body></html>";
        HTTPSampleResult result = new HTTPSampleResult();
        jmctx.setCurrentSampler(context);
        jmctx.setCurrentSampler(config);
        result.setResponseData(responseText.getBytes());
        result.setSampleLabel(context.toString());
        result.setSamplerData(context.toString());
        result.setURL(context.getUrl());
        jmctx.setPreviousResult(result);
        parser.process();
        assertEquals(
            "http://www.apache.org/subdir/index.html",
            config.getUrl().toString());
View Full Code Here

            config.getUrl().toString());
    }

    public void testSimpleParse2() throws Exception
    {
        HTTPSampler config = makeUrlConfig("/index\\.html");
        HTTPSampler 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

                    newUrl));
    }

    public void testSimpleParse3() throws Exception
    {
        HTTPSampler config = makeUrlConfig(".*index.*");
        config.getArguments().addArgument("param1", "value1");
        HTTPSampler 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

            newUrl);
    }

    public void testSimpleParse4() throws Exception
    {
        HTTPSampler config = makeUrlConfig("/subdir/index\\..*");
        HTTPSampler 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></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

        assertEquals("http://www.apache.org/subdir/index.html", newUrl);
    }

    public void testSimpleParse5() throws Exception
    {
        HTTPSampler config = makeUrlConfig("/subdir/index\\.h.*");
        HTTPSampler context =
            makeContext("http://www.apache.org/subdir/one/previous.html");
        String responseText =
            "<html><head><title>Test page</title></head><body>"
                + "<a href=\"../index.html\">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

TOP

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

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.