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
Date Tue, 08 Apr 2003 18:33:57 GMT
mstover1    2003/04/08 11:33:57

  Modified:    src/core/org/apache/jmeter/engine/util ValueReplacer.java
               src/protocol/http/org/apache/jmeter/protocol/http/proxy
                        HttpRequestHdr.java
               src/protocol/http/org/apache/jmeter/protocol/http/sampler
                        HTTPSampler.java
  Log:
  fixing proxy server
  
  Revision  Changes    Path
  1.4       +55 -35    jakarta-jmeter/src/core/org/apache/jmeter/engine/util/ValueReplacer.java
  
  Index: ValueReplacer.java
  ===================================================================
  RCS file: /home/cvs/jakarta-jmeter/src/core/org/apache/jmeter/engine/util/ValueReplacer.java,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- ValueReplacer.java	7 Apr 2003 14:35:21 -0000	1.3
  +++ ValueReplacer.java	8 Apr 2003 18:33:56 -0000	1.4
  @@ -4,6 +4,7 @@
   import java.util.Collection;
   import java.util.HashMap;
   import java.util.Iterator;
  +import java.util.LinkedList;
   import java.util.List;
   import java.util.Map;
   
  @@ -59,6 +60,7 @@
       public void replaceValues(TestElement el) throws InvalidVariableException
       {
           PropertyIterator iter = el.propertyIterator();
  +        List newProps = new LinkedList();
           while (iter.hasNext())
           {
               JMeterProperty prop = iter.next();
  @@ -77,9 +79,14 @@
               else if (prop instanceof StringProperty)
               {
                   JMeterProperty newValue = getNewValue((StringProperty) prop);
  -                el.setProperty(newValue);
  +                newProps.add(newValue);
               }
           }
  +        Iterator props = newProps.iterator();
  +        while (props.hasNext())
  +        {
  +            el.setProperty((JMeterProperty) props.next());
  +        }
       }
   
       private JMeterProperty getNewValue(StringProperty prop) throws InvalidVariableException
  @@ -257,43 +264,43 @@
           }
           prop.setMap(newMap);
       }
  -    
  +
       private void undoReverseReplace(MapProperty prop)
  +    {
  +        Map newMap = null;
  +        try
  +        {
  +            newMap = (Map) prop.getObjectValue().getClass().newInstance();
  +        }
  +        catch (Exception e)
           {
  -            Map newMap = null;
  -            try
  +            log.error("", e);
  +            return;
  +        }
  +        PropertyIterator iter = prop.valueIterator();
  +        while (iter.hasNext())
  +        {
  +            JMeterProperty val = iter.next();
  +            if (val instanceof TestElementProperty)
  +            {
  +                undoReverseReplace((TestElement) val.getObjectValue());
  +            }
  +            else if (val instanceof StringProperty)
  +            {
  +                val = substituteReferences((StringProperty) val);
  +            }
  +            else if (val instanceof CollectionProperty)
               {
  -                newMap = (Map) prop.getObjectValue().getClass().newInstance();
  +                undoReverseReplace((CollectionProperty) val);
               }
  -            catch (Exception e)
  +            else if (val instanceof MapProperty)
               {
  -                log.error("", e);
  -                return;
  -            }
  -            PropertyIterator iter = prop.valueIterator();
  -            while (iter.hasNext())
  -            {
  -                JMeterProperty val = iter.next();
  -                if (val instanceof TestElementProperty)
  -                {
  -                    undoReverseReplace((TestElement) val.getObjectValue());
  -                }
  -                else if (val instanceof StringProperty)
  -                {
  -                    val = substituteReferences((StringProperty) val);
  -                }
  -                else if (val instanceof CollectionProperty)
  -                {
  -                    undoReverseReplace((CollectionProperty) val);
  -                }
  -                else if (val instanceof MapProperty)
  -                {
  -                    undoReverseReplace((MapProperty) val);
  -                }
  -                newMap.put(val.getName(), val);
  +                undoReverseReplace((MapProperty) val);
               }
  -            prop.setMap(newMap);
  +            newMap.put(val.getName(), val);
           }
  +        prop.setMap(newMap);
  +    }
   
       /**
            * Remove variables references and replace with the raw string values.
  @@ -342,12 +349,13 @@
       public void undoReverseReplace(TestElement el)
       {
           PropertyIterator iter = el.propertyIterator();
  +        List newProps = new LinkedList();
           while (iter.hasNext())
           {
               JMeterProperty prop = iter.next();
               if (prop instanceof StringProperty)
               {
  -                el.setProperty(substituteReferences((StringProperty) prop));
  +                newProps.add(substituteReferences((StringProperty) prop));
               }
               else if (prop instanceof TestElementProperty)
               {
  @@ -362,6 +370,11 @@
                   undoReverseReplace((MapProperty) prop);
               }
           }
  +        Iterator props = newProps.iterator();
  +        while (props.hasNext())
  +        {
  +            el.setProperty((JMeterProperty) props.next());
  +        }
       }
   
       /**
  @@ -370,12 +383,13 @@
       public void reverseReplace(TestElement el)
       {
           PropertyIterator iter = el.propertyIterator();
  +        List newProps = new LinkedList();
           while (iter.hasNext())
           {
               JMeterProperty prop = iter.next();
               if (prop instanceof StringProperty)
               {
  -                el.setProperty(substituteValues((StringProperty) prop));
  +                newProps.add(substituteValues((StringProperty) prop));
               }
               else if (prop instanceof TestElementProperty)
               {
  @@ -390,6 +404,12 @@
                   reverseReplace((MapProperty) prop);
               }
           }
  +        Iterator props = newProps.iterator();
  +        while (props.hasNext())
  +        {
  +            el.setProperty((JMeterProperty) props.next());
  +
  +        }
       }
   
       private StringProperty substituteValues(StringProperty prop)
  @@ -415,7 +435,7 @@
               String value = (String) variables.get(key);
               input = StringUtilities.substitute(input, "${" + key + "}", value);
           }
  -        return new StringProperty(prop.getName(),input);
  +        return new StringProperty(prop.getName(), input);
       }
   
       public static class Test extends TestCase
  @@ -453,7 +473,7 @@
               replacer.reverseReplace(element);
               assertEquals("${server}", element.getPropertyAsString("domain"));
               args = (List) element.getProperty("args").getObjectValue();
  -            assertEquals("${password}", ((JMeterProperty)args.get(1)).getStringValue());
  +            assertEquals("${password}", ((JMeterProperty) args.get(1)).getStringValue());
           }
   
           public void testReplace() throws Exception
  
  
  
  1.9       +4 -4      jakarta-jmeter/src/protocol/http/org/apache/jmeter/protocol/http/proxy/HttpRequestHdr.java
  
  Index: HttpRequestHdr.java
  ===================================================================
  RCS file: /home/cvs/jakarta-jmeter/src/protocol/http/org/apache/jmeter/protocol/http/proxy/HttpRequestHdr.java,v
  retrieving revision 1.8
  retrieving revision 1.9
  diff -u -r1.8 -r1.9
  --- HttpRequestHdr.java	1 Apr 2003 15:08:57 -0000	1.8
  +++ HttpRequestHdr.java	8 Apr 2003 18:33:57 -0000	1.9
  @@ -142,7 +142,7 @@
   		while (keys.hasNext())
   		{
   			String key = (String) keys.next();
  -			if (!key.equals("proxy-connection") && !key.equals("content-length") &&
!key.equals("accept-encoding"))
  +			if (!key.equals("proxy-connection") && !key.equals("content-length") /*&&
!key.equals("accept-encoding")*/)
   			{
   				manager.add((Header) headers.get(key));
   			}
  
  
  
  1.28      +17 -4     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.27
  retrieving revision 1.28
  diff -u -r1.27 -r1.28
  --- HTTPSampler.java	7 Apr 2003 14:35:27 -0000	1.27
  +++ HTTPSampler.java	8 Apr 2003 18:33:57 -0000	1.28
  @@ -63,7 +63,6 @@
   import java.net.URL;
   import java.net.URLConnection;
   import java.util.ArrayList;
  -import java.util.Iterator;
   
   import org.apache.jmeter.config.Arguments;
   import org.apache.jmeter.protocol.http.control.AuthManager;
  @@ -78,6 +77,7 @@
   import org.apache.jmeter.testelement.property.BooleanProperty;
   import org.apache.jmeter.testelement.property.CollectionProperty;
   import org.apache.jmeter.testelement.property.IntegerProperty;
  +import org.apache.jmeter.testelement.property.JMeterProperty;
   import org.apache.jmeter.testelement.property.PropertyIterator;
   import org.apache.jmeter.testelement.property.TestElementProperty;
   import org.apache.jmeter.util.SSLManager;
  @@ -222,9 +222,22 @@
       public void setProperty(String key, String prop)
       {
           super.setProperty(key, prop);
  +        log.error("Setting property in HTTPSampler: " + key);
           if (PATH.equals(key))
           {
  -            setEncodedPath(prop.toString());
  +            log.error("Setting encoded path");
  +            setEncodedPath(prop);
  +        }
  +    }
  +    
  +    public void setProperty(JMeterProperty prop)
  +    {
  +        log.debug("setting property " + prop.getName() + " in HTTPSampler");
  +        super.setProperty(prop);
  +        if (PATH.equals(prop.getName()))
  +        {
  +            log.error("Setting encoded path");
  +            setEncodedPath(prop.getStringValue());
           }
       }
   
  
  
  

---------------------------------------------------------------------
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