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/16 18:41:31 UTC
cvs commit: jakarta-jmeter/src_1/org/apache/jmeter/visualizers ViewResultsFullVisualizer.java
mstover1 02/05/16 09:41:30
Modified: src/org/apache/jmeter/protocol/http/sampler HTTPSampler.java
src_1/org/apache/jmeter/assertions AssertionResult.java
src_1/org/apache/jmeter/gui GuiPackage.java MainFrame.java
src_1/org/apache/jmeter/gui/action Start.java
src_1/org/apache/jmeter/protocol/ftp/config FtpConfig.java
src_1/org/apache/jmeter/protocol/ftp/sampler FTPSampler.java
src_1/org/apache/jmeter/protocol/http/proxy Proxy.java
src_1/org/apache/jmeter/protocol/http/sampler
HTTPSampler.java HTTPSamplerFull.java
src_1/org/apache/jmeter/reporters ResultCollector.java
src_1/org/apache/jmeter/samplers SampleResult.java
src_1/org/apache/jmeter/save SaveService.java
src_1/org/apache/jmeter/threads/gui ThreadGroupGui.java
src_1/org/apache/jmeter/visualizers
ViewResultsFullVisualizer.java
Added: src_1/org/apache/jmeter/gui/util
NumberFieldErrorListener.java
Removed: src_1/org/apache/jmeter/configuration
SampleResultBuilder.java
SampleResultSAXHandler.java
Log:
All sorts of cosmetic improvements and refactoring
Revision Changes Path
1.37 +14 -14 jakarta-jmeter/src/org/apache/jmeter/protocol/http/sampler/HTTPSampler.java
Index: HTTPSampler.java
===================================================================
RCS file: /home/cvs/jakarta-jmeter/src/org/apache/jmeter/protocol/http/sampler/HTTPSampler.java,v
retrieving revision 1.36
retrieving revision 1.37
diff -u -r1.36 -r1.37
--- HTTPSampler.java 10 May 2002 13:00:10 -0000 1.36
+++ HTTPSampler.java 16 May 2002 16:41:29 -0000 1.37
@@ -82,8 +82,8 @@
* HTTP requests, including cookies and authentication.
*
*@author Michael Stover
- *@created $Date: 2002/05/10 13:00:10 $
- *@version $Revision: 1.36 $
+ *@created $Date: 2002/05/16 16:41:29 $
+ *@version $Revision: 1.37 $
*/
public class HTTPSampler implements Sampler
{
@@ -559,27 +559,27 @@
protected byte[] getResponseHeaders(HttpURLConnection conn,
SampleResult res) throws IOException
{
- ByteArrayOutputStream bytes = new ByteArrayOutputStream();
- bytes.write("HTTP/1.1 ".getBytes("8859_1"));
- bytes.write(Integer.toString(conn.getResponseCode()).getBytes("8859_1"));
- bytes.write(" ".getBytes("8859_1"));
- bytes.write(conn.getResponseMessage().getBytes("8859_1"));
- bytes.write("\n".getBytes("8859_1"));
+ StringBuffer header = new StringBuffer();
+ header.append("HTTP/1.1 ");
+ header.append(conn.getResponseCode());
+ header.append(" ");
+ header.append(conn.getResponseMessage());
+ header.append("\n");
HashMap hValues = new HashMap(20);
for (int i = 1; conn.getHeaderFieldKey(i) != null; i++)
{
hValues.put(conn.getHeaderFieldKey(i), conn.getHeaderField(i));
if(!conn.getHeaderFieldKey(i).equalsIgnoreCase("transfer-encoding"))
{
- bytes.write(conn.getHeaderFieldKey(i).getBytes("8859_1"));
- bytes.write(": ".getBytes("8859_1"));
- bytes.write(conn.getHeaderField(i).getBytes("8859_1"));
- bytes.write("\n".getBytes("8859_1"));
+ header.append(conn.getHeaderFieldKey(i));
+ header.append(": ");
+ header.append(conn.getHeaderField(i));
+ header.append("\n");
}
}
- bytes.write("\n".getBytes("8859_1"));
+ header.append("\n");
res.putValue(Sampler.HEADER, hValues);
- return bytes.toByteArray();
+ return header.toString().getBytes("8859_1");
}
}
1.4 +1 -3 jakarta-jmeter/src_1/org/apache/jmeter/assertions/AssertionResult.java
Index: AssertionResult.java
===================================================================
RCS file: /home/cvs/jakarta-jmeter/src_1/org/apache/jmeter/assertions/AssertionResult.java,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- AssertionResult.java 29 Apr 2002 17:08:06 -0000 1.3
+++ AssertionResult.java 16 May 2002 16:41:29 -0000 1.4
@@ -68,16 +68,14 @@
* @version 1.0
*/
-public class AssertionResult extends DefaultConfiguration implements Serializable {
+public class AssertionResult implements Serializable {
- public final static String TAG_NAME = "assertionResult";
private boolean failure;
private boolean error;
private String failureMessage;
public AssertionResult()
{
- super(TAG_NAME,"org.apache.jmeter.assertion.AssertionResult");
}
public boolean isFailure()
1.4 +24 -5 jakarta-jmeter/src_1/org/apache/jmeter/gui/GuiPackage.java
Index: GuiPackage.java
===================================================================
RCS file: /home/cvs/jakarta-jmeter/src_1/org/apache/jmeter/gui/GuiPackage.java,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- GuiPackage.java 1 May 2002 23:48:51 -0000 1.3
+++ GuiPackage.java 16 May 2002 16:41:29 -0000 1.4
@@ -54,12 +54,14 @@
*/
package org.apache.jmeter.gui;
-import java.awt.*;
-import javax.swing.*;
+import java.awt.event.ActionEvent;
-import org.apache.jmeter.gui.tree.*;
-import org.apache.jmeter.util.ListedHashTree;
import org.apache.jmeter.exceptions.IllegalUserActionException;
+import org.apache.jmeter.gui.action.ActionRouter;
+import org.apache.jmeter.gui.tree.JMeterTreeListener;
+import org.apache.jmeter.gui.tree.JMeterTreeModel;
+import org.apache.jmeter.testelement.TestListener;
+import org.apache.jmeter.util.ListedHashTree;
/**
* Title: JMeter
@@ -70,7 +72,7 @@
* @version 1.0
*/
-public class GuiPackage
+public class GuiPackage implements TestListener
{
private static GuiPackage guiPack;
@@ -94,6 +96,23 @@
guiPack.setTreeModel(treeModel);
}
return guiPack;
+ }
+
+ public void testStarted(String host)
+ {
+ }
+
+ public void testStarted()
+ {
+ }
+
+ public void testEnded()
+ {
+ ActionRouter.getInstance().actionPerformed(new ActionEvent(this,1,"stop"));
+ }
+
+ public void testEnded(String host)
+ {
}
public void addSubTree(ListedHashTree subTree) throws IllegalUserActionException
1.3 +25 -6 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.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- MainFrame.java 29 Apr 2002 17:08:08 -0000 1.2
+++ MainFrame.java 16 May 2002 16:41:29 -0000 1.3
@@ -60,23 +60,29 @@
import org.apache.jmeter.gui.action.ActionRouter;
import org.apache.jmeter.gui.tree.*;
import org.apache.jmeter.gui.util.JMeterMenuBar;
+import org.apache.jmeter.util.JMeterUtils;
+import org.apache.jmeter.gui.action.Start;
/****************************************
* Title: JMeter Description: Copyright: Copyright (c) 2000 Company: Apache
*
*@author Michael Stover
- *@created $Date: 2002/04/29 17:08:08 $
+ *@created $Date: 2002/05/16 16:41:29 $
*@version 1.0
***************************************/
public class MainFrame extends JFrame
{
- JPanel all, mainPanel, toolPanel;
+ JPanel all, mainPanel;
+ Box toolPanel;
JScrollPane treePanel;
JMeterMenuBar menuBar;
JTree tree;
TreeModel treeModel;
ActionListener actionHandler;
JMeterTreeListener treeListener;
+ ImageIcon runningIcon = JMeterUtils.getImage("thread.enabled.gif");
+ ImageIcon stoppedIcon = JMeterUtils.getImage("thread.disabled.gif");
+ JButton runningIndicator;
private boolean running;
/****************************************
@@ -89,6 +95,9 @@
public MainFrame(ActionListener actionHandler, TreeModel treeModel, JMeterTreeListener
treeListener)
{
+ runningIndicator = new JButton(stoppedIcon);
+ runningIndicator.setMargin(new Insets(0,0,0,0));
+ runningIndicator.setBorder(BorderFactory.createEmptyBorder());
this.treeListener = treeListener;
this.actionHandler = actionHandler;
this.treeModel = treeModel;
@@ -240,6 +249,14 @@
***************************************/
public void setRunning(boolean newRunning)
{
+ if(newRunning)
+ {
+ runningIndicator.setIcon(runningIcon);
+ }
+ else
+ {
+ runningIndicator.setIcon(stoppedIcon);
+ }
running = newRunning;
this.menuBar.setEnabled(newRunning);
}
@@ -295,8 +312,10 @@
private void createToolBar()
{
- toolPanel = new JPanel();
- toolPanel.add(Box.createHorizontalGlue());
+ toolPanel = new Box(BoxLayout.X_AXIS);
+ toolPanel.add(Box.createRigidArea(new Dimension(10,15)));
+ toolPanel.add(Box.createGlue());
+ toolPanel.add(runningIndicator);
}
private void createTreePanel()
@@ -326,8 +345,8 @@
* !ToDo (Class description)
*
*@author $Author: mstover1 $
- *@created $Date: 2002/04/29 17:08:08 $
- *@version $Revision: 1.2 $
+ *@created $Date: 2002/05/16 16:41:29 $
+ *@version $Revision: 1.3 $
***************************************/
private class WindowHappenings extends WindowAdapter
{
1.4 +4 -2 jakarta-jmeter/src_1/org/apache/jmeter/gui/action/Start.java
Index: Start.java
===================================================================
RCS file: /home/cvs/jakarta-jmeter/src_1/org/apache/jmeter/gui/action/Start.java,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- Start.java 2 May 2002 22:54:58 -0000 1.3
+++ Start.java 16 May 2002 16:41:29 -0000 1.4
@@ -109,6 +109,7 @@
convertSubTree(tree.get(item));
TestElement testElement = item.createTestElement();
tree.replace(item,testElement);
+
}
}
@@ -120,11 +121,11 @@
***************************************/
public void doAction(ActionEvent e)
{
- if(engine == null)
+ if(engine == null && e.getActionCommand().equals("start"))
{
startEngine();
}
- else
+ else if(e.getActionCommand().equals("stop"))
{
engine.stopTest();
GuiPackage.getInstance().getMainFrame().setRunning(false);
@@ -143,6 +144,7 @@
engine = new StandardJMeterEngine();
ListedHashTree testTree = gui.getTreeModel().getTestPlan();
convertSubTree(testTree);
+ testTree.add(testTree.getArray()[0],gui);
engine.configure(testTree);
gui.getMainFrame().setRunning(true);
engine.runTest();
1.1 jakarta-jmeter/src_1/org/apache/jmeter/gui/util/NumberFieldErrorListener.java
Index: NumberFieldErrorListener.java
===================================================================
package org.apache.jmeter.gui.util;
import java.awt.event.*;
import javax.swing.*;
import javax.swing.text.JTextComponent;
import java.awt.Component;
import java.awt.TextComponent;
/**
* @author mstover
*
* To change this generated comment edit the template variable "typecomment":
* Window>Preferences>Java>Templates.
*/
public class NumberFieldErrorListener extends FocusAdapter {
private static NumberFieldErrorListener listener = new NumberFieldErrorListener();
public static NumberFieldErrorListener getNumberFieldErrorListener()
{
return listener;
}
/****************************************
* !ToDo (Method description)
*
*@param e !ToDo (Parameter description)
***************************************/
public void focusLost(FocusEvent e)
{
Component source = (Component)e.getSource();
String text = "";
if(source instanceof JTextComponent)
{
text = ((JTextComponent)source).getText();
}
else if(source instanceof TextComponent)
{
text = ((TextComponent)source).getText();
}
try
{
Integer.parseInt(text);
}
catch(NumberFormatException nfe)
{
JOptionPane.showMessageDialog(source, "You must enter a valid number",
"Invalid data", JOptionPane.WARNING_MESSAGE);
new FocusRequester(source);
}
}
}
1.3 +5 -6 jakarta-jmeter/src_1/org/apache/jmeter/protocol/ftp/config/FtpConfig.java
Index: FtpConfig.java
===================================================================
RCS file: /home/cvs/jakarta-jmeter/src_1/org/apache/jmeter/protocol/ftp/config/FtpConfig.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- FtpConfig.java 29 Apr 2002 17:08:09 -0000 1.2
+++ FtpConfig.java 16 May 2002 16:41:29 -0000 1.3
@@ -55,6 +55,7 @@
package org.apache.jmeter.protocol.ftp.config;
import org.apache.jmeter.config.*;
+import org.apache.jmeter.protocol.ftp.sampler.FTPSampler;
import org.apache.jmeter.util.JMeterUtils;
import java.util.Collection;
import java.io.*;
@@ -70,8 +71,6 @@
public class FtpConfig extends ConfigTestElement implements Serializable
{
- public static final String SERVER = "server";
- public static final String FILENAME = "filename";
public FtpConfig()
{
@@ -91,19 +90,19 @@
public void setServer(String newServer)
{
- this.setProperty(SERVER,newServer);
+ this.setProperty(FTPSampler.SERVER,newServer);
}
public String getServer()
{
- return (String)this.getProperty(SERVER);
+ return (String)this.getProperty(FTPSampler.SERVER);
}
public void setFilename(String newFilename)
{
- this.setProperty(FILENAME,newFilename);
+ this.setProperty(FTPSampler.FILENAME,newFilename);
}
public String getFilename()
{
- return (String)this.getProperty(FILENAME);
+ return (String)this.getProperty(FTPSampler.FILENAME);
}
/**
1.5 +49 -12 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.4
retrieving revision 1.5
diff -u -r1.4 -r1.5
--- FTPSampler.java 29 Apr 2002 17:08:10 -0000 1.4
+++ FTPSampler.java 16 May 2002 16:41:29 -0000 1.5
@@ -68,8 +68,8 @@
* A sampler which understands FTP file requests
*
*@author $Author: mstover1 $
- *@created $Date: 2002/04/29 17:08:10 $
- *@version $Revision: 1.4 $
+ *@created $Date: 2002/05/16 16:41:29 $
+ *@version $Revision: 1.5 $
***********************************************************/
public class FTPSampler extends AbstractSampler
@@ -86,7 +86,49 @@
public void addCustomTestElement(TestElement element)
{
+ if(element instanceof FtpConfig || element instanceof LoginConfig)
+ {
+ mergeIn(element);
+ }
+ }
+
+ public String getUsername()
+ {
+ return getPropertyAsString(LoginConfig.USERNAME);
+ }
+
+ public String getPassword()
+ {
+ return getPropertyAsString(LoginConfig.PASSWORD);
+ }
+
+ public void setServer(String newServer)
+ {
+ this.setProperty(SERVER,newServer);
+ }
+ public String getServer()
+ {
+ return (String)this.getProperty(SERVER);
+ }
+ public void setFilename(String newFilename)
+ {
+ this.setProperty(FILENAME,newFilename);
+ }
+ public String getFilename()
+ {
+ return (String)this.getProperty(FILENAME);
}
+
+ /**
+ * Returns a formatted string label describing this sampler
+ * Example output:
+ * ftp://ftp.nowhere.com/pub/README.txt
+ *
+ * @return a formatted string label describing this sampler
+ */
+ public String getLabel() {
+ return ("ftp://" + this.getServer() + "/" + this.getFilename());
+ }
/************************************************************
* !ToDo (Method description)
@@ -101,21 +143,16 @@
ResultSet rs = null;
Statement stmt = null;
boolean isSuccessful = false;
- FtpConfig ftpConfig = (FtpConfig)e.getConfigElement(FtpConfig.class);
- res.setSampleLabel(ftpConfig.getLabel());
- LoginConfig loginConfig = (LoginConfig)e.getConfigElement(LoginConfig.class);
+ //FtpConfig ftpConfig = (FtpConfig)e.getConfigElement(FtpConfig.class);
+ res.setSampleLabel(getLabel());
+ //LoginConfig loginConfig = (LoginConfig)e.getConfigElement(LoginConfig.class);
long start = System.currentTimeMillis();
try
{
- // removed the next two lines - System.out.println is a resource DOG, and putting this in the middle
- // of a timed operation skews the results big time. -- jkb
-// System.out.println("Connecting to "+ftpConfig.getServer()+" trying to get "+ftpConfig.getFilename());
-// System.out.println("Username = "+loginConfig.getUsername());
FtpClient ftp = new FtpClient();
- ftp.connect(ftpConfig.getServer(), loginConfig.getUsername(),
- loginConfig.getPassword());
+ ftp.connect(getServer(), getUsername(),getPassword());
ftp.setPassive(true); // this should probably come from the setup dialog
- String s = ftp.get(ftpConfig.getFilename());
+ String s = ftp.get(getFilename());
res.setResponseData(s.getBytes());
// set the response code here somewhere
ftp.disconnect();
1.7 +1 -1 jakarta-jmeter/src_1/org/apache/jmeter/protocol/http/proxy/Proxy.java
Index: Proxy.java
===================================================================
RCS file: /home/cvs/jakarta-jmeter/src_1/org/apache/jmeter/protocol/http/proxy/Proxy.java,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -r1.6 -r1.7
--- Proxy.java 13 May 2002 12:19:14 -0000 1.6
+++ Proxy.java 16 May 2002 16:41:29 -0000 1.7
@@ -147,7 +147,7 @@
byte[] serverResponse = sampler.sample().getResponseData();
writeToClient(serverResponse,
new BufferedOutputStream(ClientSocket.getOutputStream()));
- //headers.removeHeaderNamed("cookie");
+ headers.removeHeaderNamed("cookie");
target.deliverSampler(sampler,new TestElement[]{headers});
} catch (UnknownHostException uhe) {
System.out.println("Server Not Found.");
1.8 +7 -14 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.7
retrieving revision 1.8
diff -u -r1.7 -r1.8
--- HTTPSampler.java 13 May 2002 12:19:14 -0000 1.7
+++ HTTPSampler.java 16 May 2002 16:41:30 -0000 1.8
@@ -80,8 +80,8 @@
* HTTP requests, including cookies and authentication.
*
*@author Michael Stover
- *@created $Date: 2002/05/13 12:19:14 $
- *@version $Revision: 1.7 $
+ *@created $Date: 2002/05/16 16:41:30 $
+ *@version $Revision: 1.8 $
***************************************/
public class HTTPSampler extends AbstractSampler
{
@@ -455,14 +455,8 @@
headerBuf.append(" ");
headerBuf.append(conn.getResponseMessage());
headerBuf.append("\n");
- DefaultConfiguration headers = new DefaultConfiguration(HTTPSampler.HEADERS,
- "org.apache.jmeter.protocol.http.samplers.HTTPSampler");
for(int i = 1; conn.getHeaderFieldKey(i) != null; i++)
{
- DefaultConfiguration header = new DefaultConfiguration(HTTPSampler.HEADER,
- "org.apache.jmeter.protocol.http.samplers.HTTPSampler");
- header.setAttribute("name",conn.getHeaderFieldKey(i));
- header.setValue(conn.getHeaderField(i));
if(!conn.getHeaderFieldKey(i).equalsIgnoreCase("transfer-encoding"))
{
headerBuf.append(conn.getHeaderFieldKey(i));
@@ -472,8 +466,6 @@
}
}
headerBuf.append("\n");
- //headerBytes.close();
- res.addChild(headers);
return headerBuf.toString().getBytes("8859_1");
}
@@ -627,10 +619,10 @@
}
}
URL newUrl = new URL(loc);
- this.setDomain(newUrl.getHost());
- this.setPath(newUrl.getFile());
- this.setArguments(new Arguments());
- this.setMethod(HTTPSampler.GET);
+ urlConfig.setDomain(newUrl.getHost());
+ urlConfig.setPath(newUrl.getFile());
+ urlConfig.setArguments(new Arguments());
+ urlConfig.setMethod(HTTPSampler.GET);
}
/****************************************
@@ -742,6 +734,7 @@
System.arraycopy(ret,0,complete,head.length,ret.length);
res.setResponseData(complete);
res.setSuccessful(true);
+ res.setDataType(res.TEXT);
return time;
}
1.7 +2 -1 jakarta-jmeter/src_1/org/apache/jmeter/protocol/http/sampler/HTTPSamplerFull.java
Index: HTTPSamplerFull.java
===================================================================
RCS file: /home/cvs/jakarta-jmeter/src_1/org/apache/jmeter/protocol/http/sampler/HTTPSamplerFull.java,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -r1.6 -r1.7
--- HTTPSamplerFull.java 29 Apr 2002 17:08:12 -0000 1.6
+++ HTTPSamplerFull.java 16 May 2002 16:41:30 -0000 1.7
@@ -82,7 +82,7 @@
*
* @author Khor Soon Hin
* @version 1.0
- * @created $Date: 2002/04/29 17:08:12 $
+ * @created $Date: 2002/05/16 16:41:30 $
*/
public class HTTPSamplerFull extends HTTPSampler
{
@@ -342,6 +342,7 @@
UrlConfig urlConfig = new UrlConfig();
urlConfig.setMethod(HTTPSampler.GET);
HttpURLConnection conn = null;
+ res.setSamplerData(urlConfig);
try
{
conn = setupConnection(url, urlConfig);
1.10 +17 -14 jakarta-jmeter/src_1/org/apache/jmeter/reporters/ResultCollector.java
Index: ResultCollector.java
===================================================================
RCS file: /home/cvs/jakarta-jmeter/src_1/org/apache/jmeter/reporters/ResultCollector.java,v
retrieving revision 1.9
retrieving revision 1.10
diff -u -r1.9 -r1.10
--- ResultCollector.java 2 May 2002 23:18:24 -0000 1.9
+++ ResultCollector.java 16 May 2002 16:41:30 -0000 1.10
@@ -64,14 +64,14 @@
import org.xml.sax.SAXException;
import org.apache.jmeter.exceptions.*;
import org.apache.jmeter.testelement.TestListener;
-import org.apache.jmeter.configuration.SampleResultBuilder;
import org.apache.jmeter.util.TextFile;
+import org.apache.jmeter.save.SaveService;
/**
* Title: Description: Copyright: Copyright (c) 2001 Company:
*
*@author Michael Stover
- *@created $Date: 2002/05/02 23:18:24 $
+ *@created $Date: 2002/05/16 16:41:30 $
*@version 1.0
*/
@@ -148,12 +148,15 @@
public void loadExistingFile()
throws SAXException, IOException, ConfigurationException {
inLoading = true;
+ if(new File(filename).exists())
+ {
clear();
- try {
- Configuration savedSamples = getConfiguration(filename);
- readSamples(savedSamples);
- } catch(Exception e) {
- e.printStackTrace();
+ try {
+ Configuration savedSamples = getConfiguration(filename);
+ readSamples(savedSamples);
+ } catch(Exception e) {
+ e.printStackTrace();
+ }
}
inLoading = false;
}
@@ -220,7 +223,7 @@
IOException,ConfigurationException
{
ByteArrayOutputStream tempOut = new ByteArrayOutputStream();
- serializer.serialize(tempOut, result);
+ serializer.serialize(tempOut, SaveService.getConfiguration(result,true));
String serVer = tempOut.toString();
return serVer.substring(serVer.indexOf(System.getProperty("line.separator")));
}
@@ -236,7 +239,7 @@
Configuration[] samples = testResults.getChildren();
for(int i = 0; i < samples.length; i++)
{
- SampleResult result = (SampleResult)samples[i];
+ SampleResult result = SaveService.getSampleResult(samples[i]);
sendToVisualizer(result);
recordResult(result);
}
@@ -251,7 +254,7 @@
private Configuration getConfiguration(String filename) throws SAXException,
IOException,ConfigurationException
{
- SampleResultBuilder builder = new SampleResultBuilder();
+ DefaultConfigurationBuilder builder = new DefaultConfigurationBuilder();
return builder.buildFromFile(filename);
}
@@ -387,7 +390,7 @@
}
catch(Exception err)
{
- //err.printStackTrace(); //should throw exception back to caller
+ err.printStackTrace(); //should throw exception back to caller
}
}
@@ -417,10 +420,10 @@
private synchronized boolean isResultMarked(SampleResult res)
{
- boolean marked;
- if(!(marked = res.getAttributeAsBoolean(ResultCollector.COLLECTED,false)))
+ boolean marked = res.isMarked();
+ if(!marked)
{
- res.setAttribute(ResultCollector.COLLECTED,"true");
+ res.setMarked();
}
return marked;
}
1.8 +50 -88 jakarta-jmeter/src_1/org/apache/jmeter/samplers/SampleResult.java
Index: SampleResult.java
===================================================================
RCS file: /home/cvs/jakarta-jmeter/src_1/org/apache/jmeter/samplers/SampleResult.java,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -r1.7 -r1.8
--- SampleResult.java 13 May 2002 12:19:14 -0000 1.7
+++ SampleResult.java 16 May 2002 16:41:30 -0000 1.8
@@ -67,10 +67,10 @@
* sample of an entry.
*
*@author $Author: mstover1 $
- *@created $Date: 2002/05/13 12:19:14 $
- *@version $Revision: 1.7 $
+ *@created $Date: 2002/05/16 16:41:30 $
+ *@version $Revision: 1.8 $
*/
-public class SampleResult extends DefaultConfiguration implements Serializable
+public class SampleResult implements Serializable
{
//public final static String URL = "sampler.url";
@@ -78,6 +78,18 @@
public final static String TEXT = "text";
public final static String BINARY = "bin";
private byte[] responseData;
+ private String responseCode;
+ private String label;
+ private TestElement samplerData;
+ private String threadName;
+ private String responseMessage;
+ private long timeStamp = 0;
+ private List assertionResults = new ArrayList();
+ private List subResults = new ArrayList();
+ private String dataType;
+ private boolean success;
+ private boolean mark = false;
+
Map map;
long time;
@@ -118,91 +130,88 @@
*/
public SampleResult()
{
- super(TAG_NAME,"org.apache.jmeter.samplers.SampleResult");
map = new HashMap();
time = 0;
}
+ public void setMarked()
+ {
+ mark = true;
+ }
+
+ public boolean isMarked()
+ {
+ return mark;
+ }
+
public String getResponseCode()
{
- return getAttribute(RESPONSE_CODE,"");
+ return responseCode;
}
public void setResponseCode(String code)
{
- setAttribute(RESPONSE_CODE,code);
+ responseCode = code;
}
public String getResponseMessage()
{
- return getAttribute(RESPONSE_MESSAGE,"");
+ return responseMessage;
}
public void setResponseMessage(String msg)
{
- setAttribute(RESPONSE_MESSAGE,msg);
+ responseMessage = msg;
}
public String getThreadName()
{
- return getAttribute(THREAD_NAME,"");
+ return threadName;
}
public void setThreadName(String threadName)
{
- setAttribute(THREAD_NAME,threadName);
+ this.threadName = threadName;
}
public long getTimeStamp()
{
- return getAttributeAsLong(TIME_STAMP,0L);
+ return timeStamp;
}
public void setTimeStamp(long timeStamp)
{
- setAttribute(TIME_STAMP,""+timeStamp);
+ this.timeStamp = timeStamp;
}
public String getSampleLabel()
{
- return getAttribute(SAMPLE_LABEL,"Display name of SampleResult not set");
+ return label;
}
public void setSampleLabel(String label)
{
- setAttribute(SAMPLE_LABEL,label);
+ this.label = label;
}
public void addAssertionResult(AssertionResult assertResult)
{
- addChild(assertResult);
+ assertionResults.add(assertResult);
}
public AssertionResult[] getAssertionResults()
{
- Configuration[] subs = getChildren(AssertionResult.TAG_NAME);
- AssertionResult[] subResults = new AssertionResult[subs.length];
- for(int i = 0;i < subs.length;i++)
- {
- subResults[i] = (AssertionResult)subs[i];
- }
- return subResults;
+ return (AssertionResult[])assertionResults.toArray(new AssertionResult[0]);
}
public void addSubResult(SampleResult subResult)
{
- addChild(subResult);
+ subResults.add(subResult);
}
public SampleResult[] getSubResults()
{
- Configuration[] subs = getChildren(SampleResult.TAG_NAME);
- SampleResult[] subResults = new SampleResult[subs.length];
- for(int i = 0;i < subs.length;i++)
- {
- subResults[i] = (SampleResult)subs[i];
- }
- return subResults;
+ return (SampleResult[])subResults.toArray(new SampleResult[0]);
}
/**
@@ -222,7 +231,7 @@
*/
public void setTime(long t)
{
- setAttribute(TOTAL_TIME, "" + t);
+ time = t;
}
/**
@@ -238,26 +247,7 @@
addChild(responseChild);*/
}
- /**
- * Gets the hexString attribute of the SampleResult object
- *
- *@param bytes Description of the Parameter
- *@return The hexString value
- */
- private String getHexString(byte[] bytes)
- {
- StringBuffer hex = new StringBuffer();
- for(int i = 0; i < bytes.length; i++)
- {
- String hexString = Integer.toHexString((int)bytes[i]);
- if(hexString.length() == 1)
- {
- hex.append("0");
- }
- hex.append(hexString);
- }
- return hex.toString();
- }
+
/**
@@ -278,22 +268,14 @@
return bytes.toByteArray();*/
}
- public void setSamplerData(Sampler s)
+ public void setSamplerData(TestElement s)
{
- this.addChild(SaveService.getConfigForTestElement((String)s.getProperty(TestElement.NAME),
- s));
+ samplerData = s;
}
- public Sampler getSamplerData()
+ public TestElement getSamplerData()
{
- try
- {
- return (Sampler)SaveService.createTestElement(getChild("testelement"));
- }
- catch(Exception e)
- {
- return null;
- }
+ return samplerData;
}
/**
@@ -303,7 +285,7 @@
*/
public long getTime()
{
- return getAttributeAsLong(TOTAL_TIME,0L);
+ return time;
}
/**
@@ -313,17 +295,17 @@
*/
public boolean isSuccessful()
{
- return getAttributeAsBoolean(SUCCESS,true);
+ return success;
}
public void setDataType(String dataType)
{
- setAttribute(DATA_TYPE,dataType);
+ this.dataType = dataType;
}
public String getDataType()
{
- return getAttribute(DATA_TYPE,TEXT);
+ return dataType;
}
/**
@@ -333,27 +315,7 @@
*/
public void setSuccessful(boolean success)
{
- setAttribute(SUCCESS, "" + success);
- }
-
- /**
- * Get an array of all the names
- *
- *@return !ToDo (Return description)
- */
- public String[] getNames()
- {
- return (String[])map.keySet().toArray(new String[0]);
- }
-
- /**
- * Remove a key-value pair.
- *
- *@param key !ToDo (Parameter description)
- */
- public void remove(String key)
- {
- map.remove(key);
+ this.success = success;
}
/**
1.4 +106 -0 jakarta-jmeter/src_1/org/apache/jmeter/save/SaveService.java
Index: SaveService.java
===================================================================
RCS file: /home/cvs/jakarta-jmeter/src_1/org/apache/jmeter/save/SaveService.java,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- SaveService.java 13 May 2002 12:19:14 -0000 1.3
+++ SaveService.java 16 May 2002 16:41:30 -0000 1.4
@@ -3,9 +3,11 @@
import org.apache.avalon.framework.configuration.*;
import org.apache.jmeter.util.ListedHashTree;
import org.apache.jmeter.testelement.TestElement;
+import org.apache.jmeter.assertions.AssertionResult;
import java.util.*;
import java.io.*;
import org.xml.sax.SAXException;
+import org.apache.jmeter.samplers.SampleResult;
/**
* <p>Title: </p>
* <p>Description: </p>
@@ -17,6 +19,19 @@
public class SaveService
{
+ private static final String ASSERTION_RESULT_TAG_NAME = "assertionResult";
+ private static final String SAMPLE_RESULT_TAG_NAME = "sampleResult";
+ private static final String TIME = "time";
+ private static final String LABEL = "label";
+ private static final String RESPONSE_CODE = "responseCode";
+ private static final String RESPONSE_MESSAGE = "responseMessage";
+ private static final String THREAD_NAME = "threadName";
+ private static final String DATA_TYPE = "dataType";
+ private static final String TIME_STAMP = "timeStamp";
+ private static final String BINARY = "binary";
+ private static final String FAILURE_MESSAGE = "failureMessage";
+ private static final String ERROR = "error";
+ private static final String FAILURE = "failure";
public SaveService()
{
@@ -41,6 +56,30 @@
throw new IOException("Problem using Avalon Configuration tools");
}
}
+
+ public static SampleResult getSampleResult(Configuration config)
+ {
+ SampleResult result = new SampleResult();
+ result.setThreadName(config.getAttribute(THREAD_NAME,""));
+ result.setDataType(config.getAttribute(DATA_TYPE,""));
+ result.setResponseCode(config.getAttribute(RESPONSE_CODE,""));
+ result.setResponseMessage(config.getAttribute(RESPONSE_MESSAGE,""));
+ result.setTime(config.getAttributeAsLong(TIME,0L));
+ result.setTimeStamp(config.getAttributeAsLong(TIME_STAMP,0L));
+ result.setSampleLabel(config.getAttribute(LABEL,""));
+ result.setResponseData(getBinaryData(config.getChild(BINARY)));
+ Configuration[] subResults = config.getChildren(SAMPLE_RESULT_TAG_NAME);
+ for(int i = 0;i < subResults.length;i++)
+ {
+ result.addSubResult(getSampleResult(subResults[i]));
+ }
+ Configuration[] assResults = config.getChildren(ASSERTION_RESULT_TAG_NAME);
+ for(int i = 0;i < assResults.length;i++)
+ {
+ result.addAssertionResult(getAssertionResult(assResults[i]));
+ }
+ return result;
+ }
private static List getConfigsFromTree(ListedHashTree subTree)
{
@@ -60,6 +99,73 @@
configs.add(config);
}
return configs;
+ }
+
+ public static Configuration getConfiguration(byte[] bin)
+ {
+ DefaultConfiguration config = new DefaultConfiguration(BINARY,"JMeter Save Service");
+ try {
+ config.setValue(new String(bin,"utf-8"));
+ } catch(UnsupportedEncodingException e) {
+ e.printStackTrace();
+ }
+ return config;
+ }
+
+ public static byte[] getBinaryData(Configuration config)
+ {
+ try {
+ return config.getValue("").getBytes("utf-8");
+ } catch(UnsupportedEncodingException e) {
+ return new byte[0];
+ }
+ }
+
+ public static AssertionResult getAssertionResult(Configuration config)
+ {
+ AssertionResult result = new AssertionResult();
+ result.setError(config.getAttributeAsBoolean(ERROR,false));
+ result.setFailure(config.getAttributeAsBoolean(FAILURE,false));
+ result.setFailureMessage(config.getAttribute(FAILURE_MESSAGE,""));
+ return result;
+ }
+
+ public static Configuration getConfiguration(AssertionResult assResult)
+ {
+ DefaultConfiguration config = new DefaultConfiguration(ASSERTION_RESULT_TAG_NAME,
+ "JMeter Save Service");
+ config.setAttribute(FAILURE_MESSAGE,assResult.getFailureMessage());
+ config.setAttribute(ERROR,""+assResult.isError());
+ config.setAttribute(FAILURE,""+assResult.isFailure());
+ return config;
+ }
+
+ public static Configuration getConfiguration(SampleResult result,boolean funcTest)
+ {
+ DefaultConfiguration config = new DefaultConfiguration(SAMPLE_RESULT_TAG_NAME,"JMeter Save Service");
+ config.setAttribute(TIME,""+result.getTime());
+ config.setAttribute(LABEL,result.getSampleLabel());
+ config.setAttribute(RESPONSE_CODE,result.getResponseCode());
+ config.setAttribute(RESPONSE_MESSAGE,result.getResponseMessage());
+ config.setAttribute(THREAD_NAME,result.getThreadName());
+ config.setAttribute(DATA_TYPE,result.getDataType());
+ config.setAttribute(TIME_STAMP,""+result.getTimeStamp());
+ config.addChild(getConfigForTestElement(null,result.getSamplerData()));
+ SampleResult[] subResults = result.getSubResults();
+ for(int i = 0;i < subResults.length;i++)
+ {
+ config.addChild(getConfiguration(subResults[i],funcTest));
+ }
+ if(funcTest)
+ {
+ AssertionResult[] assResults = result.getAssertionResults();
+ for(int i = 0;i < assResults.length;i++)
+ {
+ config.addChild(getConfiguration(assResults[i]));
+ }
+ config.addChild(getConfiguration(result.getResponseData()));
+ }
+ return config;
}
public static Configuration getConfigForTestElement(String named,TestElement item)
1.6 +5 -69 jakarta-jmeter/src_1/org/apache/jmeter/threads/gui/ThreadGroupGui.java
Index: ThreadGroupGui.java
===================================================================
RCS file: /home/cvs/jakarta-jmeter/src_1/org/apache/jmeter/threads/gui/ThreadGroupGui.java,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -r1.5 -r1.6
--- ThreadGroupGui.java 29 Apr 2002 17:08:14 -0000 1.5
+++ ThreadGroupGui.java 16 May 2002 16:41:30 -0000 1.6
@@ -66,6 +66,7 @@
import org.apache.jmeter.gui.util.FocusRequester;
import org.apache.jmeter.gui.util.MenuFactory;
import org.apache.jmeter.gui.util.VerticalLayout;
+import org.apache.jmeter.gui.util.NumberFieldErrorListener;
import org.apache.jmeter.testelement.TestElement;
import org.apache.jmeter.threads.ThreadGroup;
import org.apache.jmeter.util.JMeterUtils;
@@ -74,12 +75,11 @@
* Title: JMeter Description: Copyright: Copyright (c) 2000 Company: Apache
*
*@author Michael Stover
- *@created $Date: 2002/04/29 17:08:14 $
+ *@created $Date: 2002/05/16 16:41:30 $
*@version 1.0
***************************************/
-public class ThreadGroupGui extends JPanel implements KeyListener,
- JMeterGUIComponent
+public class ThreadGroupGui extends JPanel implements JMeterGUIComponent
{
LoopControlPanel loopPanel;
@@ -192,63 +192,6 @@
}
/****************************************
- * !ToDo (Method description)
- *
- *@param e !ToDo (Parameter description)
- ***************************************/
- public void keyReleased(KeyEvent e)
- {
- String field = e.getComponent().getName();
- if(field.equals(THREAD_NAME))
- {
- try
- {
- Integer.parseInt(threadInput.getText());
- }
- catch(NumberFormatException nfe)
- {
- if(threadInput.getText().length() > 0)
- {
- JOptionPane.showMessageDialog(this, "You must enter a valid number",
- "Invalid data", JOptionPane.WARNING_MESSAGE);
-
- // Right now, the cleanest thing to do is simply clear the
- // entire text field. We do not want to set the text to
- // the default because that would be confusing to the user.
- // For example, the user typed "5t" instead of "56". After
- // the user closes the error dialog, the text would change
- // from "5t" to "1". A litle confusing. If anything, it
- // should display just "5". Future enhancement...
- threadInput.setText("");
- }
- }
- }
- else if(field.equals(RAMP_NAME))
- {
- try
- {
- Integer.parseInt(rampInput.getText());
- }
- catch(NumberFormatException nfe)
- {
- if(rampInput.getText().length() > 0)
- {
- JOptionPane.showMessageDialog(this, "You must enter a valid number",
- "Invalid data", JOptionPane.WARNING_MESSAGE);
- rampInput.setText("");
- }
- }
- }
- }
-
- /****************************************
- * !ToDo (Method description)
- *
- *@param e !ToDo (Parameter description)
- ***************************************/
- public void keyTyped(KeyEvent e) { }
-
- /****************************************
* !ToDoo (Method description)
*
*@return !ToDo (Return description)
@@ -258,13 +201,6 @@
return JMeterUtils.getResString("ThreadGroup");
}
- /****************************************
- * !ToDo (Method description)
- *
- *@param e !ToDo (Parameter description)
- ***************************************/
- public void keyPressed(KeyEvent e) { }
-
private void init()
{
this.setLayout(new VerticalLayout(5, VerticalLayout.LEFT, VerticalLayout.TOP));
@@ -299,7 +235,7 @@
threadPanel.add(threadLabel);
threadInput = new JTextField(5);
threadInput.setText("1");
- threadInput.addKeyListener(this);
+ threadInput.addFocusListener(NumberFieldErrorListener.getNumberFieldErrorListener());
threadInput.setName(THREAD_NAME);
threadPanel.add(threadInput);
threadPropsPanel.add(threadPanel);
@@ -312,7 +248,7 @@
rampInput = new JTextField(5);
rampInput.setText("1");
rampInput.setName(RAMP_NAME);
- rampInput.addKeyListener(this);
+ rampInput.addFocusListener(NumberFieldErrorListener.getNumberFieldErrorListener());
rampPanel.add(rampInput);
threadPropsPanel.add(rampPanel);
1.8 +7 -2 jakarta-jmeter/src_1/org/apache/jmeter/visualizers/ViewResultsFullVisualizer.java
Index: ViewResultsFullVisualizer.java
===================================================================
RCS file: /home/cvs/jakarta-jmeter/src_1/org/apache/jmeter/visualizers/ViewResultsFullVisualizer.java,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -r1.7 -r1.8
--- ViewResultsFullVisualizer.java 2 May 2002 22:55:00 -0000 1.7
+++ ViewResultsFullVisualizer.java 16 May 2002 16:41:30 -0000 1.8
@@ -55,6 +55,7 @@
package org.apache.jmeter.visualizers;
import java.awt.*;
import java.awt.event.*;
+import java.io.UnsupportedEncodingException;
import java.util.*;
import javax.swing.*;
import javax.swing.event.*;
@@ -79,7 +80,7 @@
*
*@author Khor Soon Hin
*@created 2001/07/25
- *@version $Revision: 1.7 $ $Date: 2002/05/02 22:55:00 $
+ *@version $Revision: 1.8 $ $Date: 2002/05/16 16:41:30 $
***************************************/
public class ViewResultsFullVisualizer extends ViewResultsVisualizer implements
TreeSelectionListener
@@ -272,7 +273,11 @@
ImageIcon icon = null;
if(res.getDataType().equals(SampleResult.TEXT))
{
- response = new String(responseBytes);
+ try {
+ response = new String(responseBytes,"utf-8");
+ } catch(UnsupportedEncodingException err) {
+ response = new String(responseBytes);
+ }
}
else
{
--
To unsubscribe, e-mail: <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>