Package org.apache.jmeter.protocol.http.control

Source Code of org.apache.jmeter.protocol.http.control.HttpTestSample

package org.apache.jmeter.protocol.http.control;

import java.util.*;

import org.apache.jmeter.config.ConfigElement;
import org.apache.jmeter.protocol.http.config.UrlConfig;
import org.apache.jmeter.samplers.NewEntry;
import org.apache.jmeter.control.NewSamplerController;
import org.apache.jmeter.control.NoEntryException;
import org.apache.jmeter.samplers.SampleResult;

/*************************
*  Title: Apache JMeter Description: Copyright: Copyright (c) 2000 Company:
*  Apache Foundation
*
*@author     Michael Stover
*@created    $Date: 2000/12/22 01:41:49 $
*@version    1.0
************************/

public class HttpTestSample implements NewSamplerController
{
  private List urls;
  private UrlConfig defaultUrl;
  private List additionalConfigElements;
  private String name;
  private Iterator entryIterator;

  /*************************
   *  Constructor for the HttpTestSample object
   ************************/
  public HttpTestSample()
  {
    additionalConfigElements = new LinkedList();
    urls = new LinkedList();
  }

  /*************************
   *  Sets the name of this controller.
   *
   *@param  name  The new Name value
   ************************/
  public void setName(String name)
  {
    this.name = name;
  }

  /*************************
   *  Returns the name of this Controller
   *
   *@return    The Name value
   ************************/
  public String getName()
  {
    return name;
  }

  /*************************
   *  Get the next Entry to be sampled.
   *
   *@return                       Description of the Returned Value
   *@exception  NoEntryException  Description of Exception
   ************************/
  public NewEntry nextEntry() throws NoEntryException
  {
    if (noMoreEntries())
    {
      entryIterator = allEntries().iterator();
      if (entryIterator.hasNext())
      {
        return (NewEntry) entryIterator.next();
      }
      else
      {
        throw new NoEntryException();
      }
    }
    else
    {
      return (NewEntry) entryIterator.next();
    }
  }

  /*************************
   *  Gets the full set of unique entries this controller has. The behavior of
   *  this method is highly dependent on the controller's implementation.
   *
   *@return    Description of the Returned Value
   ************************/
  public Collection allEntries()
  {
    List allEntries = new LinkedList();
    for (Iterator iter = urls.iterator(); iter.hasNext(); )
    {
      NewEntry entry = new NewEntry();
      entry.addConfigElement((ConfigElement) iter.next());
      entry.addConfigElement(defaultUrl);
      for (Iterator iterB = additionalConfigElements.iterator(); iterB.hasNext(); )
      {
        entry.addConfigElement((ConfigElement) iterB.next());
      }
      allEntries.add(entry);
    }
    return allEntries;
  }

  /*************************
   *  Add a config element to the controller
   *
   *@param  config  The feature to be added to the ConfigElement attribute
   ************************/
  public void addConfigElement(ConfigElement config)
  {
    if (config instanceof UrlConfig)
    {
      urls.add(config);
    }
    else
    {
      additionalConfigElements.add(config);
    }
  }

  public void setDefaultUrl(UrlConfig config)
  {
    defaultUrl = config;
  }

  /*************************
   *  this method is ignored.
   *
   *@param  result  Description of Parameter
   ************************/
  public void returnSampleResult(SampleResult result)
  {
  }

  private boolean noMoreEntries()
  {
    return entryIterator == null || !entryIterator.hasNext();
  }

  public void addSamplerController(NewSamplerController controller)
  {
  }
}
TOP

Related Classes of org.apache.jmeter.protocol.http.control.HttpTestSample

TOP
Copyright © 2018 www.massapi.com. 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.