jakarta-jmeter-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mstov...@apache.org
Subject cvs commit: jakarta-jmeter/src/protocol/http/org/apache/jmeter/protocol/http/sampler HTTPSampler.java HTTPSamplerFull.java
Date Wed, 09 Apr 2003 15:19:07 GMT
mstover1    2003/04/09 08:19:07

  Modified:    bin      jmeter.properties
               src/protocol/http/org/apache/jmeter/protocol/http/control
                        CookieManager.java
               src/protocol/http/org/apache/jmeter/protocol/http/control/gui
                        HttpTestSampleGui.java
               src/protocol/http/org/apache/jmeter/protocol/http/sampler
                        HTTPSampler.java HTTPSamplerFull.java
  Log:
  fixing cookies and downloading images from web pages
  
  Revision  Changes    Path
  1.64      +1 -1      jakarta-jmeter/bin/jmeter.properties
  
  Index: jmeter.properties
  ===================================================================
  RCS file: /home/cvs/jakarta-jmeter/bin/jmeter.properties,v
  retrieving revision 1.63
  retrieving revision 1.64
  diff -u -r1.63 -r1.64
  --- jmeter.properties	7 Apr 2003 18:11:55 -0000	1.63
  +++ jmeter.properties	9 Apr 2003 15:19:06 -0000	1.64
  @@ -74,7 +74,7 @@
   log_level.jmeter.util=WARN
   log_level.jmeter.util.classfinder=WARN
   log_level.jmeter.test=DEBUG
  -log_level.jmeter.protocol.http=WARN
  +log_level.jmeter.protocol.http=DEBUG
   log_level.jmeter.protocol.ftp=WARN
   log_level.jmeter.protocol.jdbc=WARN
   log_level.jmeter.protocol.java=WARN
  
  
  
  1.8       +13 -3     jakarta-jmeter/src/protocol/http/org/apache/jmeter/protocol/http/control/CookieManager.java
  
  Index: CookieManager.java
  ===================================================================
  RCS file: /home/cvs/jakarta-jmeter/src/protocol/http/org/apache/jmeter/protocol/http/control/CookieManager.java,v
  retrieving revision 1.7
  retrieving revision 1.8
  diff -u -r1.7 -r1.8
  --- CookieManager.java	7 Apr 2003 14:35:25 -0000	1.7
  +++ CookieManager.java	9 Apr 2003 15:19:07 -0000	1.8
  @@ -189,6 +189,16 @@
   			 }
   			 reader.close();
   	  }
  +      
  +      public void recoverRunningVersion()
  +      {
  +          //do nothing, the cookie manager has to accept changes.
  +      }
  +      
  +      public void setRunningVersion(boolean running)
  +      {
  +          //do nothing, the cookie manager has to accept changes.
  +      }
   
   	  /** add a cookie */
   	  public void add(Cookie c) {
  @@ -315,7 +325,7 @@
   
   			 Vector removeIndices = new Vector();
   			 for (int i = getCookies().size() - 1; i >= 0; i--) {
  -					 Cookie cookie = (Cookie) getCookies().get(i);
  +					 Cookie cookie = (Cookie) getCookies().get(i).getObjectValue();
   					 if (cookie == null)
   							continue;
   					 if (cookie.getPath().equals(newCookie.getPath()) &&
  @@ -339,7 +349,7 @@
   	  public void removeCookieNamed(String name) {
   			 Vector removeIndices = new Vector();
   			 for (int i = getCookies().size() - 1; i > 0; i--) {
  -					 Cookie cookie = (Cookie) getCookies().get(i);
  +					 Cookie cookie = (Cookie) getCookies().get(i).getObjectValue();
   					 if (cookie == null)
   							continue;
   					 if (cookie.getName().equals(name))
  
  
  
  1.7       +102 -111  jakarta-jmeter/src/protocol/http/org/apache/jmeter/protocol/http/control/gui/HttpTestSampleGui.java
  
  Index: HttpTestSampleGui.java
  ===================================================================
  RCS file: /home/cvs/jakarta-jmeter/src/protocol/http/org/apache/jmeter/protocol/http/control/gui/HttpTestSampleGui.java,v
  retrieving revision 1.6
  retrieving revision 1.7
  diff -u -r1.6 -r1.7
  --- HttpTestSampleGui.java	7 Apr 2003 14:35:26 -0000	1.6
  +++ HttpTestSampleGui.java	9 Apr 2003 15:19:07 -0000	1.7
  @@ -84,56 +84,41 @@
   
   public class HttpTestSampleGui extends AbstractSamplerGui
   {
  -	private UrlConfigGui urlConfigGui;
  -	private JCheckBox getImages;
  +    private UrlConfigGui urlConfigGui;
  +    private JCheckBox getImages;
   
  -	/****************************************
  -	 * !ToDo (Constructor description)
  -	 ***************************************/
  -	public HttpTestSampleGui()
  -	{
  -		init();
  -	}
  -
  -	/****************************************
  -	 * !ToDo (Method description)
  -	 *
  -	 *@param element  !ToDo (Parameter description)
  -	 ***************************************/
  -	public void configure(TestElement element)
  -	{
  -		super.configure(element);
  -		urlConfigGui.configure(element);
  -		String testClass = element.getPropertyAsString(TestElement.TEST_CLASS);
  -		if(testClass != null && testClass.endsWith("Full"))
  -		{
  -			getImages.setSelected(true);
  -		}
  -		else
  -		{
  -			getImages.setSelected(false);
  -		}
  -	}
  -
  -	/****************************************
  -	 * !ToDo (Method description)
  -	 *
  -	 *@return   !ToDo (Return description)
  -	 ***************************************/
  -	public TestElement createTestElement()
  -	{
  -		HTTPSampler sampler;
  -        if(getImages.isSelected())
  -        {
  -            sampler = new HTTPSamplerFull();
  -        }
  -        else
  -        {
  -            sampler = new HTTPSampler();
  -        }
  -		modifyTestElement(sampler);
  -		return sampler;
  -	}
  +    /****************************************
  +     * !ToDo (Constructor description)
  +     ***************************************/
  +    public HttpTestSampleGui()
  +    {
  +        init();
  +    }
  +
  +    /****************************************
  +     * !ToDo (Method description)
  +     *
  +     *@param element  !ToDo (Parameter description)
  +     ***************************************/
  +    public void configure(TestElement element)
  +    {
  +        super.configure(element);
  +        urlConfigGui.configure(element);
  +        String testClass = element.getPropertyAsString(TestElement.TEST_CLASS);
  +        getImages.setSelected(((HTTPSampler) element).isImageParser());
  +    }
  +
  +    /****************************************
  +     * !ToDo (Method description)
  +     *
  +     *@return   !ToDo (Return description)
  +     ***************************************/
  +    public TestElement createTestElement()
  +    {
  +        HTTPSampler sampler = new HTTPSampler();
  +        modifyTestElement(sampler);
  +        return sampler;
  +    }
   
       /**
        * Modifies a given TestElement to mirror the data in the gui components.
  @@ -141,73 +126,79 @@
        */
       public void modifyTestElement(TestElement sampler)
       {
  -        TestElement el = urlConfigGui.createTestElement();	
  +        TestElement el = urlConfigGui.createTestElement();
           sampler.clear();
           sampler.addTestElement(el);
  +        if (getImages.isSelected())
  +        {
  +            ((HTTPSampler)sampler).setImageParser(true);
  +        }
  +        else
  +        {
  +            ((HTTPSampler)sampler).setImageParser(false);
  +        }
           this.configureTestElement(sampler);
       }
  -    
   
  +    /****************************************
  +     * Gets the ClassLabel attribute of the HttpTestSample object
  +     *
  +     *@return   The ClassLabel value
  +     ***************************************/
  +    public String getStaticLabel()
  +    {
  +        return JMeterUtils.getResString("web_testing_title");
  +    }
  +
  +    private void init()
  +    {
  +        this.setLayout(new GridLayout(1, 1));
  +
  +        // MAIN PANEL
  +        JPanel mainPanel = new JPanel();
  +        Border margin = new EmptyBorder(10, 10, 5, 10);
  +        mainPanel.setBorder(margin);
  +        mainPanel.setLayout(new BorderLayout());
  +        JPanel titlePanel = new JPanel(new BorderLayout());
  +
  +        // TITLE
  +        JLabel panelTitleLabel = new JLabel(JMeterUtils.getResString("web_testing_title"));
  +        Font curFont = panelTitleLabel.getFont();
  +        int curFontSize = curFont.getSize();
  +        curFontSize += 4;
  +        panelTitleLabel.setFont(new Font(curFont.getFontName(), curFont.getStyle(), curFontSize));
  +        titlePanel.add(panelTitleLabel, BorderLayout.NORTH);
  +
  +        // NAME
  +        titlePanel.add(getNamePanel(), BorderLayout.SOUTH);
  +        mainPanel.add(titlePanel, BorderLayout.NORTH);
  +
  +        // URL CONFIG
  +        urlConfigGui = new MultipartUrlConfigGui();
  +        mainPanel.add(urlConfigGui, BorderLayout.CENTER);
   
  -	/****************************************
  -	 * Gets the ClassLabel attribute of the HttpTestSample object
  -	 *
  -	 *@return   The ClassLabel value
  -	 ***************************************/
  -	public String getStaticLabel()
  -	{
  -		return JMeterUtils.getResString("web_testing_title");
  -	}
  -
  -	private void init()
  -	{
  -		this.setLayout(new GridLayout(1,1));
  -
  -		// MAIN PANEL
  -		JPanel mainPanel = new JPanel();
  -		Border margin = new EmptyBorder(10, 10, 5, 10);
  -		mainPanel.setBorder(margin);
  -		mainPanel.setLayout(new BorderLayout());
  -		JPanel titlePanel = new JPanel(new BorderLayout());
  -
  -		// TITLE
  -		JLabel panelTitleLabel = new JLabel(JMeterUtils.getResString("web_testing_title"));
  -		Font curFont = panelTitleLabel.getFont();
  -		int curFontSize = curFont.getSize();
  -		curFontSize += 4;
  -		panelTitleLabel.setFont(new Font(curFont.getFontName(), curFont.getStyle(), curFontSize));
  -		titlePanel.add(panelTitleLabel,BorderLayout.NORTH);
  -
  -		// NAME
  -		titlePanel.add(getNamePanel(),BorderLayout.SOUTH);
  -		mainPanel.add(titlePanel,BorderLayout.NORTH);
  -
  -		// URL CONFIG
  -		urlConfigGui = new MultipartUrlConfigGui();
  -		mainPanel.add(urlConfigGui,BorderLayout.CENTER);
  -
  -		// OPTIONAL TASKS
  -		mainPanel.add(createOptionalTasksPanel(),BorderLayout.SOUTH);
  -
  -		this.add(mainPanel);
  -	}
  -
  -	private JPanel createOptionalTasksPanel()
  -	{
  -		// OPTIONAL TASKS
  -		JPanel optionalTasksPanel = new JPanel();
  -		optionalTasksPanel.setLayout(new VerticalLayout(5, VerticalLayout.LEFT, VerticalLayout.TOP));
  -		optionalTasksPanel.setBorder(BorderFactory.createTitledBorder(BorderFactory.createEtchedBorder(),
JMeterUtils.getResString("optional_tasks")));
  -
  -		// RETRIEVE IMAGES
  -		JPanel retrieveImagesPanel = new JPanel();
  -		retrieveImagesPanel.setLayout(new BoxLayout(retrieveImagesPanel, BoxLayout.X_AXIS));
  -		retrieveImagesPanel.setBorder(BorderFactory.createEmptyBorder(0, 10, 0, 10));
  -		getImages = new JCheckBox(JMeterUtils.getResString("web_testing_retrieve_images"));
  -		retrieveImagesPanel.add(getImages);
  +        // OPTIONAL TASKS
  +        mainPanel.add(createOptionalTasksPanel(), BorderLayout.SOUTH);
   
  -		optionalTasksPanel.add(retrieveImagesPanel);
  +        this.add(mainPanel);
  +    }
   
  -		return optionalTasksPanel;
  -	}
  +    private JPanel createOptionalTasksPanel()
  +    {
  +        // OPTIONAL TASKS
  +        JPanel optionalTasksPanel = new JPanel();
  +        optionalTasksPanel.setLayout(new VerticalLayout(5, VerticalLayout.LEFT, VerticalLayout.TOP));
  +        optionalTasksPanel.setBorder(BorderFactory.createTitledBorder(BorderFactory.createEtchedBorder(),
JMeterUtils.getResString("optional_tasks")));
  +
  +        // RETRIEVE IMAGES
  +        JPanel retrieveImagesPanel = new JPanel();
  +        retrieveImagesPanel.setLayout(new BoxLayout(retrieveImagesPanel, BoxLayout.X_AXIS));
  +        retrieveImagesPanel.setBorder(BorderFactory.createEmptyBorder(0, 10, 0, 10));
  +        getImages = new JCheckBox(JMeterUtils.getResString("web_testing_retrieve_images"));
  +        retrieveImagesPanel.add(getImages);
  +
  +        optionalTasksPanel.add(retrieveImagesPanel);
  +
  +        return optionalTasksPanel;
  +    }
   }
  
  
  
  1.31      +59 -15    jakarta-jmeter/src/protocol/http/org/apache/jmeter/protocol/http/sampler/HTTPSampler.java
  
  Index: HTTPSampler.java
  ===================================================================
  RCS file: /home/cvs/jakarta-jmeter/src/protocol/http/org/apache/jmeter/protocol/http/sampler/HTTPSampler.java,v
  retrieving revision 1.30
  retrieving revision 1.31
  diff -u -r1.30 -r1.31
  --- HTTPSampler.java	8 Apr 2003 21:21:39 -0000	1.30
  +++ HTTPSampler.java	9 Apr 2003 15:19:07 -0000	1.31
  @@ -74,6 +74,7 @@
   import org.apache.jmeter.samplers.Entry;
   import org.apache.jmeter.samplers.SampleResult;
   import org.apache.jmeter.testelement.PerSampleClonable;
  +import org.apache.jmeter.testelement.TestElement;
   import org.apache.jmeter.testelement.property.BooleanProperty;
   import org.apache.jmeter.testelement.property.CollectionProperty;
   import org.apache.jmeter.testelement.property.IntegerProperty;
  @@ -99,7 +100,8 @@
    *@created   $Date$
    *@version   $Revision$
    ***************************************/
  -public class HTTPSampler extends AbstractSampler implements PerSampleClonable {
  +public class HTTPSampler extends AbstractSampler implements PerSampleClonable
  +{
       public final static String HEADERS = "headers";
       public final static String HEADER = "header";
       public final static String ARGUMENTS = "HTTPsampler.Arguments";
  @@ -126,13 +128,15 @@
       public final static String NORMAL_FORM = "normal_form";
       public final static String MULTIPART_FORM = "multipart_form";
       public final static String ENCODED_PATH = "HTTPSampler.encoded_path";
  -    
  +    public final static String IMAGE_PARSER = "HTTPSampler.image_parser";
  +
       /** A number to indicate that the port has not been set.  **/
       public static final int UNSPECIFIED_PORT = 0;
       private static final int MAX_REDIRECTS = 10;
       protected static String encoding = "iso-8859-1";
       private static final PostWriter postWriter = new PostWriter();
       transient protected HttpURLConnection conn;
  +    private HTTPSamplerFull imageSampler;
   
       private static PatternCacheLRU patternCache = new PatternCacheLRU(1000, new Perl5Compiler());
   
  @@ -224,7 +228,7 @@
       {
           return getPropertyAsString(ENCODED_PATH);
       }
  -    
  +
       public void setProperty(JMeterProperty prop)
       {
           super.setProperty(prop);
  @@ -233,13 +237,13 @@
               setEncodedPath(prop.getStringValue());
           }
       }
  -    
  +
       public void addProperty(JMeterProperty prop)
       {
           super.addProperty(prop);
  -        if(PATH.equals(prop.getName()))
  +        if (PATH.equals(prop.getName()))
           {
  -            super.addProperty(new StringProperty(ENCODED_PATH,encodePath(prop.getStringValue())));
  +            super.addProperty(new StringProperty(ENCODED_PATH, encodePath(prop.getStringValue())));
           }
       }
   
  @@ -265,7 +269,7 @@
       }
       public void setUseKeepAlive(boolean value)
       {
  -        setProperty(new BooleanProperty(USE_KEEPALIVE,value));
  +        setProperty(new BooleanProperty(USE_KEEPALIVE, value));
       }
       public boolean getUseKeepAlive()
       {
  @@ -287,6 +291,27 @@
           Arguments args = this.getArguments();
           args.addArgument(new HTTPArgument(name, value));
       }
  +    
  +    public void addTestElement(TestElement el)
  +    {
  +        if(el instanceof CookieManager)
  +        {
  +            setCookieManager((CookieManager)el);
  +        }
  +        else if(el instanceof HeaderManager)
  +        {
  +            setHeaderManager((HeaderManager)el);
  +        }
  +        else if(el instanceof AuthManager)
  +        {
  +            setAuthManager((AuthManager)el);
  +        }
  +        else
  +        {
  +            super.addTestElement(el);
  +        }
  +    }
  +    
       public void addArgument(String name, String value, String metadata)
       {
           Arguments args = this.getArguments();
  @@ -294,7 +319,7 @@
       }
       public void setPort(int value)
       {
  -        setProperty(new IntegerProperty(PORT,value));
  +        setProperty(new IntegerProperty(PORT, value));
       }
       public int getPort()
       {
  @@ -347,7 +372,7 @@
       }
       public CookieManager getCookieManager()
       {
  -        return (CookieManager) getProperty(COOKIE_MANAGER).getObjectValue();
  +        return (CookieManager)getProperty(COOKIE_MANAGER).getObjectValue();
       }
       public void setMimetype(String value)
       {
  @@ -358,6 +383,16 @@
           return getPropertyAsString(MIMETYPE);
       }
   
  +    public boolean isImageParser()
  +    {
  +        return getPropertyAsBoolean(IMAGE_PARSER);
  +    }
  +
  +    public void setImageParser(boolean parseImages)
  +    {
  +        setProperty(new BooleanProperty(IMAGE_PARSER, parseImages));
  +    }
  +
       /****************************************
        * !ToDo (Field description)
        ***************************************/
  @@ -682,7 +717,7 @@
                   headerBuf.append(": ");
                   headerBuf.append(conn.getHeaderField(i));
                   headerBuf.append("\n");
  -            }            
  +            }
           }
           headerBuf.append("\n");
           return headerBuf.toString().getBytes("8859_1");
  @@ -946,6 +981,14 @@
               }
               res.setTime(time);
               log.debug("End : sample2");
  +            if (isImageParser())
  +            {
  +                if (imageSampler == null)
  +                {
  +                    imageSampler = new HTTPSamplerFull();
  +                }
  +                res = imageSampler.parseForImages(res, this);
  +            }
               return res;
           }
           catch (IOException ex)
  @@ -1023,13 +1066,14 @@
               return "";
           }
       }
  +
       public static class Test extends junit.framework.TestCase
       {
           public Test(String name)
           {
               super(name);
           }
  -        
  +
           public void testArgumentWithoutEquals() throws Exception
           {
               HTTPSampler sampler = new HTTPSampler();
  @@ -1037,9 +1081,9 @@
               sampler.setMethod(HTTPSampler.GET);
               sampler.setPath("/index.html?pear");
               sampler.setDomain("www.apache.org");
  -            assertEquals("http://www.apache.org:80/index.html?pear",sampler.getUrl().toString());
  +            assertEquals("http://www.apache.org:80/index.html?pear", sampler.getUrl().toString());
           }
  -        
  +
           public void testMakingUrl() throws Exception
           {
               HTTPSampler config = new HTTPSampler();
  
  
  
  1.10      +41 -34    jakarta-jmeter/src/protocol/http/org/apache/jmeter/protocol/http/sampler/HTTPSamplerFull.java
  
  Index: HTTPSamplerFull.java
  ===================================================================
  RCS file: /home/cvs/jakarta-jmeter/src/protocol/http/org/apache/jmeter/protocol/http/sampler/HTTPSamplerFull.java,v
  retrieving revision 1.9
  retrieving revision 1.10
  diff -u -r1.9 -r1.10
  --- HTTPSamplerFull.java	7 Apr 2003 14:35:27 -0000	1.9
  +++ HTTPSamplerFull.java	9 Apr 2003 15:19:07 -0000	1.10
  @@ -120,7 +120,7 @@
    * @version	$Id$
    * @created	$Date$
    */
  -public class HTTPSamplerFull extends HTTPSampler
  +public class HTTPSamplerFull
   {
       /** Used to store the Logger (used for debug and error messages). */
       transient private static Logger log =
  @@ -163,22 +163,27 @@
        * @param entry	an entry to be sampled
        * @return	results of the sampling
        */
  -    public SampleResult sample(Entry e)
  +    public SampleResult sample(HTTPSampler sampler)
       {
           // Sample the container page.
           log.debug("Start : HTTPSamplerFull sample");
  -        SampleResult res = super.sample(e);
  +        SampleResult res = sampler.sample(new Entry());
           if(log.isDebugEnabled())
           {
               log.debug("Main page loading time - " + res.getTime());
           }
   
           // Now parse the HTML page
  +        return parseForImages(res,sampler);
  +    }
  +
  +    protected SampleResult parseForImages(SampleResult res,HTTPSampler sampler)
  +    {
           String displayName = res.getSampleLabel();
           Document html = null;
           try
           {
  -            baseUrl = getUrl();
  +            baseUrl = sampler.getUrl();
               if(log.isDebugEnabled())
               {
                   log.debug("baseUrl - " + baseUrl.toString());
  @@ -189,8 +194,8 @@
           {
               log.error("Error parsing document - " + se);
               res.setResponseData(se.toString().getBytes());
  -            res.setResponseCode(NON_HTTP_RESPONSE_CODE);
  -            res.setResponseMessage(NON_HTTP_RESPONSE_MESSAGE);
  +            res.setResponseCode(HTTPSampler.NON_HTTP_RESPONSE_CODE);
  +            res.setResponseMessage(HTTPSampler.NON_HTTP_RESPONSE_MESSAGE);
               res.setSuccessful(false);
               return res;
           }
  @@ -199,31 +204,31 @@
               log.error("Error creating URL '" + displayName + "'");
               log.error("MalformedURLException - " + mfue);
               res.setResponseData(mfue.toString().getBytes());
  -            res.setResponseCode(NON_HTTP_RESPONSE_CODE);
  -            res.setResponseMessage(NON_HTTP_RESPONSE_MESSAGE);
  +            res.setResponseCode(HTTPSampler.NON_HTTP_RESPONSE_CODE);
  +            res.setResponseMessage(HTTPSampler.NON_HTTP_RESPONSE_MESSAGE);
               res.setSuccessful(false);
               return res;
           }
  -
  +        
           // Now parse the DOM tree
  -
  +        
           // This is used to ignore duplicated binary files.
           Set uniqueURLs = new HashSet();
  -
  +        
           // look for images
  -        parseNodes(html, "img", false, "src", uniqueURLs, res);
  +        parseNodes(html, "img", false, "src", uniqueURLs, res,sampler);
           // look for applets
  -
  +        
           // This will only work with an Applet .class file.
           // Ideally, this should be upgraded to work with Objects (IE)
           //	and archives (.jar and .zip) files as well.
  -
  -        parseNodes(html, "applet", false, "code", uniqueURLs, res);
  +        
  +        parseNodes(html, "applet", false, "code", uniqueURLs, res,sampler);
           // look for input tags with image types
  -        parseNodes(html, "input", true, "src", uniqueURLs, res);
  +        parseNodes(html, "input", true, "src", uniqueURLs, res,sampler);
           // look for background images
  -        parseNodes(html, "body", false, "background", uniqueURLs, res);
  -
  +        parseNodes(html, "body", false, "background", uniqueURLs, res,sampler);
  +        
           // Okay, we're all done now
           if(log.isDebugEnabled())
           {
  @@ -245,7 +250,7 @@
        * @param res		<code>SampleResult</code> to store sampling results
        */
       protected void parseNodes(Document html, String htmlTag, boolean type,
  -            String srcTag, Set uniques, SampleResult res)
  +            String srcTag, Set uniques, SampleResult res,HTTPSampler sampler)
       {
           log.debug("Start : HTTPSamplerFull parseNodes");
           NodeList nodeList = html.getElementsByTagName(htmlTag);
  @@ -312,8 +317,8 @@
                             " , " + binUrlStr + "'");
                   log.error("MalformedURLException - " + mfue);
                   binRes.setResponseData(mfue.toString().getBytes());
  -                binRes.setResponseCode(NON_HTTP_RESPONSE_CODE);
  -                binRes.setResponseMessage(NON_HTTP_RESPONSE_MESSAGE);
  +                binRes.setResponseCode(HTTPSampler.NON_HTTP_RESPONSE_CODE);
  +                binRes.setResponseMessage(HTTPSampler.NON_HTTP_RESPONSE_MESSAGE);
                   binRes.setSuccessful(false);
                   res.addSubResult(binRes);
                   break;
  @@ -331,14 +336,14 @@
                   //   a binary file that it already has in its cache.
                   try
                   {
  -                    loadBinary(binUrl, binRes);
  +                    loadBinary(binUrl, binRes,sampler);
                   }
                   catch(IOException ioe)
                   {
                       log.error("Error reading from URL - " + ioe);
                       binRes.setResponseData(ioe.toString().getBytes());
  -                    binRes.setResponseCode(NON_HTTP_RESPONSE_CODE);
  -                    binRes.setResponseMessage(NON_HTTP_RESPONSE_MESSAGE);
  +                    binRes.setResponseCode(HTTPSampler.NON_HTTP_RESPONSE_CODE);
  +                    binRes.setResponseMessage(HTTPSampler.NON_HTTP_RESPONSE_MESSAGE);
                       binRes.setSuccessful(false);
                   }
                   log.debug("Adding result");
  @@ -365,15 +370,16 @@
        *
        * @throws IOException indicates a problem reading from the URL
        */
  -    protected byte[] loadBinary(URL url, SampleResult res) throws IOException
  +    protected byte[] loadBinary(URL url, SampleResult res,HTTPSampler sampler) throws IOException
       {
           log.debug("Start : loadBinary");
           byte[] ret = new byte[0];
           res.setSamplerData(new HTTPSampler(url).toString());
  +        HttpURLConnection conn;
           try
           {
  -            conn = setupConnection(url, GET);
  -            connect();
  +            conn = sampler.setupConnection(url, HTTPSampler.GET);
  +            sampler.connect();
           }
           catch(IOException ioe)
           {
  @@ -396,7 +402,7 @@
               int errorLevel = getErrorLevel(conn, res);
               if (errorLevel == 2)
               {
  -                ret = readResponse(conn);
  +                ret = sampler.readResponse(conn);
                   res.setSuccessful(true);
                   long endTime = System.currentTimeMillis();
                   if(log.isDebugEnabled())
  @@ -482,8 +488,8 @@
               log.error("getErrorLevel : " +
                       "Error getting response code for HttpUrlConnection - ",e2);
               res.setResponseData(e2.toString().getBytes());
  -            res.setResponseCode(NON_HTTP_RESPONSE_CODE);
  -            res.setResponseMessage(NON_HTTP_RESPONSE_MESSAGE);
  +            res.setResponseCode(HTTPSampler.NON_HTTP_RESPONSE_CODE);
  +            res.setResponseMessage(HTTPSampler.NON_HTTP_RESPONSE_MESSAGE);
               res.setSuccessful(false);
           }
           log.debug("End   : getErrorLevel");
  @@ -576,7 +582,7 @@
   
       public static class Test extends TestCase
       {
  -        private HTTPSamplerFull hsf;
  +        private HTTPSampler hsf;
   
           transient private static Logger log =
                   Hierarchy.getDefaultHierarchy().getLoggerFor("jmeter.test");
  @@ -589,10 +595,11 @@
           protected void setUp()
           {
               log.debug("Start : setUp1");
  -            hsf = new HTTPSamplerFull();
  +            hsf = new HTTPSampler();
               hsf.setMethod(HTTPSampler.GET);
               hsf.setProtocol("file");
               hsf.setPath("HTTPSamplerFullTestFile.txt");
  +            hsf.setImageParser(true);
               log.debug("End   : setUp1");
           }
   
  
  
  

---------------------------------------------------------------------
To unsubscribe, e-mail: jmeter-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: jmeter-dev-help@jakarta.apache.org


Mime
View raw message