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

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


        continue;
      }
      String hrefStr = namedItem.getNodeValue();
      try
      {
        HTTPSampler newUrl = HtmlParser.createUrlFromAnchor(hrefStr, (HTTPSampler)result.getSamplerData());
        newUrl.setMethod(HTTPSampler.GET);
        if (HtmlParser.isAnchorMatched(newUrl, config))
        {
          potentialLinks.add(newUrl);
        }
      }
View Full Code Here


        isMon.setSelected(((HTTPSampler) element).isMonitor());
    }

    public TestElement createTestElement()
    {
        HTTPSampler sampler = new HTTPSampler();
        modifyTestElement(sampler);
        return sampler;
    }
View Full Code Here

            gui = new HttpTestSampleGui();
        }
       
        public void testCloneSampler() throws Exception
        {
            HTTPSampler sampler = (HTTPSampler)gui.createTestElement();
            sampler.addArgument("param","value");
            HTTPSampler clonedSampler = (HTTPSampler)sampler.clone();
            clonedSampler.setRunningVersion(true);
            sampler.getArguments().getArgument(0).setValue("new value");
            assertEquals(
                "Sampler didn't clone correctly",
                "new value",
                sampler.getArguments().getArgument(0).getValue());
View Full Code Here

   *@return                           !ToDo (Return description)
   *@exception MalformedURLException  !ToDo (Exception description)
   ***************************************/
  public static HTTPSampler createUrlFromAnchor(String parsedUrlString, HTTPSampler context) throws MalformedURLException
  {
    HTTPSampler url = new HTTPSampler();
    url.setDomain(context.getDomain());
    url.setProtocol(context.getProtocol());
    url.setPort(context.getPort());

    // In JDK1.3, we can get the path using getPath(). However, in JDK1.2, we have to parse
    // the file to obtain the path. In the source for JDK1.3.1, they determine the path to
    // be from the start of the file up to the LAST question mark (if any).
    String contextPath = null;
    String contextFile = context.getPath();
    int indexContextQuery = contextFile.lastIndexOf('?');
    if(indexContextQuery != -1)
      contextPath = contextFile.substring(0, indexContextQuery);

    else
      contextPath = contextFile;

    int queryStarts = parsedUrlString.indexOf("?");

    if(queryStarts == -1)
      queryStarts = parsedUrlString.length();

    if(parsedUrlString.startsWith("/"))
      url.setPath(parsedUrlString.substring(0, queryStarts));

    else if(parsedUrlString.startsWith(".."))
      url.setPath(contextPath.substring(0, contextPath.substring(0,
          contextPath.lastIndexOf("/")).lastIndexOf("/")) +
          parsedUrlString.substring(2, queryStarts));

    else if(!parsedUrlString.toLowerCase().startsWith("http"))
      url.setPath(contextPath.substring(0, contextPath.lastIndexOf("/")) +
          "/" + parsedUrlString.substring(0, queryStarts));

    else
    {
      URL u = new URL(parsedUrlString);

      // Determine the path. (See JDK1.2/1.3 comment above.)
      String uPath = null;
      String uFile = u.getFile();
      int indexUQuery = uFile.lastIndexOf('?');
      if(indexUQuery != -1)
        uPath = uFile.substring(0, indexUQuery);

      else
        uPath = uFile;

      url.setPath(uPath);
      url.setDomain(u.getHost());
      url.setProtocol(u.getProtocol());
      url.setPort(u.getPort());
    }

    if(queryStarts < parsedUrlString.length())
      url.parseArguments(parsedUrlString.substring(queryStarts + 1));

    return url;
  }
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

  {
    NamedNodeMap atts = tempNode.getAttributes();
    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

  {
    Arguments args = new Arguments();
    args.addArgument("username","mstover");
    args.addArgument("password","pass");
    args.addArgument("action","login");
    config = new HTTPSampler();
    config.setName("Full Config");
    config.setProperty(HTTPSampler.DOMAIN,"www.lazer.com");
    config.setProperty(HTTPSampler.PATH,"login.jsp");
    config.setProperty(HTTPSampler.METHOD,HTTPSampler.POST);
    config.setProperty(new TestElementProperty(HTTPSampler.ARGUMENTS,args));
    defaultConfig = new HTTPSampler();
    defaultConfig.setName("default");
    defaultConfig.setProperty(HTTPSampler.DOMAIN,"www.xerox.com");
    defaultConfig.setProperty(HTTPSampler.PATH,"default.html");
    partialConfig = new HTTPSampler();
    partialConfig.setProperty(HTTPSampler.PATH,"main.jsp");
    partialConfig.setProperty(HTTPSampler.METHOD,HTTPSampler.GET);
  }
View Full Code Here

       
        public void testSendCookie() throws Exception
        {
            CookieManager man = new CookieManager();
            man.add(new Cookie("id","value","jakarta.apache.org","/",false,9999999999L));
            HTTPSampler sampler = new HTTPSampler();
            sampler.setDomain("jakarta.apache.org");
            sampler.setPath("/index.html");
            sampler.setMethod(HTTPSampler.GET);
            assertNotNull(man.getCookieHeaderForURL(sampler.getUrl()));
        }
View Full Code Here

       
        public void testSendCookie2() throws Exception
                {
                    CookieManager man = new CookieManager();
                    man.add(new Cookie("id","value",".apache.org","/",false,9999999999L));
                    HTTPSampler sampler = new HTTPSampler();
                    sampler.setDomain("jakarta.apache.org");
                    sampler.setPath("/index.html");
                    sampler.setMethod(HTTPSampler.GET);
                    assertNotNull(man.getCookieHeaderForURL(sampler.getUrl()));
                }
View Full Code Here

        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

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.