mstover1 2002/07/10 17:26:52
Modified: . build.xml
src_1/org/apache/jmeter NewDriver.java
src_1/org/apache/jmeter/gui MainFrame.java
src_1/org/apache/jmeter/protocol/http/modifier
ParamMask.java
src_1/org/apache/jmeter/protocol/http/modifier/gui
ParamModifierGui.java
src_1/org/apache/jmeter/protocol/http/sampler
MultipartFormSampler.java
src_1/org/apache/jmeter/resources messages.properties
messages_ja.properties messages_no.properties
Added: lib xalan.jar xml-apis.jar
src_1/org/apache/jmeter/protocol/all/modifier
InvalidVariableException.java ResponseVariable.java
Variable.java
Log:
Changes to fix JDK1.3 compatibility problems
Creating Variable interface for built-in functions.
Revision Changes Path
1.62 +2 -3 jakarta-jmeter/build.xml
Index: build.xml
===================================================================
RCS file: /home/cvs/jakarta-jmeter/build.xml,v
retrieving revision 1.61
retrieving revision 1.62
diff -u -r1.61 -r1.62
--- build.xml 29 Jun 2002 00:36:59 -0000 1.61
+++ build.xml 11 Jul 2002 00:26:51 -0000 1.62
@@ -173,9 +173,8 @@
file="${sources.src.dir}/org/apache/jmeter/help.txt"/>
<mkdir dir="./lib/ext/"/>
- <jar jarfile="./lib/ext/ApacheJMeter_core.jar"
excludes="**/NewDriver.class,**/NonGuiDriver.class"
manifest="${sources.src.dir}/MANIFEST" basedir="${classes.dest.dir}"/>
- <jar jarfile="ApacheJMeter.jar"
includes="**/NewDriver.class,**/NonGuiDriver.class"
manifest="${sources.src.dir}/MANIFEST" basedir="${classes.dest.dir}"/>
- </target>
+ <jar jarfile="./lib/ext/ApacheJMeter_core.jar" excludes="**/NewDriver*"
manifest="${sources.src.dir}/MANIFEST" basedir="${classes.dest.dir}"/>
+ <jar jarfile="ApacheJMeter.jar" includes="**/NewDriver*"
manifest="${sources.src.dir}/MANIFEST" basedir="${classes.dest.dir}"/>
</target>
<!--
- Copies the jar file to bin/ and everything else needed to run JMeter
1.1 jakarta-jmeter/lib/xalan.jar
<<Binary file>>
1.1 jakarta-jmeter/lib/xml-apis.jar
<<Binary file>>
1.9 +16 -2 jakarta-jmeter/src_1/org/apache/jmeter/NewDriver.java
Index: NewDriver.java
===================================================================
RCS file: /home/cvs/jakarta-jmeter/src_1/org/apache/jmeter/NewDriver.java,v
retrieving revision 1.8
retrieving revision 1.9
diff -u -r1.8 -r1.9
--- NewDriver.java 29 Jun 2002 00:36:59 -0000 1.8
+++ NewDriver.java 11 Jul 2002 00:26:52 -0000 1.9
@@ -55,6 +55,7 @@
package org.apache.jmeter;
import java.io.File;
+import java.io.FilenameFilter;
import java.lang.reflect.Method;
import java.net.MalformedURLException;
import java.net.URL;
@@ -62,6 +63,9 @@
import java.util.LinkedList;
import java.util.List;
+import sun.security.krb5.internal.i;
+import sun.security.krb5.internal.crypto.e;
+
@@ -84,8 +88,18 @@
String jmDir = System.getProperty("user.dir")+File.separator+"..";
File libDir = new File(jmDir+File.separator+"lib");
File extDir = new
File(jmDir+File.separator+"lib"+File.separator+"ext");
- File[] libJars = libDir.listFiles();
- File[] extJars = extDir.listFiles();
+ File[] libJars = libDir.listFiles(new FilenameFilter() {
+ public boolean accept(File dir,String name) {
+ if(name.endsWith(".jar"))
+ return true;
+ return false;
+ }});
+ File[] extJars = extDir.listFiles(new FilenameFilter() {
+ public boolean accept(File dir,String name) {
+ if(name.endsWith(".jar"))
+ return true;
+ return false;
+ }});
StringBuffer classpath = new StringBuffer();
for(int i = 0;i < libJars.length;i++)
{
1.14 +8 -4 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.13
retrieving revision 1.14
diff -u -r1.13 -r1.14
--- MainFrame.java 29 Jun 2002 00:37:00 -0000 1.13
+++ MainFrame.java 11 Jul 2002 00:26:52 -0000 1.14
@@ -288,7 +288,11 @@
public void testEnded()
{
- stoppingMessage.dispose();
+ if(stoppingMessage != null)
+ {
+ stoppingMessage.dispose();
+ stoppingMessage = null;
+ }
testEnded("local");
menuBar.setEnabled(false);
}
1.1
jakarta-jmeter/src_1/org/apache/jmeter/protocol/all/modifier/InvalidVariableException.java
Index: InvalidVariableException.java
===================================================================
package org.apache.jmeter.protocol.all.modifier;
/**
* @author mstover
*
* To change this generated comment edit the template variable "typecomment":
* Window>Preferences>Java>Templates.
*/
public class InvalidVariableException extends Exception {
public InvalidVariableException()
{
}
public InvalidVariableException(String msg)
{
super(msg);
}
}
1.1
jakarta-jmeter/src_1/org/apache/jmeter/protocol/all/modifier/ResponseVariable.java
Index: ResponseVariable.java
===================================================================
package org.apache.jmeter.protocol.all.modifier;
import java.net.URLDecoder;
import java.net.URLEncoder;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.LinkedList;
import java.util.List;
import java.util.Random;
import java.util.StringTokenizer;
import junit.framework.TestCase;
import org.apache.jmeter.samplers.SampleResult;
import org.apache.oro.text.regex.MalformedPatternException;
import org.apache.oro.text.regex.MatchResult;
import org.apache.oro.text.regex.Pattern;
import org.apache.oro.text.regex.PatternCompiler;
import org.apache.oro.text.regex.PatternMatcher;
import org.apache.oro.text.regex.PatternMatcherInput;
import org.apache.oro.text.regex.Perl5Compiler;
import org.apache.oro.text.regex.Perl5Matcher;
import org.apache.oro.text.regex.Util;
import sun.security.krb5.internal.crypto.e;
/**
* @author mstover
*
* To change this generated comment edit the template variable "typecomment":
* Window>Preferences>Java>Templates.
*/
public class ResponseVariable implements Variable {
public static final String ALL = "ALL";
public static final String RAND = "RAND";
public static final String KEY = "responseVariable";
Random rand = new Random();
Pattern searchPattern;
Object[] template;
String valueIndex,prefix,suffix,between;
PatternCompiler compiler = new Perl5Compiler();
Pattern templatePattern;
public ResponseVariable()
{
try {
templatePattern = compiler.compile("\\$(\\d+)\\$");
} catch(MalformedPatternException e) {
e.printStackTrace();
}
}
/**
* @see Variable#getValue(SampleResult, Sampler)
*/
public String getValue(SampleResult previousResult)
{
List collectAllMatches = new ArrayList();
try {
PatternMatcher matcher = new Perl5Matcher();
String responseText = new
String(previousResult.getResponseData());
PatternMatcherInput input = new
PatternMatcherInput(responseText);
while(matcher.contains(input,searchPattern))
{
MatchResult match = matcher.getMatch();
collectAllMatches.add(match);
}
} catch(NumberFormatException e) {
e.printStackTrace();
}
if(collectAllMatches.size() == 0)
{
return "";
}
if(valueIndex.equals(ALL))
{
StringBuffer value = new StringBuffer();
Iterator it = collectAllMatches.iterator();
boolean first = true;
while(it.hasNext())
{
if(!first)
{
value.append(between);
first = false;
}
value.append(generateResult((MatchResult)it.next()));
}
return value.toString();
}
else if(valueIndex.equals(RAND))
{
return generateResult((MatchResult)collectAllMatches.get(
rand.nextInt(collectAllMatches.size())));
}
else
{
try {
int index = Integer.parseInt(valueIndex) - 1;
return
generateResult((MatchResult)collectAllMatches.get(index));
} catch(NumberFormatException e) {
float ratio = Float.parseFloat(valueIndex);
return
generateResult((MatchResult)collectAllMatches.get(
(int)(collectAllMatches.size() * ratio
+ .5) - 1));
}
}
}
private String generateResult(MatchResult match)
{
StringBuffer result = new StringBuffer();
for(int a = 0;a < template.length;a++)
{
if(template[a] instanceof String)
{
result.append(template[a]);
}
else
{
result.append(match.group(((Integer)template[a]).intValue()));
}
}
return result.toString();
}
public String getReferenceKey()
{
return KEY;
}
public void setParameters(String params) throws InvalidVariableException
{
StringTokenizer tk = new StringTokenizer(params,",",true);
valueIndex = "1";
prefix = "";
suffix = "";
between = "";
String temp = null;
try {
searchPattern =
compiler.compile(URLDecoder.decode(tk.nextToken()));
} catch(MalformedPatternException e) {
throw new InvalidVariableException(e.getMessage());
}
tk.nextToken();
generateTemplate(URLDecoder.decode(tk.nextToken()));
if(tk.hasMoreTokens())
{
tk.nextToken();
temp = tk.nextToken();
if(!temp.equals(","))
{
valueIndex = temp;
}
}
if(tk.hasMoreTokens())
{
if(!temp.equals(","))
{
tk.nextToken();
}
temp = tk.nextToken();
if(!temp.equals(","))
{
between = URLDecoder.decode(temp);
}
}
}
private void generateTemplate(String rawTemplate)
{
List pieces = new ArrayList();
List combined = new LinkedList();
PatternMatcher matcher = new Perl5Matcher();
Util.split(pieces,new Perl5Matcher(),templatePattern,rawTemplate);
PatternMatcherInput input = new PatternMatcherInput(rawTemplate);
int count = 0;
Iterator iter = pieces.iterator();
boolean startsWith = isFirstElementGroup(rawTemplate);
while(iter.hasNext())
{
boolean matchExists = matcher.contains(input,templatePattern);
if(startsWith)
{
if(matchExists)
{
combined.add(new
Integer(matcher.getMatch().group(1)));
}
combined.add(iter.next());
}
else
{
combined.add(iter.next());
if(matchExists)
{
combined.add(new
Integer(matcher.getMatch().group(1)));
}
}
}
if(matcher.contains(input,templatePattern))
{
combined.add(new Integer(matcher.getMatch().group(1)));
}
template = combined.toArray();
}
private boolean isFirstElementGroup(String rawData)
{
try {
Pattern pattern = compiler.compile("^\\$\\d+\\$");
return new Perl5Matcher().contains(rawData,pattern);
} catch(MalformedPatternException e) {
e.printStackTrace();
return false;
}
}
public static class Test extends TestCase
{
ResponseVariable variable;
SampleResult result;
public Test(String name)
{
super(name);
}
public void setUp()
{
variable = new ResponseVariable();
result = new SampleResult();
String data = "<company-xmlext-query-ret><row><value
field=\"RetCode\">LIS_OK</value><value"+
" field=\"RetCodeExtension\"></value><value
field=\"alias\"></value><value"+
" field=\"positioncount\"></value><value
field=\"invalidpincount\">0</value><value"+
" field=\"pinposition1\">1</value><value"+
" field=\"pinpositionvalue1\"></value><value"+
" field=\"pinposition2\">5</value><value"+
" field=\"pinpositionvalue2\"></value><value"+
" field=\"pinposition3\">6</value><value"+
"
field=\"pinpositionvalue3\"></value></row></company-xmlext-query-ret>";
result.setResponseData(data.getBytes());
}
public void testVariableExtraction() throws Exception
{
variable.setParameters(URLEncoder.encode("<value
field=\"(pinposition\\d+)\">(\\d+)</value>")+",$2$,2");
String match = variable.getValue(result);
assertEquals("5",match);
}
public void testVariableExtraction2() throws Exception
{
variable.setParameters(URLEncoder.encode("<value
field=\"(pinposition\\d+)\">(\\d+)</value>")+",$1$,3");
String match = variable.getValue(result);
assertEquals("pinposition3",match);
}
public void testComma() throws Exception
{
variable.setParameters(URLEncoder.encode("<value,?
field=\"(pinposition\\d+)\">(\\d+)</value>")+",$1$,3");
String match = variable.getValue(result);
assertEquals("pinposition3",match);
}
public void testVariableExtraction3() throws Exception
{
variable.setParameters(URLEncoder.encode("<value
field=\"(pinposition\\d+)\">(\\d+)</value>")+
",_$1$,.5");
String match = variable.getValue(result);
assertEquals("_pinposition2",match);
}
public void testVariableExtraction4() throws Exception
{
variable.setParameters(URLEncoder.encode(
"<value
field=\"(pinposition\\d+)\">(\\d+)</value>")+","+URLEncoder.encode("$2$, ")+
",.333");
String match = variable.getValue(result);
assertEquals("1, ",match);
}
}
}
1.1
jakarta-jmeter/src_1/org/apache/jmeter/protocol/all/modifier/Variable.java
Index: Variable.java
===================================================================
package org.apache.jmeter.protocol.all.modifier;
import java.util.Collection;
import java.util.Map;
import org.apache.jmeter.samplers.SampleResult;
/**
* @author mstover
*
* To change this generated comment edit the template variable "typecomment":
* Window>Preferences>Java>Templates.
*/
public interface Variable {
public String getValue(SampleResult previousResult);
public void setParameters(String parameters) throws InvalidVariableException;
public String getReferenceKey();
}
1.4 +37 -10
jakarta-jmeter/src_1/org/apache/jmeter/protocol/http/modifier/ParamMask.java
Index: ParamMask.java
===================================================================
RCS file:
/home/cvs/jakarta-jmeter/src_1/org/apache/jmeter/protocol/http/modifier/ParamMask.java,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- ParamMask.java 29 Apr 2002 17:08:11 -0000 1.3
+++ ParamMask.java 11 Jul 2002 00:26:52 -0000 1.4
@@ -8,6 +8,7 @@
* policies for how that value changes. Used in {@link ParamModifier}.
*
*@author David La France
+ *@author <a href="mailto:[EMAIL PROTECTED]">Scott Eade</a>
*@created Jan 18, 2002
*/
public class ParamMask extends AbstractTestElement implements Serializable
@@ -17,6 +18,7 @@
private String UPPER_BOUND = "ParamModifier.upper_bound";
private String LOWER_BOUND = "ParamModifier.lower_bound";
private String INCREMENT = "ParamModifier.increment";
+ private String SUFFIX = "ParamModifier.suffix";
private long _value = 0;
@@ -30,13 +32,14 @@
setLowerBound(0);
setUpperBound(0);
setIncrement(0);
+ setSuffix("");
}
/**
- * Sets the prefix for the <code>long</code> value. The two are used appended
- * as the parameter value to be replaced. This allows a wider range of
- * posibilities for the parameter values.
+ * Sets the prefix for the <code>long</code> value. The prefix, the value
+ * and the suffix are concatenated to give the parameter value. This allows
+ * a wider range of posibilities for the parameter values.
*
*@param prefix A string to prefix to the parameter value
*/
@@ -51,8 +54,6 @@
* This is usually not used, as the method {@link #resetValue} is used to
define a policy for
* the starting value.
*
- *
- *
*@param val The new parameter value
*/
public void setValue(long val)
@@ -102,8 +103,21 @@
/**
+ * Sets the suffix for the <code>long</code> value. The prefix, the value
+ * and the suffix are concatenated to give the parameter value. This allows
+ * a wider range of posibilities for the parameter values.
+ *
+ *@param suffix A string to suffix to the parameter value
+ */
+ public void setSuffix(String suffix)
+ {
+ setProperty(SUFFIX, suffix);
+ }
+
+
+ /**
* Acessor method to return the <code>String</code> that will be prefixed to
- * the <code>long</code> value, creating the complete parameter value.
+ * the <code>long</code> value.
*
*@return The parameter value prefix
*/
@@ -152,6 +166,18 @@
}
+ /**
+ * Acessor method to return the <code>String</code> that will be suffixed to
+ * the <code>long</code> value.
+ *
+ *@return The parameter value suffix
+ */
+ public String getSuffix()
+ {
+ return (String) getProperty(SUFFIX);
+ }
+
+
/*
*
----------------------------------------------------------------------------------------------
* Methods
@@ -160,9 +186,9 @@
/**
* <P>
*
- * Returns the current value, prefixed, as a string, then increments it. If
- * the incremented value is above the upper bound, the value is reset to the
- * lower bound. <BR>
+ * Returns the current value, prefixed and suffixed, as a string, then
+ * increments it. If the incremented value is above the upper bound, the
+ * value is reset to the lower bound. <BR>
* <P>
*
* This method determines the policy of what happens when an upper bound is
@@ -174,7 +200,7 @@
public String getNextValue()
{
// return the current value (don't forget the prefix!)
- String retval = getPrefix() + Long.toString(_value);
+ String retval = getPrefix() + Long.toString(_value) + getSuffix();
// increment the value
_value += getIncrement();
@@ -218,6 +244,7 @@
sb.append("Lower Bound = " + getLowerBound() + "\n");
sb.append("Upper Bound = " + getUpperBound() + "\n");
sb.append("Increment = " + getIncrement() + "\n");
+ sb.append("Suffix = " + getSuffix() + "\n");
sb.append("-------------------------------\n");
return sb.toString();
1.4 +24 -2
jakarta-jmeter/src_1/org/apache/jmeter/protocol/http/modifier/gui/ParamModifierGui.java
Index: ParamModifierGui.java
===================================================================
RCS file:
/home/cvs/jakarta-jmeter/src_1/org/apache/jmeter/protocol/http/modifier/gui/ParamModifierGui.java,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- ParamModifierGui.java 29 Apr 2002 17:08:11 -0000 1.3
+++ ParamModifierGui.java 11 Jul 2002 00:26:52 -0000 1.4
@@ -16,6 +16,7 @@
* A swing panel to allow UI with the ParamModifier class.
*
*@author David La France
+ *@author <a href="mailto:[EMAIL PROTECTED]">Scott Eade</a>
*@created Jan 18, 2002
*@version $Revision$
***************************************/
@@ -27,12 +28,14 @@
private final String LOWERBOUND = "lowerBound";
private final String UPPERBOUND = "upperBound";
private final String INCREMENT = "increment";
+ private final String SUFFIX = "suffix";
private JTextField _fieldName;
private JTextField _prefix;
private JTextField _lowerBound;
private JTextField _upperBound;
private JTextField _increment;
+ private JTextField _suffix;
/****************************************
@@ -80,6 +83,8 @@
mask.setLowerBound(Long.parseLong(_lowerBound.getText()));
mask.setIncrement(Long.parseLong(_increment.getText()));
mask.setUpperBound(Long.parseLong(_upperBound.getText()));
+ mask.setSuffix(_suffix.getText());
+ mask.resetValue();
return modifier;
}
@@ -156,11 +161,12 @@
***************************************/
private void updateGui(ParamModifier model)
{
- _fieldName.setText(model.getMask().getName());
+ _fieldName.setText(model.getMask().getFieldName());
_prefix.setText(model.getMask().getPrefix());
_lowerBound.setText(Long.toString(model.getMask().getLowerBound()));
_upperBound.setText(Long.toString(model.getMask().getUpperBound()));
_increment.setText(Long.toString(model.getMask().getIncrement()));
+ _suffix.setText(model.getMask().getSuffix());
}
private JPanel getParameterMaskPanel()
@@ -205,6 +211,13 @@
gridBagConstraints.insets = new Insets(5, 15, 0, 0);
paramMaskPanel.add(increment, gridBagConstraints);
+ JLabel suffix = new JLabel(JMeterUtils.getResString("ID Suffix"));
+ gridBagConstraints = new GridBagConstraints();
+ gridBagConstraints.fill = GridBagConstraints.HORIZONTAL;
+ gridBagConstraints.ipadx = 40;
+ gridBagConstraints.insets = new Insets(5, 15, 0, 0);
+ paramMaskPanel.add(suffix, gridBagConstraints);
+
_fieldName = new JTextField("", 10);
gridBagConstraints = new GridBagConstraints();
gridBagConstraints.gridx = 0;
@@ -252,6 +265,15 @@
_increment.addFocusListener(this);
_increment.setName(INCREMENT);
paramMaskPanel.add(_increment, gridBagConstraints);
+
+ _suffix = new JTextField("", 5);
+ gridBagConstraints = new GridBagConstraints();
+ gridBagConstraints.gridx = 5;
+ gridBagConstraints.gridy = 1;
+ gridBagConstraints.fill = GridBagConstraints.HORIZONTAL;
+ gridBagConstraints.insets = new Insets(10, 15, 0, 0);
+ _suffix.setName(SUFFIX);
+ paramMaskPanel.add(_suffix, gridBagConstraints);
return paramMaskPanel;
}
1.6 +1 -0
jakarta-jmeter/src_1/org/apache/jmeter/protocol/http/sampler/MultipartFormSampler.java
Index: MultipartFormSampler.java
===================================================================
RCS file:
/home/cvs/jakarta-jmeter/src_1/org/apache/jmeter/protocol/http/sampler/MultipartFormSampler.java,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -r1.5 -r1.6
--- MultipartFormSampler.java 18 Jun 2002 01:01:14 -0000 1.5
+++ MultipartFormSampler.java 11 Jul 2002 00:26:52 -0000 1.6
@@ -193,6 +193,7 @@
out.write(buf, 0, read);
}
out.write(CRLF);
+ in.close();
}
/************************************************************
1.21 +1 -0
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.20
retrieving revision 1.21
diff -u -r1.20 -r1.21
--- messages.properties 10 Jul 2002 01:21:03 -0000 1.20
+++ messages.properties 11 Jul 2002 00:26:52 -0000 1.21
@@ -207,6 +207,7 @@
lower_bound=Lower Bound
upper_bound=Upper Bound
increment=Increment
+id_suffix=ID Suffix
url_multipart_config_title=HTTP Multipart Request Defaults
view_results_in_table=View Results in Table
http_response_code=HTTP response code
1.20 +1 -0
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.19
retrieving revision 1.20
diff -u -r1.19 -r1.20
--- messages_ja.properties 10 Jul 2002 01:21:03 -0000 1.19
+++ messages_ja.properties 11 Jul 2002 00:26:52 -0000 1.20
@@ -201,6 +201,7 @@
lower_bound=Lower Bound
upper_bound=Upper Bound
increment=Increment
+id_suffix=ID Suffix
url_multipart_config_title=HTTP Multipart Request Defaults
view_results_in_table=View Results in Table
http_response_code=HTTP response code
1.20 +1 -0
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.19
retrieving revision 1.20
diff -u -r1.19 -r1.20
--- messages_no.properties 10 Jul 2002 01:21:03 -0000 1.19
+++ messages_no.properties 11 Jul 2002 00:26:52 -0000 1.20
@@ -200,6 +200,7 @@
lower_bound=Lower Bound
upper_bound=Upper Bound
increment=Increment
+id_suffix=ID Suffix
url_multipart_config_title=HTTP Multipart Request Defaults
view_results_in_table=View Results in Table
http_response_code=HTTP response code
--
To unsubscribe, e-mail: <mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>