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

The following examples show how to use org.apache.jmeter.protocol.http.sampler.HTTPSampler. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: JmeterTestPlanTask.java    From ambari-metrics with Apache License 2.0 6 votes vote down vote up
private HTTPSampler createGetSampler(String name, String domain, int port, String path, String encoding, Map<String, String> parameters) {

    HTTPSampler sampler = new HTTPSampler();
    sampler.setDomain(domain);
    sampler.setPort(port);
    sampler.setPath(path);
    sampler.setMethod(HTTPConstants.GET);

    if (encoding != null)
      sampler.setContentEncoding(encoding);

    for (Map.Entry<String, String> entry : parameters.entrySet()) {
      sampler.addArgument(entry.getKey(), entry.getValue());
    }
    sampler.setName(name);
    return sampler;
  }
 
Example #2
Source File: JmeterTestPlanTask.java    From ambari-metrics with Apache License 2.0 5 votes vote down vote up
private void createThreadGroupHashTree(int appIndex, Properties amsJmeterProperties, HashTree amsTestPlanTree, TestPlan amsTestPlan) {

    AppGetMetric appGetMetric = appGetMetrics.get(appIndex);
    String app = appGetMetric.getApp();
    int interval = appGetMetric.getInterval();

    //Read and validate AMS information.
    String[] amsHostPort = amsJmeterProperties.getProperty("ams-host-port").split(":");
    String amsHost = amsHostPort[0];
    String amsPath = amsJmeterProperties.getProperty("ams-path");
    int amsPort = Integer.valueOf(amsHostPort[1]);
    int numLoops = Integer.valueOf(amsJmeterProperties.getProperty("num-get-calls-per-app"));

    LoopController loopController = createLoopController(app + " GET loop controller", numLoops, false);
    for (GetMetricRequestInfo request : appGetMetric.getMetricRequests()) {

      ThreadGroup threadGroup = createThreadGroup(app + " GET threadGroup", 1, 0, loopController);

      HashTree threadGroupHashTree = amsTestPlanTree.add(amsTestPlan, threadGroup);
      Map<String, String> parametersMap = getAppSpecificParameters(app, request, amsJmeterProperties);

      HTTPSampler sampler = createGetSampler("GET " + app + " metrics", amsHost, amsPort, amsPath, null, parametersMap);

      if (numLoops > 1) {
        threadGroupHashTree.add(createConstantTimer(interval));
      }

      threadGroupHashTree.add(sampler);
    }
  }
 
Example #3
Source File: Http2JMeter.java    From jsflight with Apache License 2.0 5 votes vote down vote up
public void addAuthHttpSample(HashTree txTree, String login)
{
    HTTPSampler sample = new HTTPSampler();
    sample.setProperty(TestElement.GUI_CLASS, "HttpTestSampleGui");
    sample.setDomain("${host}");
    sample.setProperty(HTTPSampler.PORT, "${port}");
    sample.setMethod("GET");
    sample.setPath("/sd/operator?processAs=" + login);
    sample.setFollowRedirects(true);
    sample.setName("Auth " + login);
    txTree.add(sample);
}