khammond    01/09/28 23:15:05

  Modified:    src/org/apache/jmeter/gui/action Load.java
  Log:
  Command action was being using JMeterUtils, which is correct.  But, it was accessing 
the RESOURCE field directly instead of using the getter method.  I changed it to use 
the getter method, getResString(String).
  
  Revision  Changes    Path
  1.10      +250 -251  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.9
  retrieving revision 1.10
  diff -u -r1.9 -r1.10
  --- Load.java 2001/08/31 00:46:43     1.9
  +++ Load.java 2001/09/29 06:15:05     1.10
  @@ -1,251 +1,250 @@
  -/*
  - * ====================================================================
  - * 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.*;
  -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/31 00:46:43 $
  - *@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/31 00:46:43 $
  -      *@version    $Revision: 1.9 $
  -      ***********************************************************/
  -     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"));
  -     }
  -
  -}
  +/*
  + * ====================================================================
  + * 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.xml.sax.XMLReader;
  +
  +import org.apache.xerces.parsers.SAXParser;
  +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 org.apache.jmeter.control.LogicController;
  +
  +import junit.framework.*;
  +
  +/************************************************************
  + *  Title: JMeter Description: Copyright: Copyright (c) 2000 Company: Apache
  + *
  + *@author     Michael Stover
  + *@created    $Date: 2001/09/29 06:15:05 $
  + *@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: khammond $
  +      *@created    $Date: 2001/09/29 06:15:05 $
  +      *@version    $Revision: 1.10 $
  +      ***********************************************************/
  +     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.getResString("open"));
  +     }
  +}
  
  
  

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

Reply via email to