You are viewing a plain text version of this content. The canonical link for it is here.
Posted to jmeter-dev@jakarta.apache.org by ms...@apache.org on 2002/07/19 23:35:37 UTC

cvs commit: jakarta-jmeter/src_1/org/apache/jmeter/util ClassFinder.java

mstover1    2002/07/19 14:35:37

  Modified:    src_1/org/apache/jmeter/config Argument.java
               src_1/org/apache/jmeter/gui/util
                        TextAreaTableCellEditor.java
               src_1/org/apache/jmeter/junit/protocol/http/parser
                        HtmlParserTester.java
               src_1/org/apache/jmeter/protocol/http/parser HtmlParser.java
               src_1/org/apache/jmeter/util ClassFinder.java
  Log:
  Fixing Argument cloning incorrectly
  Assertion GUI awkward to edit values - improved
  Made HTMLParser check for literal value matches before regular expressions.
  
  Revision  Changes    Path
  1.3       +0 -10     jakarta-jmeter/src_1/org/apache/jmeter/config/Argument.java
  
  Index: Argument.java
  ===================================================================
  RCS file: /home/cvs/jakarta-jmeter/src_1/org/apache/jmeter/config/Argument.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- Argument.java	29 Apr 2002 17:08:06 -0000	1.2
  +++ Argument.java	19 Jul 2002 21:35:36 -0000	1.3
  @@ -97,16 +97,6 @@
   	public void addTestElement(TestElement el) { }
   
   	/****************************************
  -	 * !ToDo (Method description)
  -	 *
  -	 *@return   !ToDo (Return description)
  -	 ***************************************/
  -	public Object clone()
  -	{
  -		return new Argument(getName(), getValue());
  -	}
  -
  -	/****************************************
   	 * Sets the Name attribute of the Argument object
   	 *
   	 *@param newName  The new Name value
  
  
  
  1.2       +8 -1      jakarta-jmeter/src_1/org/apache/jmeter/gui/util/TextAreaTableCellEditor.java
  
  Index: TextAreaTableCellEditor.java
  ===================================================================
  RCS file: /home/cvs/jakarta-jmeter/src_1/org/apache/jmeter/gui/util/TextAreaTableCellEditor.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- TextAreaTableCellEditor.java	14 Jun 2002 22:45:16 -0000	1.1
  +++ TextAreaTableCellEditor.java	19 Jul 2002 21:35:37 -0000	1.2
  @@ -97,7 +97,14 @@
       {
       	if (anEvent instanceof MouseEvent)
   		{
  -			if (((MouseEvent)anEvent).getClickCount() > 1)
  +			if (((MouseEvent)anEvent).getClickCount() > 0)
  +			{
  +				return true;
  +			}
  +		}
  +		else if(anEvent instanceof FocusEvent)
  +		{
  +			if(((FocusEvent)anEvent).getID() == FocusEvent.FOCUS_GAINED)
   			{
   				return true;
   			}
  
  
  
  1.6       +24 -0     jakarta-jmeter/src_1/org/apache/jmeter/junit/protocol/http/parser/HtmlParserTester.java
  
  Index: HtmlParserTester.java
  ===================================================================
  RCS file: /home/cvs/jakarta-jmeter/src_1/org/apache/jmeter/junit/protocol/http/parser/HtmlParserTester.java,v
  retrieving revision 1.5
  retrieving revision 1.6
  diff -u -r1.5 -r1.6
  --- HtmlParserTester.java	29 Apr 2002 17:08:09 -0000	1.5
  +++ HtmlParserTester.java	19 Jul 2002 21:35:37 -0000	1.6
  @@ -171,6 +171,30 @@
   		assertEquals("test=goto",config.getQueryString());
   	}
   	
  +	/************************************************************
  +	 *  A unit test for JUnit
  +	 *
  +	 *@exception  Exception  Description of Exception
  +	 ***********************************************************/
  +	public void testBadCharParse() throws Exception
  +	{
  +		HTTPSampler config = makeUrlConfig(".*index.html");
  +		config.getArguments().addArgument("te$st","g.*");
  +		config.setMethod(HTTPSampler.POST);
  +		HTTPSampler context = makeContext("http://www.apache.org/subdir/previous.html");
  +		String responseText = "<html><head><title>Test page</title></head><body>" +
  +				"<form action=\"index.html\" method=\"POST\"><input type=\"checkbox\" name=\"te$st\""+
  +				" value=\"goto\">Goto index page</form></body></html>";
  +		SampleResult result = new SampleResult();
  +		result.setResponseData(responseText.getBytes());
  +		result.setSampleLabel(context.toString());
  +		result.setSamplerData(context);
  +		parser.modifyEntry(config, result);
  +		assertEquals("http://www.apache.org:80/subdir/index.html",
  +				config.getUrl().toString());
  +		assertEquals("te%24st=goto",config.getQueryString());
  +	}
  +	
   	private HTTPSampler makeContext(String url) throws MalformedURLException
   	{
   		URL u = new URL(url);
  
  
  
  1.7       +17 -10    jakarta-jmeter/src_1/org/apache/jmeter/protocol/http/parser/HtmlParser.java
  
  Index: HtmlParser.java
  ===================================================================
  RCS file: /home/cvs/jakarta-jmeter/src_1/org/apache/jmeter/protocol/http/parser/HtmlParser.java,v
  retrieving revision 1.6
  retrieving revision 1.7
  diff -u -r1.6 -r1.7
  --- HtmlParser.java	23 May 2002 15:47:05 -0000	1.6
  +++ HtmlParser.java	19 Jul 2002 21:35:37 -0000	1.7
  @@ -113,7 +113,8 @@
   	 *@return                               !ToDo (Return description)
   	 *@exception MalformedPatternException  !ToDo (Exception description)
   	 ***************************************/
  -	public static synchronized boolean isAnchorMatched(UrlConfig newLink, HTTPSampler config) throws MalformedPatternException
  +	public static synchronized boolean isAnchorMatched(UrlConfig newLink, 
  +			HTTPSampler config) throws MalformedPatternException
   	{
   		boolean ok = true;
   
  @@ -138,21 +139,25 @@
   		while(iter.hasNext())
   		{
   			Argument item = (Argument)iter.next();
  -
  -			if(!(ok = ok && matcher.contains(query, compiler.compile(item.getName()))))
  +			if(query.indexOf(item.getName()+"=") == -1)
   			{
  -				return false;
  +				if(!(ok = ok && matcher.contains(query, compiler.compile(item.getName()))))
  +				{
  +					return false;
  +				}
   			}
   		}
   
  -		if(config.getDomain() != null || config.getDomain().length() > 0)
  +		if(config.getDomain() != null && config.getDomain().length() > 0 &&
  +				!newLink.getDomain().equals(config.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 && !newLink.getPath().equals(config.getPath()) && matcher.matches(newLink.getPath(), 
  +				compiler.compile("[/]*" + config.getPath()))))
   			return false;
   
   		if(!(ok = ok && matcher.matches(newLink.getProtocol(), compiler.compile(config.getProtocol()))))
  @@ -171,8 +176,10 @@
   	 ***************************************/
   	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 (arg.getName().equals(patternArg.getName()) || 
  +				matcher.matches(arg.getName(), compiler.compile(patternArg.getName()))) &&
  +				(arg.getValue().equals(patternArg.getValue()) || 
  +				matcher.matches((String)arg.getValue(), compiler.compile((String)patternArg.getValue())));
   	}
   
   	/****************************************
  
  
  
  1.7       +5 -58     jakarta-jmeter/src_1/org/apache/jmeter/util/ClassFinder.java
  
  Index: ClassFinder.java
  ===================================================================
  RCS file: /home/cvs/jakarta-jmeter/src_1/org/apache/jmeter/util/ClassFinder.java,v
  retrieving revision 1.6
  retrieving revision 1.7
  diff -u -r1.6 -r1.7
  --- ClassFinder.java	12 Jul 2002 02:05:49 -0000	1.6
  +++ ClassFinder.java	19 Jul 2002 21:35:37 -0000	1.7
  @@ -1,109 +1,56 @@
   /*
  -
    * ====================================================================
  -
    * The Apache Software License, Version 1.1
  -
    *
  -
    * Copyright (c) 2001 The Apache Software Foundation.  All rights
  -
    * reserved.
  -
    *
  -
    * Redistribution and use in source and binary forms, with or without
  -
    * modification, are permitted provided that the following conditions
  -
    * are met:
  -
    *
  -
    * 1. Redistributions of source code must retain the above copyright
  -
    * notice, this list of conditions and the following disclaimer.
  -
    *
  -
    * 2. Redistributions in binary form must reproduce the above copyright
  -
    * notice, this list of conditions and the following disclaimer in
  -
    * the documentation and/or other materials provided with the
  -
    * distribution.
  -
    *
  -
    * 3. The end-user documentation included with the redistribution,
  -
    * if any, must include the following acknowledgment:
  -
    * "This product includes software developed by the
  -
    * Apache Software Foundation (http://www.apache.org/)."
  -
    * Alternately, this acknowledgment may appear in the software itself,
  -
    * if and wherever such third-party acknowledgments normally appear.
  -
    *
  -
    * 4. The names "Apache" and "Apache Software Foundation" and
  -
    * "Apache JMeter" must not be used to endorse or promote products
  -
    * derived from this software without prior written permission. For
  -
    * written permission, please contact apache@apache.org.
  -
    *
  -
    * 5. Products derived from this software may not be called "Apache",
  -
    * "Apache JMeter", nor may "Apache" appear in their name, without
  -
    * prior written permission of the Apache Software Foundation.
  -
    *
  -
    * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
  -
    * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
  -
    * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
  -
    * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
  -
    * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
  -
    * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
  -
    * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
  -
    * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
  -
    * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
  -
    * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
  -
    * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  -
    * SUCH DAMAGE.
  -
    * ====================================================================
  -
    *
  -
    * This software consists of voluntary contributions made by many
  -
    * individuals on behalf of the Apache Software Foundation.  For more
  -
    * information on the Apache Software Foundation, please see
  -
    * <http://www.apache.org/>.
  -
    */
   package org.apache.jmeter.util;
   import java.io.File;
  @@ -331,7 +278,7 @@
   				if ((strClassName.indexOf("$") == -1) || innerClasses) {
   					// might throw an exception, assume this is ignorable
   					try {
  -						tempClass = Class.forName(strClassName);
  +						tempClass = Class.forName(strClassName,true,Thread.currentThread().getContextClassLoader());
   						for (i = 0; i < interfaces.length; i++) {
   							if (classImplementsInterface(tempClass, interfaces[i])) {
   								foundIt = true;
  @@ -557,7 +504,7 @@
   			if ((strClassName.indexOf("$") == -1) || innerClasses) {
   				// might throw an exception, assume this is ignorable
   				try {
  -					tempClass = Class.forName(strClassName);
  +					tempClass = Class.forName(strClassName,true,Thread.currentThread().getContextClassLoader());
   					findAllSubclassesOneClass(
   						tempClass,
   						listAllClasses,
  @@ -634,7 +581,7 @@
   					// Class.forName() doesn't like nulls
   					if (strClassName == null)
   						continue;
  -					c = Class.forName(strClassName);
  +					c = Class.forName(strClassName,true,Thread.currentThread().getContextClassLoader());
   					if (!c.isInterface() && !Modifier.isAbstract(c.getModifiers())) {
   						bIsSubclass = theClass.isAssignableFrom(c);
   					} else {
  
  
  

--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>