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

Examples of org.apache.jmeter.protocol.http.sampler.HTTPSamplerBase$ASyncSample


     * @param testElement
     */
    public void modifyTestElement(TestElement testElement) {
        stopTableEditing();
        if (testElement instanceof HTTPSamplerBase) {
            HTTPSamplerBase base = (HTTPSamplerBase) testElement;
            int rows = tableModel.getRowCount();
            Iterator modelData = tableModel.iterator();
            HTTPFileArg[] files = new HTTPFileArg[rows];
            int row=0;
            while (modelData.hasNext()) {
                HTTPFileArg file = (HTTPFileArg) modelData.next();
                files[row++]=file;
            }
            base.setHTTPFiles(files);
        }
    }
View Full Code Here


     *
     * @param testElement the HTTPSamplerBase to be used to configure the GUI
     */
    public void configure(TestElement testElement) {
        if (testElement instanceof HTTPSamplerBase) {
            HTTPSamplerBase base = (HTTPSamplerBase) testElement;
            tableModel.clearData();
            HTTPFileArg[] files = base.getHTTPFiles();
            for(int i=0; i< files.length; i++){
                tableModel.addRow(files[i]);           
            }
            checkDeleteAndBrowseStatus();
        }
View Full Code Here

    for (int x = 0; x < rootList.getLength(); x++) {
      urls.addAll(HtmlParsingUtils.createURLFromForm(rootList.item(x), result.getURL()));
    }
    Iterator iter = urls.iterator();
    while (iter.hasNext()) {
      HTTPSamplerBase newUrl = (HTTPSamplerBase) iter.next();
      newUrl.setMethod(HTTPConstants.POST);
      if (log.isDebugEnabled()) {
          log.debug("Potential Form match: " + newUrl.toString());
      }
      if (HtmlParsingUtils.isAnchorMatched(newUrl, config)) {
        log.debug("Matched!");
        potentialLinks.add(newUrl);
      }
View Full Code Here

      String hrefStr = namedItem.getNodeValue();
      if (hrefStr.startsWith("javascript:")) { // $NON-NLS-1$
        continue; // No point trying these
      }
      try {
        HTTPSamplerBase newUrl = HtmlParsingUtils.createUrlFromAnchor(hrefStr, new URL(result.getURL(), base));
        newUrl.setMethod(HTTPConstants.GET);
        if (log.isDebugEnabled()) {
            log.debug("Potential <a href> match: " + newUrl);
        }
        if (HtmlParsingUtils.isAnchorMatched(newUrl, config)) {
          log.debug("Matched!");
View Full Code Here

           if (namedItem == null) {
               continue;
           }
           String hrefStr = namedItem.getNodeValue();
           try {
               HTTPSamplerBase newUrl = HtmlParsingUtils.createUrlFromAnchor(
                       hrefStr, new URL(result.getURL(), base));
               newUrl.setMethod(HTTPConstants.GET);
               if (log.isDebugEnabled()) {
                   log.debug("Potential <frame src> match: " + newUrl);
               }
               if (HtmlParsingUtils.isAnchorMatched(newUrl, config)) {
                   log.debug("Matched!");
View Full Code Here

        String testGetRequest = "GET " + url
            + "?" + queryString
            + " HTTP/1.1\r\n\r\n";
        // Use null for url and contentEncoding, to simulate that HttpRequestHdr do not
        // know the encoding for the page
        HTTPSamplerBase s = getSamplerForRequest(null, testGetRequest, null);
        assertEquals(HTTPSamplerBase.GET, s.getMethod());
        assertEquals(queryString, s.getQueryString());
        assertEquals(contentEncoding, s.getContentEncoding());

        // Check arguments
        Arguments arguments = s.getArguments();
        assertEquals(3, arguments.getArgumentCount());
        // When the encoding is not known, the argument will get the encoded value, and the "encode?" set to false
        checkArgument((HTTPArgument)arguments.getArgument(0), "abc%3FSPACE", "a+b", "a+b", contentEncoding, false);
        checkArgument((HTTPArgument)arguments.getArgument(1), "space", "a%20b", "a%20b", contentEncoding, false);
        checkArgument((HTTPArgument)arguments.getArgument(2), "query", "What%3F", "What%3F", contentEncoding, false);

        // A HTTP GET request, with UTF-8 encoding
        contentEncoding = "UTF-8";
        queryString = "abc%3FSPACE=a+b&space=a%20b&query=What%3F";
        testGetRequest = "GET " + url
            + "?" + queryString
            + " HTTP/1.1\r\n\r\n";
        s = getSamplerForRequest(url, testGetRequest, contentEncoding);
        assertEquals(HTTPSamplerBase.GET, s.getMethod());
        String expectedQueryString = "abc%3FSPACE=a+b&space=a+b&query=What%3F";
        assertEquals(expectedQueryString, s.getQueryString());
        assertEquals(contentEncoding, s.getContentEncoding());

        // Check arguments
        arguments = s.getArguments();
        assertEquals(3, arguments.getArgumentCount());
        checkArgument((HTTPArgument)arguments.getArgument(0), "abc?SPACE", "a b", "a+b", contentEncoding, true);
        checkArgument((HTTPArgument)arguments.getArgument(1), "space", "a b", "a+b", contentEncoding, true);
        checkArgument((HTTPArgument)arguments.getArgument(2), "query", "What?", "What%3F", contentEncoding, true);
       
        // A HTTP POST request, with unknown encoding
        contentEncoding = "";
        String postBody = "abc%3FSPACE=a+b&space=a%20b&query=What%3F";
        String testPostRequest = "POST " + url + " HTTP/1.1\r\n"
            + "Content-type: "
            + HTTPSamplerBase.APPLICATION_X_WWW_FORM_URLENCODED + "\r\n"
            + "Content-length: " + getBodyLength(postBody, contentEncoding) + "\r\n"
            + "\r\n"
            + postBody;
        // Use null for url and contentEncoding, to simulate that HttpRequestHdr do not
        // know the encoding for the page
        s = getSamplerForRequest(null, testPostRequest, null);
        assertEquals(HTTPSamplerBase.POST, s.getMethod());
        assertEquals(queryString, s.getQueryString());
        assertEquals(contentEncoding, s.getContentEncoding());
        assertFalse(s.getDoMultipartPost());
       
        // Check arguments
        arguments = s.getArguments();
        assertEquals(3, arguments.getArgumentCount());
        // When the encoding is not known, the argument will get the encoded value, and the "encode?" set to false
        checkArgument((HTTPArgument)arguments.getArgument(0), "abc%3FSPACE", "a+b", "a+b", contentEncoding, false);
        checkArgument((HTTPArgument)arguments.getArgument(1), "space", "a%20b", "a%20b", contentEncoding, false);
        checkArgument((HTTPArgument)arguments.getArgument(2), "query", "What%3F", "What%3F", contentEncoding, false);

        // A HTTP POST request, with UTF-8 encoding
        contentEncoding = "UTF-8";
        postBody = "abc?SPACE=a+b&space=a%20b&query=What?";
        testPostRequest = "POST " + url + " HTTP/1.1\n"
            + "Content-type: "
            + HTTPSamplerBase.APPLICATION_X_WWW_FORM_URLENCODED + "\r\n"
            + "Content-length: " + getBodyLength(postBody, contentEncoding) + "\r\n"
            + "\r\n"
            + postBody;
        s = getSamplerForRequest(url, testPostRequest, contentEncoding);
        assertEquals(HTTPSamplerBase.POST, s.getMethod());
        expectedQueryString = "abc%3FSPACE=a+b&space=a+b&query=What%3F";
        assertEquals(expectedQueryString, s.getQueryString());
        assertEquals(contentEncoding, s.getContentEncoding());
        assertFalse(s.getDoMultipartPost());
       
        // Check arguments
        arguments = s.getArguments();
        assertEquals(3, arguments.getArgumentCount());
        checkArgument((HTTPArgument)arguments.getArgument(0), "abc?SPACE", "a b", "a+b", contentEncoding, true);
        checkArgument((HTTPArgument)arguments.getArgument(1), "space", "a b", "a+b", contentEncoding, true);
        checkArgument((HTTPArgument)arguments.getArgument(2), "query", "What?", "What%3F", contentEncoding, true);
    }
View Full Code Here

            "GET " + url
            + "?param1=" + param1Value + "&param2=" + param2ValueEncoded + " "
            + "HTTP/1.1\r\n\r\n";
        // Use null for url and contentEncoding, to simulate that HttpRequestHdr do not
        // know the encoding for the page
        HTTPSamplerBase s = getSamplerForRequest(null, testGetRequest, null);
        assertEquals(HTTPSamplerBase.GET, s.getMethod());
        assertEquals(contentEncoding, s.getContentEncoding());
        // Check arguments
        Arguments arguments = s.getArguments();
        assertEquals(2, arguments.getArgumentCount());
        checkArgument((HTTPArgument)arguments.getArgument(0), "param1", param1Value, param1Value, contentEncoding, false);
        // When the encoding is not known, the argument will get the encoded value, and the "encode?" set to false
        checkArgument((HTTPArgument)arguments.getArgument(1), "param2", param2ValueEncoded, param2ValueEncoded, contentEncoding, false);

        // A HTTP GET request, with UTF-8 encoding
        contentEncoding = "UTF-8";
        param1Value = "yes";
        param2Value = "0+5 -\u007c\u2aa1\u266a\u0153\u20a1\u0115\u0364\u00c5\u2052\uc385%C3%85";
        param2ValueEncoded = URLEncoder.encode(param2Value, contentEncoding);
        testGetRequest =
            "GET " + url
            + "?param1=" + param1Value + "&param2=" + param2ValueEncoded + " "
            + "HTTP/1.1\r\n\r\n";
        s = getSamplerForRequest(url, testGetRequest, contentEncoding);
        assertEquals(HTTPSamplerBase.GET, s.getMethod());
        assertEquals(contentEncoding, s.getContentEncoding());
        // Check arguments
        arguments = s.getArguments();
        assertEquals(2, arguments.getArgumentCount());
        checkArgument((HTTPArgument)arguments.getArgument(0), "param1", param1Value, param1Value, contentEncoding, false);
        checkArgument((HTTPArgument)arguments.getArgument(1), "param2", param2Value, param2ValueEncoded, contentEncoding, true);

        // A HTTP GET request, with ISO-8859-1 encoding
        contentEncoding = "ISO-8859-1";
        param1Value = "yes";
        param2Value = "0+5 -\u00c5%C3%85";
        param2ValueEncoded = URLEncoder.encode(param2Value, contentEncoding);
        testGetRequest =
            "GET " + url
            + "?param1=" + param1Value + "&param2=" + param2ValueEncoded + " "
            + "HTTP/1.1\r\n\r\n";
        s = getSamplerForRequest(url, testGetRequest, contentEncoding);
        assertEquals(HTTPSamplerBase.GET, s.getMethod());
        assertEquals(contentEncoding, s.getContentEncoding());
        // Check arguments
        arguments = s.getArguments();
        assertEquals(2, arguments.getArgumentCount());
        checkArgument((HTTPArgument)arguments.getArgument(0), "param1", param1Value, param1Value, contentEncoding, false);
        checkArgument((HTTPArgument)arguments.getArgument(1), "param2", param2Value, param2ValueEncoded, contentEncoding, true);
    }
View Full Code Here

            + "\r\n"
            + postBody;
       
        // Use null for url and contentEncoding, to simulate that HttpRequestHdr do not
        // know the encoding for the page
        HTTPSamplerBase s = getSamplerForRequest(null, testPostRequest, null);
        assertEquals(HTTPSamplerBase.POST, s.getMethod());
        assertEquals(contentEncoding, s.getContentEncoding());
        // Check arguments
        Arguments arguments = s.getArguments();
        assertEquals(2, arguments.getArgumentCount());
        checkArgument((HTTPArgument)arguments.getArgument(0), "param1", param1Value, param1Value, contentEncoding, false);
        // When the encoding is not known, the argument will get the encoded value, and the "encode?" set to false
        checkArgument((HTTPArgument)arguments.getArgument(1), "param2", param2ValueEncoded, param2ValueEncoded, contentEncoding, false);

        // A HTTP POST request, with UTF-8 encoding
        contentEncoding = "UTF-8";
        param1Value = "yes";
        param2Value = "0+5 -\u007c\u2aa1\u266a\u0153\u20a1\u0115\u0364\u00c5\u2052\uc385%C3%85";
        param2ValueEncoded = URLEncoder.encode(param2Value, contentEncoding);
        postBody = "param1=" + param1Value + "&param2=" + param2ValueEncoded + "\r\n";
        testPostRequest =
            "POST " + url + " HTTP/1.1\r\n"
            + "Content-type: "
            + HTTPSamplerBase.APPLICATION_X_WWW_FORM_URLENCODED + "\r\n"
            + "Content-length: " + getBodyLength(postBody, contentEncoding) + "\r\n"
            + "\r\n"
            + postBody;

        s = getSamplerForRequest(url, testPostRequest, contentEncoding);
        assertEquals(HTTPSamplerBase.POST, s.getMethod());
        assertEquals(contentEncoding, s.getContentEncoding());
        // Check arguments
        arguments = s.getArguments();
        assertEquals(2, arguments.getArgumentCount());
        checkArgument((HTTPArgument)arguments.getArgument(0), "param1", param1Value, param1Value, contentEncoding, false);
        checkArgument((HTTPArgument)arguments.getArgument(1), "param2", param2Value, param2ValueEncoded, contentEncoding, true);

        // A HTTP POST request, with ISO-8859-1 encoding
        contentEncoding = "ISO-8859-1";
        param1Value = "yes";
        param2Value = "0+5 -\u00c5%C3%85";
        param2ValueEncoded = URLEncoder.encode(param2Value, contentEncoding);
        postBody = "param1=" + param1Value + "&param2=" + param2ValueEncoded + "\r\n";
        testPostRequest =
            "POST " + url + " HTTP/1.1\r\n"
            + "Content-type: "
            + HTTPSamplerBase.APPLICATION_X_WWW_FORM_URLENCODED + "\r\n"
            + "Content-length: " + getBodyLength(postBody, contentEncoding) + "\r\n"
            + "\r\n"
            + postBody;

        s = getSamplerForRequest(url, testPostRequest, contentEncoding);
        assertEquals(HTTPSamplerBase.POST, s.getMethod());
        assertEquals(contentEncoding, s.getContentEncoding());
        // Check arguments
        arguments = s.getArguments();
        assertEquals(2, arguments.getArgumentCount());
        checkArgument((HTTPArgument)arguments.getArgument(0), "param1", param1Value, param1Value, contentEncoding, false);
        checkArgument((HTTPArgument)arguments.getArgument(1), "param2", param2Value, param2ValueEncoded, contentEncoding, true);
    }
View Full Code Here

        String titleValue = "mytitle";
        String descriptionValue = "mydescription";
        String postBody = createMultipartFormBody(titleValue, descriptionValue, contentEncoding, true, boundary, endOfLine);
        String testPostRequest = createMultipartFormRequest(url, postBody, contentEncoding, boundary, endOfLine);

        HTTPSamplerBase s = getSamplerForRequest(url, testPostRequest, contentEncoding);
        assertEquals(HTTPSamplerBase.POST, s.getMethod());
        assertEquals(contentEncoding, s.getContentEncoding());
        assertTrue(s.getDoMultipartPost());
       
        // Check arguments
        Arguments arguments = s.getArguments();
        assertEquals(2, arguments.getArgumentCount());
        checkArgument((HTTPArgument)arguments.getArgument(0), "title", titleValue, titleValue, contentEncoding, false);
        checkArgument((HTTPArgument)arguments.getArgument(1), "description", descriptionValue, descriptionValue, contentEncoding, false);
       
        // A HTTP POST request, multipart/form-data, simple values,
        // with \r\n as end of line, which is according to spec,
        // and with more headers in each multipart
        endOfLine = "\r\n";
        titleValue = "mytitle";
        descriptionValue = "mydescription";
        postBody = createMultipartFormBody(titleValue, descriptionValue, contentEncoding, true, boundary, endOfLine);
        testPostRequest = createMultipartFormRequest(url, postBody, contentEncoding, boundary, endOfLine);

        s = getSamplerForRequest(url, testPostRequest, contentEncoding);
        assertEquals(HTTPSamplerBase.POST, s.getMethod());
        assertEquals(contentEncoding, s.getContentEncoding());
        assertTrue(s.getDoMultipartPost());
       
        // Check arguments
        arguments = s.getArguments();
        assertEquals(2, arguments.getArgumentCount());
        checkArgument((HTTPArgument)arguments.getArgument(0), "title", titleValue, titleValue, contentEncoding, false);
        checkArgument((HTTPArgument)arguments.getArgument(1), "description", descriptionValue, descriptionValue, contentEncoding, false);

        // A HTTP POST request, multipart/form-data, simple values,
        // with \n as end of line, which should also be handled,
        // and with more headers in each multipart
        endOfLine = "\n";
        titleValue = "mytitle";
        descriptionValue = "mydescription";
        postBody = createMultipartFormBody(titleValue, descriptionValue, contentEncoding, true, boundary, endOfLine);
        testPostRequest = createMultipartFormRequest(url, postBody, contentEncoding, boundary, endOfLine);

        s = getSamplerForRequest(url, testPostRequest, contentEncoding);
        assertEquals(HTTPSamplerBase.POST, s.getMethod());
        assertEquals(contentEncoding, s.getContentEncoding());
        assertTrue(s.getDoMultipartPost());
       
        // Check arguments
        arguments = s.getArguments();
        assertEquals(2, arguments.getArgumentCount());
        checkArgument((HTTPArgument)arguments.getArgument(0), "title", titleValue, titleValue, contentEncoding, false);
        checkArgument((HTTPArgument)arguments.getArgument(1), "description", descriptionValue, descriptionValue, contentEncoding, false);
       
        // A HTTP POST request, multipart/form-data, with value that will change
        // if they are url encoded
        // Values are similar to __VIEWSTATE parameter that .net uses
        endOfLine = "\r\n";
        titleValue = "/wEPDwULLTE2MzM2OTA0NTYPZBYCAgMPZ/rA+8DZ2dnZ2dnZ2d/GNDar6OshPwdJc=";
        descriptionValue = "mydescription";
        postBody = createMultipartFormBody(titleValue, descriptionValue, contentEncoding, true, boundary, endOfLine);
        testPostRequest = createMultipartFormRequest(url, postBody, contentEncoding, boundary, endOfLine);

        s = getSamplerForRequest(url, testPostRequest, contentEncoding);
        assertEquals(HTTPSamplerBase.POST, s.getMethod());
        assertEquals(contentEncoding, s.getContentEncoding());
        assertTrue(s.getDoMultipartPost());
       
        // Check arguments
        arguments = s.getArguments();
        assertEquals(2, arguments.getArgumentCount());
        checkArgument((HTTPArgument)arguments.getArgument(0), "title", titleValue, titleValue, contentEncoding, false);
        checkArgument((HTTPArgument)arguments.getArgument(1), "description", descriptionValue, descriptionValue, contentEncoding, false);
    }
View Full Code Here

        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(HTTPSamplerBase.POST, s.getMethod());
        assertEquals(contentEncoding, s.getContentEncoding());
        assertEquals("", s.getQueryString());
        assertTrue(s.getDoMultipartPost());

        // Check arguments
        Arguments arguments = s.getArguments();
        assertEquals(0, arguments.getArgumentCount());
        assertEquals(fileFieldValue, s.getFileField());
        assertEquals(fileName, s.getFilename());
        assertEquals(mimeType, s.getMimetype());
    }       
View Full Code Here

TOP

Related Classes of org.apache.jmeter.protocol.http.sampler.HTTPSamplerBase$ASyncSample

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.