mstover1    01/08/17 14:21:36

  Modified:    .        .cvsignore
               src/org/apache/jmeter/control GenericController.java
               src/org/apache/jmeter/gui/action Load.java
               src/org/apache/jmeter/protocol/http/sampler HTTPSampler.java
               src/org/apache/jmeter/util JMeterUtils.java
                        ListedHashTree.java
  Added:       bin/testfiles Modification Manager.jmx Test Plan.jmx
  Log:
  Routine to convert old .jmx files to new format upon loading.
  
  Revision  Changes    Path
  1.2       +1 -0      jakarta-jmeter/.cvsignore
  
  Index: .cvsignore
  ===================================================================
  RCS file: /home/cvs/jakarta-jmeter/.cvsignore,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- .cvsignore        2001/03/12 23:57:37     1.1
  +++ .cvsignore        2001/08/17 21:21:36     1.2
  @@ -1 +1,2 @@
   velocity.log
  +bin/classes
  
  
  
  No                   revision
  
  
  No                   revision
  
  
  No                   revision
  
  
  No                   revision
  
  
  1.17      +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.16
  retrieving revision 1.17
  diff -u -r1.16 -r1.17
  --- GenericController.java    2001/08/16 23:36:55     1.16
  +++ GenericController.java    2001/08/17 21:21:36     1.17
  @@ -5,7 +5,7 @@
    *                   companies.
    *
    *  All rights reserved
  - * $Header: 
/home/cvs/jakarta-jmeter/src/org/apache/jmeter/control/GenericController.java,v 1.16 
2001/08/16 23:36:55 mstover1 Exp $
  + * $Header: 
/home/cvs/jakarta-jmeter/src/org/apache/jmeter/control/GenericController.java,v 1.17 
2001/08/17 21:21:36 mstover1 Exp $
    */
   package org.apache.jmeter.control;
   import java.util.*;
  @@ -20,7 +20,7 @@
    *  Title: JMeter Description: Copyright: Copyright (c) 2000 Company: Apache
    *
    *@author     Michael Stover
  - *@created    $Date: 2001/08/16 23:36:55 $
  + *@created    $Date: 2001/08/17 21:21:36 $
    *@version    1.0
    ***********************************************************/
   
  @@ -313,7 +313,7 @@
         ***********************************************************/
        protected Entry endEntryCycle()
        {
  -             if (controlIt.hasNext())
  +             if (controlIt != null && controlIt.hasNext())
                {
                        current = (SamplerController)controlIt.next();
                }
  
  
  
  1.8       +206 -119  jakarta-jmeter/src/org/apache/jmeter/gui/action/Load.java
  
  Index: Load.java
  ===================================================================
  RCS file: /home/cvs/jakarta-jmeter/src/org/apache/jmeter/gui/action/Load.java,v
  retrieving revision 1.7
  retrieving revision 1.8
  diff -u -r1.7 -r1.8
  --- Load.java 2001/07/26 00:34:45     1.7
  +++ Load.java 2001/08/17 21:21:36     1.8
  @@ -1,119 +1,206 @@
  -/*
  - * ====================================================================
  - * 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 [EMAIL PROTECTED]
  - *
  - * 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.gui.action;
  -
  -import java.awt.event.ActionEvent;
  -import java.util.*;
  -import javax.swing.JFileChooser;
  -import java.io.*;
  -
  -import org.xml.sax.InputSource;
  -import org.apache.xerces.parsers.SAXParser;
  -import org.xml.sax.XMLReader;
  -
  -import org.apache.jmeter.gui.*;
  -import org.apache.jmeter.save.*;
  -import org.apache.jmeter.save.xml.*;
  -import org.apache.jmeter.util.*;
  -
  -/**
  - * Title:        JMeter
  - * Description:
  - * Copyright:    Copyright (c) 2000
  - * Company:      Apache
  - * @author Michael Stover
  - * @version 1.0
  - */
  -
  -public class Load implements Command
  -{
  -
  -     private static Set commands = new HashSet();
  -     static
  -     {
  -             commands.add(JMeterUtils.RESOURCES.getString("open"));
  -     }
  -
  -     public Load()
  -     {
  -     }
  -     public void doAction(ActionEvent e)
  -     {
  -             JFileChooser chooser = FileDialoger.promptToOpenFile();
  -             FileInputStream reader = null;
  -             try {
  -                      File f = chooser.getSelectedFile();
  -                      if (f!=null) {
  -                     reader = new FileInputStream(f);
  -                     XmlHandler handler =
  -                              new XmlHandler(new JMeterNameSpaceHandler());
  -                     XMLReader parser = JMeterUtils.getXMLParser();
  -                     parser.setContentHandler(handler);
  -                     parser.setErrorHandler(handler);
  -                     parser.parse(new InputSource(reader));
  -                     ListedHashTree tree = handler.getDataTree();
  -                     GuiPackage.getInstance().addSubTree(handler.getDataTree());
  -                      }
  -             }
  -             catch (Throwable ex) {
  -                     ex.printStackTrace();
  -             }
  -     }
  -
  -     public Set getActionNames()
  -     {
  -             return commands;
  -     }
  -}
  +/* Project: Mako
  + *  Copyright (c) Xerox Corporation 1999-2001. All rights reserved.  Xerox, The
  + *                   Document Company, and the stylized X are trademarks of the 
Xerox
  + *                   Corporation. All other products are trademarks of their 
respective
  + *                   companies.
  + *
  + *  All rights reserved
  + * $Header: /home/cvs/jakarta-jmeter/src/org/apache/jmeter/gui/action/Load.java,v 
1.8 2001/08/17 21:21:36 mstover1 Exp $
  + */
  +package org.apache.jmeter.gui.action;
  +
  +import java.awt.event.ActionEvent;
  +import java.util.*;
  +import javax.swing.JFileChooser;
  +import java.io.*;
  +
  +import org.xml.sax.InputSource;
  +import org.apache.xerces.parsers.SAXParser;
  +import org.xml.sax.XMLReader;
  +
  +import org.apache.jmeter.gui.*;
  +import org.apache.jmeter.save.*;
  +import org.apache.jmeter.save.xml.*;
  +import org.apache.jmeter.util.*;
  +import org.apache.jmeter.protocol.http.config.UrlConfig;
  +import org.apache.jmeter.protocol.http.control.HttpTestSample;
  +import org.apache.jmeter.protocol.http.config.UrlConfigFull;
  +
  +import junit.framework.*;
  +
  +import org.apache.jmeter.control.LogicController;
  +
  +/************************************************************
  + *  Title: JMeter Description: Copyright: Copyright (c) 2000 Company: Apache
  + *
  + *@author     Michael Stover
  + *@created    $Date: 2001/08/17 21:21:36 $
  + *@version    1.0
  + ***********************************************************/
  +
  +public class Load implements Command
  +{
  +
  +     private static Set commands = new HashSet();
  +
  +     /************************************************************
  +      *  !ToDo (Constructor description)
  +      ***********************************************************/
  +     public Load()
  +     {
  +     }
  +
  +     /************************************************************
  +      *  !ToDoo (Method description)
  +      *
  +      *@return    !ToDo (Return description)
  +      ***********************************************************/
  +     public Set getActionNames()
  +     {
  +             return commands;
  +     }
  +
  +     /************************************************************
  +      *  !ToDo (Method description)
  +      *
  +      *@param  e  !ToDo (Parameter description)
  +      ***********************************************************/
  +     public void doAction(ActionEvent e)
  +     {
  +             JFileChooser chooser = FileDialoger.promptToOpenFile();
  +             FileInputStream reader = null;
  +             try
  +             {
  +                     File f = chooser.getSelectedFile();
  +                     if (f != null)
  +                     {
  +                             reader = new FileInputStream(f);
  +                             XmlHandler handler =
  +                                             new XmlHandler(new 
JMeterNameSpaceHandler());
  +                             XMLReader parser = JMeterUtils.getXMLParser();
  +                             parser.setContentHandler(handler);
  +                             parser.setErrorHandler(handler);
  +                             parser.parse(new InputSource(reader));
  +                             ListedHashTree tree = handler.getDataTree();
  +                             updateTree(tree);
  +                             GuiPackage.getInstance().addSubTree(tree);
  +                     }
  +             }
  +             catch (Throwable ex)
  +             {
  +                     ex.printStackTrace();
  +             }
  +     }
  +
  +     private void updateTree(ListedHashTree tree)
  +     {
  +             List items = new LinkedList(tree.list());
  +             Iterator iter = items.iterator();
  +             while (iter.hasNext())
  +             {
  +                     Object item = iter.next();
  +                     System.out.println("Main item = " + item);
  +                     if (item instanceof HttpTestSample)
  +                     {
  +                             List subItems = new LinkedList(tree.list(item));
  +                             boolean replaced = false;
  +                             Iterator iter2 = subItems.iterator();
  +                             while (iter2.hasNext())
  +                             {
  +                                     Object config = iter2.next();
  +                                     System.out.println("subitem = " + config);
  +                                     if (config instanceof UrlConfig)
  +                                     {
  +                                             System.out.println("Replacing a 
UrlConfig");
  +                                             replaced = true;
  +                                             HttpTestSample newControl = new 
HttpTestSample();
  +                                             
newControl.setDefaultUrl((UrlConfig)config);
  +                                             if (config instanceof UrlConfigFull)
  +                                             {
  +                                                     newControl.setGetImages(true);
  +                                             }
  +                                             tree.get(item).replace(config, 
newControl);
  +                                     }
  +                             }
  +                             if (replaced)
  +                             {
  +                                     UrlConfig newConfig = 
((HttpTestSample)item).getDefaultUrl();
  +                                     LogicController newControl = new 
LogicController();
  +                                     tree.replace(item, newControl);
  +                                     tree.add(newControl, newConfig);
  +                             }
  +                     }
  +                     else
  +                     {
  +                             updateTree(tree.get(item));
  +                     }
  +             }
  +     }
  +
  +     /************************************************************
  +      *  !ToDo (Class description)
  +      *
  +      *@author     $Author: mstover1 $
  +      *@created    $Date: 2001/08/17 21:21:36 $
  +      *@version    $Revision: 1.8 $
  +      ***********************************************************/
  +     public static class Test extends TestCase
  +     {
  +             File testFile1, testFile2;
  +             static Load loader = new Load();
  +
  +             public Test(String name)
  +             {
  +                     super(name);
  +             }
  +
  +             /************************************************************
  +              *  !ToDo
  +              ***********************************************************/
  +             public void setUp()
  +             {
  +                     testFile1 = new File(System.getProperty("user.dir") + 
"/bin/testfiles", "Test Plan.jmx");
  +                     testFile2 = new File(System.getProperty("user.dir") + 
"/bin/testfiles", "Modification Manager.jmx");
  +             }
  +
  +             /************************************************************
  +              *  !ToDo
  +              *
  +              *@exception  Exception  !ToDo (Exception description)
  +              ***********************************************************/
  +             public void testUpdateTree() throws Exception
  +             {
  +
  +                     ListedHashTree tree = getTree(testFile2);
  +                     loader.updateTree(tree);
  +                     System.out.println(tree.list().get(0));
  +                     System.out.println(tree.list(tree.list().get(0)).get(0));
  +                     assertTrue(tree.list(tree.list().get(0)).get(0) instanceof 
LogicController);
  +             }
  +
  +             private ListedHashTree getTree(File f)
  +             {
  +                     try
  +                     {
  +                             FileInputStream reader = new FileInputStream(f);
  +                             XmlHandler handler =
  +                                             new XmlHandler(new 
JMeterNameSpaceHandler());
  +                             XMLReader parser = JMeterUtils.getXMLParser();
  +                             parser.setContentHandler(handler);
  +                             parser.setErrorHandler(handler);
  +                             parser.parse(new InputSource(reader));
  +                             ListedHashTree tree = handler.getDataTree();
  +                             return tree;
  +                     }
  +                     catch(Exception e)
  +                     {
  +                             return null;
  +                     }
  +             }
  +     }
  +     static
  +     {
  +             commands.add(JMeterUtils.RESOURCES.getString("open"));
  +     }
  +
  +}
  
  
  
  1.23      +4 -3      
jakarta-jmeter/src/org/apache/jmeter/protocol/http/sampler/HTTPSampler.java
  
  Index: HTTPSampler.java
  ===================================================================
  RCS file: 
/home/cvs/jakarta-jmeter/src/org/apache/jmeter/protocol/http/sampler/HTTPSampler.java,v
  retrieving revision 1.22
  retrieving revision 1.23
  diff -u -r1.22 -r1.23
  --- HTTPSampler.java  2001/08/16 23:36:56     1.22
  +++ HTTPSampler.java  2001/08/17 21:21:36     1.23
  @@ -6,7 +6,7 @@
    * companies.
    *
    * All rights reserved
  - * $Header: 
/home/cvs/jakarta-jmeter/src/org/apache/jmeter/protocol/http/sampler/HTTPSampler.java,v
 1.22 2001/08/16 23:36:56 mstover1 Exp $
  + * $Header: 
/home/cvs/jakarta-jmeter/src/org/apache/jmeter/protocol/http/sampler/HTTPSampler.java,v
 1.23 2001/08/17 21:21:36 mstover1 Exp $
    */
   package org.apache.jmeter.protocol.http.sampler;
   
  @@ -31,8 +31,8 @@
    *  HTTP requests, including cookies and authentication.
    *
    *@author     Michael Stover
  - *@created    $Date: 2001/08/16 23:36:56 $
  - *@version    $Revision: 1.22 $
  + *@created    $Date: 2001/08/17 21:21:36 $
  + *@version    $Revision: 1.23 $
    */
   public class HTTPSampler implements Sampler
   {
  @@ -360,6 +360,7 @@
                {
                        u = url.getUrl();
                        res.putValue(SampleResult.SAMPLE_LABEL, u.toString());
  +                     res.putValue(HTTPSampler.URL,u);
                                                                // specify the data to 
the result.
                                                                
res.putValue(HttpSampleResult.DATA, url);
   
  
  
  
  1.10      +2 -128    jakarta-jmeter/src/org/apache/jmeter/util/JMeterUtils.java
  
  Index: JMeterUtils.java
  ===================================================================
  RCS file: /home/cvs/jakarta-jmeter/src/org/apache/jmeter/util/JMeterUtils.java,v
  retrieving revision 1.9
  retrieving revision 1.10
  diff -u -r1.9 -r1.10
  --- JMeterUtils.java  2001/07/14 19:51:07     1.9
  +++ JMeterUtils.java  2001/08/17 21:21:36     1.10
  @@ -80,7 +80,7 @@
    *
    *@author     <a href="mailto:[EMAIL PROTECTED]";>Stefano Mazzocchi</a>
    *@created    June 28, 2001
  - *@version    $Revision: 1.9 $ $Date: 2001/07/14 19:51:07 $
  + *@version    $Revision: 1.10 $ $Date: 2001/08/17 21:21:36 $
    */
   
   public class JMeterUtils
  @@ -100,45 +100,27 @@
         *@param  file  Description of Parameter
         *@return       The Properties value
         */
  -
        public static Properties getProperties(String file)
        {
  -
  -
                Properties p = new Properties();
  -
  -
                try
                {
  -
                        File f = new File(file);
  -
                        p.load(new FileInputStream(f));
  -
                }
                catch (Exception e)
                {
  -
                        p.clear();
  -
                        try
                        {
  -
                                
p.load(JMeterUtils.class.getClassLoader().getSystemResourceAsStream("org/apache/jmeter/jmeter.properties"));
  -
                        }
                        catch (IOException ex)
                        {
  -
                                //JMeter.fail("Could not read internal resource. 
Archive is broken.");
  -
                        }
  -
                }
  -
  -
                appProperties = p;
  -
                return p;
        }
   
  @@ -147,21 +129,17 @@
                return RESOURCES.getString(key);
        }
   
  -
        /**
         *  This gets the currently defined appProperties. It can only be called after
         *  the getProperties(String file) method is called.
         *
         *@return    The JMeterProperties value
         */
  -
        public static Properties getJMeterProperties()
        {
  -
                return appProperties;
        }
   
  -
        /**
         *  This looks for the requested image in the classpath under
         *  org.apache.jmeter.images. <name>
  @@ -169,84 +147,58 @@
         *@param  name  Description of Parameter
         *@return       The Image value
         */
  -
        public static ImageIcon getImage(String name)
        {
  -
                return new 
ImageIcon(JMeterUtils.class.getClassLoader().getSystemResource("org/apache/jmeter/images/"
 + name));
        }
   
  -
        /**
         *  Creates the vector of Timers plugins.
         *
         *@param  properties  Description of Parameter
         *@return             The Timers value
         */
  -
        public static Vector getTimers(Properties properties)
        {
  -
                return instantiate(getVector(properties, "timer."), 
"org.apache.jmeter.timers.Timer");
        }
   
  -
        /**
         *  Creates the vector of visualizer plugins.
         *
         *@param  properties  Description of Parameter
         *@return             The Visualizers value
         */
  -
        public static Vector getVisualizers(Properties properties)
        {
  -
                return instantiate(getVector(properties, "visualizer."),
                                "org.apache.jmeter.visualizers.Visualizer");
        }
   
  -
        /**
         *  Creates a vector of SampleController plugins.
         *
         *@param  properties  The properties with information about the samplers
         *@return             The Controllers value
         */
  -
        public static Vector getControllers(Properties properties)
        {
  -
                String name = "controller.";
  -
                Vector v = new Vector();
  -
                Enumeration names = properties.keys();
  -
                while (names.hasMoreElements())
                {
  -
                        String prop = (String) names.nextElement();
  -
                        if (prop.startsWith(name))
                        {
  -
                                Object o = instantiate(properties.getProperty(prop),
                                                
"org.apache.jmeter.control.SamplerController");
  -
  -                             // 
((org.apache.jmeter.control.SamplerController)o).setPropName(
  -
  -                             //              prop.substring(name.length()));
  -
                                v.addElement(o);
  -
                        }
  -
                }
  -
                return v;
        }
   
  -
        /**
         *  Create a string of class names for a particular SamplerController
         *
  @@ -254,56 +206,44 @@
         *@param  name        The name of the sampler controller.
         *@return             The TestSamples value
         */
  -
        public static String[] getTestSamples(Properties properties, String name)
        {
  -
                return (String[]) getVector(properties, name + 
".testsample").toArray(new String[0]);
        }
   
  -
        /**
         *  Create an instance of an org.xml.sax.Parser
         *
         *@param  properties  The properties file containing the parser's class name
         *@return             The XMLParser value
         */
  -
        public static XMLReader getXMLParser(Properties properties)
        {
  -
                return (XMLReader) instantiate(properties.getProperty("xml.parser"),
                                "org.xml.sax.Parser");
        }
   
  -
        /**
         *  Create an instance of an org.xml.sax.Parser based on the default props.
         *
         *@return    The XMLParser value
         */
  -
        public static XMLReader getXMLParser()
        {
  -
                return getXMLParser(getJMeterProperties());
        }
   
  -
        /**
         *  Creates the vector of alias strings.
         *
         *@param  properties  Description of Parameter
         *@return             The Alias value
         */
  -
        public static Hashtable getAlias(Properties properties)
        {
  -
                return getHashtable(properties, "alias.");
        }
   
  -
        /**
         *  Creates a vector of strings for all the properties that start with a common
         *  prefix.
  @@ -312,32 +252,21 @@
         *@param  name        Description of Parameter
         *@return             The Vector value
         */
  -
        public static Vector getVector(Properties properties, String name)
        {
  -
                Vector v = new Vector();
  -
                Enumeration names = properties.keys();
  -
                while (names.hasMoreElements())
                {
  -
                        String prop = (String) names.nextElement();
  -
                        if (prop.startsWith(name))
                        {
  -
                                v.addElement(properties.getProperty(prop));
  -
                        }
  -
                }
  -
                return v;
        }
   
  -
        /**
         *  Creates a vector of strings for all the properties that start with a common
         *  prefix.
  @@ -346,32 +275,21 @@
         *@param  name        Description of Parameter
         *@return             The Hashtable value
         */
  -
        public static Hashtable getHashtable(Properties properties, String name)
        {
  -
                Hashtable t = new Hashtable();
  -
                Enumeration names = properties.keys();
  -
                while (names.hasMoreElements())
                {
  -
                        String prop = (String) names.nextElement();
  -
                        if (prop.startsWith(name))
                        {
  -
                                t.put(prop.substring(name.length()), 
properties.getProperty(prop));
  -
                        }
  -
                }
  -
                return t;
        }
   
  -
        /**
         *  Get a int value with default if not present.
         *
  @@ -379,30 +297,21 @@
         *@param  defaultVal  the default value.
         *@return             The PropDefault value
         */
  -
        public static int getPropDefault(String propName, int defaultVal)
        {
  -
                int ans;
  -
                try
                {
  -
                        ans = (Integer.valueOf(
                                        appProperties.getProperty(propName, 
Integer.toString(defaultVal)))).intValue();
  -
                }
                catch (Exception e)
                {
  -
                        ans = defaultVal;
  -
                }
  -
                return ans;
        }
   
  -
        /**
         *  Get a boolean value with default if not present.
         *
  @@ -410,50 +319,33 @@
         *@param  defaultVal  the default value.
         *@return             The PropDefault value
         */
  -
        public static boolean getPropDefault(String propName, boolean defaultVal)
        {
  -
                boolean ans;
  -
                try
                {
  -
                        String strVal = appProperties.getProperty(propName,
                                        (new Boolean(defaultVal)).toString());
  -
  -
                        if (strVal.equalsIgnoreCase("true") || 
strVal.equalsIgnoreCase("t"))
                        {
  -
                                ans = true;
                        }
  -
  -                     else
  -                                     if (strVal.equalsIgnoreCase("false") || 
strVal.equalsIgnoreCase("f"))
  +                     else if (strVal.equalsIgnoreCase("false") || 
strVal.equalsIgnoreCase("f"))
                        {
  -
                                ans = false;
                        }
  -
                        else
                        {
  -
                                ans = ((Integer.valueOf(strVal)).intValue() == 1);
                        }
  -
                }
                catch (Exception e)
                {
  -
                        ans = defaultVal;
  -
                }
  -
                return ans;
        }
   
  -
        /**
         *  Get a long value with default if not present.
         *
  @@ -461,29 +353,20 @@
         *@param  defaultVal  the default value.
         *@return             The PropDefault value
         */
  -
        public static long getPropDefault(String propName, long defaultVal)
        {
  -
                long ans;
  -
                try
                {
  -
                        ans = (Long.valueOf(appProperties.getProperty(propName, 
Long.toString(defaultVal)))).longValue();
  -
                }
                catch (Exception e)
                {
  -
                        ans = defaultVal;
  -
                }
  -
                return ans;
        }
   
  -
        /**
         *  Get a String value with default if not present.
         *
  @@ -491,28 +374,19 @@
         *@param  defaultVal  the default value.
         *@return             The PropDefault value
         */
  -
        public static String getPropDefault(String propName, String defaultVal)
        {
  -
                String ans;
  -
                try
                {
  -
                        ans = appProperties.getProperty(propName, defaultVal);
  -
                }
                catch (Exception e)
                {
  -
                        ans = defaultVal;
  -
                }
  -
                return ans;
        }
  -
   
        /**
         *  Sets the selection of the JComboBox to the Object 'name' from the list in
  
  
  
  1.7       +44 -27    jakarta-jmeter/src/org/apache/jmeter/util/ListedHashTree.java
  
  Index: ListedHashTree.java
  ===================================================================
  RCS file: /home/cvs/jakarta-jmeter/src/org/apache/jmeter/util/ListedHashTree.java,v
  retrieving revision 1.6
  retrieving revision 1.7
  diff -u -r1.6 -r1.7
  --- ListedHashTree.java       2001/07/27 21:35:44     1.6
  +++ ListedHashTree.java       2001/08/17 21:21:36     1.7
  @@ -213,6 +213,15 @@
         set(keys,values);
     }
   
  +  public void set(Collection values)
  +  {
  +     Iterator iter = this.list().iterator();
  +     while (iter.hasNext()) {
  +             this.remove(iter.next());
  +     }
  +     this.add(values);
  +  }
  +
   /********************************************************************
     Sets a series of keys into the ListedHashTree.  It sets up the first object in the
     key list as a key in the current node, recurses into the next ListedHashTree node 
through
  @@ -236,6 +245,14 @@
         }
     }
   
  +  public void replace(Object currentKey,Object newKey)
  +  {
  +     ListedHashTree tree = this.get(currentKey);
  +     data.remove(currentKey);
  +     data.put(newKey,tree);
  +     order.set(order.indexOf(currentKey),newKey);
  +  }
  +
   /********************************************************************
     Sets a series of keys into the ListedHashTree.  It sets up the first object in the
     key list as a key in the current node, recurses into the next ListedHashTree node 
through
  @@ -842,37 +859,37 @@
     private List order;
   
     /** The method debugs the entire tree all the way down (recursively)adding a tab 
at each level.
  -       The debugging is only supported on the log4j output files.
  -       @param numTabs The number of tabs (preferably make the first call with a 
value 0)
  +       The debugging is only supported on the log4j output files.
  +       @param numTabs The number of tabs (preferably make the first call with a 
value 0)
     */
     public void debugDeep(int numTabs){
  -       if(!log.isDebugEnabled())
  -             return;
  -       if(numTabs == 0 && order.size() > 0)
  -             log.debug("==============Starting the debugDeep:" + this + 
"===============");
  -
  -       StringBuffer tabBuffer = new StringBuffer(numTabs);
  -       for(int i = 0; i < numTabs; i++)
  -             tabBuffer.append("\t");
  -       String tabs = tabBuffer.toString();
  -
  -       for(Iterator iter = order.iterator(); iter.hasNext();){
  -               Object obj = iter.next();
  -               log.debug(tabs + obj);
  -               ListedHashTree tree = get(obj);
  -               tree.debugDeep(numTabs + 1);
  -             }
  -       if(numTabs == 0  && order.size() > 0)
  -             log.debug("==============Ending the debugDeep===============");
  -    }
  +       if(!log.isDebugEnabled())
  +             return;
  +       if(numTabs == 0 && order.size() > 0)
  +             log.debug("==============Starting the debugDeep:" + this + 
"===============");
  +
  +       StringBuffer tabBuffer = new StringBuffer(numTabs);
  +       for(int i = 0; i < numTabs; i++)
  +             tabBuffer.append("\t");
  +       String tabs = tabBuffer.toString();
  +
  +       for(Iterator iter = order.iterator(); iter.hasNext();){
  +               Object obj = iter.next();
  +               log.debug(tabs + obj);
  +               ListedHashTree tree = get(obj);
  +               tree.debugDeep(numTabs + 1);
  +                     }
  +       if(numTabs == 0  && order.size() > 0)
  +             log.debug("==============Ending the debugDeep===============");
  +      }
   
        /** Debugs all the elements in the current ListedHashTree
        */
  -    public void debugShallow(){
  -       if(!log.isDebugEnabled())
  -             return;
  -       for(Iterator iter = order.iterator(); iter.hasNext();)
  -               log.debug(iter.next());
  -    }
  +      public void debugShallow(){
  +       if(!log.isDebugEnabled())
  +             return;
  +       for(Iterator iter = order.iterator(); iter.hasNext();)
  +               log.debug(iter.next());
  +      }
   
   }
  
  
  

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

Reply via email to