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 se...@apache.org on 2003/01/10 14:59:51 UTC
cvs commit: jakarta-jmeter/src/core/org/apache/jmeter/timers/gui AbstractTimerGui.java
seade 2003/01/10 05:59:51
Modified: src/core/org/apache/jmeter/timers Timer.java
src/components/org/apache/jmeter/timers/gui
ConstantThroughputTimerGui.java
GaussianRandomTimerGui.java ConstantTimerGui.java
UniformRandomTimerGui.java
src/components/org/apache/jmeter/timers
GaussianRandomTimer.java
ConstantThroughputTimer.java RandomTimer.java
UniformRandomTimer.java ConstantTimer.java
src/core/org/apache/jmeter/timers/gui AbstractTimerGui.java
Log:
Allows the delay value for timers to be set using variables. This provides a convenient way of altering the value of several timers in one go.
Revision Changes Path
1.2 +42 -90 jakarta-jmeter/src/core/org/apache/jmeter/timers/Timer.java
Index: Timer.java
===================================================================
RCS file: /home/cvs/jakarta-jmeter/src/core/org/apache/jmeter/timers/Timer.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- Timer.java 11 Aug 2002 19:24:49 -0000 1.1
+++ Timer.java 10 Jan 2003 13:59:50 -0000 1.2
@@ -1,155 +1,107 @@
/*
-
* ====================================================================
-
* 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.timers;
-
-
-
-
-
+import java.io.Serializable;
/**
-
* This interface defines those methods that must be implemented
-
* by timer plugins.
-
*
-
- * @author <a href="mailto:stefano@apache.org">Stefano Mazzocchi</a>
-
- * @version $Revision$ $Date$
-
+ * @author <a href="mailto:stefano@apache.org">Stefano Mazzocchi</a>
+ * @author <a href="mailto:seade@backstagetech.com.au">Scott Eade</a>
+ * @version $Id$
*/
+public interface Timer extends Serializable
+{
+ /**
+ * This method is called after a sampling process is done to know how much
+ * time the sampling thread has to wait until sampling again.
+ *
+ * @return the computed delay value.
+ */
+ public long delay();
+
+ /**
+ * Set the range value.
+ *
+ * @param range
+ */
+ public void setRange(double range);
+
+ /**
+ * Get the range value.
+ *
+ * @return double
+ */
+ public double getRange();
+
+ /**
+ * Set the delay value.
+ *
+ * @param delay the delay value (this is a String as it can be set using a
+ * variable).
+ */
+ public void setDelay(String delay);
+
+ /**
+ * Get the delay value for display.
+ *
+ * @return String
+ */
+ public String getDelay();
-public interface Timer extends java.io.Serializable {
-
-
-
- /**
-
- * This method is called after a sampling process is done
-
- * to know how much time the sampling thread has to wait
-
- * until sampling again.
-
- */
-
- public long delay();
-
- public void setRange(double range);
- public double getRange();
-
- public void setDelay(long delay);
- public long getDelay();
}
-
1.3 +97 -70 jakarta-jmeter/src/components/org/apache/jmeter/timers/gui/ConstantThroughputTimerGui.java
Index: ConstantThroughputTimerGui.java
===================================================================
RCS file: /home/cvs/jakarta-jmeter/src/components/org/apache/jmeter/timers/gui/ConstantThroughputTimerGui.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- ConstantThroughputTimerGui.java 24 Dec 2002 14:34:50 -0000 1.2
+++ ConstantThroughputTimerGui.java 10 Jan 2003 13:59:50 -0000 1.3
@@ -52,12 +52,13 @@
* information on the Apache Software Foundation, please see
* <http://www.apache.org/>.
*/
+
package org.apache.jmeter.timers.gui;
+
import java.awt.Font;
import java.awt.event.KeyEvent;
import java.awt.event.KeyListener;
-import javax.swing.JComponent;
import javax.swing.JLabel;
import javax.swing.JOptionPane;
import javax.swing.JPanel;
@@ -73,17 +74,17 @@
/**
* GUI for the Constant Throughput Timer.
*
- * @author <a href="mailto:jsalvata@atg.com">Jordi Salvat i Alabart</a>
- * @created $Date$
- * @version 1.0
+ * @author <a href="mailto:jsalvata@atg.com">Jordi Salvat i Alabart</a>
+ * @author <a href="mailto:seade@backstagetech.com.au">Scott Eade</a>
+ * @version $Id$
*/
public class ConstantThroughputTimerGui
extends AbstractTimerGui
implements KeyListener
{
private final String DEFAULT_THROUGHPUT = "60";
-
private final String THROUGHPUT_FIELD = "Throughput Field";
+
private JTextField throughputField;
/**
@@ -92,27 +93,42 @@
*/
public ConstantThroughputTimerGui()
{
- init();
+ init();
}
+ /**
+ * Get the title to display for this component.
+ *
+ * @see org.apache.jmeter.gui.JMeterGUIComponent#getStaticLabel()
+ */
public String getStaticLabel()
{
- return JMeterUtils.getResString("constant_throughput_timer_title");
+ return JMeterUtils.getResString("constant_throughput_timer_title");
}
+ /**
+ * Create the test element underlying this GUI component.
+ *
+ * @see org.apache.jmeter.gui.JMeterGUIComponent#createTestElement()
+ */
public TestElement createTestElement()
{
- ConstantThroughputTimer timer = new ConstantThroughputTimer();
- this.configureTestElement(timer);
- timer.setThroughput(Long.parseLong(throughputField.getText()));
- return timer;
+ ConstantThroughputTimer timer = new ConstantThroughputTimer();
+ this.configureTestElement(timer);
+ timer.setThroughput(Long.parseLong(throughputField.getText()));
+ return timer;
}
+ /**
+ * Configure this GUI component from the underlying TestElement.
+ *
+ * @see org.apache.jmeter.gui.JMeterGUIComponent#configure(TestElement)
+ */
public void configure(TestElement el)
{
- super.configure(el);
- ConstantThroughputTimer e= (ConstantThroughputTimer)el;
- throughputField.setText(String.valueOf(e.getThroughput()));
+ super.configure(el);
+ ConstantThroughputTimer e= (ConstantThroughputTimer)el;
+ throughputField.setText(String.valueOf(e.getThroughput()));
}
/**
@@ -123,34 +139,44 @@
*/
public void keyReleased(KeyEvent e)
{
- String n = e.getComponent().getName();
- if(n.equals(THROUGHPUT_FIELD))
- {
- try
- {
- Long.parseLong(throughputField.getText());
- }
- catch(NumberFormatException nfe)
- {
- if(throughputField.getText().length() > 0)
+ String n = e.getComponent().getName();
+ if(n.equals(THROUGHPUT_FIELD))
{
- JOptionPane.showMessageDialog(this,
- "You must enter a valid number",
- "Invalid data", JOptionPane.WARNING_MESSAGE);
- // We reset the text to be an empty string instead
- // of the default value. If we reset it to the
- // default value, then the user has to delete
- // that value and reenter his/her own. That's
- // too much trouble for the user.
+ try
+ {
+ Long.parseLong(throughputField.getText());
+ }
+ catch(NumberFormatException nfe)
+ {
+ if(throughputField.getText().length() > 0)
+ {
+ JOptionPane.showMessageDialog(this,
+ "You must enter a valid number",
+ "Invalid data", JOptionPane.WARNING_MESSAGE);
+ // We reset the text to be an empty string instead
+ // of the default value. If we reset it to the
+ // default value, then the user has to delete
+ // that value and reenter his/her own. That's
+ // too much trouble for the user.
+ }
+ }
}
- }
- }
}
+ /**
+ * Process a KeyEvent.
+ *
+ * @param e the event to handle.
+ */
public void keyPressed(KeyEvent e)
{
}
+ /**
+ * Process a KeyEvent.
+ *
+ * @param e the event to handle.
+ */
public void keyTyped(KeyEvent e)
{
}
@@ -160,41 +186,42 @@
*/
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("constant_throughput_timer_title"));
- 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(getNamePanel());
-
- // throughput
- JPanel throughputPanel = new JPanel();
- JLabel throughputLabel = new JLabel(
- JMeterUtils.getResString("constant_throughput_timer_throughput"));
- throughputPanel.add(throughputLabel);
- throughputField = new JTextField(6);
- throughputField.setText(DEFAULT_THROUGHPUT);
- throughputPanel.add(throughputField);
- mainPanel.add(throughputPanel);
-
- throughputField.addKeyListener(this);
- throughputField.setName(THROUGHPUT_FIELD);
-
- this.add(mainPanel);
+ 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("constant_throughput_timer_title"));
+ 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(getNamePanel());
+
+ // throughput
+ JPanel throughputPanel = new JPanel();
+ JLabel throughputLabel = new JLabel(
+ JMeterUtils.getResString("constant_throughput_timer_throughput"));
+ throughputPanel.add(throughputLabel);
+ throughputField = new JTextField(6);
+ throughputField.setText(DEFAULT_THROUGHPUT);
+ throughputPanel.add(throughputField);
+ mainPanel.add(throughputPanel);
+
+ throughputField.addKeyListener(this);
+ throughputField.setName(THROUGHPUT_FIELD);
+
+ this.add(mainPanel);
}
+
}
1.4 +56 -47 jakarta-jmeter/src/components/org/apache/jmeter/timers/gui/GaussianRandomTimerGui.java
Index: GaussianRandomTimerGui.java
===================================================================
RCS file: /home/cvs/jakarta-jmeter/src/components/org/apache/jmeter/timers/gui/GaussianRandomTimerGui.java,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- GaussianRandomTimerGui.java 17 Oct 2002 19:47:15 -0000 1.3
+++ GaussianRandomTimerGui.java 10 Jan 2003 13:59:50 -0000 1.4
@@ -52,7 +52,9 @@
* information on the Apache Software Foundation, please see
* <http://www.apache.org/>.
*/
+
package org.apache.jmeter.timers.gui;
+
import java.awt.Font;
import java.awt.event.KeyEvent;
import java.awt.event.KeyListener;
@@ -74,14 +76,13 @@
import org.apache.jmeter.util.JMeterUtils;
import org.apache.jorphan.gui.layout.VerticalLayout;
-/****************************************
- * Title: JMeter Description: Copyright: Copyright (c) 2000 Company: Apache
+/**
+ * Implementation of a gaussian random timer.
*
- *@author Michael Stover
- *@created $Date$
- *@version 1.0
- ***************************************/
-
+ * @author Michael Stover
+ * @author <a href="mailto:seade@backstagetech.com.au">Scott Eade</a>
+ * @version $Id$
+ */
public class GaussianRandomTimerGui extends AbstractTimerGui implements KeyListener
{
@@ -94,34 +95,44 @@
private JTextField delayField;
private JTextField rangeField;
- /****************************************
- * !ToDo (Constructor description)
- ***************************************/
+ /**
+ * No-arg constructor.
+ */
public GaussianRandomTimerGui()
{
init();
}
- /****************************************
- * !ToDo (Method description)
+ /**
+ * Handle an error.
*
- *@param e !ToDo (Parameter description)
- *@param thrower !ToDo (Parameter description)
- ***************************************/
+ * @param e the Exception that was thrown.
+ * @param thrower the JComponent that threw the Exception.
+ */
public static void error(Exception e, JComponent thrower)
{
JOptionPane.showMessageDialog(thrower, e, "Error", JOptionPane.ERROR_MESSAGE);
}
+ /**
+ * Create the test element underlying this GUI component.
+ *
+ * @see org.apache.jmeter.gui.JMeterGUIComponent#createTestElement()
+ */
public TestElement createTestElement()
{
RandomTimer timer = new GaussianRandomTimer();
this.configureTestElement(timer);
- timer.setDelay(Long.parseLong(delayField.getText()));
+ timer.setDelay(delayField.getText());
timer.setRange(Double.parseDouble(rangeField.getText()));
return timer;
}
+ /**
+ * Configure this GUI component from the underlying TestElement.
+ *
+ * @see org.apache.jmeter.gui.JMeterGUIComponent#configure(TestElement)
+ */
public void configure(TestElement el)
{
super.configure(el);
@@ -129,36 +140,26 @@
rangeField.setText(el.getProperty(RandomTimer.RANGE).toString());
}
+ /**
+ * Get the title to display for this component.
+ *
+ * @see org.apache.jmeter.gui.JMeterGUIComponent#getStaticLabel()
+ */
public String getStaticLabel()
{
return JMeterUtils.getResString("gaussian_timer_title");
}
- /****************************************
- * !ToDo (Method description)
+ /**
+ * Process a KeyEvent.
*
- *@param e !ToDo (Parameter description)
- ***************************************/
+ * @param e the event to handle.
+ */
public void keyReleased(KeyEvent e)
{
String temp = e.getComponent().getName();
- if(temp.equals(DELAY_FIELD))
- {
- try
- {
- Long.parseLong(delayField.getText());
- }
- catch(NumberFormatException nfe)
- {
- if(delayField.getText().length() > 0)
- {
- JOptionPane.showMessageDialog(this, "You must enter a valid number",
- "Invalid data", JOptionPane.WARNING_MESSAGE);
- }
- }
- }
- else if(temp.equals(RANGE_FIELD))
+ if(temp.equals(RANGE_FIELD))
{
try
{
@@ -175,20 +176,27 @@
}
}
- /****************************************
- * !ToDo (Method description)
+ /**
+ * Process a KeyEvent.
*
- *@param e !ToDo (Parameter description)
- ***************************************/
- public void keyPressed(KeyEvent e) { }
+ * @param e the event to handle.
+ */
+ public void keyPressed(KeyEvent e)
+ {
+ }
- /****************************************
- * !ToDo (Method description)
+ /**
+ * Process a KeyEvent.
*
- *@param e !ToDo (Parameter description)
- ***************************************/
- public void keyTyped(KeyEvent e) { }
+ * @param e the event to handle.
+ */
+ public void keyTyped(KeyEvent e)
+ {
+ }
+ /**
+ * Initialize this component.
+ */
private void init()
{
this.setLayout(new VerticalLayout(5, VerticalLayout.LEFT, VerticalLayout.TOP));
@@ -232,7 +240,7 @@
JPanel avgDelayPanel = new JPanel();
JLabel delayLabel = new JLabel(JMeterUtils.getResString("gaussian_timer_delay"));
avgDelayPanel.add(delayLabel);
- delayField = new JTextField(6);
+ delayField = new JTextField(20);
delayField.setText(DEFAULT_DELAY);
delayField.setName(DELAY_FIELD);
delayField.addKeyListener(this);
@@ -244,4 +252,5 @@
// Set the initial focus to the delay field
new FocusRequester(rangeField);
}
+
}
1.4 +43 -67 jakarta-jmeter/src/components/org/apache/jmeter/timers/gui/ConstantTimerGui.java
Index: ConstantTimerGui.java
===================================================================
RCS file: /home/cvs/jakarta-jmeter/src/components/org/apache/jmeter/timers/gui/ConstantTimerGui.java,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- ConstantTimerGui.java 17 Oct 2002 19:47:15 -0000 1.3
+++ ConstantTimerGui.java 10 Jan 2003 13:59:50 -0000 1.4
@@ -52,10 +52,10 @@
* information on the Apache Software Foundation, please see
* <http://www.apache.org/>.
*/
+
package org.apache.jmeter.timers.gui;
+
import java.awt.Font;
-import java.awt.event.KeyEvent;
-import java.awt.event.KeyListener;
import javax.swing.JComponent;
import javax.swing.JLabel;
@@ -70,103 +70,80 @@
import org.apache.jmeter.util.JMeterUtils;
import org.apache.jorphan.gui.layout.VerticalLayout;
-/****************************************
- * Title: JMeter Description: Copyright: Copyright (c) 2000 Company: Apache
+/**
+ * The GUI for ConstantTimer.
*
- *@author Michael Stover
- *@created $Date$
- *@version 1.0
- ***************************************/
-
-public class ConstantTimerGui extends AbstractTimerGui implements KeyListener
+ * @author Michael Stover
+ * @author <a href="mailto:seade@backstagetech.com.au">Scott Eade</a>
+ * @version $Id$
+ */
+public class ConstantTimerGui extends AbstractTimerGui
{
+ /**
+ * The default value for the delay.
+ */
private final String DEFAULT_DELAY = "300";
private final String DELAY_FIELD = "Delay Field";
+
private JTextField delayField;
- /****************************************
- * !ToDo (Constructor description)
- ***************************************/
+ /**
+ * No-arg constructor.
+ */
public ConstantTimerGui()
{
init();
}
- /****************************************
- * !ToDo (Method description)
+ /**
+ * Handle an error.
*
- *@param e !ToDo (Parameter description)
- *@param thrower !ToDo (Parameter description)
- ***************************************/
+ * @param e the Exception that was thrown.
+ * @param thrower the JComponent that threw the Exception.
+ */
public static void error(Exception e, JComponent thrower)
{
JOptionPane.showMessageDialog(thrower, e, "Error", JOptionPane.ERROR_MESSAGE);
}
+ /**
+ * Get the title to display for this component.
+ *
+ * @see org.apache.jmeter.gui.JMeterGUIComponent#getStaticLabel()
+ */
public String getStaticLabel()
{
return JMeterUtils.getResString("constant_timer_title");
}
+ /**
+ * Create the test element underlying this GUI component.
+ *
+ * @see org.apache.jmeter.gui.JMeterGUIComponent#createTestElement()
+ */
public TestElement createTestElement()
{
ConstantTimer timer = new ConstantTimer();
this.configureTestElement(timer);
- timer.setDelay(Long.parseLong(delayField.getText()));
+ timer.setDelay(delayField.getText());
return timer;
}
+ /**
+ * Configure this GUI component from the underlying TestElement.
+ *
+ * @see org.apache.jmeter.gui.JMeterGUIComponent#configure(TestElement)
+ */
public void configure(TestElement el)
{
super.configure(el);
- delayField.setText(((ConstantTimer)el).getDelay()+"");
- }
-
- /****************************************
- * !ToDo (Method description)
- *
- *@param e !ToDo (Parameter description)
- ***************************************/
- public void keyReleased(KeyEvent e)
- {
- String n = e.getComponent().getName();
- if(n.equals(DELAY_FIELD))
- {
- try
- {
- Long.parseLong(delayField.getText());
- }
- catch(NumberFormatException nfe)
- {
- if(delayField.getText().length() > 0)
- {
- JOptionPane.showMessageDialog(this, "You must enter a valid number",
- "Invalid data", JOptionPane.WARNING_MESSAGE);
- // We reset the text to be an empty string instead
- // of the default value. If we reset it to the
- // default value, then the user has to delete
- // that value and reenter his/her own. That's
- // too much trouble for the user.
- }
- }
- }
+ delayField.setText(((ConstantTimer)el).getDelay());
}
- /****************************************
- * !ToDo (Method description)
- *
- *@param e !ToDo (Parameter description)
- ***************************************/
- public void keyPressed(KeyEvent e) { }
-
- /****************************************
- * !ToDo (Method description)
- *
- *@param e !ToDo (Parameter description)
- ***************************************/
- public void keyTyped(KeyEvent e) { }
-
+ /**
+ * Initialize this component.
+ */
private void init()
{
this.setLayout(new VerticalLayout(5, VerticalLayout.LEFT, VerticalLayout.TOP));
@@ -192,14 +169,13 @@
JPanel delayPanel = new JPanel();
JLabel delayLabel = new JLabel(JMeterUtils.getResString("constant_timer_delay"));
delayPanel.add(delayLabel);
- delayField = new JTextField(6);
+ delayField = new JTextField(20);
delayField.setText(DEFAULT_DELAY);
delayPanel.add(delayField);
mainPanel.add(delayPanel);
-
- delayField.addKeyListener(this);
delayField.setName(DELAY_FIELD);
this.add(mainPanel);
}
+
}
1.4 +56 -48 jakarta-jmeter/src/components/org/apache/jmeter/timers/gui/UniformRandomTimerGui.java
Index: UniformRandomTimerGui.java
===================================================================
RCS file: /home/cvs/jakarta-jmeter/src/components/org/apache/jmeter/timers/gui/UniformRandomTimerGui.java,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- UniformRandomTimerGui.java 17 Oct 2002 19:47:15 -0000 1.3
+++ UniformRandomTimerGui.java 10 Jan 2003 13:59:50 -0000 1.4
@@ -52,7 +52,9 @@
* information on the Apache Software Foundation, please see
* <http://www.apache.org/>.
*/
+
package org.apache.jmeter.timers.gui;
+
import java.awt.Font;
import java.awt.event.KeyEvent;
import java.awt.event.KeyListener;
@@ -74,14 +76,13 @@
import org.apache.jmeter.util.JMeterUtils;
import org.apache.jorphan.gui.layout.VerticalLayout;
-/****************************************
- * Title: JMeter Description: Copyright: Copyright (c) 2000 Company: Apache
+/**
+ * Implementation of a uniform random timer.
*
- *@author Michael Stover
- *@created $Date$
- *@version 1.0
- ***************************************/
-
+ * @author Michael Stover
+ * @author <a href="mailto:seade@backstagetech.com.au">Scott Eade</a>
+ * @version $Id$
+ */
public class UniformRandomTimerGui extends AbstractTimerGui implements KeyListener
{
@@ -94,39 +95,54 @@
private JTextField delayField;
private JTextField rangeField;
- /****************************************
- * !ToDo (Constructor description)
- ***************************************/
+ /**
+ * No-arg constructor.
+ */
public UniformRandomTimerGui()
{
init();
}
- /****************************************
- * !ToDo (Method description)
+ /**
+ * Handle an error.
*
- *@param e !ToDo (Parameter description)
- *@param thrower !ToDo (Parameter description)
- ***************************************/
+ * @param e the Exception that was thrown.
+ * @param thrower the JComponent that threw the Exception.
+ */
public static void error(Exception e, JComponent thrower)
{
JOptionPane.showMessageDialog(thrower, e, "Error", JOptionPane.ERROR_MESSAGE);
}
+ /**
+ * Get the title to display for this component.
+ *
+ * @see org.apache.jmeter.gui.JMeterGUIComponent#getStaticLabel()
+ */
public String getStaticLabel()
{
return JMeterUtils.getResString("uniform_timer_title");
}
+ /**
+ * Create the test element underlying this GUI component.
+ *
+ * @see org.apache.jmeter.gui.JMeterGUIComponent#createTestElement()
+ */
public TestElement createTestElement()
{
RandomTimer timer = new UniformRandomTimer();
this.configureTestElement(timer);
- timer.setDelay(Long.parseLong(delayField.getText()));
+ timer.setDelay(delayField.getText());
timer.setRange(Double.parseDouble(rangeField.getText()));
return timer;
}
+ /**
+ * Configure this GUI component from the underlying TestElement.
+ *
+ * @see org.apache.jmeter.gui.JMeterGUIComponent#configure(TestElement)
+ */
public void configure(TestElement el)
{
super.configure(el);
@@ -134,32 +150,16 @@
rangeField.setText(el.getProperty(RandomTimer.RANGE).toString());
}
-
- /****************************************
- * !ToDo (Method description)
+ /**
+ * Process a KeyEvent.
*
- *@param e !ToDo (Parameter description)
- ***************************************/
+ * @param e the event to handle.
+ */
public void keyReleased(KeyEvent e)
{
String temp = e.getComponent().getName();
- if(temp.equals(DELAY_FIELD))
- {
- try
- {
- Long.parseLong(delayField.getText());
- }
- catch(NumberFormatException nfe)
- {
- if(delayField.getText().length() > 0)
- {
- JOptionPane.showMessageDialog(this, "You must enter a valid number",
- "Invalid data", JOptionPane.WARNING_MESSAGE);
- }
- }
- }
- else if(temp.equals(RANGE_FIELD))
+ if (temp.equals(RANGE_FIELD))
{
try
{
@@ -176,20 +176,27 @@
}
}
- /****************************************
- * !ToDo (Method description)
+ /**
+ * Process a KeyEvent.
*
- *@param e !ToDo (Parameter description)
- ***************************************/
- public void keyPressed(KeyEvent e) { }
+ * @param e the event to handle.
+ */
+ public void keyPressed(KeyEvent e)
+ {
+ }
- /****************************************
- * !ToDo (Method description)
+ /**
+ * Process a KeyEvent.
*
- *@param e !ToDo (Parameter description)
- ***************************************/
- public void keyTyped(KeyEvent e) { }
+ * @param e the event to handle.
+ */
+ public void keyTyped(KeyEvent e)
+ {
+ }
+ /**
+ * Initialize this component.
+ */
private void init()
{
this.setLayout(new VerticalLayout(5, VerticalLayout.LEFT, VerticalLayout.TOP));
@@ -233,7 +240,7 @@
JPanel avgDelayPanel = new JPanel();
JLabel delayLabel = new JLabel(JMeterUtils.getResString("uniform_timer_delay"));
avgDelayPanel.add(delayLabel);
- delayField = new JTextField(6);
+ delayField = new JTextField(20);
delayField.setText(DEFAULT_DELAY);
delayField.setName(DELAY_FIELD);
delayField.addKeyListener(this);
@@ -245,4 +252,5 @@
// Set the initial focus to the range field
new FocusRequester(rangeField);
}
+
}
1.2 +6 -5 jakarta-jmeter/src/components/org/apache/jmeter/timers/GaussianRandomTimer.java
Index: GaussianRandomTimer.java
===================================================================
RCS file: /home/cvs/jakarta-jmeter/src/components/org/apache/jmeter/timers/GaussianRandomTimer.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- GaussianRandomTimer.java 11 Aug 2002 19:24:41 -0000 1.1
+++ GaussianRandomTimer.java 10 Jan 2003 13:59:51 -0000 1.2
@@ -55,8 +55,7 @@
package org.apache.jmeter.timers;
-import java.util.*;
-import java.io.*;
+import java.io.Serializable;
import org.apache.jmeter.util.JMeterUtils;
@@ -65,17 +64,19 @@
* to be instantiable and implements a random delay with
* an average value and a gaussian distributed variation.
*
- * @author <a href="mailto:stefano@apache.org">Stefano Mazzocchi</a>
- * @version $Revision$ $Date$
+ * @author <a href="mailto:stefano@apache.org">Stefano Mazzocchi</a>
+ * @author <a href="mailto:seade@backstagetech.com.au">Scott Eade</a>
+ * @version $Id$
*/
public class GaussianRandomTimer extends RandomTimer implements Serializable
{
public long delay() {
- return (long) Math.abs((this.random.nextGaussian() * getRange()) + getDelay());
+ return (long) Math.abs((this.random.nextGaussian() * getRange()) + super.delay());
}
public String toString() {
return JMeterUtils.getResString("gaussian_timer_memo");
}
+
}
1.3 +48 -42 jakarta-jmeter/src/components/org/apache/jmeter/timers/ConstantThroughputTimer.java
Index: ConstantThroughputTimer.java
===================================================================
RCS file: /home/cvs/jakarta-jmeter/src/components/org/apache/jmeter/timers/ConstantThroughputTimer.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- ConstantThroughputTimer.java 24 Dec 2002 14:34:50 -0000 1.2
+++ ConstantThroughputTimer.java 10 Jan 2003 13:59:51 -0000 1.3
@@ -66,13 +66,13 @@
* Timer paces the samplers under it's influence so that the total number of
* samples per unit of time approaches a given constant as much as possible.
*
- * @author <a href="mailto:jsalvata@atg.com">Jordi Salvat i Alabart</a>
- * @created $Date$
- * @version $Revision$ $Date$
+ * @author <a href="mailto:jsalvata@atg.com">Jordi Salvat i Alabart</a>
+ * @author <a href="mailto:seade@backstagetech.com.au">Scott Eade</a>
+ * @version $Id$
*/
public class ConstantThroughputTimer
- extends AbstractTestElement
- implements Timer, Serializable
+ extends AbstractTestElement
+ implements Timer, Serializable
{
public final static String THROUGHPUT= "ConstantThroughputTimer.throughput";
private static List addableList= new LinkedList();
@@ -104,8 +104,8 @@
*/
public void setThroughput(long throughput)
{
- setProperty(THROUGHPUT,new Long(throughput));
- delay= 60000/throughput;
+ setProperty(THROUGHPUT,new Long(throughput));
+ delay= 60000/throughput;
}
/**
@@ -120,22 +120,22 @@
*/
public double getRange()
{
- return (double)0;
+ return (double)0;
}
/**
* Not implemented.
*/
- public void setDelay(long delay)
+ public void setDelay(String delay)
{
}
/**
* Not implemented.
*/
- public long getDelay()
+ public String getDelay()
{
- return 0;
+ return "";
}
/**
@@ -145,38 +145,43 @@
*/
public long getThroughput()
{
- Object throughput = getProperty(THROUGHPUT);
- if(throughput instanceof Long)
- {
- return ((Long)throughput).longValue();
- }
- else
- {
- return Long.parseLong((String)throughput);
- }
- }
-
+ Object throughput = getProperty(THROUGHPUT);
+ if(throughput instanceof Long)
+ {
+ return ((Long)throughput).longValue();
+ }
+ else
+ {
+ return Long.parseLong((String)throughput);
+ }
+ }
+
+ /**
+ * Retrieve the delay to use during test execution.
+ *
+ * @see org.apache.jmeter.timers.Timer#delay()
+ */
public synchronized long delay()
{
- long currentTime= System.currentTimeMillis();
- long currentTarget= targetTime==0 ? currentTime : targetTime;
- targetTime=currentTarget+delay;
- if (currentTime > currentTarget)
- {
- // We're behind schedule -- try to catch up:
- return 0;
- }
- return currentTarget-currentTime;
- }
-
- /************************************************************
- * !ToDo (Method description)
- *
- *@return !ToDo (Return description)
- ***********************************************************/
+ long currentTime = System.currentTimeMillis();
+ long currentTarget = targetTime == 0 ? currentTime : targetTime;
+ targetTime = currentTarget + delay;
+ if (currentTime > currentTarget)
+ {
+ // We're behind schedule -- try to catch up:
+ return 0;
+ }
+ return currentTarget - currentTime;
+ }
+
+ /**
+ * Provide a description of this timer class.
+ *
+ * @return the description of this timer class.
+ */
public String toString()
{
- return JMeterUtils.getResString("constant_throughput_timer_memo");
+ return JMeterUtils.getResString("constant_throughput_timer_memo");
}
/**
@@ -187,8 +192,9 @@
* @return a fresh copy of this ConstantThroughputTimer
*/
public Object clone() {
- ConstantThroughputTimer result= (ConstantThroughputTimer)super.clone();
- result.targetTime= 0;
- return result;
+ ConstantThroughputTimer result = (ConstantThroughputTimer)super.clone();
+ result.targetTime = 0;
+ return result;
}
+
}
1.2 +23 -27 jakarta-jmeter/src/components/org/apache/jmeter/timers/RandomTimer.java
Index: RandomTimer.java
===================================================================
RCS file: /home/cvs/jakarta-jmeter/src/components/org/apache/jmeter/timers/RandomTimer.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- RandomTimer.java 11 Aug 2002 19:24:41 -0000 1.1
+++ RandomTimer.java 10 Jan 2003 13:59:51 -0000 1.2
@@ -55,52 +55,48 @@
package org.apache.jmeter.timers;
-import java.util.*;
-import java.io.*;
+import java.io.Serializable;
+import java.util.Random;
-import org.apache.jmeter.testelement.AbstractTestElement;
-
-/************************************************************
- * This class implements a random timer with its own panel and fields for value
- * update and user interaction. Since this class does not define the delay()
- * method, is abstract and must be extended to provide full functionality.
+/***
+ * This class implements a random timer with its own panel and fields for value
+ * update and user interaction. Since this class does not define the delay()
+ * method, is abstract and must be extended to provide full functionality.
*
- *@author <a href="mailto:stefano@apache.org">Stefano Mazzocchi</a>
- *@created $Date$
- *@version $Revision$ $Date$
- ***********************************************************/
-
-public abstract class RandomTimer extends ConstantTimer implements Timer,Serializable
+ * @author <a href="mailto:stefano@apache.org">Stefano Mazzocchi</a>
+ * @author <a href="mailto:seade@backstagetech.com.au">Scott Eade</a>
+ * @version $Id$
+ */
+public abstract class RandomTimer extends ConstantTimer implements Timer, Serializable
{
public final static String RANGE = "RandomTimer.range";
protected Random random;
- /************************************************************
- * !ToDo (Constructor description)
- ***********************************************************/
+ /**
+ * No-arg constructor.
+ */
public RandomTimer()
{
this.random = new Random();
}
- /************************************************************
- * !ToDo (Method description)
- *
- *@param range !ToDo (Parameter description)
- ***********************************************************/
+ /**
+ * Set the range value.
+ */
public void setRange(double range)
{
setProperty(RANGE,new Double(range));
}
- /************************************************************
- * !ToDoo (Method description)
- *
- *@return !ToDo (Return description)
- ***********************************************************/
+ /**
+ * Get the range value.
+ *
+ * @return double
+ */
public double getRange()
{
return this.getPropertyAsDouble(RANGE);
}
+
}
1.2 +4 -4 jakarta-jmeter/src/components/org/apache/jmeter/timers/UniformRandomTimer.java
Index: UniformRandomTimer.java
===================================================================
RCS file: /home/cvs/jakarta-jmeter/src/components/org/apache/jmeter/timers/UniformRandomTimer.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- UniformRandomTimer.java 11 Aug 2002 19:24:41 -0000 1.1
+++ UniformRandomTimer.java 10 Jan 2003 13:59:51 -0000 1.2
@@ -55,8 +55,7 @@
package org.apache.jmeter.timers;
-import java.util.*;
-import java.io.*;
+import java.io.Serializable;
import org.apache.jmeter.util.JMeterUtils;
@@ -72,11 +71,12 @@
{
public long delay()
{
- return (long) Math.abs((this.random.nextDouble() * getRange()) + getDelay());
+ return (long) Math.abs((this.random.nextDouble() * getRange()) + super.delay());
}
public String toString()
{
return JMeterUtils.getResString("uniform_timer_memo");
}
+
}
1.2 +85 -60 jakarta-jmeter/src/components/org/apache/jmeter/timers/ConstantTimer.java
Index: ConstantTimer.java
===================================================================
RCS file: /home/cvs/jakarta-jmeter/src/components/org/apache/jmeter/timers/ConstantTimer.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- ConstantTimer.java 11 Aug 2002 19:24:41 -0000 1.1
+++ ConstantTimer.java 10 Jan 2003 13:59:51 -0000 1.2
@@ -60,92 +60,117 @@
import org.apache.jmeter.util.JMeterUtils;
import org.apache.jmeter.testelement.AbstractTestElement;
-
-/************************************************************
- * This class implements a constant timer with its own panel and fields for
- * value update and user interaction.
+import org.apache.jmeter.testelement.ThreadListener;
+import org.apache.jmeter.testelement.VariablesCollection;
+import org.apache.jmeter.threads.JMeterVariables;
+
+/**
+ * This class implements a constant timer with its own panel and fields for
+ * value update and user interaction.
*
- *@author <a href="mailto:stefano@apache.org">Stefano Mazzocchi</a>
- *@created $Date$
- *@version $Revision$ $Date$
- ***********************************************************/
-
-public class ConstantTimer extends AbstractTestElement implements Timer, Serializable
+ * @author <a href="mailto:stefano@apache.org">Stefano Mazzocchi</a>
+ * @author <a href="mailto:seade@backstagetech.com.au">Scott Eade</a>
+ * @version $Revision$ $Date$
+ */
+public class ConstantTimer extends AbstractTestElement
+ implements Timer, Serializable, ThreadListener
{
public final static String DELAY = "ConstantTimer.delay";
+ private VariablesCollection vars = new VariablesCollection();
+ private JMeterVariables variables;
private static List addableList = new LinkedList();
+ private long delay = 0;
- /************************************************************
- * !ToDo (Constructor description)
- ***********************************************************/
+ /**
+ * No-arg constructor.
+ *
+ * @see java.lang.Object#Object()
+ */
public ConstantTimer()
{
}
- /************************************************************
- * !ToDo (Method description)
- *
- *@param delay !ToDo (Parameter description)
- ***********************************************************/
- public void setDelay(long delay)
- {
- setProperty(DELAY,new Long(delay));
+ /**
+ * Set the delay for this timer.
+ *
+ * @see org.apache.jmeter.timers.Timer#setDelay(String)
+ */
+ public void setDelay(String delay)
+ {
+ setProperty(DELAY, delay);
}
- /************************************************************
- * !ToDo (Method description)
- *
- *@param range !ToDo (Parameter description)
- ***********************************************************/
+ /**
+ * Set the range (not used for this timer).
+ *
+ * @see org.apache.jmeter.timers.Timer#setRange(double)
+ */
public void setRange(double range)
{
}
- /************************************************************
- * !ToDoo (Method description)
- *
- *@return !ToDo (Return description)
- ***********************************************************/
- public long getDelay()
- {
- Object delay = getProperty(DELAY);
- if(delay instanceof Long)
- {
- return ((Long)delay).longValue();
- }
- else
- {
- return Long.parseLong((String)delay);
- }
- }
-
- /************************************************************
- * !ToDoo (Method description)
- *
- *@return !ToDo (Return description)
- ***********************************************************/
+ /**
+ * Get the delay value for display.
+ *
+ * @return the delay value for display.
+ * @see org.apache.jmeter.timers.Timer#getDelay()
+ */
+ public String getDelay()
+ {
+ return (String) getProperty(DELAY);
+ }
+
+ /**
+ * Retrieve the range (not used for this timer).
+ *
+ * @return the range (always zero for this timer).
+ * @see org.apache.jmeter.timers.Timer#getRange()
+ */
public double getRange()
{
return (double)0;
}
- /************************************************************
- * !ToDo (Method description)
- *
- *@return !ToDo (Return description)
- ***********************************************************/
+ /**
+ * Retrieve the delay to use during test execution.
+ *
+ * @return the delay.
+ */
public long delay()
{
- return getDelay();
+ return delay;
}
- /************************************************************
- * !ToDo (Method description)
- *
- *@return !ToDo (Return description)
- ***********************************************************/
+ /**
+ * Provide a description of this timer class.
+ *
+ * @return the description of this timer class.
+ */
public String toString()
{
return JMeterUtils.getResString("constant_timer_memo");
}
+
+ /**
+ * Gain access to any variables that have been defined.
+ *
+ * @see org.apache.jmeter.testelement.ThreadListener#iterationStarted(int)
+ */
+ public void iterationStarted(int iterationCount)
+ {
+ variables = vars.getVariables();
+ String delayString = (String) getProperty(DELAY);
+ delay = Long.parseLong(delayString);
+ }
+
+ /**
+ * Make changes to variables available elsewhere.
+ *
+ * @see org.apache.jmeter.testelement.ThreadListener#setJMeterVariables(JMeterVariables)
+ */
+ public void setJMeterVariables(JMeterVariables jmVars)
+ {
+ //vars.addJMeterVariables(jmVars);
+ }
+
}
1.2 +10 -13 jakarta-jmeter/src/core/org/apache/jmeter/timers/gui/AbstractTimerGui.java
Index: AbstractTimerGui.java
===================================================================
RCS file: /home/cvs/jakarta-jmeter/src/core/org/apache/jmeter/timers/gui/AbstractTimerGui.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- AbstractTimerGui.java 11 Aug 2002 19:24:49 -0000 1.1
+++ AbstractTimerGui.java 10 Jan 2003 13:59:51 -0000 1.2
@@ -5,29 +5,26 @@
import javax.swing.JPopupMenu;
import org.apache.jmeter.gui.AbstractJMeterGuiComponent;
-import org.apache.jmeter.gui.NamePanel;
import org.apache.jmeter.gui.util.MenuFactory;
-import org.apache.jmeter.testelement.TestElement;
/**
* Title: JMeter
* Description:
- * Copyright: Copyright (c) 2000
+ * Copyright: Copyright (c) 2003
* Company: Apache
* @author Michael Stover
* @version 1.0
*/
-
public abstract class AbstractTimerGui extends AbstractJMeterGuiComponent
{
+ public JPopupMenu createPopupMenu()
+ {
+ return MenuFactory.getDefaultTimerMenu();
+ }
- public JPopupMenu createPopupMenu()
- {
- return MenuFactory.getDefaultTimerMenu();
- }
-
- public Collection getMenuCategories()
- {
- return Arrays.asList(new String[]{MenuFactory.TIMERS});
- }
+ public Collection getMenuCategories()
+ {
+ return Arrays.asList(new String[]{MenuFactory.TIMERS});
+ }
+
}
--
To unsubscribe, e-mail: <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>