mstover1    02/02/18 16:05:35

  Modified:    src/org/apache/jmeter/control GenericController.java
               src/org/apache/jmeter/junit/protocol/http/parser
                        HtmlParserTester.java
               src/org/apache/jmeter/protocol/http/modifier
                        AnchorModifier.java
               src/org/apache/jmeter/protocol/http/parser HtmlParser.java
               src/org/apache/jmeter/samplers Entry.java
  Log:
  Improving HTML link parsing, removing "assert" usage (jdk1.4 compatibility problems)
  
  Revision  Changes    Path
  1.22      +3 -3      
jakarta-jmeter/src/org/apache/jmeter/control/GenericController.java
  
  Index: GenericController.java
  ===================================================================
  RCS file: 
/home/cvs/jakarta-jmeter/src/org/apache/jmeter/control/GenericController.java,v
  retrieving revision 1.21
  retrieving revision 1.22
  diff -u -r1.21 -r1.22
  --- GenericController.java    16 Feb 2002 03:21:40 -0000      1.21
  +++ GenericController.java    19 Feb 2002 00:05:35 -0000      1.22
  @@ -66,7 +66,7 @@
    *  Title: JMeter Description: Copyright: Copyright (c) 2000 Company: Apache
    *
    *@author     Michael Stover
  - *@created    $Date: 2002/02/16 03:21:40 $
  + *@created    $Date: 2002/02/19 00:05:35 $
    *@version    1.0
    ***********************************************************/
   
  @@ -217,9 +217,9 @@
         *
         *@param  assert  !ToDo
         ***********************************************************/
  -     public void addAssertion(Assertion assert)
  +     public void addAssertion(Assertion assertion)
        {
  -             assertions.add(assert);
  +             assertions.add(assertion);
        }
   
        /************************************************************
  
  
  
  1.7       +2 -2      
jakarta-jmeter/src/org/apache/jmeter/junit/protocol/http/parser/HtmlParserTester.java
  
  Index: HtmlParserTester.java
  ===================================================================
  RCS file: 
/home/cvs/jakarta-jmeter/src/org/apache/jmeter/junit/protocol/http/parser/HtmlParserTester.java,v
  retrieving revision 1.6
  retrieving revision 1.7
  diff -u -r1.6 -r1.7
  --- HtmlParserTester.java     16 Feb 2002 03:21:40 -0000      1.6
  +++ HtmlParserTester.java     19 Feb 2002 00:05:35 -0000      1.7
  @@ -164,14 +164,14 @@
         ***********************************************************/
        public void testSimpleFormParse() throws Exception
        {
  -             UrlConfig config = makeUrlConfig(".*/index\\.html");
  +             UrlConfig config = makeUrlConfig(".*index.html");
                config.addArgument("test","g.*");
                config.setMethod(UrlConfig.POST);
                URL context = new URL("http://www.apache.org/subdir/previous.html";);
                Entry entry = new Entry();
                entry.addConfigElement(config);
                String responseText = "<html><head><title>Test 
page</title></head><body>" +
  -                             "<form action=\"index.html\"><input type=\"checkbox\" 
name=\"test\""+
  +                             "<form action=\"index.html\" method=\"POST\"><input 
type=\"checkbox\" name=\"test\""+
                                " value=\"goto\">Goto index page</form></body></html>";
                SampleResult result = new SampleResult();
                result.putValue(SampleResult.TEXT_RESPONSE,responseText.getBytes());
  
  
  
  1.11      +11 -10    
jakarta-jmeter/src/org/apache/jmeter/protocol/http/modifier/AnchorModifier.java
  
  Index: AnchorModifier.java
  ===================================================================
  RCS file: 
/home/cvs/jakarta-jmeter/src/org/apache/jmeter/protocol/http/modifier/AnchorModifier.java,v
  retrieving revision 1.10
  retrieving revision 1.11
  diff -u -r1.10 -r1.11
  --- AnchorModifier.java       16 Feb 2002 19:43:26 -0000      1.10
  +++ AnchorModifier.java       19 Feb 2002 00:05:35 -0000      1.11
  @@ -79,7 +79,7 @@
    *  Apache
    *
    *@author     Michael Stover
  - *@created    $Date: 2002/02/16 19:43:26 $
  + *@created    $Date: 2002/02/19 00:05:35 $
    *@version    1.0
    ***********************************************************/
   
  @@ -231,23 +231,24 @@
        private void addFormUrls(Document html,SampleResult result,UrlConfig config,
                        List potentialLinks)
        {
  -             NodeList nodeList = html.getElementsByTagName("form");
  -             for(int x = 0;x < nodeList.getLength();x++)
  +             NodeList rootList = html.getChildNodes();
  +             List urls = new LinkedList();
  +             for(int x = 0;x < rootList.getLength();x++)
                {
  -                     Node tempNode = nodeList.item(x);
  -                     Node form = tempNode.cloneNode(true);
  +                     urls.addAll(HtmlParser.createURLFromForm(rootList.item(x),
  +                                     (URL)result.getValue(HTTPSampler.URL)));
  +             }
  +             Iterator iter = urls.iterator();
  +             while (iter.hasNext())
  +             {
  +                     UrlConfig newUrl = (UrlConfig)iter.next();
                        try
                        {
  -                             UrlConfig newUrl = HtmlParser.createURLFromForm(form,
  -                                             (URL)result.getValue(HTTPSampler.URL));
                                newUrl.setMethod(UrlConfig.POST);
                                if(HtmlParser.isAnchorMatched(newUrl,config))
                                {
                                        potentialLinks.add(newUrl);
                                }
  -                     }
  -                     catch (MalformedURLException e)
  -                     {
                        }
                        catch (org.apache.oro.text.regex.MalformedPatternException e)
                        {
  
  
  
  1.18      +240 -221  
jakarta-jmeter/src/org/apache/jmeter/protocol/http/parser/HtmlParser.java
  
  Index: HtmlParser.java
  ===================================================================
  RCS file: 
/home/cvs/jakarta-jmeter/src/org/apache/jmeter/protocol/http/parser/HtmlParser.java,v
  retrieving revision 1.17
  retrieving revision 1.18
  diff -u -r1.17 -r1.18
  --- HtmlParser.java   18 Feb 2002 18:16:44 -0000      1.17
  +++ HtmlParser.java   19 Feb 2002 00:05:35 -0000      1.18
  @@ -52,66 +52,66 @@
    * information on the Apache Software Foundation, please see
    * <http://www.apache.org/>.
    */
  -
   package org.apache.jmeter.protocol.http.parser;
  -
  +import java.io.*;
   import java.net.*;
   import java.util.*;
  -import java.io.*;
  -
  +import org.w3c.dom.*;
  +import org.w3c.tidy.Tidy;
  +import org.xml.sax.SAXException;
  +import junit.framework.TestCase;
   import org.apache.jmeter.config.*;
  +import org.apache.jmeter.config.Argument;
   import org.apache.jmeter.protocol.http.config.UrlConfig;
   import org.apache.jmeter.samplers.Entry;
   import org.apache.jmeter.util.JMeterUtils;
  -import org.apache.jmeter.config.Argument;
  -
  -import org.apache.oro.text.regex.*;
   import org.apache.log4j.*;
  +import org.apache.oro.text.regex.*;
   
  -import junit.framework.TestCase;
  -
  -import org.w3c.tidy.Tidy;
  -import org.w3c.dom.*;
  -import org.xml.sax.SAXException;
  -
  -/************************************************************
  - *  Title: Description: Copyright: Copyright (c) 2001 Company:
  +/****************************************
  + * Title: Description: Copyright: Copyright (c) 2001 Company:
    *
  - *@author     Michael Stover
  - *@created    June 14, 2001
  - *@version    1.0
  - ***********************************************************/
  + *@author    Michael Stover
  + *@created   June 14, 2001
  + *@version   1.0
  + ***************************************/
   
   public class HtmlParser implements Serializable
   {
  -     private int compilerOptions = Perl5Compiler.CASE_INSENSITIVE_MASK |
  -                     Perl5Compiler.MULTILINE_MASK | Perl5Compiler.READ_ONLY_MASK;
   
  +     /****************************************
  +      * !ToDo (Field description)
  +      ***************************************/
        protected static Category catClass =
                        Category.getInstance(HtmlParser.class.getName());
   
  +     /****************************************
  +      * !ToDo (Field description)
  +      ***************************************/
        protected static String utfEncodingName;
  +     private int compilerOptions = Perl5Compiler.CASE_INSENSITIVE_MASK |
  +                     Perl5Compiler.MULTILINE_MASK | Perl5Compiler.READ_ONLY_MASK;
   
  -     private transient static Perl5Compiler compiler = new Perl5Compiler();
  +     private static transient Perl5Compiler compiler = new Perl5Compiler();
   
  -     private transient static Perl5Matcher matcher = new Perl5Matcher();
  +     private static transient Perl5Matcher matcher = new Perl5Matcher();
   
  -     /************************************************************
  -      *  Constructor for the HtmlParser object
  -      ***********************************************************/
  +     /****************************************
  +      * Constructor for the HtmlParser object
  +      ***************************************/
   
        public HtmlParser()
        {
        }
   
  -     /************************************************************
  -      *  !ToDoo (Method description)
  +     /****************************************
  +      * !ToDoo (Method description)
         *
  -      *@param  newLink                        !ToDo (Parameter description)
  -      *@param  config                         !ToDo (Parameter description)
  -      *@return                                !ToDo (Return description)
  -      *@exception  MalformedPatternException  !ToDo (Exception description)
  -      ***********************************************************/
  +      *@param newLink                        !ToDo (Parameter description)
  +      *@param config                         !ToDo (Parameter description)
  +      *@return                               !ToDo (Return description)
  +      *@exception MalformedPatternException  !ToDo (Exception description)
  +      ***************************************/
        public static synchronized boolean isAnchorMatched(UrlConfig newLink, 
UrlConfig config) throws MalformedPatternException
        {
                boolean ok = true;
  @@ -121,7 +121,7 @@
                // In JDK1.2, URLDecoder.decode has Exception in its throws clause. 
However, it
                // was removed in JDK1.3. Since JMeter is JDK1.2-compatible, we need 
to catch
                // Exception.
  -             String query = null; 
  +             String query = null;
                try
                {
                        query = URLDecoder.decode(newLink.getQueryString());
  @@ -131,51 +131,52 @@
                        // do nothing. query will remain null.
                }
   
  -             if (query == null && config.getArguments().getArgumentCount() > 0)
  -             {
  +             if(query == null && config.getArguments().getArgumentCount() > 0)
                        return false;
  -             }
   
  -             while (iter.hasNext())
  +             while(iter.hasNext())
                {
                        Argument item = (Argument)iter.next();
   
  -                     if (!(ok = ok && matcher.contains(query, 
compiler.compile(item.getName() + "=" + item.getValue()))))
  +                     if(!(ok = ok && matcher.contains(query, 
compiler.compile(item.getName() + "=" + item.getValue()))))
                        {
  +                             System.out.println("Failed argument = " + 
item.getName() + "=" + item.getValue() + " query = " + query);
                                return false;
                        }
                }
   
  -             if (!(ok = ok && matcher.matches(newLink.getDomain(),
  +             if(!(ok = ok && matcher.matches(newLink.getDomain(),
                                compiler.compile(config.getDomain()))))
  -             {
                        return false;
  -             }
   
  -             if (!(ok = ok && matcher.matches(newLink.getPath(), 
compiler.compile("[/]*"+config.getPath()))))
  -             {
  +             if(!(ok = ok && matcher.matches(newLink.getPath(), 
compiler.compile("[/]*" + config.getPath()))))
                        return false;
  -             }
   
  -             if (!(ok = ok && matcher.matches(newLink.getProtocol(), 
compiler.compile(config.getProtocol()))))
  -             {
  +             if(!(ok = ok && matcher.matches(newLink.getProtocol(), 
compiler.compile(config.getProtocol()))))
                        return false;
  -             }
   
                return ok;
        }
   
  -     public static synchronized boolean isArgumentMatched(Argument arg,Argument 
patternArg) throws MalformedPatternException
  +     /****************************************
  +      * !ToDoo (Method description)
  +      *
  +      *@param arg                            !ToDo (Parameter description)
  +      *@param patternArg                     !ToDo (Parameter description)
  +      *@return                               !ToDo (Return description)
  +      *@exception MalformedPatternException  !ToDo (Exception description)
  +      ***************************************/
  +     public static synchronized boolean isArgumentMatched(Argument arg, Argument 
patternArg) throws MalformedPatternException
        {
  -             return 
matcher.matches(arg.getName(),compiler.compile(patternArg.getName())) &&
  -                             
matcher.matches((String)arg.getValue(),compiler.compile((String)patternArg.getValue()));
  +             return matcher.matches(arg.getName(), 
compiler.compile(patternArg.getName())) &&
  +                             matcher.matches((String)arg.getValue(), 
compiler.compile((String)patternArg.getValue()));
        }
   
  -     /************************************************************
  -      *  Returns <code>tidy</code> as HTML parser
  +     /****************************************
  +      * Returns <code>tidy</code> as HTML parser
         *
  -      *@return    a <code>tidy</code> HTML parser
  -      ***********************************************************/
  +      *@return   a <code>tidy</code> HTML parser
  +      ***************************************/
        public static Tidy getParser()
        {
                catClass.debug("Start : getParser1");
  @@ -184,23 +185,21 @@
                tidy.setQuiet(true);
                tidy.setShowWarnings(false);
   
  -             if (catClass.isDebugEnabled())
  -             {
  +             if(catClass.isDebugEnabled())
                        catClass.debug("getParser1 : tidy parser created - " + tidy);
  -             }
   
                catClass.debug("End : getParser1");
   
                return tidy;
        }
   
  -     /************************************************************
  -      *  Returns a node representing a whole xml given an xml document
  +     /****************************************
  +      * Returns a node representing a whole xml given an xml document
         *
  -      *@param  text              an xml document
  -      *@return                   a node representing a whole xml
  -      *@exception  SAXException  !ToDo (Exception description)
  -      ***********************************************************/
  +      *@param text              an xml document
  +      *@return                  a node representing a whole xml
  +      *@exception SAXException  !ToDo (Exception description)
  +      ***************************************/
        public static Node getDOM(String text) throws SAXException
        {
                catClass.debug("Start : getDOM1");
  @@ -210,16 +209,14 @@
                        Node node = getParser().parseDOM(new
                                        
ByteArrayInputStream(text.getBytes(getUTFEncodingName())), null);
   
  -                     if (catClass.isDebugEnabled())
  -                     {
  +                     if(catClass.isDebugEnabled())
                                catClass.debug("node : " + node);
  -                     }
   
                        catClass.debug("End : getDOM1");
   
                        return node;
                }
  -             catch (UnsupportedEncodingException e)
  +             catch(UnsupportedEncodingException e)
                {
                        catClass.error("getDOM1 : Unsupported encoding exception - " + 
e);
                        catClass.debug("End : getDOM1");
  @@ -227,66 +224,60 @@
                }
        }
   
  -     /************************************************************
  -      *  Returns the encoding type which is different for different jdks even though
  -      *  the mean the same thing i.e. UTF8 or UTF-8
  +     /****************************************
  +      * Returns the encoding type which is different for different jdks even though
  +      * the mean the same thing i.e. UTF8 or UTF-8
         *
  -      *@return    either UTF8 or UTF-8 depending on the jdk version
  -      ***********************************************************/
  +      *@return   either UTF8 or UTF-8 depending on the jdk version
  +      ***************************************/
        public static String getUTFEncodingName()
        {
                catClass.debug("Start : getUTFEncodingName1");
   
  -             if (utfEncodingName == null)
  +             if(utfEncodingName == null)
                {
                        String versionNum = System.getProperty("java.version");
   
  -                     if (catClass.isDebugEnabled())
  -                     {
  +                     if(catClass.isDebugEnabled())
                                catClass.debug("getUTFEncodingName1 : versionNum - " + 
versionNum);
  -                     }
   
  -                     if (versionNum.startsWith("1.1"))
  -                     {
  +                     if(versionNum.startsWith("1.1"))
                                utfEncodingName = "UTF8";
  -                     }
  +
                        else
  -                     {
                                utfEncodingName = "UTF-8";
  -                     }
  +
                }
   
  -             if (catClass.isDebugEnabled())
  -             {
  +             if(catClass.isDebugEnabled())
                        catClass.debug("getUTFEncodingName1 : Returning 
utfEncodingName - " +
                                        utfEncodingName);
  -             }
   
                catClass.debug("End : getUTFEncodingName1");
   
                return utfEncodingName;
        }
   
  -     /************************************************************
  -      *  !ToDo (Method description)
  +     /****************************************
  +      * !ToDo (Method description)
         *
  -      *@return    !ToDo (Return description)
  -      ***********************************************************/
  +      *@return   !ToDo (Return description)
  +      ***************************************/
        public static Document createEmptyDoc()
        {
                return new Tidy().createEmptyDocument();
        }
   
  -     /************************************************************
  -      *  Create a new URL based on an HREF string plus a contextual URL object.
  -      *  Given that an HREF string might be of three possible forms, some processing
  -      *  is required.
  +     /****************************************
  +      * Create a new URL based on an HREF string plus a contextual URL object. Given
  +      * that an HREF string might be of three possible forms, some processing is
  +      * required.
         *
  -      *@param  parsedUrlString            !ToDo (Parameter description)
  -      *@param  context                    !ToDo (Parameter description)
  -      *@return                            !ToDo (Return description)
  -      *@exception  MalformedURLException  !ToDo (Exception description)
  -      ***********************************************************/
  +      *@param parsedUrlString            !ToDo (Parameter description)
  +      *@param context                    !ToDo (Parameter description)
  +      *@return                           !ToDo (Return description)
  +      *@exception MalformedURLException  !ToDo (Exception description)
  +      ***************************************/
        public static UrlConfig createUrlFromAnchor(String parsedUrlString, URL 
context) throws MalformedURLException
        {
                UrlConfig url = new UrlConfig();
  @@ -300,37 +291,29 @@
                String contextPath = null;
                String contextFile = context.getFile();
                int indexContextQuery = contextFile.lastIndexOf('?');
  -             if (indexContextQuery != -1)
  -             {
  +             if(indexContextQuery != -1)
                        contextPath = contextFile.substring(0, indexContextQuery);
  -             }
  +
                else
  -             {
                        contextPath = contextFile;
  -             }
   
                int queryStarts = parsedUrlString.indexOf("?");
   
  -             if (queryStarts == -1)
  -             {
  +             if(queryStarts == -1)
                        queryStarts = parsedUrlString.length();
  -             }
   
  -             if (parsedUrlString.startsWith("/"))
  -             {
  +             if(parsedUrlString.startsWith("/"))
                        url.setPath(parsedUrlString.substring(0, queryStarts));
  -             }
  -             else if (parsedUrlString.startsWith(".."))
  -             {
  +
  +             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"))
  -             {
  +
  +             else if(!parsedUrlString.toLowerCase().startsWith("http"))
                        url.setPath(contextPath.substring(0, 
contextPath.lastIndexOf("/")) +
                                        "/" + parsedUrlString.substring(0, 
queryStarts));
  -             }
  +
                else
                {
                        URL u = new URL(parsedUrlString);
  @@ -339,14 +322,11 @@
                        String uPath = null;
                        String uFile = u.getFile();
                        int indexUQuery = uFile.lastIndexOf('?');
  -                     if (indexUQuery != -1)
  -                     {
  +                     if(indexUQuery != -1)
                                uPath = uFile.substring(0, indexUQuery);
  -                     }
  +
                        else
  -                     {
                                uPath = uFile;
  -                     }
   
                        url.setPath(uPath);
                        url.setDomain(u.getHost());
  @@ -354,143 +334,121 @@
                        url.setPort(u.getPort());
                }
   
  -             if (queryStarts < parsedUrlString.length())
  -             {
  +             if(queryStarts < parsedUrlString.length())
                        url.parseArguments(parsedUrlString.substring(queryStarts + 1));
  -             }
   
                return url;
        }
   
  -     /************************************************************
  -      *  !ToDo (Method description)
  +     /****************************************
  +      * !ToDo (Method description)
         *
  -      *@param  formNode                   !ToDo (Parameter description)
  -      *@param  context                    !ToDo (Parameter description)
  -      *@return                            !ToDo (Return description)
  -      *@exception  MalformedURLException  !ToDo (Exception description)
  -      ***********************************************************/
  +      *@param context                    !ToDo (Parameter description)
  +      *@param doc                        !ToDo (Parameter description)
  +      *@return                           !ToDo (Return description)
  +      ***************************************/
   
  -     public static UrlConfig createURLFromForm(Node formNode, URL context) throws 
MalformedURLException
  +     public static List createURLFromForm(Node doc, URL context)
        {
                String selectName = null;
  -             NodeList childNodes = formNode.getChildNodes();
  -             NamedNodeMap atts = formNode.getAttributes();
  -             if(atts.getNamedItem("action") == null)
  -             {
  -                     throw new MalformedURLException();
  -             }
  -             String action = atts.getNamedItem("action").getNodeValue();
  -             UrlConfig url = createUrlFromAnchor(action, context);
  -             recurseForm(childNodes, url, selectName);
  -
  -             return url;
  +             LinkedList urlConfigs = new LinkedList();
  +             recurseForm(doc, urlConfigs, context, selectName, false);
  +             /*
  +              * NamedNodeMap atts = formNode.getAttributes();
  +              * if(atts.getNamedItem("action") == null)
  +              * {
  +              * throw new MalformedURLException();
  +              * }
  +              * String action = atts.getNamedItem("action").getNodeValue();
  +              * UrlConfig url = createUrlFromAnchor(action, context);
  +              * recurseForm(doc, url, selectName,true,formStart);
  +              */
  +             return urlConfigs;
        }
   
  -     /************************************************************
  -      *  !ToDo (Class description)
  -      *
  -      *@author     $Author: khammond $
  -      *@created    $Date: 2002/02/18 18:16:44 $
  -      *@version    $Revision: 1.17 $
  -      ***********************************************************/
  -     public static class Test extends TestCase
  +     private static boolean recurseForm(Node tempNode, LinkedList urlConfigs, URL 
context,
  +                     String selectName, boolean inForm)
        {
  -             private static Category catClass =
  -                             Category.getInstance(Test.class.getName());
  -
  -             /************************************************************
  -              *  !ToDo (Constructor description)
  -              *
  -              *@param  name  !ToDo (Parameter description)
  -              ***********************************************************/
  -             public Test(String name)
  -             {
  -                     super(name);
  -             }
  -
  -             /************************************************************
  -              *  !ToDo
  -              ***********************************************************/
  -             public void testGetUTFEncodingName()
  -             {
  -                     catClass.debug("Start : testGetUTFEncodingName1");
  -                     String javaVersion = System.getProperty("java.version");
  -                     utfEncodingName = null;
  -                     System.setProperty("java.version", "1.1");
  -                     assertEquals("UTF8", HtmlParser.getUTFEncodingName());
  -                     // need to clear utfEncodingName variable first 'cos
  -                     // getUTFEncodingName checks to see if it's null
  -                     utfEncodingName = null;
  -                     System.setProperty("java.version", "1.2");
  -                     assertEquals("UTF-8", HtmlParser.getUTFEncodingName());
  -                     System.setProperty("java.version", javaVersion);
  -                     catClass.debug("End : testGetUTFEncodingName1");
  -             }
  -
  -             /************************************************************
  -              *  !ToDo
  -              ***********************************************************/
  -             protected void setUp()
  -             {
  -             }
  -     }
  -
  -     private static void recurseForm(NodeList childNodes, UrlConfig url, String 
selectName)
  -     {
  -             for (int x = 0; x < childNodes.getLength(); x++)
  +             NamedNodeMap nodeAtts = tempNode.getAttributes();
  +             String tag = tempNode.getNodeName();
  +             try
                {
  -                     Node tempNode = childNodes.item(x);
  -                     NamedNodeMap nodeAtts = tempNode.getAttributes();
  -                     String tag = tempNode.getNodeName();
  -                     try
  +                     if(inForm)
                        {
  -                             if (tag.equalsIgnoreCase("input"))
  +                             UrlConfig url = (UrlConfig)urlConfigs.getLast();
  +                             if(tag.equalsIgnoreCase("form"))
                                {
  -                                     
url.addArgument(getAttributeValue(nodeAtts,"name"),
  -                                                     
getAttributeValue(nodeAtts,"value"));
  +                                     try
  +                                     {
  +                                             
urlConfigs.add(createFormUrlConfig(tempNode, context));
  +                                     }
  +                                     catch(MalformedURLException e)
  +                                     {
  +                                             inForm = false;
  +                                     }
                                }
  -                             else if (tag.equalsIgnoreCase("textarea"))
  +                             else if(tag.equalsIgnoreCase("input"))
                                {
  +                                     url.addArgument(getAttributeValue(nodeAtts, 
"name"),
  +                                                     getAttributeValue(nodeAtts, 
"value"));
  +                             }
  +
  +                             else if(tag.equalsIgnoreCase("textarea"))
                                        try
                                        {
  -                                             
url.addArgument(getAttributeValue(nodeAtts,"name"),
  +                                             
url.addArgument(getAttributeValue(nodeAtts, "name"),
                                                                
tempNode.getFirstChild().getNodeValue());
                                        }
                                        catch(NullPointerException e)
                                        {
  -                                             
url.addArgument(getAttributeValue(nodeAtts,"name"),"");
  +                                             
url.addArgument(getAttributeValue(nodeAtts, "name"), "");
                                        }
  -                             }
  -                             else if (tag.equalsIgnoreCase("select"))
  -                             {
  -                                     selectName = 
getAttributeValue(nodeAtts,"name");
  -                             }
  -                             else if (tag.equalsIgnoreCase("option"))
  +
  +                             else if(tag.equalsIgnoreCase("select"))
  +                                     selectName = getAttributeValue(nodeAtts, 
"name");
  +
  +                             else if(tag.equalsIgnoreCase("option"))
                                {
  -                                     String value = 
getAttributeValue(nodeAtts,"value");
  -                                     if (value == null || value.equals(""))
  -                                     {
  +                                     String value = getAttributeValue(nodeAtts, 
"value");
  +                                     if(value == null || value.equals(""))
                                                value = 
tempNode.getFirstChild().getNodeValue();
  -                                     }
   
                                        url.addArgument(selectName, value);
                                }
                        }
  -                     catch (Exception ex) {
  -                             System.out.println("Some bad HTML 
"+printNode(tempNode));
  +                     else if(tag.equalsIgnoreCase("form"))
  +                     {
  +                             try
  +                             {
  +                                     urlConfigs.add(createFormUrlConfig(tempNode, 
context));
  +                                     inForm = true;
  +                             }
  +                             catch(MalformedURLException e)
  +                             {
  +                                     inForm = false;
  +                             }
  +                             try{Thread.sleep(5000);}catch(Exception e){}
                        }
  -
  -                     recurseForm(tempNode.getChildNodes(),url,selectName);
                }
  +             catch(Exception ex)
  +             {
  +                     System.out.println("Some bad HTML " + printNode(tempNode));
  +             }
  +             NodeList childNodes = tempNode.getChildNodes();
  +             for(int x = 0; x < childNodes.getLength(); x++)
  +             {
  +                     inForm = recurseForm(childNodes.item(x), urlConfigs, context, 
selectName, inForm);
  +             }
  +             return inForm;
        }
   
  -     private static String getAttributeValue(NamedNodeMap att,String attName)
  +     private static String getAttributeValue(NamedNodeMap att, String attName)
        {
  -             try {
  +             try
  +             {
                        return att.getNamedItem(attName).getNodeValue();
                }
  -             catch (Exception ex)
  +             catch(Exception ex)
                {
                        return "";
                }
  @@ -502,7 +460,7 @@
                buf.append("<");
                buf.append(node.getNodeName());
                NamedNodeMap atts = node.getAttributes();
  -             for(int x = 0;x < atts.getLength();x++)
  +             for(int x = 0; x < atts.getLength(); x++)
                {
                        buf.append(" ");
                        buf.append(atts.item(x).getNodeName());
  @@ -514,5 +472,66 @@
                buf.append(">");
   
                return buf.toString();
  +     }
  +
  +     /****************************************
  +      * !ToDo (Class description)
  +      *
  +      *@author    $Author: mstover1 $
  +      *@created   $Date: 2002/02/19 00:05:35 $
  +      *@version   $Revision: 1.18 $
  +      ***************************************/
  +     public static class Test extends TestCase
  +     {
  +             private static Category catClass =
  +                             Category.getInstance(Test.class.getName());
  +
  +             /****************************************
  +              * !ToDo (Constructor description)
  +              *
  +              *@param name  !ToDo (Parameter description)
  +              ***************************************/
  +             public Test(String name)
  +             {
  +                     super(name);
  +             }
  +
  +             /****************************************
  +              * !ToDo
  +              ***************************************/
  +             public void testGetUTFEncodingName()
  +             {
  +                     catClass.debug("Start : testGetUTFEncodingName1");
  +                     String javaVersion = System.getProperty("java.version");
  +                     utfEncodingName = null;
  +                     System.setProperty("java.version", "1.1");
  +                     assertEquals("UTF8", HtmlParser.getUTFEncodingName());
  +                     // need to clear utfEncodingName variable first 'cos
  +                     // getUTFEncodingName checks to see if it's null
  +                     utfEncodingName = null;
  +                     System.setProperty("java.version", "1.2");
  +                     assertEquals("UTF-8", HtmlParser.getUTFEncodingName());
  +                     System.setProperty("java.version", javaVersion);
  +                     catClass.debug("End : testGetUTFEncodingName1");
  +             }
  +
  +             /****************************************
  +              * !ToDo
  +              ***************************************/
  +             protected void setUp()
  +             {
  +             }
  +     }
  +
  +     private static UrlConfig createFormUrlConfig(Node tempNode, URL context) throws
  +                     MalformedURLException
  +     {
  +             NamedNodeMap atts = tempNode.getAttributes();
  +             if(atts.getNamedItem("action") == null)
  +                     throw new MalformedURLException();
  +             String action = atts.getNamedItem("action").getNodeValue();
  +             System.out.println("starting form action = "+action);
  +             UrlConfig url = createUrlFromAnchor(action, context);
  +             return url;
        }
   }
  
  
  
  1.13      +3 -3      jakarta-jmeter/src/org/apache/jmeter/samplers/Entry.java
  
  Index: Entry.java
  ===================================================================
  RCS file: /home/cvs/jakarta-jmeter/src/org/apache/jmeter/samplers/Entry.java,v
  retrieving revision 1.12
  retrieving revision 1.13
  diff -u -r1.12 -r1.13
  --- Entry.java        16 Aug 2001 23:36:57 -0000      1.12
  +++ Entry.java        19 Feb 2002 00:05:35 -0000      1.13
  @@ -63,7 +63,7 @@
    *  Apache Foundation
    *
    *@author     Michael Stover
  - *@created    $Date: 2001/08/16 23:36:57 $
  + *@created    $Date: 2002/02/19 00:05:35 $
    *@version    1.0
    ***********************************************************/
   
  @@ -85,9 +85,9 @@
                assertions = new LinkedList();
        }
   
  -     public void addAssertion(Assertion assert)
  +     public void addAssertion(Assertion assertion)
        {
  -             assertions.add(assert);
  +             assertions.add(assertion);
        }
   
        public List getAssertions()
  
  
  

--
To unsubscribe, e-mail:   <mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>

Reply via email to