jsalvata 2002/12/29 07:31:45
Added: src/components/org/apache/jmeter/visualizers
AccumListener.java GraphAccumListener.java
GraphListener.java
src/core/org/apache/jmeter/config Argument.java
Arguments.java LoginConfig.java
src/core/org/apache/jmeter/config/gui ArgumentsPanel.java
LoginConfigGui.java
src/core/org/apache/jmeter/control GenericController.java
LoopController.java
src/core/org/apache/jmeter/control/gui
LogicControllerGui.java LoopControlPanel.java
src/protocol/http/org/apache/jmeter/protocol/http/control/gui
RecordController.java
Removed: src/components/org/apache/jmeter/config Argument.java
Arguments.java LoginConfig.java
src/components/org/apache/jmeter/config/gui
ArgumentsPanel.java LoginConfigGui.java
src/components/org/apache/jmeter/control
GenericController.java LoopController.java
src/components/org/apache/jmeter/control/gui
LogicControllerGui.java LoopControlPanel.java
RecordController.java
src/core/org/apache/jmeter/visualizers AccumListener.java
GraphAccumListener.java GraphListener.java
Log:
Shuffling some files around to achieve section independence.
Revision Changes Path
1.1
jakarta-jmeter/src/components/org/apache/jmeter/visualizers/AccumListener.java
Index: AccumListener.java
===================================================================
package org.apache.jmeter.visualizers;
/**
* @author Administrator
*
* To change this generated comment edit the template variable "typecomment":
* Window>Preferences>Java>Templates.
*/
public interface AccumListener
{
public void updateGui(RunningSample s);
}
1.1
jakarta-jmeter/src/components/org/apache/jmeter/visualizers/GraphAccumListener.java
Index: GraphAccumListener.java
===================================================================
/*
* ====================================================================
* The Apache Software License, Version 1.1
*
* Copyright (c) 2001 The Apache Software Foundation. All rights
* reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
*
* 3. The end-user documentation included with the redistribution,
* if any, must include the following acknowledgment:
* "This product includes software developed by the
* Apache Software Foundation (http://www.apache.org/)."
* Alternately, this acknowledgment may appear in the software itself,
* if and wherever such third-party acknowledgments normally appear.
*
* 4. The names "Apache" and "Apache Software Foundation" and
* "Apache JMeter" must not be used to endorse or promote products
* derived from this software without prior written permission. For
* written permission, please contact [EMAIL PROTECTED]
*
* 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.visualizers;
import org.apache.jmeter.samplers.SampleResult;
/**
* Title: JMeter
* Description:
* Copyright: Copyright (c) 2000
* Company: Apache
* @author Khor Soon Hin
* @created 2001/08/12
* @version 1.0
*/
public interface GraphAccumListener
{
public void updateGui(SampleResult s);
public void updateGui();
}
1.1
jakarta-jmeter/src/components/org/apache/jmeter/visualizers/GraphListener.java
Index: GraphListener.java
===================================================================
/*
* ====================================================================
* The Apache Software License, Version 1.1
*
* Copyright (c) 2001 The Apache Software Foundation. All rights
* reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
*
* 3. The end-user documentation included with the redistribution,
* if any, must include the following acknowledgment:
* "This product includes software developed by the
* Apache Software Foundation (http://www.apache.org/)."
* Alternately, this acknowledgment may appear in the software itself,
* if and wherever such third-party acknowledgments normally appear.
*
* 4. The names "Apache" and "Apache Software Foundation" and
* "Apache JMeter" must not be used to endorse or promote products
* derived from this software without prior written permission. For
* written permission, please contact [EMAIL PROTECTED]
*
* 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.visualizers;
/**
* Title: JMeter
* Description:
* Copyright: Copyright (c) 2000
* Company: Apache
* @author Michael Stover
* @version 1.0
*/
public interface GraphListener
{
public void updateGui(Sample s);
public void updateGui();
}
1.1 jakarta-jmeter/src/core/org/apache/jmeter/config/Argument.java
Index: Argument.java
===================================================================
/*
* ====================================================================
* The Apache Software License, Version 1.1
*
* Copyright (c) 2001 The Apache Software Foundation. All rights
* reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
*
* 3. The end-user documentation included with the redistribution,
* if any, must include the following acknowledgment:
* "This product includes software developed by the
* Apache Software Foundation (http://www.apache.org/)."
* Alternately, this acknowledgment may appear in the software itself,
* if and wherever such third-party acknowledgments normally appear.
*
* 4. The names "Apache" and "Apache Software Foundation" and
* "Apache JMeter" must not be used to endorse or promote products
* derived from this software without prior written permission. For
* written permission, please contact [EMAIL PROTECTED]
*
* 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.config;
import java.io.*;
import org.apache.jmeter.testelement.AbstractTestElement;
import org.apache.jmeter.testelement.TestElement;
//Mark Walsh, 2002-08-03, add metadata attribute
// add constructor Argument(String name, Object value, Object metadata)
// add MetaData get and set methods
/****************************************
* Title: Apache JMeter Description: Copyright: Copyright (c) 2000 Company:
* Apache Foundation
*
*@author Michael Stover
*@created March 13, 2001
*@version 1.0
***************************************/
public class Argument extends AbstractTestElement implements Serializable
{
protected final static String NAME = "Argument.name";
protected final static String VALUE = "Argument.value";
private final static String METADATA = "Argument.metadata";
/****************************************
* Constructor for the Argument object
*
*@param name Description of Parameter
*@param value Description of Parameter
*@param metadata Description of Parameter
***************************************/
public Argument(String name, Object value, Object metadata)
{
setProperty(NAME, name);
setProperty(VALUE, value);
setProperty(METADATA, metadata);
}
/****************************************
* Constructor for the Argument object
*
*@param name Description of Parameter
*@param value Description of Parameter
***************************************/
public Argument(String name, Object value)
{
setProperty(NAME, name);
setProperty(VALUE, value);
}
/****************************************
* Constructor for the Argument object
***************************************/
public Argument() { }
/****************************************
* !ToDo
*
*@param el !ToDo
***************************************/
public void addTestElement(TestElement el) { }
/****************************************
* Sets the Name attribute of the Argument object
*
*@param newName The new Name value
***************************************/
public void setName(String newName)
{
setProperty(NAME, newName);
}
/****************************************
* Sets the Value attribute of the Argument object
*
*@param newValue The new Value value
***************************************/
public void setValue(Object newValue)
{
setProperty(VALUE, newValue);
}
/****************************************
* Sets the Meta Data attribute of the Argument object
*
*@param newMetaData The new Metadata value
***************************************/
public void setMetaData(Object newMetaData)
{
setProperty(METADATA, newMetaData);
}
/****************************************
* Gets the Name attribute of the Argument object
*
*@return The Name value
***************************************/
public String getName()
{
return (String)getProperty(NAME);
}
/****************************************
* Gets the Value attribute of the Argument object
*
*@return The Value value
***************************************/
public Object getValue()
{
return (String)getProperty(VALUE);
}
/****************************************
* Gets the Meta Data attribute of the Argument object
*
*@return The MetaData value
***************************************/
public Object getMetaData()
{
String meta = (String)getProperty(METADATA);
if(meta == null)
{
meta = "=";
}
return meta;
}
}
1.1 jakarta-jmeter/src/core/org/apache/jmeter/config/Arguments.java
Index: Arguments.java
===================================================================
/*
* ====================================================================
* The Apache Software License, Version 1.1
*
* Copyright (c) 2001 The Apache Software Foundation. All rights
* reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
*
* 3. The end-user documentation included with the redistribution,
* if any, must include the following acknowledgment:
* "This product includes software developed by the
* Apache Software Foundation (http://www.apache.org/)."
* Alternately, this acknowledgment may appear in the software itself,
* if and wherever such third-party acknowledgments normally appear.
*
* 4. The names "Apache" and "Apache Software Foundation" and
* "Apache JMeter" must not be used to endorse or promote products
* derived from this software without prior written permission. For
* written permission, please contact [EMAIL PROTECTED]
*
* 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.config;
import java.io.Serializable;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import org.apache.jmeter.util.JMeterUtils;
// Mark Walsh, 2002-08-03 add method addArgument(String name, Object value, Object
metadata)
// modify methods toString(), addEmptyArgument(), addArgument(String name, Object
value)
/****************************************
* Title: Apache JMeter Description: Copyright: Copyright (c) 2000 Company:
* Apache Foundation
*
*@author Michael Stover
*@created $Date: 2002/12/29 15:31:45 $
*@version 1.0
***************************************/
public class Arguments extends ConfigTestElement implements Serializable
{
/****************************************
* !ToDo (Field description)
***************************************/
public static String[] COLUMN_NAMES = {
JMeterUtils.getResString("name"),
JMeterUtils.getResString("value"),
JMeterUtils.getResString("metadata")
};
private final static String ARGUMENTS = "Arguments.arguments";
/****************************************
* !ToDo (Constructor description)
***************************************/
public Arguments()
{
setProperty(ARGUMENTS,new ArrayList());
}
public List getArguments()
{
return (List)getProperty(ARGUMENTS);
}
public void setArguments(List arguments)
{
setProperty(ARGUMENTS,arguments);
}
public Map getArgumentsAsMap()
{
Iterator iter = getArguments().iterator();
Map argMap = new HashMap();
while(iter.hasNext())
{
Argument arg = (Argument)iter.next();
argMap.put(arg.getName(),arg.getValue());
}
return argMap;
}
/****************************************
* !ToDo
*
*@param name !ToDo
*@param value !ToDo
***************************************/
public void addArgument(String name, Object value)
{
getArguments().add(new Argument(name, value, null));
}
public void addArgument(Argument arg)
{
getArguments().add(arg);
}
/****************************************
* !ToDo
*
*@param name !ToDo
*@param value !ToDo
*@param metadata Hold addition information
***************************************/
public void addArgument(String name, Object value, Object metadata)
{
getArguments().add(new Argument(name, value, metadata));
}
/****************************************
* !ToDo (Method description)
*
*@return !ToDo (Return description)
***************************************/
public Iterator iterator()
{
return getArguments().iterator();
}
/****************************************
* !ToDo (Method description)
*
*@return !ToDo (Return description)
***************************************/
public String toString()
{
StringBuffer str = new StringBuffer();
Iterator iter = getArguments().iterator();
while(iter.hasNext())
{
Argument arg = (Argument)iter.next();
if (arg.getMetaData() == null) {
str.append(arg.getName() + "=" + arg.getValue());
} else {
str.append(arg.getName() + arg.getMetaData() +
arg.getValue());
}
if(iter.hasNext())
{
str.append("&");
}
}
return str.toString();
}
/****************************************
* !ToDo (Method description)
*
*@param row !ToDo (Parameter description)
***************************************/
public void removeArgument(int row)
{
if(row < getArguments().size())
{
getArguments().remove(row);
}
}
/****************************************
* !ToDo (Method description)
*
*@param arg !ToDo (Parameter description)
***************************************/
public void removeArgument(Argument arg)
{
getArguments().remove(arg);
}
public void removeArgument(String argName)
{
Iterator iter = getArguments().iterator();
while(iter.hasNext())
{
Argument arg = (Argument)iter.next();
if(arg.getName().equals(argName))
{
iter.remove();
}
}
}
/****************************************
* !ToDo (Method description)
***************************************/
public void removeAllArguments()
{
if(getArguments().size() > 0)
{
getArguments().clear();
}
}
/****************************************
* !ToDo
***************************************/
public void addEmptyArgument()
{
getArguments().add(new Argument("", "",null));
}
/****************************************
* !ToDoo (Method description)
*
*@return !ToDo (Return description)
***************************************/
public int getArgumentCount()
{
return getArguments().size();
}
/****************************************
* !ToDoo (Method description)
*
*@param row !ToDo (Parameter description)
*@return !ToDo (Return description)
***************************************/
public Argument getArgument(int row)
{
Argument argument = null;
if(row < getArguments().size())
{
argument = (Argument)getArguments().get(row);
}
return argument;
}
}
1.1
jakarta-jmeter/src/core/org/apache/jmeter/config/LoginConfig.java
Index: LoginConfig.java
===================================================================
/*
* ====================================================================
* The Apache Software License, Version 1.1
*
* Copyright (c) 2001 The Apache Software Foundation. All rights
* reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
*
* 3. The end-user documentation included with the redistribution,
* if any, must include the following acknowledgment:
* "This product includes software developed by the
* Apache Software Foundation (http://www.apache.org/)."
* Alternately, this acknowledgment may appear in the software itself,
* if and wherever such third-party acknowledgments normally appear.
*
* 4. The names "Apache" and "Apache Software Foundation" and
* "Apache JMeter" must not be used to endorse or promote products
* derived from this software without prior written permission. For
* written permission, please contact [EMAIL PROTECTED]
*
* 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.config;
import java.io.Serializable;
/************************************************************
* Title: JMeter Description: Copyright: Copyright (c) 2000 Company: Apache
*
*@author Michael Stover
*@created March 13, 2001
*@version 1.0
***********************************************************/
public class LoginConfig extends ConfigTestElement implements Serializable
{
/************************************************************
* Constructor for the LoginConfig object
***********************************************************/
public LoginConfig()
{
}
/************************************************************
* Sets the Username attribute of the LoginConfig object
*
*@param username The new Username value
***********************************************************/
public void setUsername(String username)
{
setProperty(ConfigTestElement.USERNAME, username);
}
/************************************************************
* Sets the Password attribute of the LoginConfig object
*
*@param password The new Password value
***********************************************************/
public void setPassword(String password)
{
setProperty(ConfigTestElement.PASSWORD, password);
}
/************************************************************
* Gets the Username attribute of the LoginConfig object
*
*@return The Username value
***********************************************************/
public String getUsername()
{
return (String)this.getProperty(ConfigTestElement.USERNAME);
}
/************************************************************
* Gets the Password attribute of the LoginConfig object
*
*@return The Password value
***********************************************************/
public String getPassword()
{
return (String)this.getProperty(ConfigTestElement.PASSWORD);
}
}
1.1
jakarta-jmeter/src/core/org/apache/jmeter/config/gui/ArgumentsPanel.java
Index: ArgumentsPanel.java
===================================================================
/*
* ====================================================================
* The Apache Software License, Version 1.1
*
* Copyright (c) 2001 The Apache Software Foundation. All rights
* reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
*
* 3. The end-user documentation included with the redistribution,
* if any, must include the following acknowledgment:
* "This product includes software developed by the
* Apache Software Foundation (http://www.apache.org/)."
* Alternately, this acknowledgment may appear in the software itself,
* if and wherever such third-party acknowledgments normally appear.
*
* 4. The names "Apache" and "Apache Software Foundation" and
* "Apache JMeter" must not be used to endorse or promote products
* derived from this software without prior written permission. For
* written permission, please contact [EMAIL PROTECTED]
*
* 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.config.gui;
import java.awt.BorderLayout;
import java.awt.Dimension;
import java.awt.FlowLayout;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.FocusEvent;
import java.awt.event.FocusListener;
import java.util.Collection;
import java.util.Iterator;
import javax.swing.BorderFactory;
import javax.swing.JButton;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JScrollPane;
import javax.swing.JTable;
import javax.swing.ListSelectionModel;
import javax.swing.event.CellEditorListener;
import javax.swing.event.ChangeEvent;
import javax.swing.table.TableCellEditor;
import junit.framework.TestCase;
import org.apache.jmeter.config.Argument;
import org.apache.jmeter.config.Arguments;
import org.apache.jmeter.gui.util.PowerTableModel;
import org.apache.jmeter.gui.util.TextAreaCellRenderer;
import org.apache.jmeter.gui.util.TextAreaTableCellEditor;
import org.apache.jmeter.testelement.TestElement;
import org.apache.jmeter.util.JMeterUtils;
import org.apache.jorphan.collections.Data;
/****************************************
* Title: JMeter Description: Copyright: Copyright (c) 2000 Company: Apache
*
*@author Michael Stover
*@created March 13, 2001
*@version 1.0
***************************************/
public class ArgumentsPanel extends AbstractConfigGui implements FocusListener,
ActionListener,CellEditorListener
{
JTable table;
JButton add;
JButton delete;
protected PowerTableModel tableModel;
String name;
JLabel tableLabel;
private static String ADD = "add";
private static String DELETE = "delete";
/****************************************
* Constructor for the ArgumentsPanel object
***************************************/
public ArgumentsPanel()
{
this(JMeterUtils.getResString("paramtable"));
}
public void editingCanceled(ChangeEvent e)
{
}
public void editingStopped(ChangeEvent e)
{
}
public ArgumentsPanel(String label)
{
tableLabel = new JLabel(label);
init();
}
protected JTable getTable()
{
return table;
}
protected JButton getDeleteButton()
{
return delete;
}
protected JButton getAddButton()
{
return add;
}
/****************************************
* !ToDoo (Method description)
*
*@return !ToDo (Return description)
***************************************/
public Collection getMenuCategories()
{
return null;
}
/****************************************
* !ToDoo (Method description)
*
*@return !ToDo (Return description)
***************************************/
public String getStaticLabel()
{
return "Argument List";
}
/****************************************
* !ToDo (Method description)
*
*@return !ToDo (Return description)
***************************************/
public TestElement createTestElement()
{
Data model = tableModel.getData();
Arguments args = new Arguments();
model.reset();
while(model.next())
{
args.addArgument((String)model.getColumnValue(Arguments.COLUMN_NAMES[0]),
model.getColumnValue(Arguments.COLUMN_NAMES[1]));
}
this.configureTestElement(args);
return (TestElement)args.clone();
}
/****************************************
* !ToDo (Method description)
*
*@param el !ToDo (Parameter description)
***************************************/
public void configure(TestElement el)
{
super.configure(el);
if(el instanceof Arguments)
{
tableModel.clearData();
Iterator iter = ((Arguments)el).getArguments().iterator();
while(iter.hasNext())
{
Argument arg = (Argument)iter.next();
tableModel.addRow(new
Object[]{arg.getName(),arg.getValue()});
}
}
checkDeleteStatus();
}
/****************************************
* Description of the Method
*
*@param e Description of Parameter
***************************************/
public void focusLost(FocusEvent e)
{
}
/****************************************
* Description of the Method
*
*@param e Description of Parameter
***************************************/
public void focusGained(FocusEvent e) { }
/****************************************
* Description of the Method
*
*@param e Description of Parameter
***************************************/
public void actionPerformed(ActionEvent e)
{
String action = e.getActionCommand();
if(action.equals(DELETE))
{
deleteArgument();
}
else if(action.equals(ADD))
{
addArgument();
}
}
protected void deleteArgument() {
// If a table cell is being edited, we must cancel the editing before
// deleting the row
if(table.isEditing())
{
TableCellEditor cellEditor =
table.getCellEditor(table.getEditingRow(), table.getEditingColumn());
cellEditor.cancelCellEditing();
}
int rowSelected = table.getSelectedRow();
if(rowSelected >= 0)
{
tableModel.removeRow(rowSelected);
tableModel.fireTableDataChanged();
// Disable DELETE if there are no rows in the table to delete.
if(tableModel.getRowCount() == 0)
{
delete.setEnabled(false);
}
// Table still contains one or more rows, so highlight (select)
// the appropriate one.
else
{
int rowToSelect = rowSelected;
if(rowSelected >= tableModel.getRowCount())
{
rowToSelect = rowSelected - 1;
}
table.setRowSelectionInterval(rowToSelect,
rowToSelect);
}
}
}
protected void addArgument() {
// If a table cell is being edited, we should accept the current value
// and stop the editing before adding a new row.
if(table.isEditing())
{
TableCellEditor cellEditor =
table.getCellEditor(table.getEditingRow(), table.getEditingColumn());
cellEditor.stopCellEditing();
}
tableModel.addNewRow();
tableModel.fireTableDataChanged();
// Enable DELETE (which may already be enabled, but it won't hurt)
delete.setEnabled(true);
// Highlight (select) the appropriate row.
int rowToSelect = tableModel.getRowCount() - 1;
table.setRowSelectionInterval(rowToSelect, rowToSelect);
}
/****************************************
* !ToDo
***************************************/
public void addInnerPanel()
{
initializeTableModel();
table = new JTable(tableModel);
table.setEnabled(true);
table.addFocusListener(this);
TextAreaTableCellEditor editor = new TextAreaTableCellEditor();
table.setDefaultEditor(String.class,
editor);
editor.addCellEditorListener(this);
TextAreaCellRenderer renderer = new TextAreaCellRenderer();
table.setRowHeight(renderer.getPreferredHeight());
table.setDefaultRenderer(String.class,renderer);
table.setCellSelectionEnabled(true);
table.setRowSelectionAllowed(true);
table.setColumnSelectionAllowed(false);
table.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
JScrollPane scroller = new JScrollPane(table);
Dimension tableDim = scroller.getPreferredSize();
tableDim.height = 70;
scroller.setPreferredSize(tableDim);
scroller.setColumnHeaderView(table.getTableHeader());
add = new JButton(JMeterUtils.getResString("add"));
add.setActionCommand(ADD);
add.setEnabled(true);
delete = new JButton(JMeterUtils.getResString("delete"));
delete.setActionCommand(DELETE);
checkDeleteStatus();
JPanel buttonPanel = new JPanel();
buttonPanel.setBorder(BorderFactory.createEmptyBorder(0, 10, 0, 10));
add.addActionListener(this);
delete.addActionListener(this);
buttonPanel.add(add);
buttonPanel.add(delete);
this.add(scroller,BorderLayout.CENTER);
this.add(buttonPanel,BorderLayout.SOUTH);
}
protected void initializeTableModel() {
tableModel = new PowerTableModel(new
String[]{Arguments.COLUMN_NAMES[0],Arguments.COLUMN_NAMES[1]},
new Class[]{String.class,String.class});
}
protected void checkDeleteStatus() {
// Disable DELETE if there are no rows in the table to delete.
if(tableModel.getRowCount() == 0)
{
delete.setEnabled(false);
}
else
{
delete.setEnabled(true);
}
}
/****************************************
* !ToDo (Method description)
**************************************
public void removeInnerPanel()
{
table.setEnabled(false);
add.setEnabled(false);
delete.setEnabled(false);
tableModel.removeAllRows();
tableModel.fireTableDataChanged();
this.remove(innerPanel);
innerPanel = null;
}*/
private void init()
{
this.setLayout(new BorderLayout(0,0));
this.setBorder(BorderFactory.createEmptyBorder(0, 10, 0, 10));
JPanel labelPanel = new JPanel(new FlowLayout(FlowLayout.CENTER));
labelPanel.add(tableLabel);
this.add(labelPanel,BorderLayout.NORTH);
this.addInnerPanel();
}
public static class Test extends TestCase {
public Test(String name)
{
super(name);
}
public void testArgumentCreation() throws Exception
{
ArgumentsPanel gui = new ArgumentsPanel();
gui.tableModel.addNewRow();
gui.tableModel.setValueAt("howdy",0,0);
gui.tableModel.setValueAt("doody",0,1);
assertEquals("=",((Argument)((Arguments)gui.createTestElement()).getArguments().get(0)).getMetaData());
}
}
}
1.1
jakarta-jmeter/src/core/org/apache/jmeter/config/gui/LoginConfigGui.java
Index: LoginConfigGui.java
===================================================================
/*
* ====================================================================
* The Apache Software License, Version 1.1
*
* Copyright (c) 2001 The Apache Software Foundation. All rights
* reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
*
* 3. The end-user documentation included with the redistribution,
* if any, must include the following acknowledgment:
* "This product includes software developed by the
* Apache Software Foundation (http://www.apache.org/)."
* Alternately, this acknowledgment may appear in the software itself,
* if and wherever such third-party acknowledgments normally appear.
*
* 4. The names "Apache" and "Apache Software Foundation" and
* "Apache JMeter" must not be used to endorse or promote products
* derived from this software without prior written permission. For
* written permission, please contact [EMAIL PROTECTED]
*
* 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.config.gui;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JPasswordField;
import javax.swing.JTextField;
import org.apache.jmeter.config.ConfigTestElement;
import org.apache.jmeter.testelement.TestElement;
import org.apache.jmeter.util.JMeterUtils;
import org.apache.jorphan.gui.layout.VerticalLayout;
/****************************************
* Title: JMeter Description: Copyright: Copyright (c) 2000 Company: Apache
*
*@author Michael Stover
*@created March 13, 2001
*@version 1.0
***************************************/
public class LoginConfigGui extends AbstractConfigGui
{
JTextField username = new JTextField(15);
JTextField password = new JPasswordField(15);
private boolean displayName = true;
/****************************************
* Constructor for the LoginConfigGui object
***************************************/
public LoginConfigGui()
{
this(true);
}
/****************************************
* Constructor for the LoginConfigGui object
*
*@param displayName Description of Parameter
***************************************/
public LoginConfigGui(boolean displayName)
{
this.displayName = displayName;
init();
}
public String getStaticLabel()
{
return JMeterUtils.getResString("Login Config Element");
}
public void configure(TestElement element)
{
super.configure(element);
username.setText((String)element.getProperty(ConfigTestElement.USERNAME));
password.setText((String)element.getProperty(ConfigTestElement.PASSWORD));
}
public TestElement createTestElement()
{
ConfigTestElement element = new ConfigTestElement();
configureTestElement(element);
element.setProperty(ConfigTestElement.USERNAME,username.getText());
element.setProperty(ConfigTestElement.PASSWORD,password.getText());
return element;
}
private void init()
{
this.setLayout(new VerticalLayout(1, VerticalLayout.LEFT));
if(displayName)
{
this.add(getNamePanel());
}
this.add(createUsernamePanel());
this.add(createPasswordPanel());
}
private JPanel createUsernamePanel()
{
JPanel panel = new JPanel();
panel.add(new JLabel(JMeterUtils.getResString("username")));
panel.add(username);
return panel;
}
private JPanel createPasswordPanel()
{
JPanel panel = new JPanel();
panel.add(new JLabel(JMeterUtils.getResString("password")));
panel.add(password);
return panel;
}
}
1.1
jakarta-jmeter/src/core/org/apache/jmeter/control/GenericController.java
Index: GenericController.java
===================================================================
/*
* ====================================================================
* The Apache Software License, Version 1.1
*
* Copyright (c) 2001 The Apache Software Foundation. All rights
* reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
*
* 3. The end-user documentation included with the redistribution,
* if any, must include the following acknowledgment:
* "This product includes software developed by the
* Apache Software Foundation (http://www.apache.org/)."
* Alternately, this acknowledgment may appear in the software itself,
* if and wherever such third-party acknowledgments normally appear.
*
* 4. The names "Apache" and "Apache Software Foundation" and
* "Apache JMeter" must not be used to endorse or promote products
* derived from this software without prior written permission. For
* written permission, please contact [EMAIL PROTECTED]
*
* 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.control;
import java.io.*;
import java.util.*;
import org.apache.jmeter.assertions.Assertion;
import org.apache.jmeter.config.ConfigElement;
import org.apache.jmeter.gui.*;
import org.apache.jmeter.gui.util.MenuFactory;
import org.apache.jmeter.samplers.*;
import org.apache.jmeter.samplers.SampleResult;
import org.apache.jmeter.testelement.AbstractTestElement;
import org.apache.jmeter.testelement.TestElement;
import org.apache.jmeter.testelement.PerThreadClonable;
/****************************************
* Title: JMeter Description: Copyright: Copyright (c) 2000 Company: Apache
*
*@author Michael Stover
*@created $Date: 2002/12/29 15:31:45 $
*@version 1.0
***************************************/
public class GenericController extends AbstractTestElement implements Controller,
Serializable,PerThreadClonable
{
/****************************************
* !ToDo (Field description)
***************************************/
protected List subControllersAndSamplers = new ArrayList();
/****************************************
* !ToDo (Field description)
***************************************/
protected int current;
/****************************************
* !ToDo (Field description)
***************************************/
protected Iterator controlIt;
private List configs = new LinkedList();
private boolean returnedNull = false;
private boolean done = false, timeForNext = false;
private List assertions = new LinkedList();
/****************************************
* !ToDo (Constructor description)
***************************************/
public GenericController()
{
}
public boolean isNextFirst()
{
if(current == 0)
{
return true;
}
return false;
}
/****************************************
* Gets the ConfigElements attribute of the GenericController object
*
*@return The ConfigElements value
***************************************/
protected List getConfigElements()
{
return configs;
}
private void addConfigElement(TestElement el)
{
configs.add(el);
}
public void initialize()
{
resetCurrent();
}
public void reInitialize()
{
resetCurrent();
}
protected void removeCurrentController()
{
subControllersAndSamplers.remove(current);
}
protected void resetCurrent()
{
current = 0;
}
protected void incrementCurrent()
{
current++;
}
/**
* Answers the question: when the end of subcontrollers and samplers is
reached,
* how does this Controller answert the question: hasNext()? For most
controllers,
* the answer is to return false. For some, it depends. The LoopController,
for
* instance will repeat the list of subcontrollers a given number of times
* before signalling false to 'hasNext()'.
*/
protected boolean hasNextAtEnd()
{
return false;
}
protected void nextAtEnd()
{
resetCurrent();
}
public boolean hasNext()
{
boolean retVal;
Object controller = getCurrentController();
if(controller == null)
{
retVal = hasNextAtEnd();
}
else if(controller instanceof Controller)
{
if(((Controller)controller).hasNext())
{
retVal = true;
}
else
{
currentHasNextIsFalse();
retVal = hasNext();
}
}
else
{
retVal = true;
}
if(!retVal)
{
reInitialize();
}
return retVal;
}
protected void currentHasNextIsFalse()
{
if(((Controller)getCurrentController()).isDone())
{
removeCurrentController();
}
else
{
incrementCurrent();
}
}
protected boolean shortCircuitIsDone()
{
return done;
}
protected void setShortCircuit(boolean done)
{
this.done = done;
}
public boolean isDone()
{
if(shortCircuitIsDone())
{
return true;
}
boolean isdone = true;
Iterator iter = subControllersAndSamplers.iterator();
while (iter.hasNext())
{
Object item = iter.next();
if(item instanceof Sampler)
{
return false;
}
else
{
isdone = isdone && ((Controller)item).isDone();
}
}
setShortCircuit(isdone);
return isdone;
}
protected TestElement getCurrentController()
{
if(current < subControllersAndSamplers.size())
{
return (TestElement)subControllersAndSamplers.get(current);
}
else return null;
}
/****************************************
* Gets the SubControllers attribute of the GenericController object
*
*@return The SubControllers value
***************************************/
protected List getSubControllers()
{
return subControllersAndSamplers;
}
/****************************************
* !ToDo
*
*@param child !ToDo
***************************************/
public void addTestElement(TestElement child)
{
if(child instanceof Controller || child instanceof Sampler)
{
addController(child);
}
}
private void addController(TestElement child)
{
subControllersAndSamplers.add(child);
}
/****************************************
* Retrieves the next Entry to be sampled.
*
*@return !ToDo (Return description)
***************************************/
public Sampler next()
{
TestElement controller = getCurrentController();
if(controller == null)
{
nextAtEnd();
return next();
}
if(controller instanceof Sampler)
{
incrementCurrent();
return (Sampler)controller;
}
else
{
Controller c = (Controller)controller;
if(c.hasNext())
{
Sampler s = c.next();
return s;
}
else if(c.isDone())
{
removeCurrentController();
return next();
}
else
{
incrementCurrent();
return next();
}
}
}
public static class Test extends junit.framework.TestCase
{
public Test(String name)
{
super(name);
}
public void testProcessing() throws Exception
{
GenericController controller = new GenericController();
GenericController sub_1 = new GenericController();
sub_1.addTestElement(makeSampler("one"));
sub_1.addTestElement(makeSampler("two"));
controller.addTestElement(sub_1);
controller.addTestElement(makeSampler("three"));
GenericController sub_2 = new GenericController();
GenericController sub_3 = new GenericController();
sub_2.addTestElement(makeSampler("four"));
sub_3.addTestElement(makeSampler("five"));
sub_3.addTestElement(makeSampler("six"));
sub_2.addTestElement(sub_3);
sub_2.addTestElement(makeSampler("seven"));
controller.addTestElement(sub_2);
String[] order = new
String[]{"one","two","three","four","five","six","seven"};
int counter = 7;
for (int i = 0; i < 2; i++)
{
assertEquals(7,counter);
counter = 0;
while(controller.hasNext())
{
TestElement sampler = controller.next();
assertEquals(order[counter++],sampler.getProperty(TestElement.NAME));
}
}
}
private TestElement makeSampler(String name)
{
TestSampler s = new TestSampler();
s.setName(name);
return s;
}
class TestSampler extends AbstractSampler {
public void addCustomTestElement(TestElement t) { }
public org.apache.jmeter.samplers.SampleResult
sample(org.apache.jmeter.samplers.Entry e) { return null; }
}
}
}
1.1
jakarta-jmeter/src/core/org/apache/jmeter/control/LoopController.java
Index: LoopController.java
===================================================================
/*
* ====================================================================
* The Apache Software License, Version 1.1
*
* Copyright (c) 2001 The Apache Software Foundation. All rights
* reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
*
* 3. The end-user documentation included with the redistribution,
* if any, must include the following acknowledgment:
* "This product includes software developed by the
* Apache Software Foundation (http://www.apache.org/)."
* Alternately, this acknowledgment may appear in the software itself,
* if and wherever such third-party acknowledgments normally appear.
*
* 4. The names "Apache" and "Apache Software Foundation" and
* "Apache JMeter" must not be used to endorse or promote products
* derived from this software without prior written permission. For
* written permission, please contact [EMAIL PROTECTED]
*
* 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.control;
import java.io.Serializable;
import org.apache.jmeter.util.JMeterUtils;
import org.apache.jmeter.testelement.TestElement;
import org.apache.jmeter.samplers.AbstractSampler;
/****************************************
* Title: JMeter Description: Copyright: Copyright (c) 2000 Company: Apache
*
*@author Michael Stover
*@created $Date: 2002/12/29 15:31:45 $
*@version 1.0
***************************************/
public class LoopController extends GenericController implements Serializable
{
private final static String LOOPS = "LoopController.loops";
private final static String CONTINUE_FOREVER =
"LoopController.continue_forever";
private int loopCount = 0;
/****************************************
* !ToDo (Constructor description)
***************************************/
public LoopController()
{
setContinueForever(true);
}
/****************************************
* !ToDo (Method description)
*
*@param loops !ToDo (Parameter description)
***************************************/
public void setLoops(int loops)
{
setProperty(LOOPS,new Integer(loops));
}
/****************************************
* !ToDoo (Method description)
*
*@return !ToDo (Return description)
***************************************/
public int getLoops()
{
return getPropertyAsInt(LOOPS);
}
/****************************************
* !ToDo (Method description)
*
*@param forever !ToDo (Parameter description)
***************************************/
public void setContinueForever(boolean forever)
{
setProperty(CONTINUE_FOREVER,new Boolean(forever));
}
/****************************************
* !ToDoo (Method description)
*
*@return !ToDo (Return description)
***************************************/
public boolean getContinueForever()
{
return getPropertyAsBoolean(CONTINUE_FOREVER);
}
public void initialize()
{
super.initialize();
resetLoopCount();
}
public void reInitialize()
{
super.reInitialize();
resetLoopCount();
}
protected void incrementLoopCount()
{
loopCount++;
}
protected void resetLoopCount()
{
if(!getContinueForever() && getLoops() > -1)
{
this.setShortCircuit(true);
}
else
{
loopCount = 0;
}
}
protected boolean hasNextAtEnd()
{
resetCurrent();
incrementLoopCount();
if(endOfLoop())
{
return false;
}
else
{
return hasNext();
}
}
protected void nextAtEnd()
{
resetCurrent();
incrementLoopCount();
}
private boolean endOfLoop()
{
return (!getContinueForever() || getLoops() > -1) && loopCount >=
getLoops();
}
public static class Test extends junit.framework.TestCase
{
public Test(String name)
{
super(name);
}
public void testProcessing() throws Exception
{
GenericController controller = new GenericController();
GenericController sub_1 = new GenericController();
sub_1.addTestElement(makeSampler("one"));
sub_1.addTestElement(makeSampler("two"));
controller.addTestElement(sub_1);
controller.addTestElement(makeSampler("three"));
LoopController sub_2 = new LoopController();
sub_2.setLoops(3);
GenericController sub_3 = new GenericController();
sub_2.addTestElement(makeSampler("four"));
sub_3.addTestElement(makeSampler("five"));
sub_3.addTestElement(makeSampler("six"));
sub_2.addTestElement(sub_3);
sub_2.addTestElement(makeSampler("seven"));
controller.addTestElement(sub_2);
String[] order = new
String[]{"one","two","three","four","five","six","seven",
"four","five","six","seven","four","five","six","seven"};
int counter = 15;
for (int i = 0; i < 2; i++)
{
assertEquals(15,counter);
counter = 0;
while(controller.hasNext())
{
TestElement sampler = controller.next();
assertEquals(order[counter++],sampler.getProperty(TestElement.NAME));
}
}
}
private TestElement makeSampler(String name)
{
TestSampler s= new TestSampler();
s.setName(name);
return s;
}
class TestSampler extends AbstractSampler {
public void addCustomTestElement(TestElement t) { }
public org.apache.jmeter.samplers.SampleResult
sample(org.apache.jmeter.samplers.Entry e) { return null; }
}
}
}
1.1
jakarta-jmeter/src/core/org/apache/jmeter/control/gui/LogicControllerGui.java
Index: LogicControllerGui.java
===================================================================
/*
* ====================================================================
* The Apache Software License, Version 1.1
*
* Copyright (c) 2001 The Apache Software Foundation. All rights
* reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
*
* 3. The end-user documentation included with the redistribution,
* if any, must include the following acknowledgment:
* "This product includes software developed by the
* Apache Software Foundation (http://www.apache.org/)."
* Alternately, this acknowledgment may appear in the software itself,
* if and wherever such third-party acknowledgments normally appear.
*
* 4. The names "Apache" and "Apache Software Foundation" and
* "Apache JMeter" must not be used to endorse or promote products
* derived from this software without prior written permission. For
* written permission, please contact [EMAIL PROTECTED]
*
* 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.control.gui;
import java.awt.Font;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.border.Border;
import javax.swing.border.EmptyBorder;
import org.apache.jmeter.control.GenericController;
import org.apache.jmeter.gui.NamePanel;
import org.apache.jmeter.testelement.TestElement;
import org.apache.jmeter.util.JMeterUtils;
import org.apache.jorphan.gui.layout.VerticalLayout;
/****************************************
* Title: JMeter Description: Copyright: Copyright (c) 2000 Company: Apache
*
*@author Kevin Hammond
*@created $Date: 2002/12/29 15:31:45 $
*@version 1.0
***************************************/
public class LogicControllerGui extends AbstractControllerGui
{
/****************************************
* !ToDo (Constructor description)
***************************************/
public LogicControllerGui()
{
init();
setName(getStaticLabel());
}
/****************************************
* !ToDo (Method description)
*
*@param name !ToDo (Parameter description)
***************************************/
public void setName(String name)
{
namePanel.setName(name);
}
/****************************************
* !ToDoo (Method description)
*
*@return !ToDo (Return description)
***************************************/
public String getName()
{
return namePanel.getName();
}
/****************************************
* !ToDo (Method description)
*
*@return !ToDo (Return description)
***************************************/
public TestElement createTestElement()
{
GenericController lc = new GenericController();
configureTestElement(lc);
return lc;
}
/****************************************
* !ToDoo (Method description)
*
*@return !ToDo (Return description)
***************************************/
public String getStaticLabel()
{
return JMeterUtils.getResString("logic_controller_title");
}
/****************************************
* !ToDo (Method description)
***************************************/
public void updateGui() { }
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("logic_controller_title"));
Font curFont = panelTitleLabel.getFont();
int curFontSize = curFont.getSize();
curFontSize += 4;
panelTitleLabel.setFont(new Font(curFont.getFontName(),
curFont.getStyle(), curFontSize));
mainPanel.add(panelTitleLabel);
// NAME
namePanel = new NamePanel();
mainPanel.add(namePanel);
this.add(mainPanel);
}
}
1.1
jakarta-jmeter/src/core/org/apache/jmeter/control/gui/LoopControlPanel.java
Index: LoopControlPanel.java
===================================================================
package org.apache.jmeter.control.gui;
import java.awt.Font;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.KeyEvent;
import java.awt.event.KeyListener;
import javax.swing.JCheckBox;
import javax.swing.JLabel;
import javax.swing.JOptionPane;
import javax.swing.JPanel;
import javax.swing.JTextField;
import javax.swing.border.Border;
import javax.swing.border.EmptyBorder;
import org.apache.jmeter.control.LoopController;
import org.apache.jmeter.gui.util.FocusRequester;
import org.apache.jmeter.testelement.TestElement;
import org.apache.jmeter.util.JMeterUtils;
import org.apache.jorphan.gui.layout.VerticalLayout;
/****************************************
* Title: JMeter Description: Copyright: Copyright (c) 2000 Company: Apache
*
*@author Michael Stover
*@created $Date: 2002/12/29 15:31:45 $
*@version 1.0
***************************************/
public class LoopControlPanel extends AbstractControllerGui implements KeyListener,
ActionListener
{
JCheckBox infinite;
JTextField loops;
private boolean displayName = true;
private static String INFINITE = "Infinite Field";
private static String LOOPS = "Loops Field";
/****************************************
* !ToDo (Constructor description)
***************************************/
public LoopControlPanel()
{
this(true);
}
/****************************************
* !ToDo (Constructor description)
*
*@param displayName !ToDo (Parameter description)
***************************************/
public LoopControlPanel(boolean displayName)
{
this.displayName = displayName;
init();
setState(1);
}
/****************************************
* !ToDo (Method description)
*
*@param element !ToDo (Parameter description)
***************************************/
public void configure(TestElement element)
{
setName((String)element.getProperty(TestElement.NAME));
if(element instanceof LoopController)
{
setState(((LoopController)element).getLoops());
}
else
{
setState(1);
}
}
/****************************************
* !ToDo (Method description)
*
*@return !ToDo (Return description)
***************************************/
public TestElement createTestElement()
{
LoopController lc = new LoopController();
configureTestElement(lc);
if(loops.getText().length() > 0)
{
lc.setLoops(Integer.parseInt(loops.getText()));
}
else
{
lc.setLoops(-1);
}
return lc;
}
/****************************************
* !ToDo (Method description)
*
*@param event !ToDo (Parameter description)
***************************************/
public void actionPerformed(ActionEvent event)
{
if(infinite.isSelected())
{
loops.setText("");
loops.setEnabled(false);
}
else
{
loops.setEnabled(true);
new FocusRequester(loops);
}
}
/****************************************
* Description of the Method
*
*@param e Description of Parameter
***************************************/
public void keyPressed(KeyEvent e) { }
/****************************************
* Description of the Method
*
*@param e Description of Parameter
***************************************/
public void keyTyped(KeyEvent e) { }
/****************************************
* Description of the Method
*
*@param e Description of Parameter
***************************************/
public void keyReleased(KeyEvent e)
{
String temp = e.getComponent().getName();
if(temp.equals(LOOPS))
{
try
{
Integer.parseInt(loops.getText());
}
catch(NumberFormatException ex)
{
if(loops.getText().length() > 0)
{
// We need a standard warning/error dialog.
The problem with
// having it here is that the dialog is
centered over this
// LoopControlPanel instead of begin centered
in the entire
// JMeter GUI window.
JOptionPane.showMessageDialog(this, "You must
enter a valid number",
"Invalid data",
JOptionPane.WARNING_MESSAGE);
loops.setText("");
}
}
}
}
/****************************************
* !ToDoo (Method description)
*
*@return !ToDo (Return description)
***************************************/
public String getStaticLabel()
{
return JMeterUtils.getResString("loop_controller_title");
}
private void init()
{
// The Loop Controller panel can be displayed standalone or inside
another panel.
// For standalone, we want to display the TITLE, NAME, etc.
(everything). However,
// if we want to display it within another panel, we just display the
Loop Count
// fields (not the TITLE and NAME).
// Standalone
if(displayName)
{
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("loop_controller_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());
// LOOP
mainPanel.add(createLoopCountPanel());
this.add(mainPanel);
}
// Embedded
else
{
this.add(createLoopCountPanel());
}
}
private JPanel createLoopCountPanel()
{
JPanel loopPanel = new JPanel();
// LOOP LABEL
JLabel loopsLabel = new
JLabel(JMeterUtils.getResString("iterator_num"));
loopPanel.add(loopsLabel);
// TEXT FIELD
loops = new JTextField(5);
loopPanel.add(loops);
loops.setName(LOOPS);
loops.addKeyListener(this);
loops.setText("1");
// FOREVER CHECKBOX
infinite = new JCheckBox(JMeterUtils.getResString("infinite"));
infinite.setActionCommand(INFINITE);
infinite.addActionListener(this);
loopPanel.add(infinite);
return loopPanel;
}
private void setState(int loopCount)
{
if(loopCount <= -1)
{
infinite.setSelected(true);
loops.setEnabled(false);
loops.setText("");
}
else
{
infinite.setSelected(false);
loops.setEnabled(true);
loops.setText("" + loopCount);
}
}
}
1.1
jakarta-jmeter/src/protocol/http/org/apache/jmeter/protocol/http/control/gui/RecordController.java
Index: RecordController.java
===================================================================
package org.apache.jmeter.control.gui;
import org.apache.jmeter.util.JMeterUtils;
/**
* @author Administrator
*
* To change this generated comment edit the template variable "typecomment":
* Window>Preferences>Java>Templates.
*/
public class RecordController extends LogicControllerGui
{
public String getStaticLabel()
{
return JMeterUtils.getResString("record_controller_title");
}
}
--
To unsubscribe, e-mail: <mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>