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/06/01 15:21:28 UTC
cvs commit: jakarta-jmeter/src_1/org/apache/jmeter/threads JMeterThread.java
mstover1 2002/06/01 06:21:28
Modified: src_1/org/apache/jmeter/engine JMeterEngine.java
StandardJMeterEngine.java
src_1/org/apache/jmeter/gui MainFrame.java
src_1/org/apache/jmeter/gui/action Load.java
RemoteStart.java
src_1/org/apache/jmeter/gui/util VerticalLayout.java
src_1/org/apache/jmeter/protocol/ftp/sampler FTPSampler.java
src_1/org/apache/jmeter/protocol/http/config/gui
UrlConfigGui.java
src_1/org/apache/jmeter/protocol/http/sampler
HTTPSampler.java
src_1/org/apache/jmeter/protocol/jdbc/sampler
JDBCSampler.java
src_1/org/apache/jmeter/testelement TestPlan.java
src_1/org/apache/jmeter/threads JMeterThread.java
Added: src_1/org/apache/jmeter/save/old BadHandlerException.java
JMeterNameSpaceHandler.java SaveHandler.java
Saveable.java
src_1/org/apache/jmeter/save/old/handlers
AbstractConfigElementHandler.java
ArgumentsHandler.java AssertionHandler.java
AuthManagerHandler.java CookieManagerHandler.java
FilerHandler.java FtpTestHandler.java
GenericControllerHandler.java
HeaderManagerHandler.java
HttpTestSampleHandler.java
JMeterComponentHandler.java JMeterHandler.java
JdbcTestSampleHandler.java LoopControlHandler.java
ParamMaskHandler.java ProxyControlHandler.java
TestPlanHandler.java ThreadGroupHandler.java
TimerHandler.java
src_1/org/apache/jmeter/save/old/xml NameSpaceHandler.java
NoCurrentHandlerException.java TagHandler.java
XmlHandler.java
Log:
Fixing minor GUI refresh issues (Martin Ramshaw)
Adding backwards compatibility with JMeter 1.7 saved test scripts
Revision Changes Path
1.4 +0 -0 jakarta-jmeter/src_1/org/apache/jmeter/engine/JMeterEngine.java
Index: JMeterEngine.java
===================================================================
RCS file: /home/cvs/jakarta-jmeter/src_1/org/apache/jmeter/engine/JMeterEngine.java,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- JMeterEngine.java 31 May 2002 01:34:56 -0000 1.3
+++ JMeterEngine.java 1 Jun 2002 13:21:26 -0000 1.4
@@ -61,7 +61,7 @@
* Title: JMeter Description: Copyright: Copyright (c) 2000 Company: Apache
*
*@author Michael Stover
- *@created $Date: 2002/05/31 01:34:56 $
+ *@created $Date: 2002/06/01 13:21:26 $
*@version 1.0
***********************************************************/
1.10 +0 -0 jakarta-jmeter/src_1/org/apache/jmeter/engine/StandardJMeterEngine.java
Index: StandardJMeterEngine.java
===================================================================
RCS file: /home/cvs/jakarta-jmeter/src_1/org/apache/jmeter/engine/StandardJMeterEngine.java,v
retrieving revision 1.9
retrieving revision 1.10
diff -u -r1.9 -r1.10
--- StandardJMeterEngine.java 31 May 2002 01:34:56 -0000 1.9
+++ StandardJMeterEngine.java 1 Jun 2002 13:21:26 -0000 1.10
@@ -72,8 +72,8 @@
* !ToDo (Class description)
*
*@author $Author: mstover1 $
- *@created $Date: 2002/05/31 01:34:56 $
- *@version $Revision: 1.9 $
+ *@created $Date: 2002/06/01 13:21:26 $
+ *@version $Revision: 1.10 $
***********************************************************/
public class StandardJMeterEngine implements JMeterEngine,JMeterThreadMonitor
{
1.9 +5 -5 jakarta-jmeter/src_1/org/apache/jmeter/gui/MainFrame.java
Index: MainFrame.java
===================================================================
RCS file: /home/cvs/jakarta-jmeter/src_1/org/apache/jmeter/gui/MainFrame.java,v
retrieving revision 1.8
retrieving revision 1.9
diff -u -r1.8 -r1.9
--- MainFrame.java 28 May 2002 17:30:18 -0000 1.8
+++ MainFrame.java 1 Jun 2002 13:21:26 -0000 1.9
@@ -70,7 +70,7 @@
* Title: JMeter Description: Copyright: Copyright (c) 2000 Company: Apache
*
*@author Michael Stover
- *@created $Date: 2002/05/28 17:30:18 $
+ *@created $Date: 2002/06/01 13:21:26 $
*@version 1.0
***************************************/
@@ -226,8 +226,8 @@
comp.setPreferredSize(dim);
comp.validate();
mainPanel.add(comp);
- all.validate();
- all.repaint();
+ mainPanel.validate();
+ mainPanel.repaint();
}
/****************************************
@@ -403,8 +403,8 @@
* !ToDo (Class description)
*
*@author $Author: mstover1 $
- *@created $Date: 2002/05/28 17:30:18 $
- *@version $Revision: 1.8 $
+ *@created $Date: 2002/06/01 13:21:26 $
+ *@version $Revision: 1.9 $
***************************************/
private class WindowHappenings extends WindowAdapter
{
1.6 +96 -56 jakarta-jmeter/src_1/org/apache/jmeter/gui/action/Load.java
Index: Load.java
===================================================================
RCS file: /home/cvs/jakarta-jmeter/src_1/org/apache/jmeter/gui/action/Load.java,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -r1.5 -r1.6
--- Load.java 17 May 2002 01:29:34 -0000 1.5
+++ Load.java 1 Jun 2002 13:21:26 -0000 1.6
@@ -54,28 +54,39 @@
*/
package org.apache.jmeter.gui.action;
import java.awt.event.ActionEvent;
-import java.io.*;
-import java.util.*;
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.util.HashSet;
+import java.util.Iterator;
+import java.util.LinkedList;
+import java.util.List;
+import java.util.Set;
+
import javax.swing.JFileChooser;
-import org.xml.sax.InputSource;
-import org.xml.sax.XMLReader;
-import junit.framework.*;
+import org.apache.jmeter.control.GenericController;
import org.apache.jmeter.exceptions.IllegalUserActionException;
-import org.apache.jmeter.gui.*;
+import org.apache.jmeter.gui.GuiPackage;
+import org.apache.jmeter.gui.JMeterGUIComponent;
import org.apache.jmeter.gui.util.FileDialoger;
import org.apache.jmeter.protocol.http.config.UrlConfig;
-import org.apache.jmeter.save.*;
-import org.apache.jmeter.util.*;
-import org.apache.xerces.parsers.SAXParser;
+import org.apache.jmeter.protocol.http.sampler.HTTPSampler;
import org.apache.jmeter.save.SaveService;
-import org.apache.jmeter.gui.tree.JMeterTreeNode;
+import org.apache.jmeter.save.old.JMeterNameSpaceHandler;
+import org.apache.jmeter.save.old.xml.XmlHandler;
import org.apache.jmeter.testelement.TestElement;
+import org.apache.jmeter.util.JMeterUtils;
+import org.apache.jmeter.util.ListedHashTree;
+import org.xml.sax.InputSource;
+import org.xml.sax.SAXException;
+import org.xml.sax.XMLReader;
/****************************************
* Title: JMeter Description: Copyright: Copyright (c) 2000 Company: Apache
*
*@author Michael Stover
- *@created $Date: 2002/05/17 01:29:34 $
+ *@created $Date: 2002/06/01 13:21:26 $
*@version 1.0
***************************************/
public class Load implements Command
@@ -115,18 +126,15 @@
return;
}
InputStream reader = null;
+ File f = null;
try
{
- File f = chooser.getSelectedFile();
+ f = chooser.getSelectedFile();
if(f != null)
{
reader = new FileInputStream(f);
ListedHashTree tree = SaveService.loadSubTree(reader);
- convertTree(tree);
- GuiPackage.getInstance().addSubTree(tree);
- tree = GuiPackage.getInstance().getCurrentSubTree();
- ActionRouter.getInstance().actionPerformed(new ActionEvent(
- tree.get(tree.getArray()[tree.size()-1]),e.getID(),CheckDirty.SUB_TREE_LOADED));
+ insertLoadedTree(e.getID(), tree);
}
}
catch(IllegalUserActionException ex)
@@ -135,8 +143,17 @@
}
catch(Throwable ex)
{
- ex.printStackTrace();
- JMeterUtils.reportErrorToUser("Couldn't load JMX file. May have been corrupted");
+ System.out.println("New loading didn't work, try legacy");
+ try
+ {
+ legacyLoad(f);
+ }
+ catch(Throwable err)
+ {
+ //ex.printStackTrace();
+ err.printStackTrace();
+ JMeterUtils.reportErrorToUser("Couldn't load JMX file. May have been corrupted");
+ }
}
finally
{
@@ -144,6 +161,14 @@
}
}
+ private void insertLoadedTree(int id, ListedHashTree tree) throws Exception, IllegalUserActionException {
+ convertTree(tree);
+ GuiPackage.getInstance().addSubTree(tree);
+ tree = GuiPackage.getInstance().getCurrentSubTree();
+ ActionRouter.getInstance().actionPerformed(new ActionEvent(
+ tree.get(tree.getArray()[tree.size()-1]),id,CheckDirty.SUB_TREE_LOADED));
+ }
+
private void convertTree(ListedHashTree tree) throws Exception
{
Iterator iter = new LinkedList(tree.list()).iterator();
@@ -158,53 +183,68 @@
private JMeterGUIComponent generateGUIComponent(TestElement item) throws Exception
{
+ System.out.println("getting gui for: "+item);
JMeterGUIComponent gui = (JMeterGUIComponent)Class.forName((String)item.getProperty(TestElement.GUI_CLASS)).newInstance();
gui.configure(item);
return gui;
}
-/* This was the logic for backward compatibility from 1.6 to 1.7
-/*
- private void updateTree(ListedHashTree tree)
+
+ private void legacyLoad(File f) throws Exception
{
- List items = new LinkedList(tree.list());
- Iterator iter = items.iterator();
+ 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();
+ updateTree(tree);
+ insertLoadedTree(443,tree);
+ }
- while(iter.hasNext())
- {
- Object item = iter.next();
- 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();
- if(config instanceof UrlConfig)
- {
- replaced = true;
- HttpTestSample newControl = new HttpTestSample();
- newControl.setDefaultUrl((UrlConfig)config);
- if(config instanceof UrlConfigFull)
- {
- newControl.setGetImages(true);
+
+ /**
+ * For loading a 1.6 version test tree
+ * */
+ private void updateTree(ListedHashTree tree) {
+ List items = new LinkedList(tree.list());
+ Iterator iter = items.iterator();
+
+ while (iter.hasNext()) {
+ Object item = iter.next();
+ if (item instanceof HTTPSampler) {
+ List subItems = new LinkedList(tree.list(item));
+ boolean replaced = false;
+ Iterator iter2 = subItems.iterator();
+ while (iter2.hasNext()) {
+ TestElement config = (TestElement)iter2.next();
+ if (config.getPropertyAsString(TestElement.TEST_CLASS).equals(
+ "org.apache.jmeter.protocol.http.config.UrlConfig")) {
+ replaced = true;
+ HTTPSampler newControl = new HTTPSampler();
+ newControl.setName((String)((TestElement)item).getProperty(TestElement.NAME));
+ newControl.addTestElement( config);
+ newControl.setProperty(TestElement.GUI_CLASS,
+ "org.apache.jmeter.protocol.http.control.gui.HttpTestSampleGui");
+ tree.get(item).replace(config, newControl);
}
- 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);
+ if (replaced) {
+ UrlConfig newConfig = ((HTTPSampler) item).makeUrlConfig();
+ newConfig.setProperty(TestElement.GUI_CLASS,
+ "org.apache.jmeter.protocol.http.config.gui.UrlConfigGui");
+ newConfig.setName("HTTP Request Defaults");
+ GenericController newControl = new GenericController();
+ newControl.setProperty(TestElement.GUI_CLASS,
+ "org.apache.jmeter.control.gui.LogicControllerGui");
+ newControl.setName("Simple Controller");
+ tree.replace(item, newControl);
+ tree.add(newControl, newConfig);
+ }
+ } else {
+ updateTree(tree.get(item));
}
}
- else
- {
- updateTree(tree.get(item));
- }
}
- }*/
}
1.6 +0 -0 jakarta-jmeter/src_1/org/apache/jmeter/gui/action/RemoteStart.java
Index: RemoteStart.java
===================================================================
RCS file: /home/cvs/jakarta-jmeter/src_1/org/apache/jmeter/gui/action/RemoteStart.java,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -r1.5 -r1.6
--- RemoteStart.java 31 May 2002 01:34:57 -0000 1.5
+++ RemoteStart.java 1 Jun 2002 13:21:26 -0000 1.6
@@ -69,7 +69,7 @@
* Title: Description: Copyright: Copyright (c) 2001 Company:
*
*@author Michael Stover
- *@created $Date: 2002/05/31 01:34:57 $
+ *@created $Date: 2002/06/01 13:21:26 $
*@version 1.0
***************************************/
1.4 +3 -3 jakarta-jmeter/src_1/org/apache/jmeter/gui/util/VerticalLayout.java
Index: VerticalLayout.java
===================================================================
RCS file: /home/cvs/jakarta-jmeter/src_1/org/apache/jmeter/gui/util/VerticalLayout.java,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- VerticalLayout.java 29 May 2002 22:52:35 -0000 1.3
+++ VerticalLayout.java 1 Jun 2002 13:21:26 -0000 1.4
@@ -67,8 +67,8 @@
*@author Colin Mummery e-mail:equitysoft@iname.com
* Homepage:www.kagi.com/equitysoft - Based on 'FlexLayout' in Java class
* libraries Vol 2 Chan/Lee Addison-Wesley 1998
- *@created $Date: 2002/05/29 22:52:35 $
- *@version $Revision: 1.3 $
+ *@created $Date: 2002/06/01 13:21:26 $
+ *@version $Revision: 1.4 $
***************************************/
public class VerticalLayout implements LayoutManager
@@ -231,7 +231,7 @@
***************************************/
public Dimension minimumLayoutSize(Container parent)
{
- return layoutSize(parent, false);
+ return layoutSize(parent, true);
}
//-----------------------------------------------------------------------------
/****************************************
1.8 +0 -0 jakarta-jmeter/src_1/org/apache/jmeter/protocol/ftp/sampler/FTPSampler.java
Index: FTPSampler.java
===================================================================
RCS file: /home/cvs/jakarta-jmeter/src_1/org/apache/jmeter/protocol/ftp/sampler/FTPSampler.java,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -r1.7 -r1.8
--- FTPSampler.java 31 May 2002 01:34:57 -0000 1.7
+++ FTPSampler.java 1 Jun 2002 13:21:26 -0000 1.8
@@ -68,8 +68,8 @@
* A sampler which understands FTP file requests
*
*@author $Author: mstover1 $
- *@created $Date: 2002/05/31 01:34:57 $
- *@version $Revision: 1.7 $
+ *@created $Date: 2002/06/01 13:21:26 $
+ *@version $Revision: 1.8 $
***********************************************************/
public class FTPSampler extends AbstractSampler
1.7 +3 -3 jakarta-jmeter/src_1/org/apache/jmeter/protocol/http/config/gui/UrlConfigGui.java
Index: UrlConfigGui.java
===================================================================
RCS file: /home/cvs/jakarta-jmeter/src_1/org/apache/jmeter/protocol/http/config/gui/UrlConfigGui.java,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -r1.6 -r1.7
--- UrlConfigGui.java 23 May 2002 15:47:05 -0000 1.6
+++ UrlConfigGui.java 1 Jun 2002 13:21:27 -0000 1.7
@@ -73,7 +73,7 @@
* Title: JMeter Description: Copyright: Copyright (c) 2000 Company: Apache
*
*@author Michael Stover
- *@created $Date: 2002/05/23 15:47:05 $
+ *@created $Date: 2002/06/01 13:21:27 $
*@version 1.0
***************************************/
@@ -178,7 +178,7 @@
argsPanel.configure((TestElement)el.getProperty(HTTPSampler.ARGUMENTS));
domain.setText((String)el.getProperty(HTTPSampler.DOMAIN));
port.setText((String)el.getPropertyAsString(HTTPSampler.PORT));
- if(el.getProperty(HTTPSampler.METHOD).equals("POST"))
+ if("POST".equals(el.getProperty(HTTPSampler.METHOD)))
{
post.setSelected(true);
get.setSelected(false);
@@ -189,7 +189,7 @@
post.setSelected(false);
}
path.setText((String)el.getProperty(HTTPSampler.PATH));
- if(el.getProperty(HTTPSampler.PROTOCOL).equals("http"))
+ if("http".equals(el.getProperty(HTTPSampler.PROTOCOL)))
{
http.setSelected(true);
https.setSelected(false);
1.12 +3 -3 jakarta-jmeter/src_1/org/apache/jmeter/protocol/http/sampler/HTTPSampler.java
Index: HTTPSampler.java
===================================================================
RCS file: /home/cvs/jakarta-jmeter/src_1/org/apache/jmeter/protocol/http/sampler/HTTPSampler.java,v
retrieving revision 1.11
retrieving revision 1.12
diff -u -r1.11 -r1.12
--- HTTPSampler.java 29 May 2002 23:35:56 -0000 1.11
+++ HTTPSampler.java 1 Jun 2002 13:21:27 -0000 1.12
@@ -80,8 +80,8 @@
* HTTP requests, including cookies and authentication.
*
*@author Michael Stover
- *@created $Date: 2002/05/29 23:35:56 $
- *@version $Revision: 1.11 $
+ *@created $Date: 2002/06/01 13:21:27 $
+ *@version $Revision: 1.12 $
***************************************/
public class HTTPSampler extends AbstractSampler
{
@@ -333,7 +333,7 @@
return makeUrlConfig().getQueryString();
}
- protected UrlConfig makeUrlConfig()
+ public UrlConfig makeUrlConfig()
{
MultipartUrlConfig config = new MultipartUrlConfig();
config.setDomain(getDomain());
1.9 +0 -0 jakarta-jmeter/src_1/org/apache/jmeter/protocol/jdbc/sampler/JDBCSampler.java
Index: JDBCSampler.java
===================================================================
RCS file: /home/cvs/jakarta-jmeter/src_1/org/apache/jmeter/protocol/jdbc/sampler/JDBCSampler.java,v
retrieving revision 1.8
retrieving revision 1.9
diff -u -r1.8 -r1.9
--- JDBCSampler.java 31 May 2002 01:34:57 -0000 1.8
+++ JDBCSampler.java 1 Jun 2002 13:21:27 -0000 1.9
@@ -71,8 +71,8 @@
* A sampler which understands JDBC database requests
*
*@author $Author: mstover1 $
- *@created $Date: 2002/05/31 01:34:57 $
- *@version $Revision: 1.8 $
+ *@created $Date: 2002/06/01 13:21:27 $
+ *@version $Revision: 1.9 $
***********************************************************/
public class JDBCSampler extends AbstractSampler implements TestListener
1.1 jakarta-jmeter/src_1/org/apache/jmeter/save/old/BadHandlerException.java
Index: BadHandlerException.java
===================================================================
/*
* ====================================================================
* 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/>.
*/
/**
* Title: JMeter<p>
* Description: <p>
* Copyright: Copyright (c) Michael Stover<p>
* Company: Apache JMeter<p>
* @author Michael Stover
* @version 1.0
*/
package org.apache.jmeter.save.old;
public class BadHandlerException extends Exception
{
String message;
public BadHandlerException()
{
}
public BadHandlerException(String m)
{
message = m;
}
public String getMessage()
{
return message;
}
}
1.1 jakarta-jmeter/src_1/org/apache/jmeter/save/old/JMeterNameSpaceHandler.java
Index: JMeterNameSpaceHandler.java
===================================================================
/*
* ====================================================================
* 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.save.old;
import java.io.File;
import java.io.FileInputStream;
import java.util.HashMap;
import java.util.Iterator;
import java.util.LinkedList;
import java.util.List;
import java.util.Map;
import junit.framework.TestCase;
import org.apache.jmeter.control.GenericController;
import org.apache.jmeter.gui.action.Load;
import org.apache.jmeter.protocol.http.config.UrlConfig;
import org.apache.jmeter.protocol.http.sampler.HTTPSampler;
import org.apache.jmeter.save.old.xml.NameSpaceHandler;
import org.apache.jmeter.save.old.xml.TagHandler;
import org.apache.jmeter.save.old.xml.XmlHandler;
import org.apache.jmeter.testelement.TestElement;
import org.apache.jmeter.util.ClassFinder;
import org.apache.jmeter.util.JMeterUtils;
import org.apache.jmeter.util.ListedHashTree;
import org.xml.sax.Attributes;
import org.xml.sax.InputSource;
import org.xml.sax.XMLReader;
/**
* Title: JMeter
* Description:
* Copyright: Copyright (c) 2000
* Company: Apache
* @author Michael Stover
* @version 1.0
*/
public class JMeterNameSpaceHandler implements NameSpaceHandler {
private static Map saveHandlers = new HashMap();
static {
try {
List classes =
ClassFinder.findClassesThatExtend(
new Class[] { org.apache.jmeter.save.old.xml.TagHandler.class });
Iterator iter = classes.iterator();
while (iter.hasNext()) {
String item = (String) iter.next();
try {
TagHandler obj = (TagHandler) Class.forName(item).newInstance();
saveHandlers.put(obj.getPrimaryTagName(), obj.getClass());
} catch (Exception ex) {
ex.printStackTrace();
}
}
} catch (Exception ex) {
ex.printStackTrace();
}
}
public JMeterNameSpaceHandler() {
}
public TagHandler getXmlObject(String tagName, Attributes atts) {
try {
TagHandler handler =
(TagHandler) ((Class) saveHandlers.get(tagName)).newInstance();
handler.setTagName(handler.getPrimaryTagName());
handler.setAtts(atts);
return handler;
} catch (Exception ex) {
//ex.printStackTrace();
return null;
}
}
/************************************************************
* !ToDo (Class description)
*
*@author $Author: mstover1 $
*@created $Date: 2002/06/01 13:21:27 $
*@version $Revision: 1.1 $
***********************************************************/
public static class Test extends TestCase {
File testFile1, testFile2, testFile3;
static Load loader = new Load();
public Test(String name) {
super(name);
}
private void updateTree(ListedHashTree tree) {
List items = new LinkedList(tree.list());
Iterator iter = items.iterator();
while (iter.hasNext()) {
Object item = iter.next();
if (item instanceof HTTPSampler) {
List subItems = new LinkedList(tree.list(item));
boolean replaced = false;
Iterator iter2 = subItems.iterator();
while (iter2.hasNext()) {
TestElement config = (TestElement)iter2.next();
if (config.getPropertyAsString(TestElement.TEST_CLASS).equals(
"org.apache.jmeter.protocol.http.config.UrlConfig")) {
replaced = true;
HTTPSampler newControl = new HTTPSampler();
newControl.addTestElement( config);
tree.get(item).replace(config, newControl);
}
}
if (replaced) {
UrlConfig newConfig = ((HTTPSampler) item).makeUrlConfig();
GenericController newControl = new GenericController();
tree.replace(item, newControl);
tree.add(newControl, newConfig);
}
} else {
updateTree(tree.get(item));
}
}
}
/************************************************************
* !ToDo
***********************************************************/
public void setUp() {
testFile1 =
new File(System.getProperty("user.dir") + "/testfiles", "Test Plan.jmx");
testFile2 =
new File(
System.getProperty("user.dir") + "/testfiles",
"Modification Manager.jmx");
testFile3 =
new File(System.getProperty("user.dir") + "/testfiles", "proxy.jmx");
}
/************************************************************
* !ToDo
*
*@exception Exception !ToDo (Exception description)
***********************************************************/
public void testUpdateTree() throws Exception {
ListedHashTree tree = getTree(testFile2);
updateTree(tree);
assertTrue(tree.list(tree.list().get(0)).get(0) instanceof GenericController);
}
public void testFile3() throws Exception {
ListedHashTree tree = getTree(testFile3);
//loader.updateTree(tree);
assertTrue(tree.list().get(0) instanceof org.apache.jmeter.threads.ThreadGroup);
}
private ListedHashTree getTree(File f) throws Exception {
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;
}
}
}
1.1 jakarta-jmeter/src_1/org/apache/jmeter/save/old/SaveHandler.java
Index: SaveHandler.java
===================================================================
/*
* ====================================================================
* 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.save.old;
import java.io.*;
/**
* Title: JMeter
* Description:
* Copyright: Copyright (c) 2000
* Company: Apache
* @author Michael Stover
* @version 1.0
*/
public interface SaveHandler
{
/**
* Gets the tag name that will trigger the use of this object's TagHandler.
*/
public String getPrimaryTagName();
/**
* Tells the object to save itself to the given output stream.
*/
public void save(Saveable objectToSave,Writer out) throws IOException;
}
1.1 jakarta-jmeter/src_1/org/apache/jmeter/save/old/Saveable.java
Index: Saveable.java
===================================================================
/*
* ====================================================================
* 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/>.
*/
/**
* Title: JMeter<p>
* Description: <p>
* Copyright: Copyright (c) Michael Stover<p>
* Company: Apache JMeter<p>
* @author Michael Stover
* @version 1.0
*/
package org.apache.jmeter.save.old;
import java.io.*;
import org.xml.sax.*;
import org.apache.jmeter.save.old.xml.*;
public interface Saveable
{
/**
* Gets the TagHandler that will handle the parsing of the xml for this type of
* object.
*/
public Class getTagHandlerClass();
}
1.1 jakarta-jmeter/src_1/org/apache/jmeter/save/old/handlers/AbstractConfigElementHandler.java
Index: AbstractConfigElementHandler.java
===================================================================
/*
* ====================================================================
* 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.save.old.handlers;
import java.io.IOException;
import java.io.Writer;
import java.util.List;
import org.apache.jmeter.config.ConfigTestElement;
import org.apache.jmeter.protocol.http.sampler.HTTPSampler;
import org.apache.jmeter.save.old.Saveable;
import org.apache.jmeter.save.old.xml.TagHandler;
import org.apache.jmeter.testelement.TestElement;
import org.xml.sax.Attributes;
/************************************************************
* Title: JMeter Description: Copyright: Copyright (c) 2000 Company: Apache
*
*@author Michael Stover
*@created June 9, 2001
*@version 1.0
***********************************************************/
public class AbstractConfigElementHandler extends TagHandler
{
protected ConfigTestElement config;
protected String currentProperty;
/************************************************************
* Constructor for the AbstractConfigElementHandler object
***********************************************************/
public AbstractConfigElementHandler()
{
}
/************************************************************
* This is called when a tag is first encountered for this handler class to
* handle. The attributes of the tag are passed, and the SaveHandler object is
* expected to instantiate a new object.
*
*@param atts The new Atts value
*@exception Exception Description of Exception
***********************************************************/
public void setAtts(Attributes atts) throws Exception
{
config = new ConfigTestElement();//(AbstractConfigElement)Class.forName(className).newInstance();
config.setProperty(TestElement.TEST_CLASS,atts.getValue("type"));
config.setProperty(TestElement.GUI_CLASS,JMeterHandler.getGuiClass(atts.getValue("type")));
}
/************************************************************
* Returns the AbstractConfigElement object parsed from the XML. This method
* is required to fulfill the SaveHandler interface. It is used by the XML
* routines to gather all the saved objects.
*
*@return The Model value
***********************************************************/
public Object getModel()
{
return config;
}
/************************************************************
* Gets the tag name that will trigger the use of this object's TagHandler.
*
*@return The PrimaryTagName value
***********************************************************/
public String getPrimaryTagName()
{
return "ConfigElement";
}
/************************************************************
* Called by reflection when a <property> tag is encountered. Again, the
* attributes are passed.
*
*@param atts Description of Parameter
***********************************************************/
public void property(Attributes atts)
{
currentProperty = atts.getValue("name");
}
/************************************************************
* Called by reflection when text between the begin and end <property>
* tag is encountered.
*
*@param data Description of Parameter
***********************************************************/
public void property(String data)
{
if(data != null && data.trim().length() > 0)
{
config.setProperty(JMeterHandler.convertProperty(currentProperty), data.trim());
currentProperty = null;
}
}
/************************************************************
* Called by reflection when the <property> tag is ended.
***********************************************************/
public void propertyTagEnd()
{
List children = xmlParent.takeChildObjects(this);
if(children.size() == 1)
{
config.setProperty(JMeterHandler.convertProperty(currentProperty), ((TagHandler)children.get(0)).getModel());
}
}
/************************************************************
* Tells the object to save itself to the given output stream.
*
*@param obj Description of Parameter
*@param out Description of Parameter
*@exception IOException Description of Exception
***********************************************************/
public void save(Saveable obj, Writer out) throws IOException
{
/*
AbstractConfigElement saved = (AbstractConfigElement)obj;
out.write("<ConfigElement type=\"");
out.write(JMeterHandler.convertToXML(saved.getClass().getName()));
out.write("\">\n");
Iterator iter = saved.getPropertyNames().iterator();
while(iter.hasNext())
{
String key = (String)iter.next();
Object value = saved.getProperty(key);
writeProperty(out, key, value);
}
out.write("</ConfigElement>");*/
}
/************************************************************
* Routine to write each property to xml.
*
*@param out Description of Parameter
*@param key Description of Parameter
*@param value Description of Parameter
*@exception IOException Description of Exception
***********************************************************/
protected void writeProperty(Writer out, String key, Object value) throws IOException
{
out.write("<property name=\"");
out.write(JMeterHandler.convertToXML(key));
out.write("\">");
JMeterHandler.writeObject(value, out);
out.write("</property>\n");
}
}
1.1 jakarta-jmeter/src_1/org/apache/jmeter/save/old/handlers/ArgumentsHandler.java
Index: ArgumentsHandler.java
===================================================================
/*
* ====================================================================
* 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.save.old.handlers;
import java.io.IOException;
import java.io.Writer;
import java.util.Iterator;
import org.apache.jmeter.config.Argument;
import org.apache.jmeter.config.Arguments;
import org.apache.jmeter.save.old.Saveable;
import org.apache.jmeter.save.old.xml.TagHandler;
import org.apache.jmeter.testelement.TestElement;
import org.xml.sax.Attributes;
/**
* Title: JMeter
* Description:
* Copyright: Copyright (c) 2000
* Company: Apache
* @author Michael Stover
* @version 1.0
*/
public class ArgumentsHandler extends TagHandler
{
Arguments args;
String currentArgument;
public ArgumentsHandler()
{
}
public void save(Saveable parm1, Writer out) throws java.io.IOException
{
Arguments args = (Arguments)parm1;
out.write("<Arguments>\n");
Iterator iter = args.iterator();
while (iter.hasNext())
{
writeArgument((Argument)iter.next(),out);
}
out.write("</Arguments>\n");
}
private void writeArgument(Argument arg,Writer out) throws IOException
{
out.write("<argument name=\"");
out.write(JMeterHandler.convertToXML(arg.getName()));
out.write("\">");
try
{
out.write(JMeterHandler.convertToXML(" "+arg.getValue().toString()));
}
catch (Exception ex)
{
}
out.write("</argument>\n");
}
public void setAtts(Attributes atts) throws java.lang.Exception
{
args = new Arguments();
args.setProperty(TestElement.GUI_CLASS,"org.apache.jmeter.config.gui.ArgumentsPanel");
}
public String getPrimaryTagName()
{
return "Arguments";
}
public void argument(Attributes atts)
{
currentArgument = atts.getValue("name");
}
public void argument(String data)
{
if(data != null)
{
data = data.trim();
}
args.addArgument(currentArgument,data);
currentArgument = null;
}
public Object getModel()
{
return args;
}
}
1.1 jakarta-jmeter/src_1/org/apache/jmeter/save/old/handlers/AssertionHandler.java
Index: AssertionHandler.java
===================================================================
package org.apache.jmeter.save.old.handlers;
import java.io.IOException;
import java.io.Writer;
import org.apache.jmeter.assertions.Assertion;
import org.apache.jmeter.save.old.SaveHandler;
import org.apache.jmeter.save.old.Saveable;
import org.apache.jmeter.save.old.xml.TagHandler;
import org.apache.jmeter.testelement.TestElement;
import org.xml.sax.Attributes;
/**
* Title: Jakarta-JMeter
* Description:
* Copyright: Copyright (c) 2001
* Company: Apache
* @author Michael Stover
* @version 1.0
*/
public class AssertionHandler extends TagHandler implements SaveHandler
{
Assertion model;
public AssertionHandler() {
}
public String getPrimaryTagName()
{
return "assertion";
}
public void save(Saveable objectToSave, Writer out) throws IOException {
Assertion saved = (Assertion)objectToSave;
out.write("<");
out.write(getPrimaryTagName());
out.write(" name=\"");
out.write(saved.getName());
out.write("\" class=\"");
out.write(saved.getClass().getName());
out.write("\" testType=\"");
out.write(""+saved.getTestType());
out.write("\" testField=\"");
out.write(saved.getTestField());
out.write("\">");
writeTestStrings(saved,out);
out.write("\n</");
out.write(getPrimaryTagName());
out.write(">");
}
public Object getModel()
{
return model;
}
public void setAtts(Attributes atts) throws ClassNotFoundException,IllegalAccessException,InstantiationException
{
System.out.println("Got to here");
model = (Assertion)Class.forName(atts.getValue("class")).newInstance();
model.setName(atts.getValue("name"));
model.setTestType(Integer.parseInt(atts.getValue("testType")));
model.setTestField(atts.getValue("testField"));
model.setProperty(TestElement.GUI_CLASS,JMeterHandler.getGuiClass(atts.getValue("type")));
}
public void testString(String data)
{
model.addTestString(data);
}
private void writeTestStrings(Assertion saved,Writer out) throws IOException
{
/*Iterator iter = saved.getTestStringList().iterator();
while (iter.hasNext())
{
out.write("\n<testString>");
out.write(JMeterHandler.convertToXML(iter.next().toString()));
out.write("</testString>");
}*/
}
}
1.1 jakarta-jmeter/src_1/org/apache/jmeter/save/old/handlers/AuthManagerHandler.java
Index: AuthManagerHandler.java
===================================================================
/*
* ====================================================================
* 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.save.old.handlers;
import java.io.Writer;
import java.util.Iterator;
import java.util.List;
import org.apache.jmeter.protocol.http.control.AuthManager;
import org.apache.jmeter.protocol.http.control.Authorization;
import org.apache.jmeter.save.old.Saveable;
import org.apache.jmeter.save.old.xml.TagHandler;
import org.apache.jmeter.testelement.TestElement;
import org.xml.sax.Attributes;
/**
* Title:
* Description:
* Copyright: Copyright (c) 2001
* Company:
* @author Michael Stover
* @version 1.0
*/
public class AuthManagerHandler extends TagHandler
{
private AuthManager authMan;
public AuthManagerHandler()
{
}
public void save(Saveable s, Writer out) throws java.io.IOException
{
AuthManager save = (AuthManager)s;
out.write("<AuthManager name=\"");
out.write(JMeterHandler.convertToXML(save.getName()));
out.write("\">\n");
JMeterHandler.writeObjects(save.getAuthObjects(),out);
out.write("</AuthManager>\n");
}
public void AuthManagerTagEnd()
{
List auths = xmlParent.takeChildObjects(this);
Iterator iter = auths.iterator();
while (iter.hasNext())
{
authMan.addAuth((Authorization)((TagHandler)iter.next()).getModel());
}
}
public void setAtts(Attributes atts) throws java.lang.Exception
{
authMan = new AuthManager();
authMan.setName(atts.getValue("name"));
authMan.setProperty(TestElement.GUI_CLASS,JMeterHandler.getGuiClass(atts.getValue("type")));
}
public String getPrimaryTagName()
{
return "AuthManager";
}
public Object getModel()
{
return authMan;
}
}
1.1 jakarta-jmeter/src_1/org/apache/jmeter/save/old/handlers/CookieManagerHandler.java
Index: CookieManagerHandler.java
===================================================================
/*
* ====================================================================
* 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.save.old.handlers;
import java.io.Writer;
import java.util.Iterator;
import java.util.List;
import org.apache.jmeter.protocol.http.control.Cookie;
import org.apache.jmeter.protocol.http.control.CookieManager;
import org.apache.jmeter.save.old.Saveable;
import org.apache.jmeter.save.old.xml.TagHandler;
import org.apache.jmeter.testelement.TestElement;
import org.xml.sax.Attributes;
/**
* Title:
* Description:
* Copyright: Copyright (c) 2001
* Company:
* @author Michael Stover
* @version 1.0
*/
public class CookieManagerHandler extends TagHandler
{
private CookieManager cookieManager;
public CookieManagerHandler()
{
}
public void save(Saveable cm, Writer out) throws java.io.IOException
{
CookieManager cookies = (CookieManager)cm;
out.write("<CookieManager name=\"");
out.write(JMeterHandler.convertToXML(cookies.getName()));
out.write("\">\n");
JMeterHandler.writeObjects(cookies.getCookies(),out);
out.write("</CookieManager>\n");
}
public void setAtts(Attributes atts) throws java.lang.Exception
{
cookieManager = new CookieManager();
cookieManager.setName(atts.getValue("name"));
cookieManager.setProperty(TestElement.GUI_CLASS,
"org.apache.jmeter.protocol.http.gui.CookiePanel");
}
public String getPrimaryTagName()
{
return "CookieManager";
}
public void CookieManagerTagEnd()
{
List cookies = xmlParent.takeChildObjects(this);
Iterator iter = cookies.iterator();
while (iter.hasNext())
{
cookieManager.add((Cookie)((TagHandler)iter.next()).getModel());
}
}
public Object getModel()
{
return cookieManager;
}
}
1.1 jakarta-jmeter/src_1/org/apache/jmeter/save/old/handlers/FilerHandler.java
Index: FilerHandler.java
===================================================================
package org.apache.jmeter.save.old.handlers;
import java.io.Writer;
import org.apache.jmeter.reporters.ResultCollector;
import org.apache.jmeter.save.old.Saveable;
import org.apache.jmeter.save.old.xml.TagHandler;
import org.apache.jmeter.testelement.TestElement;
import org.xml.sax.Attributes;
/**
* Title:
* Description:
* Copyright: Copyright (c) 2001
* Company:
* @author
* @version 1.0
*/
public class FilerHandler extends TagHandler
{
ResultCollector model;
public FilerHandler()
{
}
public void save(Saveable saveObject, Writer out) throws java.io.IOException
{
/* protect ourselves from bad input.
if ((saveObject == null) || (out == null))
{
// error!
}
else
{
Filer save = (Filer)saveObject;
// validate filename
String filename = save.getFile();
if (filename == null)
{
System.err.println("Error. Missing filename in File Reporter.");
filename = "";
}
out.write("<Filer type=\"");
out.write(JMeterHandler.convertToXML(save.getClass().getName()));
out.write("\" name=\"");
out.write(JMeterHandler.convertToXML(save.getName()));
out.write("\" verbose=\"");
out.write(""+save.getVerbose());
out.write("\" append=\"");
out.write(""+save.getAppend());
out.write("\" autoFlush=\"");
out.write("" + save.getAutoFlush());
out.write("\" viewSubmitData=\"");
out.write("" + save.getViewSubmitData());
out.write("\" file=\"");
out.write(JMeterHandler.convertToXML(filename));
out.write("\"/>");
}*/
}
public void setAtts(Attributes atts) throws java.lang.Exception
{
model = new ResultCollector();
model.setName(atts.getValue("name"));
model.setFilename(atts.getValue("file"));
model.setProperty(TestElement.GUI_CLASS,"org.apache.jmeter.visualizer.GraphVisualizer");
}
public String getPrimaryTagName()
{
return "Filer";
}
public Object getModel()
{
return model;
}
}
1.1 jakarta-jmeter/src_1/org/apache/jmeter/save/old/handlers/FtpTestHandler.java
Index: FtpTestHandler.java
===================================================================
/*
* ====================================================================
* 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.save.old.handlers;
import java.io.Writer;
import java.util.List;
import org.apache.jmeter.control.GenericController;
import org.apache.jmeter.protocol.ftp.sampler.FTPSampler;
import org.apache.jmeter.save.old.Saveable;
import org.apache.jmeter.save.old.xml.TagHandler;
import org.apache.jmeter.testelement.TestElement;
import org.xml.sax.Attributes;
/**
* Title: Apache JMeter Description: Copyright: Copyright (c) 2000 Company:
* Apache Foundation
*
*@created July 30, 2001
*@version 1.0
*/
public class FtpTestHandler extends TagHandler
{
FTPSampler sampler;
//Constructor for the FtpTestHandler object
public FtpTestHandler() {}
/**
* Gets the PrimaryTagName attribute of the FtpTestHandler
*/
public String getPrimaryTagName()
{
return "FtpTestSampler";
}
//called by reflection when the <defaultUrl> tag is ended
public void defaultUrlTagEnd()
{
List children = xmlParent.takeChildObjects(this);
if (children.size() == 1)
{
sampler.addTestElement((TestElement)((TagHandler)children.get(0)).getModel());
}
}
//called by reflection when the <defaultLogin> tag is ended
public void loginConfigTagEnd()
{
List children = xmlParent.takeChildObjects(this);
if (children.size() == 1)
{
sampler.addTestElement((TestElement)((TagHandler)children.get(0)).getModel());
}
}
public void setAtts(Attributes atts) throws java.lang.Exception
{
sampler = new FTPSampler();
sampler.setName(atts.getValue("name"));
sampler.setProperty(TestElement.GUI_CLASS,JMeterHandler.getGuiClass(atts.getValue("type")));
}
public Object getModel()
{
return sampler;
}
/**
* Does the saving, calls write methods below to output config info to XML config file.
*/
public void save(Saveable cont, Writer out) throws java.io.IOException
{
/*FtpTestSampler controller = (FtpTestSampler) cont;
writeMainTag(out, controller);
writeDefaultUrl(out, controller);
writeLoginConfig(out, controller);
this.writeSubElements(controller,out);
out.write("</FtpTestSampler>\n");*/
}
/**
* This method writes the opening main tag to the XML config file, i.e. <FtpTestSampler>
*/
protected void writeMainTag(Writer out, GenericController controller) throws java.io.IOException
{
out.write("<FtpTestSampler type=\"");
out.write(JMeterHandler.convertToXML(controller.getClass().getName()));
out.write("\" name=\"");
out.write(JMeterHandler.convertToXML(controller.getName()));
out.write("\">\n");
}
/**
* Write out default domain and default filename defined in 'FTP Testing'
* @exception java.io.IOException Description of Exception
*/
protected void writeDefaultUrl(Writer out)
throws java.io.IOException
{
/*out.write("<defaultUrl>\n");
JMeterHandler.writeObject(controller.getDefaultUrl(), out);
out.write("</defaultUrl>\n");*/
}
/**
* Write username and password info
*/
protected void writeLoginConfig(Writer out)
throws java.io.IOException
{
/*out.write("<loginConfig>\n");
JMeterHandler.writeObject(controller.getLoginConfig(), out);
out.write("</loginConfig>\n");*/
}
}
1.1 jakarta-jmeter/src_1/org/apache/jmeter/save/old/handlers/GenericControllerHandler.java
Index: GenericControllerHandler.java
===================================================================
/*
* ====================================================================
* 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.save.old.handlers;
import java.io.Writer;
import org.apache.jmeter.control.GenericController;
import org.apache.jmeter.control.ModifyController;
import org.apache.jmeter.save.old.Saveable;
import org.apache.jmeter.save.old.xml.TagHandler;
import org.apache.jmeter.testelement.TestElement;
import org.xml.sax.Attributes;
/************************************************************
* Title: Apache JMeter Description: Copyright: Copyright (c) 2000 Company:
* Apache Foundation
*
*@author Michael Stover
*@created February 18, 2001
*@version 1.0
***********************************************************/
public class GenericControllerHandler extends TagHandler
{
protected GenericController controller;
/************************************************************
* Constructor for the GenericControllerHandler object
***********************************************************/
public GenericControllerHandler()
{
}
/************************************************************
* Sets the Atts attribute of the GenericControllerHandler object
*
*@param atts The new Atts value
*@exception java.lang.Exception Description of Exception
***********************************************************/
public void setAtts(Attributes atts) throws java.lang.Exception
{
String className = atts.getValue("type");
if(className.equals("org.apache.jmeter.control.LogicController"))
{
controller = new GenericController();
}
else
{
controller = (GenericController)Class.forName(atts.getValue("type")).newInstance();
}
if(controller instanceof ModifyController)
{
controller = new GenericController();
}
controller.setName(atts.getValue("name"));
controller.setProperty(TestElement.GUI_CLASS,JMeterHandler.getGuiClass(atts.getValue("type")));
}
/************************************************************
* Gets the PrimaryTagName attribute of the GenericControllerHandler object
*
*@return The PrimaryTagName value
***********************************************************/
public String getPrimaryTagName()
{
return "Controller";
}
/************************************************************
* Gets the Model attribute of the GenericControllerHandler object
*
*@return The Model value
***********************************************************/
public Object getModel()
{
return controller;
}
/************************************************************
* Description of the Method
*
*@param cont Description of Parameter
*@param out Description of Parameter
*@exception java.io.IOException Description of Exception
***********************************************************/
public void save(Saveable cont, Writer out) throws java.io.IOException
{
GenericController controller = (GenericController)cont;
writeMainTag(out, controller);
writeSubElements(controller, out);
out.write("</Controller>");
}
/************************************************************
* !ToDo (Method description)
*
*@param out !ToDo (Parameter description)
*@param controller !ToDo (Parameter description)
*@exception java.io.IOException !ToDo (Exception description)
***********************************************************/
protected void writeSubControllers(Writer out, GenericController controller) throws java.io.IOException
{
}
/************************************************************
* !ToDo (Method description)
*
*@param out !ToDo (Parameter description)
*@param controller !ToDo (Parameter description)
*@exception java.io.IOException !ToDo (Exception description)
***********************************************************/
protected void writeMainTag(Writer out, GenericController controller) throws java.io.IOException
{
out.write("<Controller type=\"");
out.write(JMeterHandler.convertToXML(controller.getClass().getName()));
out.write("\" name=\"");
out.write(JMeterHandler.convertToXML(controller.getName()));
out.write("\">\n");
}
/************************************************************
* !ToDo (Method description)
*
*@param controller !ToDo (Parameter description)
*@param out !ToDo (Parameter description)
***********************************************************/
protected void writeSubElements(GenericController controller, Writer out) throws java.io.IOException
{
/*JMeterHandler.writeConfigElements(controller.getConfigElements(), out);
JMeterHandler.writeControllers(controller.getSubControllers(), out);
JMeterHandler.writeObjects(controller.getAssertions(), out);*/
}
}
1.1 jakarta-jmeter/src_1/org/apache/jmeter/save/old/handlers/HeaderManagerHandler.java
Index: HeaderManagerHandler.java
===================================================================
/*
* ====================================================================
* 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.save.old.handlers;
import java.io.Writer;
import java.util.Iterator;
import java.util.List;
import org.apache.jmeter.protocol.http.control.Header;
import org.apache.jmeter.protocol.http.control.HeaderManager;
import org.apache.jmeter.save.old.Saveable;
import org.apache.jmeter.save.old.xml.TagHandler;
import org.apache.jmeter.testelement.TestElement;
import org.xml.sax.Attributes;
/**
* Title:
* Description:
* Copyright: Copyright (c) 2001
* Company:
* @author Giacomo Pati
* @version 1.0
*/
public class HeaderManagerHandler extends TagHandler
{
private HeaderManager headerManager;
public HeaderManagerHandler()
{
}
public void save(Saveable cm, Writer out) throws java.io.IOException
{
HeaderManager headers = (HeaderManager)cm;
out.write("<HeaderManager name=\"");
out.write(JMeterHandler.convertToXML(headers.getName()));
out.write("\">\n");
JMeterHandler.writeObjects(headers.getHeaders(),out);
out.write("</HeaderManager>\n");
}
public void setAtts(Attributes atts) throws java.lang.Exception
{
headerManager = new HeaderManager();
headerManager.setProperty(TestElement.GUI_CLASS,
"org.apache.jmeter.protocol.http.gui.HeaderPanel");
headerManager.setName(atts.getValue("name"));
}
public String getPrimaryTagName()
{
return "HeaderManager";
}
public void HeaderManagerTagEnd()
{
List headers = xmlParent.takeChildObjects(this);
Iterator iter = headers.iterator();
while (iter.hasNext())
{
TestElement header = (TestElement)((TagHandler)iter.next()).getModel();
headerManager.add(new Header((String)header.getProperty(TestElement.NAME),
(String)header.getProperty("value")));
}
}
public Object getModel()
{
return headerManager;
}
}
1.1 jakarta-jmeter/src_1/org/apache/jmeter/save/old/handlers/HttpTestSampleHandler.java
Index: HttpTestSampleHandler.java
===================================================================
/*
* ====================================================================
* 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.save.old.handlers;
import java.io.Writer;
import java.util.List;
import org.apache.jmeter.control.GenericController;
import org.apache.jmeter.protocol.http.sampler.HTTPSampler;
import org.apache.jmeter.protocol.http.sampler.HTTPSamplerFull;
import org.apache.jmeter.save.old.Saveable;
import org.apache.jmeter.save.old.xml.TagHandler;
import org.apache.jmeter.testelement.TestElement;
import org.xml.sax.Attributes;
/**
* Title: Apache JMeter Description: Copyright: Copyright (c) 2000 Company:
* Apache Foundation
*
*@author Michael Stover
*@created February 18, 2001
*@version 1.0
*/
public class HttpTestSampleHandler extends TagHandler
{
HTTPSampler sampler;
/**
* Constructor for the HttpTestSampleHandler object
*/
public HttpTestSampleHandler()
{
}
public void setAtts(Attributes atts) throws java.lang.Exception
{
sampler = new HTTPSampler();
if(Boolean.valueOf(
atts.getValue("getImages")).booleanValue());
{
sampler = new HTTPSamplerFull();
}
sampler.setProperty(TestElement.GUI_CLASS,"org.apache.jmeter.protocol.http.control.gui.HttpTestSampleGui");
sampler.setName(atts.getValue("name"));
}
public Object getModel()
{
return sampler;
}
/**
* Gets the PrimaryTagName attribute of the GenericControllerHandler object
*
*@return The PrimaryTagName value
*/
public String getPrimaryTagName()
{
return "HttpTestSample";
}
public void notifySubElementEnded(Object childObj)
{
if(this.getMethodName().endsWith("defaultUrl"))
{
List children = xmlParent.takeChildObjects(this);
if (children.size() == 1)
{
sampler.addTestElement((TestElement)((TagHandler)children.get(0)).getModel());
}
}
}
/**
* Description of the Method
*
*@param cont Description of Parameter
*@param out Description of Parameter
*@exception java.io.IOException Description of Exception
*/
public void save(Saveable cont, Writer out) throws java.io.IOException
{
/*HttpTestSample controller = (HttpTestSample) cont;
writeMainTag(out, controller);
writeDefaultUrl(out, controller);
writeSubElements(controller, out);
out.write("</HttpTestSample>\n");*/
}
/**
* Description of the Method
*
*@param out Description of Parameter
*@param controller Description of Parameter
*@exception java.io.IOException Description of Exception
*/
protected void writeMainTag(Writer out, GenericController controller) throws java.io.IOException
{
/*out.write("<HttpTestSample type=\"");
out.write(JMeterHandler.convertToXML(controller.getClass().getName()));
out.write("\" name=\"");
out.write(JMeterHandler.convertToXML(controller.getName()));
out.write("\" getImages=\"");
out.write(""+((HttpTestSample)controller).isGetImages());
out.write("\">\n");*/
}
/**
* Description of the Method
*
*@param out Description of Parameter
*@param controller Description of Parameter
*@exception java.io.IOException Description of Exception
*/
protected void writeDefaultUrl(Writer out)
throws java.io.IOException
{
/*out.write("<defaultUrl>\n");
JMeterHandler.writeObject(controller.getDefaultUrl(), out);
out.write("</defaultUrl>\n");*/
}
}
1.1 jakarta-jmeter/src_1/org/apache/jmeter/save/old/handlers/JMeterComponentHandler.java
Index: JMeterComponentHandler.java
===================================================================
package org.apache.jmeter.save.old.handlers;
import java.io.Writer;
import org.apache.jmeter.gui.JMeterComponentModel;
import org.apache.jmeter.save.old.Saveable;
import org.apache.jmeter.save.old.xml.TagHandler;
import org.xml.sax.Attributes;
/**
* Title:
* Description:
* Copyright: Copyright (c) 2001
* Company:
* @author
* @version 1.0
*/
public class JMeterComponentHandler extends TagHandler
{
JMeterComponentModel model;
public JMeterComponentHandler()
{
}
public void save(Saveable saveObject, Writer out) throws java.io.IOException
{
JMeterComponentModel save = (JMeterComponentModel)saveObject;
out.write("<JMeterComponent type=\"");
out.write(JMeterHandler.convertToXML(save.getClass().getName()));
out.write("\" name=\"");
out.write(JMeterHandler.convertToXML(save.getName()));
out.write("\"/>");
}
public void setAtts(Attributes atts) throws java.lang.Exception
{
model = (JMeterComponentModel)Class.forName(atts.getValue("type")).newInstance();
model.setName(atts.getValue("name"));
}
public String getPrimaryTagName()
{
return "JMeterComponent";
}
public Object getModel()
{
return model;
}
}
1.1 jakarta-jmeter/src_1/org/apache/jmeter/save/old/handlers/JMeterHandler.java
Index: JMeterHandler.java
===================================================================
/*
* ====================================================================
* 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.save.old.handlers;
import java.io.IOException;
import java.io.Writer;
import java.util.Collection;
import java.util.HashMap;
import java.util.Iterator;
import java.util.Map;
import org.apache.jmeter.protocol.http.sampler.HTTPSampler;
import org.apache.jmeter.save.old.SaveHandler;
import org.apache.jmeter.save.old.Saveable;
import org.apache.jmeter.testelement.TestElement;
/**
* Title: Description: Copyright: Copyright (c) 2001 Company:
*
*@author Michael Stover
*@created June 8, 2001
*@version 1.0
*/
public class JMeterHandler
{
private static String TOKENS = "&'\"<>\n\r\t\f\b\\";
private static Map guiClassMap = new HashMap();
private static Map propertyConversion = new HashMap();
static
{
guiClassMap.put("org.apache.jmeter.protocol.http.config.UrlConfig","org.apache.jmeter.protocol.http.config.gui.MultipartUrlConfigGui");
guiClassMap.put("org.apache.jmeter.control.ModifyController","org.apache.jmeter.control.gui.LogicControllerGui");
guiClassMap.put("org.apache.jmeter.control.LogicController",
"org.apache.jmeter.control.gui.LogicControllerGui");
propertyConversion.put("arguments",HTTPSampler.ARGUMENTS);
propertyConversion.put("port",HTTPSampler.PORT);
propertyConversion.put("PROTOCOL",HTTPSampler.PROTOCOL);
propertyConversion.put("method",HTTPSampler.METHOD);
propertyConversion.put("domain",HTTPSampler.DOMAIN);
propertyConversion.put("path",HTTPSampler.PATH);
propertyConversion.put("name",TestElement.NAME);
}
/**
* Constructor for the JMeterHandler object
*/
public JMeterHandler()
{
}
/**
* Description of the Method
*
*@param configs Description of Parameter
*@param out Description of Parameter
*@exception IOException Description of Exception
*/
public static void writeConfigElements(Collection configs, Writer out) throws IOException
{
out.write("<configElements>\n");
writeObjects(configs, out);
out.write("</configElements>\n");
}
/**
* Description of the Method
*
*@param controls Description of Parameter
*@param out Description of Parameter
*@exception IOException Description of Exception
*/
public static void writeControllers(Collection controls, Writer out) throws IOException
{
out.write("<controllers>\n");
writeObjects(controls, out);
out.write("</controllers>\n");
}
/**
* Description of the Method
*
*@param groups Description of Parameter
*@param out Description of Parameter
*@exception IOException Description of Exception
*/
public static void writeThreadGroups(Collection groups, Writer out) throws IOException
{
out.write("<threadgroups>\n");
writeObjects(groups, out);
out.write("</threadgroups>\n");
}
/**
* Description of the Method
*
*@param listeners Description of Parameter
*@param out Description of Parameter
*@exception IOException Description of Exception
*/
public static void writeListeners(Collection listeners, Writer out) throws IOException
{
out.write("<listeners>\n");
writeObjects(listeners, out);
out.write("</listeners>\n");
}
/**
* Description of the Method
*
*@param timers Description of Parameter
*@param out Description of Parameter
*@exception IOException Description of Exception
*/
public static void writeTimers(Collection timers, Writer out) throws IOException
{
out.write("<timers>\n");
writeObjects(timers, out);
out.write("</timers>\n");
}
/**
* Description of the Method
*
*@param objects Description of Parameter
*@param out Description of Parameter
*@exception IOException Description of Exception
*/
public static void writeObjects(Collection objects, Writer out) throws IOException
{
Iterator iter = objects.iterator();
while (iter.hasNext())
{
writeObject(iter.next(), out);
out.write("\n");
}
}
/**
* Description of the Method
*
*@param obj Description of Parameter
*@param out Description of Parameter
*@exception IOException Description of Exception
*/
public static void writeObject(Object obj, Writer out) throws IOException
{
if (obj instanceof Saveable)
{
try
{
((SaveHandler) ((Saveable) obj).getTagHandlerClass().newInstance()).save(
(Saveable) obj, out);
}
catch (Exception ex)
{
ex.printStackTrace();
}
}
else
{
out.write(convertToXML(obj.toString()));
}
}
public static String getGuiClass(String testClass)
{
System.out.println("gui class: "+testClass);
return (String)guiClassMap.get(testClass);
}
public static String convertProperty(String prop)
{
if(propertyConversion.containsKey(prop))
{
return (String)propertyConversion.get(prop);
}
else return prop;
}
/**
* Description of the Method
*
*@param input Description of Parameter
*@return Description of the Returned Value
*/
public static String convertToXML(String input)
{
if (input == null)
{
return null;
}
String retVal = "";
StringBuffer buffer = new StringBuffer(input);
int length = buffer.length();
for (int i = 0; i < length; i++)
{
char ch = buffer.charAt(i);
int chInt = (int) ch;
if (Character.isLetterOrDigit(ch) || ch == '\n' || ch == '\r' || ch == '\t' || ch == ' ')
{
continue;
}
int chType = Character.getType(ch);
if (chType == Character.CONTROL || chType == Character.UNASSIGNED)
{
buffer.setCharAt(i, ' ');
}
}
input = buffer.toString();
buffer = new StringBuffer();
java.util.StringTokenizer tokenizer = new java.util.StringTokenizer(input, TOKENS, true);
while (tokenizer.hasMoreTokens())
{
String nextToken = tokenizer.nextToken();
length = nextToken.length();
if (length > 1)
{
buffer.append(nextToken);
}
else if (length == 1)
{
char ch = nextToken.charAt(0);
switch (ch)
{
case '&':
buffer.append("&");
break;
case '\'':
buffer.append("'");
break;
case '"':
buffer.append(""");
break;
case '<':
buffer.append("<");
break;
case '>':
buffer.append(">");
break;
case '\n':
case '\r':
case '\t':
case '\f':
case '\b':
case '\\':
buffer.append("&#");buffer.append((int)ch);buffer.append(";");
break;
default:
buffer.append(nextToken);
}
}
}
return buffer.toString();
}
}
1.1 jakarta-jmeter/src_1/org/apache/jmeter/save/old/handlers/JdbcTestSampleHandler.java
Index: JdbcTestSampleHandler.java
===================================================================
/*
* ====================================================================
* 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.save.old.handlers;
import java.io.Writer;
import java.util.List;
import org.apache.jmeter.control.GenericController;
import org.apache.jmeter.protocol.jdbc.sampler.JDBCSampler;
import org.apache.jmeter.save.old.Saveable;
import org.apache.jmeter.save.old.xml.TagHandler;
import org.apache.jmeter.testelement.TestElement;
import org.xml.sax.Attributes;
/************************************************************
* Title: Description: Copyright: Copyright (c) 2001 Company:
*
*@author Michael Stover
*@created $Date: 2002/06/01 13:21:27 $
*@version 1.0
***********************************************************/
public class JdbcTestSampleHandler extends TagHandler
{
JDBCSampler sampler;
/************************************************************
* !ToDo (Constructor description)
***********************************************************/
public JdbcTestSampleHandler()
{
}
/************************************************************
* Gets the PrimaryTagName attribute of the GenericControllerHandler object
*
*@return The PrimaryTagName value
***********************************************************/
public String getPrimaryTagName()
{
return "JdbcTestSample";
}
/************************************************************
* !ToDo (Method description)
*
*@param childObj !ToDo (Parameter description)
***********************************************************/
public void notifySubElementEnded(Object childObj)
{
System.out.println(childObj);
if (this.getMethodName().endsWith("defaultDb"))
{
retrieveDefaultDbConfig();
}
if (this.getMethodName().endsWith("defaultPool"))
{
retrieveDefaultPoolConfig();
}
if (this.getMethodName().endsWith("defaultSql"))
{
retrieveDefaultSqlConfig();
}
}
/************************************************************
* Description of the Method
***********************************************************/
public void defaultDbTagEnd()
{
retrieveDefaultDbConfig();
}
/************************************************************
* !ToDo (Method description)
***********************************************************/
public void defaultPoolTagEnd()
{
List children = xmlParent.takeChildObjects(this);
if (children.size() == 1)
{
sampler.addTestElement((TestElement)((TagHandler)children.get(0)).getModel());
}
}
public void setAtts(Attributes atts) throws java.lang.Exception
{
sampler = new JDBCSampler();
sampler.setProperty(TestElement.GUI_CLASS,JMeterHandler.getGuiClass(atts.getValue("type")));
sampler.setName(atts.getValue("name"));
}
public Object getModel()
{
return sampler;
}
/************************************************************
* Description of the Method
*
*@param cont Description of Parameter
*@param out Description of Parameter
*@exception java.io.IOException Description of Exception
***********************************************************/
public void save(Saveable cont, Writer out) throws java.io.IOException
{
/*JdbcTestSample controller = (JdbcTestSample)cont;
writeMainTag(out, controller);
writeDefaultDb(out, controller);
writeDefaultPool(out, controller);
writeDefaultSql(out, controller);
writeSubElements(controller, out);
out.write("</JdbcTestSample>\n");*/
}
/************************************************************
* Description of the Method
*
*@param out Description of Parameter
*@param controller Description of Parameter
*@exception java.io.IOException Description of Exception
***********************************************************/
protected void writeMainTag(Writer out, GenericController controller) throws java.io.IOException
{
/*out.write("<JdbcTestSample type=\"");
out.write(JMeterHandler.convertToXML(controller.getClass().getName()));
out.write("\" name=\"");
out.write(JMeterHandler.convertToXML(controller.getName()));
out.write("\">\n");*/
}
/************************************************************
* Description of the Method
*
*@param out Description of Parameter
*@param controller Description of Parameter
*@exception java.io.IOException Description of Exception
***********************************************************/
protected void writeDefaultDb(Writer out)
throws java.io.IOException
{
/*out.write("<defaultDb>\n");
JMeterHandler.writeObject(controller.getDefaultDbConfig(), out);
out.write("</defaultDb>\n");*/
}
/************************************************************
* !ToDo (Method description)
*
*@param out !ToDo (Parameter description)
*@param controller !ToDo (Parameter description)
*@exception java.io.IOException !ToDo (Exception description)
***********************************************************/
protected void writeDefaultPool(Writer out)
throws java.io.IOException
{
/*out.write("<defaultPool>\n");
JMeterHandler.writeObject(controller.getDefaultPoolConfig(), out);
out.write("</defaultPool>\n");*/
}
/************************************************************
* !ToDo (Method description)
*
*@param out !ToDo (Parameter description)
*@param controller !ToDo (Parameter description)
*@exception java.io.IOException !ToDo (Exception description)
***********************************************************/
protected void writeDefaultSql(Writer out) throws java.io.IOException
{
/*out.write("<defaultSql>\n");
JMeterHandler.writeObject(controller.getDefaultSqlConfig(), out);
out.write("</defaultSql>\n");*/
}
private void retrieveDefaultDbConfig()
{
List children = xmlParent.takeChildObjects(this);
if (children.size() == 1)
{
sampler.addTestElement((TestElement)((TagHandler)children.get(0)).getModel());
}
}
private void retrieveDefaultPoolConfig()
{
List children = xmlParent.takeChildObjects(this);
if (children.size() == 1)
{
sampler.addTestElement((TestElement)((TagHandler)children.get(0)).getModel());
}
}
private void retrieveDefaultSqlConfig()
{
List children = xmlParent.takeChildObjects(this);
if (children.size() == 1)
{
sampler.addTestElement((TestElement)((TagHandler)children.get(0)).getModel());
}
}
}
1.1 jakarta-jmeter/src_1/org/apache/jmeter/save/old/handlers/LoopControlHandler.java
Index: LoopControlHandler.java
===================================================================
/*
* ====================================================================
* 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.save.old.handlers;
import java.io.Writer;
import org.apache.jmeter.control.GenericController;
import org.apache.jmeter.control.LoopController;
import org.apache.jmeter.save.old.Saveable;
import org.apache.jmeter.testelement.TestElement;
import org.xml.sax.Attributes;
/************************************************************
* Title: JMeter Description: Copyright: Copyright (c) 2000 Company: Apache
*
*@author Michael Stover
*@created $Date: 2002/06/01 13:21:27 $
*@version 1.0
***********************************************************/
public class LoopControlHandler extends GenericControllerHandler
{
/************************************************************
* !ToDo (Constructor description)
***********************************************************/
public LoopControlHandler()
{
super();
}
public String getPrimaryTagName()
{
return "LoopController";
}
/************************************************************
* !ToDo (Method description)
*
*@param atts !ToDo (Parameter description)
*@exception java.lang.Exception !ToDo (Exception description)
***********************************************************/
public void setAtts(Attributes atts) throws java.lang.Exception
{
controller = (LoopController)Class.forName(atts.getValue("type")).newInstance();
controller.setProperty(TestElement.GUI_CLASS,JMeterHandler.getGuiClass(atts.getValue("type")));
((LoopController)controller).setName(atts.getValue("name"));
((LoopController)controller).setLoops(Integer.parseInt(atts.getValue("iterations")));
}
/************************************************************
* !ToDo (Method description)
*
*@param out !ToDo (Parameter description)
*@param controller !ToDo (Parameter description)
*@exception java.io.IOException !ToDo (Exception description)
***********************************************************/
protected void writeMainTag(Writer out, GenericController controller) throws java.io.IOException
{
out.write("<LoopController type=\"");
out.write(JMeterHandler.convertToXML(controller.getClass().getName()));
out.write("\" name=\"");
out.write(JMeterHandler.convertToXML(controller.getName()));
out.write("\" iterations=\"");
out.write("" + ((LoopController)controller).getLoops());
out.write("\">\n");
}
/**
* Description of the Method
*
*@param cont Description of Parameter
*@param out Description of Parameter
*@exception java.io.IOException Description of Exception
*/
public void save(Saveable cont, Writer out) throws java.io.IOException
{
LoopController controller = (LoopController) cont;
writeMainTag(out, controller);
writeSubElements(controller, out);
out.write("</LoopController>");
}
}
1.1 jakarta-jmeter/src_1/org/apache/jmeter/save/old/handlers/ParamMaskHandler.java
Index: ParamMaskHandler.java
===================================================================
package org.apache.jmeter.save.old.handlers;
import java.io.IOException;
import java.io.Writer;
import org.apache.jmeter.protocol.http.modifier.ParamMask;
import org.apache.jmeter.save.old.Saveable;
import org.apache.jmeter.save.old.xml.TagHandler;
import org.apache.jmeter.testelement.TestElement;
import org.xml.sax.Attributes;
/**
* Saves and loads a {@link ParamMask} object to/from XML format.
*
* @author David La France
* @version 1.0
*/
public class ParamMaskHandler extends TagHandler {
/**
* Default constructor
*/
public ParamMaskHandler() {
}
/**
* Writes a {@link ParamMask} object in XML format to the given <code>Writer</code>
*/
public void save(Saveable parm1, Writer out) throws IOException {
ParamMask mask = (ParamMask) parm1;
out.write("\n");
out.write(" <ParamMask>\n");
out.write(" <mask name=\"");
out.write(JMeterHandler.convertToXML(mask.getName()));
out.write("\" prefix=\"");
out.write(JMeterHandler.convertToXML(mask.getPrefix()));
out.write("\" upperBound=\"");
out.write(JMeterHandler.convertToXML(Long.toString(mask.getUpperBound())));
out.write("\" lowerBound=\"");
out.write(JMeterHandler.convertToXML(Long.toString(mask.getLowerBound())));
out.write("\" increment=\"");
out.write(JMeterHandler.convertToXML(Long.toString(mask.getIncrement())));
out.write("\">");
out.write("</mask>\n");
out.write(" </ParamMask>\n");
}
/**
* This method is automatically called whenever a "ParamMask" tag is reached. The ParamMask
* tag does not currently support attributes
*
* @param atts The attributes of the XML "ParamMask" tag
*/
public void setAtts(Attributes atts) throws Exception {
_mask = new ParamMask();
_mask.setProperty(TestElement.GUI_CLASS,JMeterHandler.getGuiClass(atts.getValue("type")));
}
public String getPrimaryTagName() {
return "ParamMask";
}
/**
* This method is automatically called whenever a "mask" tag is reached. Loads the values for
* the ParamMask
*
* @param atts The attributes of the XML "mask" tag
*/
public void mask(Attributes atts) {
_mask.setName (atts.getValue("name"));
_mask.setPrefix (atts.getValue("prefix"));
_mask.setUpperBound (Long.parseLong(atts.getValue("upperBound")));
_mask.setLowerBound (Long.parseLong(atts.getValue("lowerBound")));
_mask.setIncrement (Long.parseLong(atts.getValue("increment")));
}
/**
* This method is called with any String data found between the start and end tags of a "mask"
* tag.
*
* @param data The string data found
*/
public void mask(String data) {
}
public Object getModel() {
return _mask;
}
ParamMask _mask;
}
1.1 jakarta-jmeter/src_1/org/apache/jmeter/save/old/handlers/ProxyControlHandler.java
Index: ProxyControlHandler.java
===================================================================
/*
* ====================================================================
* 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.save.old.handlers;
import java.io.IOException;
import java.io.Writer;
import java.util.Iterator;
import java.util.List;
import org.apache.jmeter.config.Argument;
import org.apache.jmeter.config.Arguments;
import org.apache.jmeter.protocol.http.proxy.ProxyControl;
import org.apache.jmeter.save.old.Saveable;
import org.apache.jmeter.save.old.xml.TagHandler;
import org.apache.jmeter.testelement.TestElement;
import org.xml.sax.Attributes;
/************************************************************
* Title: JMeter Description: Copyright: Copyright (c) 2000 Company: Apache
*
*@author Michael Stover
*@created June 9, 2001
*@version 1.0
***********************************************************/
public class ProxyControlHandler extends AbstractConfigElementHandler
{
/************************************************************
* This is called when a tag is first encountered for this handler class to
* handle. The attributes of the tag are passed, and the SaveHandler object is
* expected to instantiate a new object.
*
*@param atts The new Atts value
*@exception Exception Description of Exception
***********************************************************/
public void setAtts(Attributes atts) throws Exception
{
String className = atts.getValue("type");
config = (ProxyControl)Class.forName(className).newInstance();
config.setProperty(TestElement.GUI_CLASS,JMeterHandler.getGuiClass(atts.getValue("type")));
}
/************************************************************
* Gets the tag name that will trigger the use of this object's TagHandler.
*
*@return The PrimaryTagName value
***********************************************************/
public String getPrimaryTagName()
{
return "ProxyControl";
}
/************************************************************
* Called by reflection when the <property> tag is ended.
***********************************************************/
public void propertyTagEnd()
{
List children = xmlParent.takeChildObjects(this);
if(children.size() == 1) {
// Include or Exclude list, encapsulated as a set of Arguments
Object model = ((TagHandler)children.get(0)).getModel();
if (model instanceof Arguments) {
Arguments args = (Arguments) model;
List list = null;
ProxyControl proxy = (ProxyControl) config;
if (currentProperty.equals("includes")) {
list = proxy.getIncludePatterns();
} else if (currentProperty.equals("excludes")) {
list = proxy.getExcludePatterns();
}
if (list != null) {
for (Iterator iter = args.iterator(); iter.hasNext(); ) {
Argument arg = (Argument) iter.next();
list.add(arg.getValue());
}
}
}
}
}
/************************************************************
* Tells the object to save itself to the given output stream.
*
*@param obj Description of Parameter
*@param out Description of Parameter
*@exception IOException Description of Exception
***********************************************************/
public void save(Saveable obj, Writer out) throws IOException
{
ProxyControl saved = (ProxyControl)obj;
String tagName = getPrimaryTagName();
out.write("<" + tagName);
out.write(" type=\"");
out.write(JMeterHandler.convertToXML(saved.getClass().getName()));
out.write("\"");
out.write(">\n");
for (Iterator iter = saved.getPropertyNames().iterator(); iter.hasNext(); ) {
String key = (String)iter.next();
Object value = saved.getProperty(key);
writeProperty(out, key, value);
}
writePatterns(saved.getIncludePatterns(), "includes", out);
writePatterns(saved.getExcludePatterns(), "excludes", out);
out.write("</" + tagName + ">");
}
private void writePatterns(List list, String name, Writer out) throws IOException {
Arguments args = new Arguments();
int i = 0;
for (Iterator iter = list.iterator(); iter.hasNext(); ) {
String pattern = (String) iter.next();
args.addArgument("arg" + i++, pattern);
}
writeProperty(out, name, args);
}
}
1.1 jakarta-jmeter/src_1/org/apache/jmeter/save/old/handlers/TestPlanHandler.java
Index: TestPlanHandler.java
===================================================================
/*
* ====================================================================
* 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.save.old.handlers;
import java.io.Writer;
import org.apache.jmeter.save.old.Saveable;
import org.apache.jmeter.save.old.xml.TagHandler;
import org.apache.jmeter.testelement.TestPlan;
import org.xml.sax.Attributes;
/************************************************************
* Title: Description: Copyright: Copyright (c) 2001 Company:
*
*@author Michael Stover
*@created $Date: 2002/06/01 13:21:27 $
*@version 1.0
***********************************************************/
public class TestPlanHandler extends TagHandler
{
/************************************************************
* !ToDo (Constructor description)
***********************************************************/
public TestPlanHandler()
{
}
/************************************************************
* !ToDo (Method description)
*
*@param atts !ToDo (Parameter description)
*@exception java.lang.Exception !ToDo (Exception description)
***********************************************************/
public void setAtts(Attributes atts) throws java.lang.Exception
{
}
/************************************************************
* !ToDoo (Method description)
*
*@return !ToDo (Return description)
***********************************************************/
public String getPrimaryTagName()
{
return "TestPlan";
}
/************************************************************
* !ToDoo (Method description)
*
*@return !ToDo (Return description)
***********************************************************/
public Object getModel()
{
return TestPlan.createTestPlan(null);
}
/************************************************************
* !ToDo (Method description)
*
*@param s !ToDo (Parameter description)
*@param out !ToDo (Parameter description)
*@exception java.io.IOException !ToDo (Exception description)
***********************************************************/
public void save(Saveable s, Writer out) throws java.io.IOException
{
/*out.write("<TestPlan>\n");
TestPlan save = (TestPlan)s;
JMeterHandler.writeThreadGroups(save.getThreadGroups(), out);
JMeterHandler.writeConfigElements(save.getConfigElements(), out);
out.write("</TestPlan>\n");*/
}
}
1.1 jakarta-jmeter/src_1/org/apache/jmeter/save/old/handlers/ThreadGroupHandler.java
Index: ThreadGroupHandler.java
===================================================================
/*
* ====================================================================
* 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.save.old.handlers;
import java.io.Writer;
import java.util.Iterator;
import org.apache.jmeter.control.LoopController;
import org.apache.jmeter.save.old.Saveable;
import org.apache.jmeter.save.old.xml.TagHandler;
import org.apache.jmeter.testelement.TestElement;
import org.apache.jmeter.threads.ThreadGroup;
import org.xml.sax.Attributes;
/************************************************************
* Title: Description: Copyright: Copyright (c) 2001 Company:
*
*@author Michael Stover
*@created $Date: 2002/06/01 13:21:27 $
*@version 1.0
***********************************************************/
public class ThreadGroupHandler extends TagHandler
{
private ThreadGroup group;
/************************************************************
* !ToDo (Constructor description)
***********************************************************/
public ThreadGroupHandler()
{
}
/************************************************************
* !ToDo (Method description)
*
*@param atts !ToDo (Parameter description)
*@exception java.lang.Exception !ToDo (Exception description)
***********************************************************/
public void setAtts(Attributes atts) throws java.lang.Exception
{
group = new ThreadGroup();
group.setName(atts.getValue("name"));
group.setProperty(TestElement.GUI_CLASS,
"org.apache.jmeter.threads.gui.ThreadGroupGui");
try
{
group.setNumThreads(Integer.parseInt(atts.getValue("numThreads")));
}
catch(NumberFormatException err)
{
group.setNumThreads(1);
}
try
{
group.setRampUp(Integer.parseInt(atts.getValue("rampUp")));
}
catch (NumberFormatException ex)
{
group.setRampUp(0);
}
}
/************************************************************
* !ToDoo (Method description)
*
*@return !ToDo (Return description)
***********************************************************/
public String getPrimaryTagName()
{
return "ThreadGroup";
}
/************************************************************
* !ToDoo (Method description)
*
*@return !ToDo (Return description)
***********************************************************/
public Object getModel()
{
return group;
}
/************************************************************
* !ToDo (Method description)
*
*@param s !ToDo (Parameter description)
*@param out !ToDo (Parameter description)
*@exception java.io.IOException !ToDo (Exception description)
***********************************************************/
public void save(Saveable s, Writer out) throws java.io.IOException
{
/*ThreadGroup save = (ThreadGroup)s;
out.write("<ThreadGroup name=\"");
out.write(JMeterHandler.convertToXML(save.getName()));
out.write("\" numThreads=\"");
out.write(String.valueOf(save.getNumThreads()));
out.write("\" rampUp=\"");
out.write(String.valueOf(save.getRampUp()));
out.write("\"");
out.write(">\n");
Collection controllers = new LinkedList();
controllers.add(save.getSamplerController());
JMeterHandler.writeControllers(controllers, out);
JMeterHandler.writeTimers(save.getTimers(), out);
JMeterHandler.writeListeners(save.getListeners(), out);
out.write("</ThreadGroup>\n");*/
}
/************************************************************
* !ToDo (Method description)
*
*@param childObj !ToDo (Parameter description)
***********************************************************/
public void notifySubElementEnded(Object childObj)
{
if (childObj instanceof LoopController)
{
Iterator children = xmlParent.takeChildObjects(this).iterator();
if (children.hasNext())
{
group.setSamplerController((LoopController)((TagHandler)children.next()).getModel());
}
}
}
}
1.1 jakarta-jmeter/src_1/org/apache/jmeter/save/old/handlers/TimerHandler.java
Index: TimerHandler.java
===================================================================
package org.apache.jmeter.save.old.handlers;
import java.io.Writer;
import org.apache.jmeter.gui.JMeterComponentModel;
import org.apache.jmeter.save.old.Saveable;
import org.apache.jmeter.save.old.xml.TagHandler;
import org.apache.jmeter.testelement.TestElement;
import org.apache.jmeter.timers.Timer;
import org.xml.sax.Attributes;
/**
* Title:
* Description:
* Copyright: Copyright (c) 2001
* Company:
* @author
* @version 1.0
*/
public class TimerHandler extends TagHandler
{
Timer timer;
public TimerHandler()
{
}
public void save(Saveable parm1, Writer out) throws java.io.IOException
{
Timer timer = (Timer)parm1;
out.write("<Timer type=\"");
out.write(JMeterHandler.convertToXML(timer.getClass().getName()));
out.write("\"");
if(timer instanceof JMeterComponentModel)
{
out.write(" name=\"");
out.write(JMeterHandler.convertToXML(((JMeterComponentModel)timer).getName()));
out.write("\"");
}
out.write(">\n");
out.write("<delay>");
out.write(Long.toString(timer.getDelay()));
out.write("</delay>\n");
out.write("<range>");
out.write(Double.toString(timer.getRange()));
out.write("</range>\n");
out.write("</Timer>\n");
}
public void setAtts(Attributes atts) throws java.lang.Exception
{
timer = (Timer)Class.forName(atts.getValue("type")).newInstance();
((TestElement)timer).setProperty(TestElement.GUI_CLASS,JMeterHandler.getGuiClass(atts.getValue("type")));
if(timer instanceof JMeterComponentModel)
{
((JMeterComponentModel)timer).setName(atts.getValue("name"));
}
}
public void delay(String data)
{
try
{
timer.setDelay(Long.parseLong(data));
}
catch(NumberFormatException e)
{
timer.setDelay(0);
}
}
public void range(String data)
{
try
{
timer.setRange(Double.parseDouble(data));
}
catch(NumberFormatException e)
{
timer.setRange(0);
}
}
public String getPrimaryTagName()
{
return "Timer";
}
public Object getModel()
{
return timer;
}
}
1.1 jakarta-jmeter/src_1/org/apache/jmeter/save/old/xml/NameSpaceHandler.java
Index: NameSpaceHandler.java
===================================================================
/*
* ====================================================================
* 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.save.old.xml;
import org.xml.sax.Attributes;
/**
* Title:
* Description:
* Copyright: Copyright (c) 2000
* Company:
* @author
* @version 1.0
*/
public interface NameSpaceHandler
{
public TagHandler getXmlObject(String tagName,Attributes atts);
}
1.1 jakarta-jmeter/src_1/org/apache/jmeter/save/old/xml/NoCurrentHandlerException.java
Index: NoCurrentHandlerException.java
===================================================================
/*
* ====================================================================
* 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.save.old.xml;
/**
* Title:
* Description:
* Copyright: Copyright (c) 2000
* Company:
* @author
* @version 1.0
*/
public class NoCurrentHandlerException extends Exception
{
public NoCurrentHandlerException()
{
}
}
1.1 jakarta-jmeter/src_1/org/apache/jmeter/save/old/xml/TagHandler.java
Index: TagHandler.java
===================================================================
/*
* ====================================================================
* 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.save.old.xml;
import java.util.*;
import java.lang.reflect.*;
import java.io.*;
import org.xml.sax.Attributes;
import org.apache.jmeter.save.old.SaveHandler;
/**
* Title:
* Description:
* Copyright: Copyright (c) 2000
* Company:
* @author
* @version 1.0
*/
public abstract class TagHandler implements SaveHandler
{
private LinkedList tagsIn = new LinkedList();
private boolean done = false;
protected String tagName;
protected XmlHandler xmlParent;
private StringBuffer dataStore;
public abstract void setAtts(Attributes atts) throws Exception;
public void setXmlParent(XmlHandler xml)
{
xmlParent = xml;
}
public void startSave(Writer out) throws IOException
{
out.write("<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n\n");
}
/************************************************************
* Indicates whether this tag has been completely parsed
*
*@return True or false whether this tag is done being parsed
***********************************************************/
public boolean isDone()
{
return done;
}
protected void setDone(boolean done)
{
this.done = done;
}
public void unknownTagStart(String name,Attributes atts)
{
}
public void unknownTagEnd(String name)
{
}
public void setData(String data)
{
}
public String getTagName()
{
return tagName;
}
public void setTagName(String tagName)
{
this.tagName = tagName;
}
public abstract Object getModel();
/************************************************************
* Handles character data passed to this class
*
*@param data The data within the XML tag to be handled
***********************************************************/
public void handleData(String data)
{
this.callTagCombo(data);
}
protected void startTag(String tag)
{
if(!tagName.equals(tag))
tagsIn.addLast(tag);
}
protected void endTag(String tag)
{
if(tagName.equals(tag))
{
setDone(true);
}
else
{
tagsIn.removeLast();
}
}
protected String getMethodName()
{
StringBuffer methodName = new StringBuffer();
boolean first = true;
for (Iterator it = tagsIn.iterator(); it.hasNext(); )
{
if (!first)
{
methodName.append("_");
}
else
{
first = false;
}
methodName.append(it.next());
}
return methodName.toString();
}
protected void callTagCombo(Attributes atts)
{
try
{
Method method = this.getClass().getMethod(getMethodName(), new Class[]{Attributes.class});
method.invoke(this, new Object[]{atts});
}
catch(NoSuchMethodException e)
{
}
catch (Exception e)
{
e.printStackTrace();
}
}
protected void callTagCombo(String data)
{
if(dataStore == null)
{
dataStore = new StringBuffer();
}
dataStore.append(data);
}
private void releaseData()
{
if(dataStore != null)
{
try
{
if(getMethodName().equals(""))
{
setData(dataStore.toString());
}
else
{
Method method = this.getClass().getMethod(getMethodName(), new Class[]{String.class});
method.invoke(this, new Object[]{dataStore.toString()});
}
}
catch(NoSuchMethodException e)
{
}
catch (Exception ex)
{
ex.printStackTrace();
}
}
dataStore = null;
}
protected void passToHandler(String localName, Attributes atts)
{
releaseData();
try
{
Class handler = this.getClass();
startTag(localName);
Method method = handler.getMethod(localName + "TagStart", new Class[]{Attributes.class});
method.invoke(this, new Object[]{atts});
}
catch (NoSuchMethodException e)
{
unknownTagStart(localName,atts);
}
catch(InvocationTargetException e)
{
e.printStackTrace();
}
catch(IllegalAccessException e)
{
e.printStackTrace();
}
callTagCombo(atts);
}
protected void passToHandler(String localName)
{
releaseData();
try
{
Class handler = this.getClass();
endTag(localName);
Method method = handler.getMethod(localName + "TagEnd", new Class[0]);
method.invoke(this, new Object[0]);
}
catch (NoSuchMethodException e)
{
unknownTagEnd(localName);
}
catch(InvocationTargetException e)
{
e.printStackTrace();
}
catch(IllegalAccessException e)
{
e.printStackTrace();
}
}
public void notifySubElementEnded(Object childObj)
{
}
}
1.1 jakarta-jmeter/src_1/org/apache/jmeter/save/old/xml/XmlHandler.java
Index: XmlHandler.java
===================================================================
/*
* ====================================================================
* 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.save.old.xml;
import org.xml.sax.helpers.DefaultHandler;
import org.xml.sax.SAXException;
import org.xml.sax.Attributes;
import org.xml.sax.InputSource;
import org.xml.sax.SAXParseException;
import org.apache.xerces.parsers.SAXParser;
import java.util.*;
import java.lang.reflect.*;
import org.apache.jmeter.util.*;
/************************************************************
* Title: Description: Copyright: Copyright (c) 2000 Company:
*
*@author
*@created $Date: 2002/06/01 13:21:28 $
*@version 1.0
***********************************************************/
public class XmlHandler extends DefaultHandler
{
protected LinkedList objectStack;
NameSpaceHandler informer;
List finalHandlers;
ListedHashTree objectHierarchy = new ListedHashTree();
boolean replaced = false;
/************************************************************
* !ToDo (Constructor description)
*
*@param informer !ToDo (Parameter description)
***********************************************************/
public XmlHandler(NameSpaceHandler informer)
{
this.informer = informer;
objectStack = new LinkedList();
finalHandlers = new LinkedList();
}
/************************************************************
* !ToDoo (Method description)
*
*@return !ToDo (Return description)
***********************************************************/
public ListedHashTree getDataTree()
{
if (!replaced)
{
replaceWithModels(objectHierarchy);
}
replaced = true;
return objectHierarchy;
}
/************************************************************
* HandlerBase implementation This reports an error that has occured. This
* indicates that a rule was broken in validation, but that parsing can
* continue.
*
*@param e !ToDo (Parameter description)
*@exception SAXException !ToDo (Exception description)
***********************************************************/
public void fatalError(SAXParseException e) throws SAXException
{
System.out.println("***Parsing Fatal Error**\n" +
" Line: " + e.getLineNumber() + "\n" +
" URI: " + e.getSystemId() + "\n" +
" Message: " + e.getMessage());
throw new SAXException("Fatal Error encountered");
}
/************************************************************
* HandlerBase implementation This reports a fatal error that has occured.
* This indicates that a rule was broken that makes continued parsing
* impossible.
*
*@param errs parse error message
*@exception SAXException !ToDo (Exception description)
***********************************************************/
public void error(SAXParseException errs) throws SAXException
{
System.out.println("***Parsing Error**\n" +
" Line: " + errs.getLineNumber() + "\n" +
" URI: " + errs.getSystemId() + "\n" +
" Message: " + errs.getMessage());
throw new SAXException("Error encountered");
}
/************************************************************
* HandlerBase implementation This reports a warning that has occured; this
* indicates that while no XML rules were broken, something appears to be
* incorrect or missing.
*
*@param err parse warning message
*@exception SAXException !ToDo (Exception description)
***********************************************************/
public void warning(SAXParseException err) throws SAXException
{
System.out.println("***Parsing Warning**\n" +
" Line: " + err.getLineNumber() + "\n" +
" URI: " + err.getSystemId() + "\n" +
" Message: " + err.getMessage());
throw new SAXException("Warning encountered");
}
/************************************************************
* !ToDo (Method description)
*
*@param chardata !ToDo (Parameter description)
*@param start !ToDo (Parameter description)
*@param end !ToDo (Parameter description)
*@exception SAXException !ToDo (Exception description)
***********************************************************/
public void characters(char[] chardata, int start, int end) throws SAXException
{
try
{
if(start >= 0 && start < chardata.length && (end + start) <= chardata.length)
{
getCurrentHandler().handleData(new String(chardata, start, end));
}
}
catch (Exception e)
{
e.printStackTrace();
}
}
/************************************************************
* !ToDo (Method description)
*
*@param uri !ToDo (Parameter description)
*@param localName !ToDo (Parameter description)
*@param qName !ToDo (Parameter description)
*@param atts !ToDo (Parameter description)
***********************************************************/
public void startElement(String uri, String localName, String qName, Attributes atts)
{
//documentElement(localName+":"+qName, atts);
TagHandler newXmlObject = informer.getXmlObject(qName, atts);
if (newXmlObject == null)
{
try
{
getCurrentHandler().passToHandler(qName, atts);
}
catch (Exception ex)
{
System.out.println("No current Handler for " + qName);
}
}
else
{
newXmlObject.setXmlParent(this);
objectHierarchy.add(objectStack, newXmlObject);
objectStack.addLast(newXmlObject);
try
{
getCurrentHandler().passToHandler(qName, atts);
}
catch (Exception ex)
{
System.out.println("(2)No current Handler for " + qName);
}
}
}
/************************************************************
* HandlerBase implementation
*
*@param uri !ToDo (Parameter description)
*@param localName !ToDo (Parameter description)
*@param qName !ToDo (Parameter description)
*@exception SAXException !ToDo (Exception description)
***********************************************************/
public void endElement(java.lang.String uri, java.lang.String localName,
java.lang.String qName) throws SAXException
{
try
{
getCurrentHandler().passToHandler(qName);
}
catch (Exception ex)
{
//ex.printStackTrace();
}
if (currentHandlerIsDone())
{
TagHandler currentHandler = (TagHandler)objectStack.removeLast();
try
{
TagHandler previousHandler = (TagHandler)objectStack.getLast();
previousHandler.notifySubElementEnded(currentHandler.getModel());
}
catch(Exception e)
{
}
}
}
/************************************************************
* !ToDo (Method description)
*
*@param handler !ToDo (Parameter description)
*@return !ToDo (Return description)
***********************************************************/
public List takeChildObjects(TagHandler handler)
{
List stack = new LinkedList();
Iterator iter = objectStack.iterator();
while (iter.hasNext())
{
Object item = iter.next();
stack.add(item);
if (item.equals(handler))
{
break;
}
}
ListedHashTree subTree = objectHierarchy.get(stack);
if (subTree == null)
{
return new LinkedList();
}
List items = new LinkedList(subTree.list());
iter = items.iterator();
while (iter.hasNext())
{
Object item = iter.next();
replaceSubItems(subTree, item);
subTree.remove(item);
}
return items;
}
/************************************************************
* !ToDoo (Method description)
*
*@param tagName !ToDo (Parameter description)
*@param atts !ToDo (Parameter description)
*@return !ToDo (Return description)
***********************************************************/
protected TagHandler getXmlObject(String tagName, Attributes atts)
{
return informer.getXmlObject(tagName, atts);
}
/************************************************************
* !ToDoo (Method description)
*
*@return !ToDo (Return description)
*@exception NoCurrentHandlerException !ToDo (Exception description)
***********************************************************/
protected TagHandler getCurrentHandler() throws NoCurrentHandlerException
{
if (objectStack.size() == 0)
{
throw new NoCurrentHandlerException();
}
else
{
return (TagHandler)objectStack.getLast();
}
}
private void replaceWithModels(ListedHashTree tree)
{
Iterator iter = new LinkedList(tree.list()).iterator();
while (iter.hasNext())
{
TagHandler item = (TagHandler)iter.next();
tree.set(item.getModel(), tree.get(item));
tree.remove(item);
replaceWithModels(tree.get(item.getModel()));
}
}
private boolean currentHandlerIsDone()
{
try
{
return getCurrentHandler().isDone();
}
catch (NoCurrentHandlerException e)
{
return false;
}
}
private void documentElement(String name, Attributes atts)
{
System.out.println("startElement= " + name);
for (int i = 0; i < atts.getLength(); i++)
{
System.out.println(" Attribute= " + atts.getQName(i) + "=" + atts.getValue(i));
}
}
private void replaceSubItems(ListedHashTree subTree, Object item)
{
ListedHashTree subSubTree = subTree.get(item);
List subItems = subSubTree.list();
Iterator iter2 = subItems.iterator();
while (iter2.hasNext())
{
Object subItem = iter2.next();
subTree.set(subItem, subSubTree.get(subItem));
}
}
}
1.5 +1 -0 jakarta-jmeter/src_1/org/apache/jmeter/testelement/TestPlan.java
Index: TestPlan.java
===================================================================
RCS file: /home/cvs/jakarta-jmeter/src_1/org/apache/jmeter/testelement/TestPlan.java,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -r1.4 -r1.5
--- TestPlan.java 1 May 2002 23:48:53 -0000 1.4
+++ TestPlan.java 1 Jun 2002 13:21:28 -0000 1.5
@@ -72,6 +72,7 @@
{
plan = new TestPlan(name);
}
+ plan.setProperty(TestElement.GUI_CLASS,"org.apache.jmeter.control.gui.TestPlanGui");
}
return plan;
}
1.13 +0 -0 jakarta-jmeter/src_1/org/apache/jmeter/threads/JMeterThread.java
Index: JMeterThread.java
===================================================================
RCS file: /home/cvs/jakarta-jmeter/src_1/org/apache/jmeter/threads/JMeterThread.java,v
retrieving revision 1.12
retrieving revision 1.13
diff -u -r1.12 -r1.13
--- JMeterThread.java 31 May 2002 01:34:57 -0000 1.12
+++ JMeterThread.java 1 Jun 2002 13:21:28 -0000 1.13
@@ -70,8 +70,8 @@
* timing, add listeners for sampling events and to stop the sampling process.
*
*@author $Author: mstover1 $
- *@created $Date: 2002/05/31 01:34:57 $
- *@version $Revision: 1.12 $
+ *@created $Date: 2002/06/01 13:21:28 $
+ *@version $Revision: 1.13 $
***************************************/
public class JMeterThread implements Runnable, java.io.Serializable {
static Map samplers = new HashMap();
--
To unsubscribe, e-mail: <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>