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

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


        public void testFiltering() throws Exception
        {
            ProxyControl control = new ProxyControl();
            control.addIncludedPattern(".*\\.jsp");
            control.addExcludedPattern(".*apache.org.*");
            HTTPSampler sampler = new HTTPSampler();
            sampler.setDomain("jakarta.org");
            sampler.setPath("index.jsp");
            assertTrue(control.filterUrl(sampler));
            sampler.setDomain("www.apache.org");
            assertTrue(!control.filterUrl(sampler));
            sampler.setPath("header.gif");
            sampler.setDomain("jakarta.org");
            assertTrue(!control.filterUrl(sampler));
        }
View Full Code Here


    public void run()
    {
        HttpRequestHdr request = new HttpRequestHdr();
        byte[] serverResponse = new byte[0];
        HeaderManager headers = new HeaderManager();
        HTTPSampler sampler = new HTTPSampler();
        try
        {
            byte[] clientRequest =
                request.parse(
                    new BufferedInputStream(clientSocket.getInputStream()));
            headers = request.getHeaderManager();

            sampler = request.getSampler();
            sampler.setHeaderManager(headers);

            serverResponse = sampler.sample().getResponseData();
            writeToClient(
                serverResponse,
                new BufferedOutputStream(clientSocket.getOutputStream()));
            headers.removeHeaderNamed("cookie");
View Full Code Here

        Sampler entry = JMeterContextService.getContext().getCurrentSampler();
    if (!(entry instanceof HTTPSampler))
    {
      return;
    }
    HTTPSampler config = (HTTPSampler) entry;
    Map currentUser = allAvailableUsers.getNextUserMods();
    PropertyIterator iter = config.getArguments().iterator();
    while (iter.hasNext())
    {
      Argument arg = (Argument) iter.next().getObjectValue();
      // if parameter name exists in http request
      // then change its value
View Full Code Here

   *@return        <code>True</code> if modified, else <code>false</code>
   */
  public void process()
  {
        Sampler sam = JMeterContextService.getContext().getCurrentSampler();
    HTTPSampler sampler = null;
    if(!(sam instanceof HTTPSampler))
    {
      return;
    }
    else
    {
      sampler = (HTTPSampler)sam;
    }
    boolean modified = false;
    PropertyIterator iter = sampler.getArguments().iterator();
    while (iter.hasNext())
    {
      Argument arg = (Argument) iter.next().getObjectValue();
      modified = modifyArgument(arg);
      if (modified)
View Full Code Here

            String html = "location: http://server.com/index.html?session_id=jfdkjdkf%20jddkfdfjkdjfdf%22;";
            response = new SampleResult();
            response.setResponseData(html.getBytes());
            URLRewritingModifier mod = new URLRewritingModifier();
            mod.setArgumentName("session_id");
            HTTPSampler 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());
        }
View Full Code Here

            String html = "<a href=\"http://server.com/index.html?session_id=jfdkjdkfjddkfdfjkdjfdf\">";
            response = new SampleResult();
            response.setResponseData(html.getBytes());
            URLRewritingModifier mod = new URLRewritingModifier();
            mod.setArgumentName("session_id");
            HTTPSampler sampler = createSampler();
            context.setCurrentSampler(sampler);
            context.setPreviousResult(response);
            mod.process();
            Arguments args = sampler.getArguments();
            assertEquals("jfdkjdkfjddkfdfjkdjfdf", ((Argument) args.getArguments().get(0).getObjectValue()).getValue());
        }
View Full Code Here

            Arguments args = sampler.getArguments();
            assertEquals("jfdkjdkfjddkfdfjkdjfdf", ((Argument) args.getArguments().get(0).getObjectValue()).getValue());
        }
        private HTTPSampler createSampler()
        {
            HTTPSampler sampler = new HTTPSampler();
            sampler.setDomain("server.com");
            sampler.setPath("index.html");
            sampler.setMethod(HTTPSampler.GET);
            sampler.setProtocol("http");
            return sampler;
        }
View Full Code Here

    public HTTPSampler getSampler()
        throws MalformedURLException, IOException, ProtocolException
    {
        HttpTestSampleGui tempGui = new HttpTestSampleGui();
        tempGui.configure(createSampler());
        HTTPSampler result = (HTTPSampler) tempGui.createTestElement();
        result.setFollowRedirects(false);
        result.setUseKeepAlive(true);
        return result;
    }
View Full Code Here

        }
    }
    private HTTPSampler createSampler()
    {
        MultipartUrlConfig urlConfig = null;
        HTTPSampler sampler = new HTTPSampler();
        sampler.setDomain(serverName());
        log.debug("Proxy: setting server: " + sampler.getDomain());
        sampler.setMethod(method);
        log.debug("Proxy: method server: " + sampler.getMethod());
        sampler.setPath(serverUrl());
        log.debug("Proxy: setting path: " + sampler.getEncodedPath());
        sampler.setName(sampler.getPath());
        sampler.setPort(serverPort());
        log.debug("Proxy: setting port: " + sampler.getPort());
        if (url.indexOf("//") > -1)
        {
            String protocol = url.substring(0, url.indexOf(":"));
            log.debug("Proxy: setting protocol to : " + protocol);
            sampler.setProtocol(protocol);
        }
        else if (sampler.getPort() == 443)
        {
            sampler.setProtocol("https");
            log.debug("Proxy: setting protocol to https");
        }
        else
        {
            log.debug("Proxy setting default protocol to: http");
            sampler.setProtocol("http");
        }
        if ((urlConfig = isMultipart(getContentType())) != null)
        {
            urlConfig.parseArguments(postData);
            sampler.setArguments(urlConfig.getArguments());
            sampler.setFileField(urlConfig.getFileFieldName());
            sampler.setFilename(urlConfig.getFilename());
            sampler.setMimetype(urlConfig.getMimeType());
        }
        else
        {
            sampler.parseArguments(postData);
        }
        return sampler;
    }
View Full Code Here

            String html = "href='index.html?session_id=jfdkjdkfjddkfdfjkdjfdf'";
            response = new SampleResult();
            response.setResponseData(html.getBytes());
            URLRewritingModifier mod = new URLRewritingModifier();
            mod.setArgumentName("session_id");
            HTTPSampler sampler = createSampler();
            context.setCurrentSampler(sampler);
            context.setPreviousResult(response);
            mod.process();
            Arguments args = sampler.getArguments();
            assertEquals("jfdkjdkfjddkfdfjkdjfdf", ((Argument) args.getArguments().get(0).getObjectValue()).getValue());
        }
View Full Code Here

TOP

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

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.