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/05/01 04:02:20 UTC
cvs commit: jakarta-jmeter/src_1/org/apache/jmeter/resources messages.properties messages_ja.properties messages_no.properties
mstover1 02/04/30 19:02:20
Modified: src/org/apache/jmeter/resources messages.properties
messages_ja.properties messages_no.properties
src_1/org/apache/jmeter/resources messages.properties
messages_ja.properties messages_no.properties
Added: bin users.dtd users.xml
src/org/apache/jmeter/protocol/http/modifier
UserParameterModifier.java
UserParameterXMLContentHandler.java
UserParameterXMLErrorHandler.java
UserParameterXMLParser.java UserSequence.java
src/org/apache/jmeter/protocol/http/modifier/gui
UserParameterModifierGui.java
Log:
New user parameter modifier from Mark Walsh
Revision Changes Path
1.1 jakarta-jmeter/bin/users.dtd
Index: users.dtd
===================================================================
<!ELEMENT allthreads (thread+)>
<!ATTLIST thread
>
<!ELEMENT thread (parameter+)>
<!ATTLIST parameter
>
<!ELEMENT parameter (paramname,paramvalue) >
<!ELEMENT paramname (#PCDATA) >
<!ELEMENT paramvalue (#PCDATA) >
1.1 jakarta-jmeter/bin/users.xml
Index: users.xml
===================================================================
<?xml version="1.0"?>
<!DOCTYPE allthreads SYSTEM "users.dtd">
<!-- all users, uses round robin selection -->
<allthreads>
<!-- unique parameters for each individual thread (ie user) -->
<thread>
<parameter>
<paramname>user_id</paramname>
<paramvalue>dduck</paramvalue>
</parameter>
<parameter>
<paramname>password</paramname>
<paramvalue>quack</paramvalue>
</parameter>
</thread>
<thread>
<parameter>
<paramname>user_id</paramname>
<paramvalue>mmouse</paramvalue>
</parameter>
<parameter>
<paramname>password</paramname>
<paramvalue>squeak</paramvalue>
</parameter>
</thread>
<thread>
<parameter>
<paramname>user_id</paramname>
<paramvalue>bbunney</paramvalue>
</parameter>
<parameter>
<paramname>password</paramname>
<paramvalue>carrot</paramvalue>
</parameter>
<parameter>
<paramname>manager</paramname>
<paramvalue>yes</paramvalue>
</parameter>
</thread>
</allthreads>
1.1 jakarta-jmeter/src/org/apache/jmeter/protocol/http/modifier/UserParameterModifier.java
Index: UserParameterModifier.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.protocol.http.modifier;
import org.apache.jmeter.config.Modifier;
import org.apache.jmeter.gui.JMeterComponentModel;
import org.apache.jmeter.config.ConfigElement;
import org.apache.jmeter.samplers.Entry;
import org.apache.jmeter.protocol.http.config.UrlConfig;
import org.apache.jmeter.protocol.http.parser.HtmlParser;
import org.apache.jmeter.protocol.http.sampler.HTTPSampler;
import org.apache.jmeter.samplers.SampleResult;
import org.apache.jmeter.samplers.Sampler;
import org.apache.jmeter.config.Argument;
import org.apache.jmeter.config.Arguments;
import org.apache.jmeter.gui.NamePanel;
import org.apache.jmeter.util.JMeterUtils;
import java.util.*;
import java.io.*;
import org.w3c.dom.*;
import org.xml.sax.SAXException;
import java.net.*;
import org.apache.jmeter.config.AbstractConfigElement;
/************************************************************
* Title: Jakarta-JMeter Description: Copyright: Copyright (c) 2001 Company:
* Apache
*
*<P>This modifier will replace any http sampler's url parameter values with
* parameter values defined in a XML file for each simulated user
*<BR>
*<P>For example if userid and password are defined in the XML parameter file
* for each user (ie thread), then simulated multiple user activity can occur
*@author Mark Walsh
*@created $Date: 2002/05/01 02:02:19 $
*@version 1.0
***********************************************************/
public class UserParameterModifier extends AbstractConfigElement implements JMeterComponentModel, Modifier, Serializable
{
//-------------------------------------------
// Constants and Data Members
//-------------------------------------------
private UserSequence allAvailableUsers ;
private String xmlURI = "users.xml"; //name of XML file containing user parameters
//-------------------------------------------
// Constructors
//-------------------------------------------
/**
* Default constructor
*/
public UserParameterModifier()
{
} //end constructor
//-------------------------------------------
// Methods
//-------------------------------------------
/*----------------------------------------------------------------------------------------------
* Methods overriden/implemented from org.apache.jmeter.config.AbstractConfigElement
*--------------------------------------------------------------------------------------------*/
/**
* Not implemented. This object does not allow child componenets
*
* @param obj A component to allow as a child
*/
public void addJMeterComponent(JMeterComponentModel obj)
{
}
/**
* Runs before the start of every test. Reload the Sequencer with the
* latest parameter data for each user
*/
public void uncompile()
{
// try to populate allUsers, if fail, leave as any empty set
Set allUsers = new HashSet();
try {
UserParameterXMLParser readXMLParameters = new UserParameterXMLParser();
allUsers = readXMLParameters.getXMLParameters(getXmlUri());
} catch (Exception e) {
// do nothing, now object allUsers contains an empty set
System.err.println("Unable to read parameters from xml file " + getXmlUri());
System.err.println("No unique values for http requests will be substituted for each thread");
}
allAvailableUsers = new UserSequence(allUsers);
}
/**
* Not implemented. This object does not allow child components
*
* @return <code>null</code>
*/
public Collection getAddList()
{
return null;
}
/**
* Returns the gui class used to interface with this object
*
* @return A gui (panel) class
*/
public Class getGuiClass()
{
return org.apache.jmeter.protocol.http.modifier.gui.UserParameterModifierGui.class;
}
/**
* Not implemented. This object does not support layered config objects
*
* @param config A config object to allow as a child
*/
public void addConfigElement(ConfigElement config)
{
}
/************************************************************
* !ToDo (Method description)
*
*@return !ToDo (Return description)
***********************************************************/
public Object clone()
{
return this;
}
/*----------------------------------------------------------------------------------------------
* Methods implemented from org.apache.jmeter.gui.JMeterComponentModel
*--------------------------------------------------------------------------------------------*/
/**
* Gets the user friendly name given to this object
*
* @return The user friendly name of this object
*/
public String getClassLabel()
{
//return JMeterUtils.getResString("user_parameter_modifier_title");
String user_parameter_modifier_title = "HTTP User Parameter Modifier";
return user_parameter_modifier_title;
}
public void setName(String name)
{
}
public String getName()
{
return getClassLabel();
}
/*----------------------------------------------------------------------------------------------
* Methods implemented from interface org.apache.jmeter.config.Modifier
*--------------------------------------------------------------------------------------------*/
/**
* Modifies an entry object to replace the value of any url parameter that matches a parameter
* name in the XML file.
*
* @param entry Entry object containing information about the current test
* @return <code>True</code> if modified, else <code>false</code>
*/
public boolean modifyEntry(Entry entry)
{
UrlConfig config = (UrlConfig)entry.getConfigElement(UrlConfig.class);
Map currentUser = allAvailableUsers.getNextUserMods();
boolean changeValue = false;
Iterator iter = config.getArguments().iterator();
while(iter.hasNext())
{
Argument arg = (Argument)iter.next();
// if parameter name exists in http request
// then change its value
// (Note: each jmeter thread (ie user) gets to have unique values)
if (currentUser.containsKey(arg.getName()) ) {
arg.setValue(currentUser.get(arg.getName()));
}
}
return changeValue;
}
/*----------------------------------------------------------------------------------------------
* Methods (used by UserParameterModifierGui to get/set the name of XML parameter file)
*--------------------------------------------------------------------------------------------*/
/**
* return the current XML file name to be read to obtain the parameter data for all users
* @return the name of the XML file containing parameter data for each user
*/
public String getXmlUri() {
return xmlURI;
}
/**
* From the GUI screen, set file name of XML to read
* @param the name of the XML file containing the HTTP name value pair parameters per user
*/
public void setXmlUri(String xmlURI) {
this.xmlURI = xmlURI;
}
}
1.1 jakarta-jmeter/src/org/apache/jmeter/protocol/http/modifier/UserParameterXMLContentHandler.java
Index: UserParameterXMLContentHandler.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.protocol.http.modifier;
import org.xml.sax.*;
import java.util.*;
import java.io.*;
/************************************************************
* Title: Jakarta-JMeter Description: Copyright: Copyright (c) 2001 Company:
* Apache
* <P>The handler used to read in XML parameter data
*@author Mark Walsh
*@created $Date: 2002/05/01 02:02:19 $
*@version 1.0
***********************************************************/
public class UserParameterXMLContentHandler implements ContentHandler {
//-------------------------------------------
// Constants and Data Members
//-------------------------------------------
// Note UserParameterXML access this variable
// to obtain the Set data via method getParsedParameters()
private Set userThreads = new HashSet();
private String paramname = "";
private String paramvalue = "";
private Map nameValuePair = new HashMap();
// buffers for collecting data from the
// "characters" SAX event
private CharArrayWriter contents = new CharArrayWriter();
//-------------------------------------------
// Constructors
//-------------------------------------------
//-------------------------------------------
// Methods
//-------------------------------------------
/*----------------------------------------------------------------------------------------------
* Methods implemented from org.xml.sax.ContentHandler
*--------------------------------------------------------------------------------------------*/
public void setDocumentLocator(Locator locator) {
}
public void startDocument()
throws SAXException {
}
public void endDocument()
throws SAXException {
}
public void startPrefixMapping(String prefix,
String uri)
throws SAXException {
}
public void endPrefixMapping(String prefix)
throws SAXException {
}
public void startElement(String namespaceURL,
String localName,
String qName,
Attributes atts)
throws SAXException {
contents.reset();
// haven't got to reset paramname & paramvalue
// but did it to keep the code looking correct
if (localName.equals("parameter")) {
paramname="";
paramvalue="";
}
// must create a new object,
// or else end up with a set full of the same Map object
if (localName.equals("thread")) {
nameValuePair = new HashMap();
}
}
public void endElement(String namespaceURI,
String localName,
String qName)
throws SAXException {
if (localName.equals("paramname")) {
paramname = contents.toString();
}
if (localName.equals("paramvalue")) {
paramvalue = contents.toString();
}
if (localName.equals("parameter")) {
nameValuePair.put(paramname,paramvalue);
}
if (localName.equals("thread")) {
userThreads.add(nameValuePair);
}
}
public void characters(char ch[],
int start,
int length)
throws SAXException {
contents.write(ch, start, length);
}
public void ignorableWhitespace(char ch[],
int start,
int length)
throws SAXException {
}
public void processingInstruction(String target,
String date)
throws SAXException {
}
public void skippedEntity(String name)
throws SAXException {
}
/*----------------------------------------------------------------------------------------------
* Methods (used by UserParameterXML to get XML parameters from XML file)
*--------------------------------------------------------------------------------------------*/
/**
* results of parsing all user parameter data defined in XML file.
* @return all users name value pairs obtained from XML file
*/
public Set getParsedParameters() {
return userThreads;
}
} // end class
1.1 jakarta-jmeter/src/org/apache/jmeter/protocol/http/modifier/UserParameterXMLErrorHandler.java
Index: UserParameterXMLErrorHandler.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.protocol.http.modifier;
import org.xml.sax.*;
import java.util.*;
import java.io.*;
/************************************************************
* Title: Jakarta-JMeter Description: Copyright: Copyright (c) 2001 Company:
* Apache
* <P> XML Parseing errors for XML parameters file are handled here
*@author Mark Walsh
*@created $Date: 2002/05/01 02:02:19 $
*@version 1.0
***********************************************************/
public class UserParameterXMLErrorHandler implements ErrorHandler {
//-------------------------------------------
// Constants and Data Members
//-------------------------------------------
//-------------------------------------------
// Constructors
//-------------------------------------------
//-------------------------------------------
// Methods
//-------------------------------------------
public void warning(SAXParseException exception)
throws SAXException {
System.err.println("**Parsing Warning**\n" +
" line: " + exception.getLineNumber() + "\n" +
" URI: :" + exception.getSystemId() + "\n" +
" Message: " + exception.getMessage() );
throw new SAXException("Warning encountered");
}
public void error(SAXParseException exception)
throws SAXException {
System.err.println("**Parsing Warning**\n" +
" line: " + exception.getLineNumber() + "\n" +
" URI: :" + exception.getSystemId() + "\n" +
" Message: " + exception.getMessage() );
throw new SAXException("Error encountered");
}
public void fatalError(SAXParseException exception)
throws SAXException {
System.err.println("**Parsing Warning**\n" +
" line: " + exception.getLineNumber() + "\n" +
" URI: :" + exception.getSystemId() + "\n" +
" Message: " + exception.getMessage() );
throw new SAXException("Fatal Error encountered");
}
} // end class
1.1 jakarta-jmeter/src/org/apache/jmeter/protocol/http/modifier/UserParameterXMLParser.java
Index: UserParameterXMLParser.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.protocol.http.modifier;
import org.xml.sax.*;
import org.xml.sax.helpers.*;
import java.io.*;
import java.util.*;
/************************************************************
* Title: Jakarta-JMeter Description: Copyright: Copyright (c) 2001 Company:
* Apache
* <P>Parse a XML file to obtain parameter name and value information
* for all users defined in the XML file.
*
*@author Mark Walsh
*@created $Date: 2002/05/01 02:02:19 $
*@version 1.0
***********************************************************/
public class UserParameterXMLParser {
//-------------------------------------------
// Constants and Data Members
//-------------------------------------------
private String vendorParseClass = "org.apache.xerces.parsers.SAXParser";
//-------------------------------------------
// Constructors
//-------------------------------------------
//-------------------------------------------
// Methods
//-------------------------------------------
/**
* parse all user parameter data defined in XML file.
* @param Name of the XML to load users parameter data
* @return all users name value pairs obtained from XML file
*/
public Set getXMLParameters(String xmlURI)
throws SAXException, IOException {
//create instances needed for parsing
XMLReader reader = XMLReaderFactory.createXMLReader(vendorParseClass);
UserParameterXMLContentHandler threadParametersContentHandler = new UserParameterXMLContentHandler();
UserParameterXMLErrorHandler parameterErrorHandler = new UserParameterXMLErrorHandler();
//register content handler
reader.setContentHandler(threadParametersContentHandler);
// register error handler
reader.setErrorHandler(parameterErrorHandler);
// Request validation
reader.setFeature("http://xml.org/sax/features/validation",true);
//parse
InputSource inputSource = new InputSource(xmlURI);
reader.parse(inputSource);
return threadParametersContentHandler.getParsedParameters();
} // end main
} // end class
1.1 jakarta-jmeter/src/org/apache/jmeter/protocol/http/modifier/UserSequence.java
Index: UserSequence.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.protocol.http.modifier;
import java.util.*;
/************************************************************
* Title: Jakarta-JMeter Description: Copyright: Copyright (c) 2001 Company:
* Apache
* <P> This module controls the Sequence in which user details are returned.
* <BR>
* <P> This module uses round robin allocation of users.
*@author Mark Walsh
*@created $Date: 2002/05/01 02:02:19 $
*@version 1.0
***********************************************************/
public class UserSequence {
//-------------------------------------------
// Constants and Data Members
//-------------------------------------------
private Set allUsers;
private Iterator indexOfUsers;
//-------------------------------------------
// Constructors
//-------------------------------------------
/**
* Load all user and parameter data into the sequence module
* <BR>
* ie a Set of Mapped "parameter names and parameter values" for each user to be loader into the sequencer
*/
public UserSequence(Set allUsers) {
this.allUsers = allUsers;
// initalise pointer to first user
indexOfUsers = allUsers.iterator();
}
//-------------------------------------------
// Methods
//-------------------------------------------
/**
* Returns the parameter data for the next user in the sequence
* @param Returns a Map object of parameter names and matching parameter values for the next user
*/
public synchronized Map getNextUserMods() {
// Use round robin allocation of user details
if (!indexOfUsers.hasNext()) {
indexOfUsers = allUsers.iterator();
}
Map user;
if (indexOfUsers.hasNext() ) {
user = (Map)indexOfUsers.next();
//debug
//System.out.println("current parameters will be changed to: " + user);
} else {
// no entries in all users, therefore create an empty Map object
user = new HashMap();
}
return user;
} // end method getNextUserMods
} // end class
1.1 jakarta-jmeter/src/org/apache/jmeter/protocol/http/modifier/gui/UserParameterModifierGui.java
Index: UserParameterModifierGui.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.protocol.http.modifier.gui;
import javax.swing.*;
import java.awt.event.*;
import javax.swing.border.*;
import javax.swing.table.*;
import java.awt.*;
import javax.swing.text.*;
import org.apache.jmeter.gui.*;
import org.apache.jmeter.protocol.http.modifier.UserParameterModifier;
import org.apache.jmeter.util.JMeterUtils;
/************************************************************
* Title: JMeter Description: Copyright: Copyright (c) 2000 Company: Apache
*
* A swing panel to allow UI with the UserParameterModifier class.
*
*@author Mark Walsh
*@created $Date: 2002/05/01 02:02:19 $
*@version 1.0
***********************************************************/
public class UserParameterModifierGui extends JPanel implements ModelSupported, FocusListener
{
//-------------------------------------------
// Constants and Data Members
//-------------------------------------------
private UserParameterModifier model;
private JTextField fileNameField;
private String fileNameDescriptorField = "fileNameField";
//-------------------------------------------
// Constructors
//-------------------------------------------
/************************************************************
* !ToDo (Constructor description)
***********************************************************/
public UserParameterModifierGui()
{
}
//-------------------------------------------
// Methods
//-------------------------------------------
/************************************************************
* !ToDo (Method description)
*
*@param model !ToDo (Parameter description)
***********************************************************/
public void setModel(Object model)
{
this.model = (UserParameterModifier)model;
init();
}
/************************************************************
* !ToDo (Method description)
***********************************************************/
public void updateGui()
{
}
/*----------------------------------------------------------------------------------------------
* Methods Private
*--------------------------------------------------------------------------------------------*/
private void init()
{
this.setLayout(new VerticalLayout(5, VerticalLayout.LEFT, VerticalLayout.TOP));
// MAIN PANEL
JPanel mainPanel = new JPanel();
Border margin = new EmptyBorder(10, 10, 5, 10);
mainPanel.setBorder(margin);
mainPanel.setLayout(new VerticalLayout(5, VerticalLayout.LEFT));
// TITLE
//JLabel panelTitleLabel = new JLabel(JMeterUtils.getResString("user_parameter_modifier_title"));
JLabel panelTitleLabel = new JLabel(JMeterUtils.getResString("HTTP User Parameter Modifier"));
Font curFont = panelTitleLabel.getFont();
int curFontSize = curFont.getSize();
curFontSize += 4;
panelTitleLabel.setFont(new Font(curFont.getFontName(), curFont.getStyle(), curFontSize));
mainPanel.add(panelTitleLabel);
// NAME
mainPanel.add(new NamePanel(model));
// FILE LOCATOR
mainPanel.add(getFileLocator() );
mainPanel.add(new JLabel(JMeterUtils.getResString("user_param_mod_help_note")));
this.add(mainPanel);
}
private JPanel getFileLocator() {
JPanel fileLocator = new JPanel();
JLabel fileName = new JLabel("File Name");
fileLocator.add(fileName);
fileNameField = new JTextField(model.getXmlUri(),15 );
fileNameField.addFocusListener(this);
fileNameField.setName(fileNameDescriptorField);
fileLocator.add(fileNameField);
return fileLocator;
}
/*----------------------------------------------------------------------------------------------
* Methods implemented from FocusListener
*--------------------------------------------------------------------------------------------*/
public void focusGained(FocusEvent evt) {
}
public void focusLost(FocusEvent evt) {
if (evt.isTemporary()) {
return;
}
String name = evt.getComponent().getName();
// set the name of the xml file to be parsed
// for parameters that need changing per thread
if (name.equals(fileNameDescriptorField) ) {
model.setXmlUri(fileNameField.getText());
}
}
}
1.49 +2 -0 jakarta-jmeter/src/org/apache/jmeter/resources/messages.properties
Index: messages.properties
===================================================================
RCS file: /home/cvs/jakarta-jmeter/src/org/apache/jmeter/resources/messages.properties,v
retrieving revision 1.48
retrieving revision 1.49
diff -u -r1.48 -r1.49
--- messages.properties 18 Mar 2002 00:48:25 -0000 1.48
+++ messages.properties 1 May 2002 02:02:19 -0000 1.49
@@ -204,3 +204,5 @@
lower_bound=Lower Bound
upper_bound=Upper Bound
increment=Increment
+http_user_parameter_modifier=HTTP User Parameter Modifier
+user_param_mod_help_note=(Do not change this. Instead, modify the file of that name in JMeter's /bin directory)
\ No newline at end of file
1.9 +3 -1 jakarta-jmeter/src/org/apache/jmeter/resources/messages_ja.properties
Index: messages_ja.properties
===================================================================
RCS file: /home/cvs/jakarta-jmeter/src/org/apache/jmeter/resources/messages_ja.properties,v
retrieving revision 1.8
retrieving revision 1.9
diff -u -r1.8 -r1.9
--- messages_ja.properties 17 Mar 2002 16:06:49 -0000 1.8
+++ messages_ja.properties 1 May 2002 02:02:19 -0000 1.9
@@ -188,4 +188,6 @@
insert_parent=Insert Parent
uniform_timer_memo=\u4E00\u69D8\u306B\u30E9\u30F3\u30C0\u30E0\u306A\u9045\u5EF6\u3092\u8FFD\u52A0
url=URL
-Success?=Success?
\ No newline at end of file
+Success?=Success?
+http_user_parameter_modifier=HTTP User Parameter Modifier
+user_param_mod_help_note=(Do not change this. Instead, modify the file of that name in JMeter's /bin directory)
\ No newline at end of file
1.5 +2 -0 jakarta-jmeter/src/org/apache/jmeter/resources/messages_no.properties
Index: messages_no.properties
===================================================================
RCS file: /home/cvs/jakarta-jmeter/src/org/apache/jmeter/resources/messages_no.properties,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -r1.4 -r1.5
--- messages_no.properties 17 Mar 2002 16:06:49 -0000 1.4
+++ messages_no.properties 1 May 2002 02:02:19 -0000 1.5
@@ -180,3 +180,5 @@
insert_parent=Insert Parent
url=URL
Success?=Success?
+http_user_parameter_modifier=HTTP User Parameter Modifier
+user_param_mod_help_note=(Do not change this. Instead, modify the file of that name in JMeter's /bin directory)
\ No newline at end of file
1.6 +3 -1 jakarta-jmeter/src_1/org/apache/jmeter/resources/messages.properties
Index: messages.properties
===================================================================
RCS file: /home/cvs/jakarta-jmeter/src_1/org/apache/jmeter/resources/messages.properties,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -r1.5 -r1.6
--- messages.properties 1 May 2002 01:39:40 -0000 1.5
+++ messages.properties 1 May 2002 02:02:19 -0000 1.6
@@ -211,4 +211,6 @@
login_config_element=Login Config Element
menu_non_test_elements=Non-Test Elements
file_already_in_use=That file is already in use
-busy_testing=I'm busy testing, please stop the test before changing settings
\ No newline at end of file
+busy_testing=I'm busy testing, please stop the test before changing settings
+http_user_parameter_modifier=HTTP User Parameter Modifier
+user_param_mod_help_note=(Do not change this. Instead, modify the file of that name in JMeter's /bin directory)
\ No newline at end of file
1.5 +3 -1 jakarta-jmeter/src_1/org/apache/jmeter/resources/messages_ja.properties
Index: messages_ja.properties
===================================================================
RCS file: /home/cvs/jakarta-jmeter/src_1/org/apache/jmeter/resources/messages_ja.properties,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -r1.4 -r1.5
--- messages_ja.properties 1 May 2002 01:39:40 -0000 1.4
+++ messages_ja.properties 1 May 2002 02:02:19 -0000 1.5
@@ -205,4 +205,6 @@
login_config_element=Login Config Element
menu_non_test_elements=Non-Test Elements
file_already_in_use=That file is already in use
-busy_testing=I'm busy testing, please stop the test before changing settings
\ No newline at end of file
+busy_testing=I'm busy testing, please stop the test before changing settings
+http_user_parameter_modifier=HTTP User Parameter Modifier
+user_param_mod_help_note=(Do not change this. Instead, modify the file of that name in JMeter's /bin directory)
\ No newline at end of file
1.5 +3 -1 jakarta-jmeter/src_1/org/apache/jmeter/resources/messages_no.properties
Index: messages_no.properties
===================================================================
RCS file: /home/cvs/jakarta-jmeter/src_1/org/apache/jmeter/resources/messages_no.properties,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -r1.4 -r1.5
--- messages_no.properties 1 May 2002 01:39:40 -0000 1.4
+++ messages_no.properties 1 May 2002 02:02:19 -0000 1.5
@@ -196,4 +196,6 @@
login_config_element=Login Config Element
menu_non_test_elements=Non-Test Elements
file_already_in_use=That file is already in use
-busy_testing=I'm busy testing, please stop the test before changing settings
\ No newline at end of file
+busy_testing=I'm busy testing, please stop the test before changing settings
+http_user_parameter_modifier=HTTP User Parameter Modifier
+user_param_mod_help_note=(Do not change this. Instead, modify the file of that name in JMeter's /bin directory)
\ No newline at end of file
--
To unsubscribe, e-mail: <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>