mstover1 2002/08/25 12:42:21
Modified: bin jmeter.bat
src/core/org/apache/jmeter/engine StandardJMeterEngine.java
src/core/org/apache/jmeter/gui/action EditCommand.java
Load.java Remove.java
src/core/org/apache/jmeter/gui/tree JMeterTreeListener.java
src/core/org/apache/jmeter/gui/util JMeterMenuBar.java
MenuFactory.java
src/core/org/apache/jmeter/resources messages.properties
messages_de.properties messages_ja.properties
messages_no.properties
src/core/org/apache/jmeter/threads ListenerNotifier.java
src/core/org/apache/jmeter/util JMeterUtils.java
LoggingManager.java
src/protocol/http/org/apache/jmeter/protocol/http/proxy
HttpRequestHdr.java
src/protocol/http/org/apache/jmeter/protocol/http/sampler
HTTPSampler.java
Added: src/core/org/apache/jmeter/gui/action ChangeLanguage.java
Log:
Can select language from menu
HTTPSampler calls urlconn.disconnect on all connections
Revision Changes Path
1.22 +1 -1 jakarta-jmeter/bin/jmeter.bat
Index: jmeter.bat
===================================================================
RCS file: /home/cvs/jakarta-jmeter/bin/jmeter.bat,v
retrieving revision 1.21
retrieving revision 1.22
diff -u -r1.21 -r1.22
--- jmeter.bat 5 Jun 2002 03:29:06 -0000 1.21
+++ jmeter.bat 25 Aug 2002 19:42:20 -0000 1.22
@@ -30,4 +30,4 @@
rem This label provides a place for the argument list loop to break out
rem and for NT handling to skip to.
-java -Xincgc -jar ApacheJMeter.jar %JMETER_CMD_LINE_ARGS%
+java -Xincgc -jar ApacheJMeter.jar %JMETER_CMD_LINE_ARGS%
\ No newline at end of file
1.7 +3 -2
jakarta-jmeter/src/core/org/apache/jmeter/engine/StandardJMeterEngine.java
Index: StandardJMeterEngine.java
===================================================================
RCS file:
/home/cvs/jakarta-jmeter/src/core/org/apache/jmeter/engine/StandardJMeterEngine.java,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -r1.6 -r1.7
--- StandardJMeterEngine.java 24 Aug 2002 16:51:13 -0000 1.6
+++ StandardJMeterEngine.java 25 Aug 2002 19:42:20 -0000 1.7
@@ -242,6 +242,7 @@
catch (InterruptedException e)
{
}
+ log.debug("Waiting for notifier thread to stop");
}
while(iter.hasNext())
{
1.2 +2 -2
jakarta-jmeter/src/core/org/apache/jmeter/gui/action/EditCommand.java
Index: EditCommand.java
===================================================================
RCS file:
/home/cvs/jakarta-jmeter/src/core/org/apache/jmeter/gui/action/EditCommand.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- EditCommand.java 11 Aug 2002 19:24:44 -0000 1.1
+++ EditCommand.java 25 Aug 2002 19:42:20 -0000 1.2
@@ -18,7 +18,7 @@
private static Set commands = new HashSet();
static
{
- commands.add(JMeterUtils.getResString("edit"));
+ commands.add("edit");
}
/****************************************
1.3 +4 -4 jakarta-jmeter/src/core/org/apache/jmeter/gui/action/Load.java
Index: Load.java
===================================================================
RCS file: /home/cvs/jakarta-jmeter/src/core/org/apache/jmeter/gui/action/Load.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- Load.java 23 Aug 2002 22:51:44 -0000 1.2
+++ Load.java 25 Aug 2002 19:42:20 -0000 1.3
@@ -100,7 +100,7 @@
static
{
- commands.add(JMeterUtils.getResString("open"));
+ commands.add("open");
}
/****************************************
1.2 +1 -1 jakarta-jmeter/src/core/org/apache/jmeter/gui/action/Remove.java
Index: Remove.java
===================================================================
RCS file:
/home/cvs/jakarta-jmeter/src/core/org/apache/jmeter/gui/action/Remove.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- Remove.java 11 Aug 2002 19:24:44 -0000 1.1
+++ Remove.java 25 Aug 2002 19:42:20 -0000 1.2
@@ -113,6 +113,6 @@
}
static
{
- commands.add(JMeterUtils.getResString("remove"));
+ commands.add("remove");
}
}
1.1
jakarta-jmeter/src/core/org/apache/jmeter/gui/action/ChangeLanguage.java
Index: ChangeLanguage.java
===================================================================
package org.apache.jmeter.gui.action;
import java.awt.Component;
import java.awt.event.ActionEvent;
import java.util.HashSet;
import java.util.Locale;
import java.util.Set;
import org.apache.jmeter.util.JMeterUtils;
import org.apache.jmeter.util.LoggingManager;
import org.apache.log.Hierarchy;
import org.apache.log.Logger;
/**
* @author Administrator
*
* To change this generated comment edit the template variable "typecomment":
* Window>Preferences>Java>Templates.
*/
public class ChangeLanguage implements Command
{
private static final Set commands = new HashSet();
public final static String CHANGE_LANGUAGE = "change_language";
private Logger log =
Hierarchy.getDefaultHierarchy().getLoggerFor(LoggingManager.GUI);
static
{
commands.add(CHANGE_LANGUAGE);
}
/**
* @see org.apache.jmeter.gui.action.Command#doAction(ActionEvent)
*/
public void doAction(ActionEvent e)
{
Locale loc = new Locale(((Component)e.getSource()).getName());
log.debug("Changing language to "+loc.getLanguage());
JMeterUtils.reinitializeLocale(loc);
}
/**
* @see org.apache.jmeter.gui.action.Command#getActionNames()
*/
public Set getActionNames()
{
return commands;
}
}
1.3 +1 -1
jakarta-jmeter/src/core/org/apache/jmeter/gui/tree/JMeterTreeListener.java
Index: JMeterTreeListener.java
===================================================================
RCS file:
/home/cvs/jakarta-jmeter/src/core/org/apache/jmeter/gui/tree/JMeterTreeListener.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- JMeterTreeListener.java 23 Aug 2002 22:51:44 -0000 1.2
+++ JMeterTreeListener.java 25 Aug 2002 19:42:20 -0000 1.3
@@ -231,7 +231,7 @@
public void valueChanged(TreeSelectionEvent e)
{
currentPath = e.getNewLeadSelectionPath();
- actionHandler.actionPerformed(new ActionEvent(this, 3333,
JMeterUtils.getResString("edit")));
+ actionHandler.actionPerformed(new ActionEvent(this, 3333, "edit"));
}
1.3 +165 -139
jakarta-jmeter/src/core/org/apache/jmeter/gui/util/JMeterMenuBar.java
Index: JMeterMenuBar.java
===================================================================
RCS file:
/home/cvs/jakarta-jmeter/src/core/org/apache/jmeter/gui/util/JMeterMenuBar.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- JMeterMenuBar.java 23 Aug 2002 22:51:44 -0000 1.2
+++ JMeterMenuBar.java 25 Aug 2002 19:42:20 -0000 1.3
@@ -51,7 +51,8 @@
* 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.gui.util;
+ */
+package org.apache.jmeter.gui.util;
import java.awt.Component;
import java.awt.event.KeyEvent;
import java.util.Collection;
@@ -66,11 +67,11 @@
import javax.swing.UIManager;
import org.apache.jmeter.gui.action.ActionRouter;
+import org.apache.jmeter.gui.action.ChangeLanguage;
import org.apache.jmeter.util.JMeterUtils;
import org.apache.jmeter.util.SSLManager;
import org.apache.log.Hierarchy;
import org.apache.log.Logger;
-
/****************************************
* Title: Apache JMeter Description: Copyright: Copyright (c) 2000 Company:
* Apache Foundation
@@ -79,11 +80,10 @@
*@created $Date$
*@version 1.0
***************************************/
-
public class JMeterMenuBar extends JMenuBar
{
- private static Logger log = Hierarchy.getDefaultHierarchy().getLoggerFor(
- "jmeter.gui");
+ private static Logger log =
+ Hierarchy.getDefaultHierarchy().getLoggerFor("jmeter.gui");
JMenu fileMenu;
JMenuItem file_save_all;
JMenuItem file_load;
@@ -109,9 +109,7 @@
JMenuItem sslManager;
JMenu helpMenu;
JMenuItem help_about;
-
String[] remoteHosts;
-
/****************************************
* !ToDo (Constructor description)
***************************************/
@@ -119,17 +117,15 @@
{
remote_engine_start = new LinkedList();
remote_engine_stop = new LinkedList();
- remoteHosts = JMeterUtils.split(
- JMeterUtils.getPropDefault("remote_hosts", ""), ",");
- if(remoteHosts.length == 1 && remoteHosts[0].equals(""))
+ remoteHosts =
+ JMeterUtils.split(JMeterUtils.getPropDefault("remote_hosts",
""), ",");
+ if (remoteHosts.length == 1 && remoteHosts[0].equals(""))
{
remoteHosts = new String[0];
}
this.getRemoteItems();
-
createMenuBar();
}
-
/****************************************
* !ToDo (Method description)
*
@@ -139,7 +135,6 @@
{
file_save_all.setEnabled(enabled);
}
-
/****************************************
* !ToDo (Method description)
*
@@ -147,12 +142,11 @@
***************************************/
public void setFileLoadEnabled(boolean enabled)
{
- if(file_load != null)
+ if (file_load != null)
{
file_load.setEnabled(enabled);
}
}
-
/****************************************
* !ToDo (Method description)
*
@@ -160,12 +154,11 @@
***************************************/
public void setEditEnabled(boolean enabled)
{
- if(editMenu != null)
+ if (editMenu != null)
{
editMenu.setEnabled(enabled);
}
}
-
/****************************************
* !ToDo (Method description)
*
@@ -174,23 +167,21 @@
public void setEditAddMenu(JMenu menu)
{
// If the Add menu already exists, remove it.
- if(edit_add != null)
+ if (edit_add != null)
{
editMenu.remove(edit_add);
}
-
// Insert the Add menu as the first menu item in the Edit menu.
edit_add = menu;
editMenu.insert(edit_add, 0);
}
-
public void setEditMenu(JPopupMenu menu)
{
- if(menu != null)
+ if (menu != null)
{
editMenu.removeAll();
Component[] comps = menu.getComponents();
- for(int i = 0;i < comps.length;i++)
+ for (int i = 0; i < comps.length; i++)
{
editMenu.add(comps[i]);
}
@@ -201,7 +192,6 @@
editMenu.setEnabled(false);
}
}
-
/****************************************
* !ToDo (Method description)
*
@@ -210,15 +200,14 @@
public void setEditAddEnabled(boolean enabled)
{
// There was a NPE being thrown without the null check here.. JKB
- if(edit_add != null)
+ if (edit_add != null)
{
edit_add.setEnabled(enabled);
}
-
// If we are enabling the Edit-->Add menu item, then we also need to
// enable the Edit menu. The Edit menu may already be enabled, but
// there's no harm it trying to enable it again.
- if(enabled)
+ if (enabled)
{
setEditEnabled(true);
}
@@ -228,13 +217,12 @@
// menu item is disabled, then we also need to disable the
Edit menu.
// The Java Look and Feel Guidelines say to disable a menu if
all
// menu items are disabled.
- if(!edit_remove.isEnabled())
+ if (!edit_remove.isEnabled())
{
editMenu.setEnabled(false);
}
}
}
-
/****************************************
* !ToDo (Method description)
*
@@ -243,11 +231,10 @@
public void setEditRemoveEnabled(boolean enabled)
{
edit_remove.setEnabled(enabled);
-
// If we are enabling the Edit-->Remove menu item, then we also need to
// enable the Edit menu. The Edit menu may already be enabled, but
// there's no harm it trying to enable it again.
- if(enabled)
+ if (enabled)
{
setEditEnabled(true);
}
@@ -257,70 +244,118 @@
// menu item is disabled, then we also need to disable the
Edit menu.
// The Java Look and Feel Guidelines say to disable a menu if
all
// menu items are disabled.
- if(!edit_add.isEnabled())
+ if (!edit_add.isEnabled())
{
editMenu.setEnabled(false);
}
}
}
-
/****************************************
* Creates the MenuBar for this application. I believe in my heart that this
* should be defined in a file somewhere, but that is for later.
***************************************/
public void createMenuBar()
{
- // FILE MENU
- fileMenu = new JMenu(JMeterUtils.getResString("file"));
- fileMenu.setMnemonic('F');
-
- file_save_all = new JMenuItem(JMeterUtils.getResString("save_all"),
'A');
- file_save_all.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_A,
KeyEvent.CTRL_MASK));
- file_save_all.setActionCommand("save_all");
- file_save_all.addActionListener(ActionRouter.getInstance());
- // Currently, SAVE ALL is not implemented. It actually generates
- // a nasty exception when selected. Therefore, for now, always
- // make the SAVE ALL menu item disabled.
- file_save_all.setEnabled(true);
-
- file_load = new JMenuItem(JMeterUtils.getResString("open"), 'O');
- file_load.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_O,
KeyEvent.CTRL_MASK));
- file_load.addActionListener(ActionRouter.getInstance());
-
- // Set default SAVE menu item to disabled since the default node that
is selected
- // is ROOT, which does not allow items to be inserted.
- file_load.setEnabled(false);
-
- file_new = new JMenuItem(JMeterUtils.getResString("new"), 'N');
- file_new.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_N,
KeyEvent.CTRL_MASK));
- file_new.setActionCommand("new");
- file_new.addActionListener(ActionRouter.getInstance());
-
- file_exit = new JMenuItem(JMeterUtils.getResString("exit"), 'X');
- file_exit.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_Q,
KeyEvent.CTRL_MASK));
- file_exit.setActionCommand("exit");
- file_exit.addActionListener(ActionRouter.getInstance());
- fileMenu.add(file_new);
- fileMenu.add(file_load);
- fileMenu.add(file_save_all);
- fileMenu.addSeparator();
- fileMenu.add(file_exit);
-
- // EDIT MENU
- editMenu = new JMenu(JMeterUtils.getResString("edit"));
- // From the Java Look and Feel Guidelines: If all items in a menu
- // are disabled, then disable the menu. Makes sense.
- editMenu.setEnabled(false);
-
+ createFileMenu();
+ makeEditMenu();
+ makeRunMenu();
+ makeOptionsMenu();
+ makeHelpMenu();
+ this.add(fileMenu);
+ this.add(editMenu);
+ this.add(runMenu);
+ this.add(optionsMenu);
+ this.add(helpMenu);
+ }
+ private void makeHelpMenu()
+ {
+ // HELP MENU
+ helpMenu = new JMenu(JMeterUtils.getResString("help"));
+ helpMenu.setMnemonic('H');
+ help_about = new JMenuItem(JMeterUtils.getResString("about"), 'A');
+ help_about.setActionCommand("about");
+ help_about.addActionListener(ActionRouter.getInstance());
+ helpMenu.add(help_about);
+ }
+ private void makeOptionsMenu()
+ {
+ // OPTIONS MENU
+ optionsMenu = new JMenu(JMeterUtils.getResString("option"));
+ JMenuItem functionHelper =
+ new
JMenuItem(JMeterUtils.getResString("function_dialog_menu_item"), 'F');
+ functionHelper.addActionListener(ActionRouter.getInstance());
+ functionHelper.setActionCommand("functions");
+ functionHelper.setAccelerator(
+ KeyStroke.getKeyStroke(KeyEvent.VK_F, KeyEvent.CTRL_MASK));
+ lafMenu = new JMenu(JMeterUtils.getResString("appearance"));
+ UIManager.LookAndFeelInfo lafs[] =
UIManager.getInstalledLookAndFeels();
+ for (int i = 0; i < lafs.length; ++i)
+ {
+ JMenuItem laf = new JMenuItem(lafs[i].getName());
+ laf.addActionListener(ActionRouter.getInstance());
+ laf.setActionCommand("laf:" + lafs[i].getClassName());
+ lafMenu.setMnemonic('L');
+ lafMenu.add(laf);
+ }
+ optionsMenu.setMnemonic('O');
+ optionsMenu.add(functionHelper);
+ optionsMenu.add(lafMenu);
+ if (SSLManager.isSSLSupported())
+ {
+ sslManager = new
JMenuItem(JMeterUtils.getResString("sslManager"));
+ sslManager.addActionListener(ActionRouter.getInstance());
+ sslManager.setActionCommand("sslManager");
+ sslManager.setMnemonic('S');
+ sslManager.setAccelerator(
+ KeyStroke.getKeyStroke(KeyEvent.VK_M,
KeyEvent.CTRL_MASK));
+ optionsMenu.add(sslManager);
+ }
+ optionsMenu.add(makeLanguageMenu());
+ }
+ private JMenu makeLanguageMenu()
+ {
+ JMenu languageMenu = new
JMenu(JMeterUtils.getResString("choose_language"));
+ languageMenu.setMnemonic('C');
+ //add english
+ JMenuItem english = new
JMenuItem(JMeterUtils.getResString("english"),'E');
+ english.addActionListener(ActionRouter.getInstance());
+ english.setActionCommand(ChangeLanguage.CHANGE_LANGUAGE);
+ english.setName("en");
+ languageMenu.add(english);
+ //add Japanese
+ JMenuItem japanese = new
JMenuItem(JMeterUtils.getResString("japanese"),'J');
+ japanese.addActionListener(ActionRouter.getInstance());
+ japanese.setActionCommand(ChangeLanguage.CHANGE_LANGUAGE);
+ japanese.setName("ja");
+ languageMenu.add(japanese);
+ //add Norwegian
+ JMenuItem norway = new
JMenuItem(JMeterUtils.getResString("norwegian"),'N');
+ norway.addActionListener(ActionRouter.getInstance());
+ norway.setActionCommand(ChangeLanguage.CHANGE_LANGUAGE);
+ norway.setName("no");
+ languageMenu.add(norway);
+ //add German
+ JMenuItem german = new
JMenuItem(JMeterUtils.getResString("german"),'G');
+ german.addActionListener(ActionRouter.getInstance());
+ german.setActionCommand(ChangeLanguage.CHANGE_LANGUAGE);
+ german.setName("de");
+ languageMenu.add(german);
+ return languageMenu;
+ }
+
+ private void makeRunMenu()
+ {
// RUN MENU
runMenu = new JMenu(JMeterUtils.getResString("run"));
runMenu.setMnemonic('R');
run_start = new JMenuItem(JMeterUtils.getResString("start"), 'S');
- run_start.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_R,
KeyEvent.CTRL_MASK));
+ run_start.setAccelerator(
+ KeyStroke.getKeyStroke(KeyEvent.VK_R, KeyEvent.CTRL_MASK));
run_start.addActionListener(ActionRouter.getInstance());
run_start.setActionCommand("start");
run_stop = new JMenuItem(JMeterUtils.getResString("stop"), 'T');
- run_stop.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_PERIOD,
KeyEvent.CTRL_MASK));
+ run_stop.setAccelerator(
+ KeyStroke.getKeyStroke(KeyEvent.VK_PERIOD,
KeyEvent.CTRL_MASK));
run_stop.setEnabled(false);
run_stop.addActionListener(ActionRouter.getInstance());
run_stop.setActionCommand("stop");
@@ -331,67 +366,62 @@
run_clearAll.addActionListener(ActionRouter.getInstance());
run_clearAll.setActionCommand(org.apache.jmeter.gui.action.Clear.CLEAR_ALL);
runMenu.add(run_start);
- if(remote_start != null)
+ if (remote_start != null)
{
runMenu.add(remote_start);
}
runMenu.add(run_stop);
- if(remote_stop != null)
+ if (remote_stop != null)
{
runMenu.add(remote_stop);
}
-
runMenu.addSeparator();
-
runMenu.add(run_clear);
runMenu.add(run_clearAll);
-
- // OPTIONS MENU
- optionsMenu = new JMenu(JMeterUtils.getResString("option"));
- JMenuItem functionHelper = new JMenuItem(JMeterUtils.getResString(
- "function_dialog_menu_item"),'F');
- functionHelper.addActionListener(ActionRouter.getInstance());
- functionHelper.setActionCommand("functions");
- functionHelper.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_F,
- KeyEvent.CTRL_MASK));
- lafMenu = new JMenu(JMeterUtils.getResString("appearance"));
- UIManager.LookAndFeelInfo lafs[] =
UIManager.getInstalledLookAndFeels();
- for(int i = 0; i < lafs.length; ++i)
- {
- JMenuItem laf = new JMenuItem(lafs[i].getName());
- laf.addActionListener(ActionRouter.getInstance());
- laf.setActionCommand("laf:" + lafs[i].getClassName());
- lafMenu.setMnemonic('L');
- lafMenu.add(laf);
- }
- optionsMenu.setMnemonic('O');
- optionsMenu.add(functionHelper);
- optionsMenu.add(lafMenu);
- if(SSLManager.isSSLSupported())
- {
- sslManager = new
JMenuItem(JMeterUtils.getResString("sslManager"));
- sslManager.addActionListener(ActionRouter.getInstance());
- sslManager.setActionCommand("sslManager");
- sslManager.setMnemonic('S');
-
sslManager.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_M, KeyEvent.CTRL_MASK));
- optionsMenu.add(sslManager);
- }
-
- // HELP MENU
- helpMenu = new JMenu(JMeterUtils.getResString("help"));
- helpMenu.setMnemonic('H');
- help_about = new JMenuItem(JMeterUtils.getResString("about"), 'A');
- help_about.setActionCommand("about");
- help_about.addActionListener(ActionRouter.getInstance());
- helpMenu.add(help_about);
-
- this.add(fileMenu);
- this.add(editMenu);
- this.add(runMenu);
- this.add(optionsMenu);
- this.add(helpMenu);
}
-
+ private void makeEditMenu()
+ {
+ // EDIT MENU
+ editMenu = new JMenu(JMeterUtils.getResString("edit"));
+ // From the Java Look and Feel Guidelines: If all items in a menu
+ // are disabled, then disable the menu. Makes sense.
+ editMenu.setEnabled(false);
+ }
+ private void createFileMenu()
+ {
+ // FILE MENU
+ fileMenu = new JMenu(JMeterUtils.getResString("file"));
+ fileMenu.setMnemonic('F');
+ file_save_all = new JMenuItem(JMeterUtils.getResString("save_all"),
'A');
+ file_save_all.setAccelerator(
+ KeyStroke.getKeyStroke(KeyEvent.VK_A, KeyEvent.CTRL_MASK));
+ file_save_all.setActionCommand("save_all");
+ file_save_all.addActionListener(ActionRouter.getInstance());
+ file_save_all.setEnabled(true);
+ file_load = new JMenuItem(JMeterUtils.getResString("open"), 'O');
+ file_load.setAccelerator(
+ KeyStroke.getKeyStroke(KeyEvent.VK_O, KeyEvent.CTRL_MASK));
+ file_load.addActionListener(ActionRouter.getInstance());
+ // Set default SAVE menu item to disabled since the default node that
is selected
+ // is ROOT, which does not allow items to be inserted.
+ file_load.setEnabled(false);
+ file_load.setActionCommand("open");
+ file_new = new JMenuItem(JMeterUtils.getResString("new"), 'N');
+ file_new.setAccelerator(
+ KeyStroke.getKeyStroke(KeyEvent.VK_N, KeyEvent.CTRL_MASK));
+ file_new.setActionCommand("new");
+ file_new.addActionListener(ActionRouter.getInstance());
+ file_exit = new JMenuItem(JMeterUtils.getResString("exit"), 'X');
+ file_exit.setAccelerator(
+ KeyStroke.getKeyStroke(KeyEvent.VK_Q, KeyEvent.CTRL_MASK));
+ file_exit.setActionCommand("exit");
+ file_exit.addActionListener(ActionRouter.getInstance());
+ fileMenu.add(file_new);
+ fileMenu.add(file_load);
+ fileMenu.add(file_save_all);
+ fileMenu.addSeparator();
+ fileMenu.add(file_exit);
+ }
/****************************************
* !ToDo (Method description)
*
@@ -402,23 +432,21 @@
{
Iterator iter = remote_engine_start.iterator();
Iterator iter2 = remote_engine_stop.iterator();
- while(iter.hasNext() && iter2.hasNext())
+ while (iter.hasNext() && iter2.hasNext())
{
- JMenuItem start = (JMenuItem)iter.next();
- JMenuItem stop = (JMenuItem)iter2.next();
- log.info("host = "+host+" start = "+start.getText());
- if(start.getText().equals(host))
+ JMenuItem start = (JMenuItem) iter.next();
+ JMenuItem stop = (JMenuItem) iter2.next();
+ log.info("host = " + host + " start = " + start.getText());
+ if (start.getText().equals(host))
{
start.setEnabled(!running);
}
- if(stop.getText().equals(host))
+ if (stop.getText().equals(host))
{
stop.setEnabled(running);
}
}
}
-
-
/****************************************
* !ToDo (Method description)
*
@@ -429,14 +457,13 @@
run_start.setEnabled(!enable);
run_stop.setEnabled(enable);
}
-
private void getRemoteItems()
{
- if(remoteHosts.length > 0)
+ if (remoteHosts.length > 0)
{
remote_start = new
JMenu(JMeterUtils.getResString("remote_start"));
remote_stop = new
JMenu(JMeterUtils.getResString("remote_stop"));
- for(int i = 0; i < remoteHosts.length; i++)
+ for (int i = 0; i < remoteHosts.length; i++)
{
JMenuItem item = new JMenuItem(remoteHosts[i]);
item.setActionCommand("remote_start");
@@ -444,7 +471,6 @@
item.addActionListener(ActionRouter.getInstance());
remote_engine_start.add(item);
remote_start.add(item);
-
item = new JMenuItem(remoteHosts[i]);
item.setActionCommand("remote_stop");
item.setName(remoteHosts[i]);
1.5 +3 -3
jakarta-jmeter/src/core/org/apache/jmeter/gui/util/MenuFactory.java
Index: MenuFactory.java
===================================================================
RCS file:
/home/cvs/jakarta-jmeter/src/core/org/apache/jmeter/gui/util/MenuFactory.java,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -r1.4 -r1.5
--- MenuFactory.java 23 Aug 2002 22:51:44 -0000 1.4
+++ MenuFactory.java 25 Aug 2002 19:42:20 -0000 1.5
@@ -192,7 +192,7 @@
addSeparator(menu);
if(removable)
{
- menu.add(makeMenuItem(JMeterUtils.getResString("remove"),
"Remove", JMeterUtils.getResString("remove")));
+ menu.add(makeMenuItem(JMeterUtils.getResString("remove"),
"Remove","remove"));
}
menu.add(makeMenuItem(JMeterUtils.getResString("cut"), "Cut", "Cut"));
menu.add(makeMenuItem(JMeterUtils.getResString("copy"), "Copy",
"Copy"));
@@ -208,7 +208,7 @@
public static void addFileMenu(JPopupMenu menu)
{
addSeparator(menu);
- menu.add(makeMenuItem(JMeterUtils.getResString("open"), "Open",
JMeterUtils.getResString("open")));
+ menu.add(makeMenuItem(JMeterUtils.getResString("open"), "Open",
"open"));
menu.add(makeMenuItem(JMeterUtils.getResString("save"), "Save",
"save"));
JMenuItem disabled =
makeMenuItem(JMeterUtils.getResString("disable"),"Disable","disable");
JMenuItem enabled =
makeMenuItem(JMeterUtils.getResString("enable"),"Enable","enable");
1.8 +6 -1
jakarta-jmeter/src/core/org/apache/jmeter/resources/messages.properties
Index: messages.properties
===================================================================
RCS file:
/home/cvs/jakarta-jmeter/src/core/org/apache/jmeter/resources/messages.properties,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -r1.7 -r1.8
--- messages.properties 20 Aug 2002 18:45:52 -0000 1.7
+++ messages.properties 25 Aug 2002 19:42:21 -0000 1.8
@@ -288,4 +288,9 @@
column_delete_disallowed=Deleting this column is not permitted
enable=Activate
disable=Disable
-ignore_subcontrollers=Ignore sub-controller blocks
\ No newline at end of file
+ignore_subcontrollers=Ignore sub-controller blocks
+choose_language=Choose Language
+english=English
+japanese=Japanese
+german=German
+norwegian=Norwegian
\ No newline at end of file
1.9 +6 -1
jakarta-jmeter/src/core/org/apache/jmeter/resources/messages_de.properties
Index: messages_de.properties
===================================================================
RCS file:
/home/cvs/jakarta-jmeter/src/core/org/apache/jmeter/resources/messages_de.properties,v
retrieving revision 1.8
retrieving revision 1.9
diff -u -r1.8 -r1.9
--- messages_de.properties 20 Aug 2002 18:45:53 -0000 1.8
+++ messages_de.properties 25 Aug 2002 19:42:21 -0000 1.9
@@ -283,4 +283,9 @@
column_delete_disallowed=Deleting this column is not permitted
enable=Activate
disable=Disable
-ignore_subcontrollers=Ignore sub-controller blocks
\ No newline at end of file
+ignore_subcontrollers=Ignore sub-controller blocks
+choose_language=Choose Language
+english=English
+japanese=Japanese
+german=Deutsch
+norwegian=Norwegian
\ No newline at end of file
1.8 +6 -1
jakarta-jmeter/src/core/org/apache/jmeter/resources/messages_ja.properties
Index: messages_ja.properties
===================================================================
RCS file:
/home/cvs/jakarta-jmeter/src/core/org/apache/jmeter/resources/messages_ja.properties,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -r1.7 -r1.8
--- messages_ja.properties 20 Aug 2002 18:45:53 -0000 1.7
+++ messages_ja.properties 25 Aug 2002 19:42:21 -0000 1.8
@@ -283,4 +283,9 @@
column_delete_disallowed=Deleting this column is not permitted
enable=Activate
disable=Disable
-ignore_subcontrollers=Ignore sub-controller blocks
\ No newline at end of file
+ignore_subcontrollers=Ignore sub-controller blocks
+choose_language=Choose Language
+english=English
+japanese=Japanese
+german=German
+norwegian=Norwegian
\ No newline at end of file
1.8 +6 -1
jakarta-jmeter/src/core/org/apache/jmeter/resources/messages_no.properties
Index: messages_no.properties
===================================================================
RCS file:
/home/cvs/jakarta-jmeter/src/core/org/apache/jmeter/resources/messages_no.properties,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -r1.7 -r1.8
--- messages_no.properties 20 Aug 2002 18:45:53 -0000 1.7
+++ messages_no.properties 25 Aug 2002 19:42:21 -0000 1.8
@@ -275,4 +275,9 @@
column_delete_disallowed=Deleting this column is not permitted
enable=Activate
disable=Disable
-ignore_subcontrollers=Ignore sub-controller blocks
\ No newline at end of file
+ignore_subcontrollers=Ignore sub-controller blocks
+choose_language=Choose Language
+english=English
+japanese=Japanese
+german=German
+norwegian=Norwegian
\ No newline at end of file
1.3 +13 -15
jakarta-jmeter/src/core/org/apache/jmeter/threads/ListenerNotifier.java
Index: ListenerNotifier.java
===================================================================
RCS file:
/home/cvs/jakarta-jmeter/src/core/org/apache/jmeter/threads/ListenerNotifier.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- ListenerNotifier.java 24 Aug 2002 16:51:14 -0000 1.2
+++ ListenerNotifier.java 25 Aug 2002 19:42:21 -0000 1.3
@@ -2,9 +2,11 @@
import java.util.Iterator;
import java.util.LinkedList;
import java.util.List;
-
import org.apache.jmeter.samplers.SampleEvent;
import org.apache.jmeter.samplers.SampleListener;
+import org.apache.jmeter.util.LoggingManager;
+import org.apache.log.Hierarchy;
+import org.apache.log.Logger;
/**
* @author Administrator
*
@@ -13,33 +15,33 @@
*/
public class ListenerNotifier extends LinkedList implements Runnable
{
+ Logger log =
+ Hierarchy.getDefaultHierarchy().getLoggerFor(LoggingManager.ENGINE);
/**
* @see java.lang.Runnable#run()
*/
boolean running;
boolean isStopped;
int sleepTime = 2000;
-
public ListenerNotifier()
{
super();
running = true;
isStopped = true;
}
-
public void run()
{
Iterator iter;
- while(running || this.size() > 0)
+ while (running || this.size() > 1)
{
- SampleEvent res = (SampleEvent)this.removeFirst();
- if(res != null)
+ SampleEvent res = (SampleEvent) this.removeFirst();
+ if (res != null)
{
- List listeners = (List)this.removeFirst();
+ List listeners = (List) this.removeFirst();
iter = listeners.iterator();
- while(iter.hasNext())
+ while (iter.hasNext())
{
-
((SampleListener)iter.next()).sampleOccurred(res);
+ ((SampleListener)
iter.next()).sampleOccurred(res);
}
}
try
@@ -50,21 +52,19 @@
{
}
}
+ log.debug("Listener Notifier stopped");
isStopped = true;
}
-
public boolean isStopped()
{
return isStopped;
}
-
- public synchronized void addLast(SampleEvent item,List listeners)
+ public synchronized void addLast(SampleEvent item, List listeners)
{
super.addLast(item);
super.addLast(listeners);
sleepTime = 0;
}
-
public synchronized Object removeFirst()
{
try
@@ -77,12 +77,10 @@
return null;
}
}
-
public void stop()
{
running = false;
}
-
public void start()
{
Thread noteThread = new Thread(this);
1.5 +7 -1 jakarta-jmeter/src/core/org/apache/jmeter/util/JMeterUtils.java
Index: JMeterUtils.java
===================================================================
RCS file: /home/cvs/jakarta-jmeter/src/core/org/apache/jmeter/util/JMeterUtils.java,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -r1.4 -r1.5
--- JMeterUtils.java 23 Aug 2002 22:51:45 -0000 1.4
+++ JMeterUtils.java 25 Aug 2002 19:42:21 -0000 1.5
@@ -68,6 +68,7 @@
import java.io.PrintWriter;
import java.util.Enumeration;
import java.util.Hashtable;
+import java.util.Locale;
import java.util.MissingResourceException;
import java.util.Properties;
import java.util.ResourceBundle;
@@ -177,6 +178,11 @@
getPropDefault(prop,"WARN")),name);
}
}
+ }
+
+ public static void reinitializeLocale(Locale loc)
+ {
+ RESOURCES =
ResourceBundle.getBundle("org.apache.jmeter.resources.messages",loc);
}
/**
1.4 +1 -1
jakarta-jmeter/src/core/org/apache/jmeter/util/LoggingManager.java
Index: LoggingManager.java
===================================================================
RCS file:
/home/cvs/jakarta-jmeter/src/core/org/apache/jmeter/util/LoggingManager.java,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- LoggingManager.java 24 Aug 2002 03:56:07 -0000 1.3
+++ LoggingManager.java 25 Aug 2002 19:42:21 -0000 1.4
@@ -15,7 +15,7 @@
*/
public class LoggingManager
{
- private static PatternFormatter format = new
PatternFormatter("%{time:MM/dd/yyyy h:mm:ss a} %{priority} - %{category}:
%{message}\n%{throwable}\n");
+ private static PatternFormatter format = new
PatternFormatter("%{time:MM/dd/yyyy h:mm:ss a} %{priority} - %{category}: %{message}
%{throwable}\n");
private static WriterTarget target;
public static final String JMETER = "jmeter";
1.4 +69 -86
jakarta-jmeter/src/protocol/http/org/apache/jmeter/protocol/http/proxy/HttpRequestHdr.java
Index: HttpRequestHdr.java
===================================================================
RCS file:
/home/cvs/jakarta-jmeter/src/protocol/http/org/apache/jmeter/protocol/http/proxy/HttpRequestHdr.java,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- HttpRequestHdr.java 14 Aug 2002 17:49:04 -0000 1.3
+++ HttpRequestHdr.java 25 Aug 2002 19:42:21 -0000 1.4
@@ -11,7 +11,6 @@
import java.util.Iterator;
import java.util.Map;
import java.util.StringTokenizer;
-
import org.apache.jmeter.protocol.http.config.MultipartUrlConfig;
import org.apache.jmeter.protocol.http.control.Header;
import org.apache.jmeter.protocol.http.control.HeaderManager;
@@ -19,12 +18,13 @@
import org.apache.jmeter.protocol.http.gui.HeaderPanel;
import org.apache.jmeter.protocol.http.sampler.HTTPSampler;
import org.apache.jmeter.testelement.TestElement;
-
+import org.apache.jmeter.util.LoggingManager;
+import org.apache.log.Hierarchy;
+import org.apache.log.Logger;
//
// Class: HttpRequestHdr
// Abstract: The headers of the client HTTP request.
//
-
/****************************************
* !ToDo (Class description)
*
@@ -34,35 +34,27 @@
***************************************/
public class HttpRequestHdr
{
-
+ Logger log =
+ Hierarchy.getDefaultHierarchy().getLoggerFor(LoggingManager.HTTP);
/****************************************
* Http Request method. Such as get or post.
***************************************/
public String method = new String();
-
/****************************************
* The requested url. The universal resource locator that hopefully uniquely
* describes the object or service the client is requesting.
***************************************/
public String url = new String();
-
/****************************************
* Version of http being used. Such as HTTP/1.0
***************************************/
public String version = new String();
-
-
-
/****************************************
* !ToDo (Field description)
***************************************/
public String postData = "";
-
static String CR = "\r\n";
-
private Map headers = new HashMap();
-
-
/****************************************
* Parses a http header from a stream.
*
@@ -79,28 +71,28 @@
ByteArrayOutputStream clientRequest = new ByteArrayOutputStream();
ByteArrayOutputStream line = new ByteArrayOutputStream();
int x;
- while((inHeaders || readLength < dataLength) && ((x = in.read()) !=
-1))
+ while ((inHeaders || readLength < dataLength) && ((x = in.read()) !=
-1))
{
line.write(x);
clientRequest.write(x);
- if(inHeaders && (byte)x == (byte)'\n')
+ if (inHeaders && (byte) x == (byte) '\n')
{
- if(line.size() < 3)
+ if (line.size() < 3)
{
inHeaders = false;
}
- if(first)
+ if (first)
{
parseFirstLine(line.toString());
first = false;
}
else
{
- dataLength =
Math.max(parseLine(line.toString()),dataLength);
+ dataLength =
Math.max(parseLine(line.toString()), dataLength);
}
line.reset();
}
- else if(!inHeaders)
+ else if (!inHeaders)
{
readLength++;
}
@@ -108,106 +100,116 @@
postData = line.toString().trim();
return clientRequest.toByteArray();
}
-
public void parseFirstLine(String firstLine)
{
+ log.debug("browser request: " + firstLine);
StringTokenizer tz = new StringTokenizer(firstLine);
method = getToken(tz).toUpperCase();
url = getToken(tz);
+ log.debug("parsed url: " + url);
version = getToken(tz);
}
-
public int parseLine(String nextLine)
{
StringTokenizer tz;
tz = new StringTokenizer(nextLine);
String token = getToken(tz);
// look for termination of HTTP command
- if(0 == token.length())
+ if (0 == token.length())
{
return 0;
}
else
{
- String name =
token.trim().substring(0,token.trim().length()-1);
+ String name = token.trim().substring(0, token.trim().length()
- 1);
String value = getRemainder(tz);
- headers.put(name.toLowerCase(),new Header(name,value));
- if(name.equalsIgnoreCase("content-length"))
+ headers.put(name.toLowerCase(), new Header(name, value));
+ if (name.equalsIgnoreCase("content-length"))
{
return Integer.parseInt(value);
}
}
return 0;
}
-
public HeaderManager getHeaderManager()
{
HeaderManager manager = new HeaderManager();
Iterator keys = headers.keySet().iterator();
- while(keys.hasNext())
+ while (keys.hasNext())
{
- String key = (String)keys.next();
- if(!key.equals("proxy-connection") &&
!key.equals("content-length"))
+ String key = (String) keys.next();
+ if (!key.equals("proxy-connection") &&
!key.equals("content-length"))
{
- manager.add((Header)headers.get(key));
+ manager.add((Header) headers.get(key));
}
}
manager.setName("Browser-derived headers");
-
manager.setProperty(TestElement.TEST_CLASS,HeaderManager.class.getName());
- manager.setProperty(TestElement.GUI_CLASS,HeaderPanel.class.getName());
- return manager;
+ manager.setProperty(TestElement.TEST_CLASS,
HeaderManager.class.getName());
+ manager.setProperty(TestElement.GUI_CLASS,
HeaderPanel.class.getName());
+ return manager;
}
-
- public HTTPSampler getSampler() throws
MalformedURLException,IOException,ProtocolException
+ public HTTPSampler getSampler()
+ throws MalformedURLException, IOException, ProtocolException
{
HttpTestSampleGui tempGui = new HttpTestSampleGui();
tempGui.configure(createSampler());
- HTTPSampler result = (HTTPSampler)tempGui.createTestElement();
+ HTTPSampler result = (HTTPSampler) tempGui.createTestElement();
result.setFollowRedirects(false);
result.setUseKeepAlive(true);
return result;
}
-
public String getContentType()
{
- Header contentTypeHeader = (Header)headers.get("content-type");
- if(contentTypeHeader != null)
+ Header contentTypeHeader = (Header) headers.get("content-type");
+ if (contentTypeHeader != null)
{
return contentTypeHeader.getValue();
}
return "";
}
-
public static MultipartUrlConfig isMultipart(String contentType)
{
- if(contentType != null &&
contentType.startsWith(MultipartUrlConfig.MULTIPART_FORM))
+ if (contentType != null
+ && contentType.startsWith(MultipartUrlConfig.MULTIPART_FORM))
{
- return new
MultipartUrlConfig(contentType.substring(contentType.indexOf("oundary=")+8));
+ return new MultipartUrlConfig(
+ contentType.substring(contentType.indexOf("oundary=")
+ 8));
}
else
{
return null;
}
}
-
private HTTPSampler createSampler()
{
MultipartUrlConfig urlConfig = null;
HTTPSampler sampler = new HTTPSampler();
sampler.setDomain(serverName());
+ log.debug("Proxy: setting server: "+sampler.getDomain());
sampler.setMethod(method);
+ log.debug("Proxy: method server: "+sampler.getMethod());
sampler.setPath(serverUrl());
+ log.debug("Proxy: setting path: "+sampler.getPath());
sampler.setName(sampler.getPath());
- if(url.indexOf(":") > -1)
+ sampler.setPort(serverPort());
+ log.debug("Proxy: setting port: "+sampler.getPort());
+ if (url.indexOf("//") > -1)
+ {
+ String protocol = url.substring(0, url.indexOf(":"));
+ log.debug("Proxy: setting protocol to : "+protocol);
+ sampler.setProtocol(protocol);
+ }
+ else if(sampler.getPort() == 443)
{
- sampler.setProtocol(url.substring(0, url.indexOf(":")));
+ sampler.setProtocol("https");
+ log.debug("Proxy: setting protocol to https");
}
else
{
+ log.debug("Proxy setting default protocol to: http");
sampler.setProtocol("http");
}
- sampler.setPort(serverPort());
- if((urlConfig = isMultipart(getContentType())) != null)
+ if ((urlConfig = isMultipart(getContentType())) != null)
{
urlConfig.parseArguments(postData);
sampler.setArguments(urlConfig.getArguments());
@@ -220,12 +222,10 @@
sampler.parseArguments(postData);
}
return sampler;
- }
-
+ }
//
// Parsing Methods
//
-
/****************************************
* Find the //server.name from an url.
*
@@ -236,29 +236,24 @@
// chop to "server.name:x/thing"
String str = url;
int i = str.indexOf("//");
- if(i < 0)
+ if (i > 0)
{
- return "";
+ str = str.substring(i + 2);
}
- str = str.substring(i + 2);
-
// chop to server.name:xx
i = str.indexOf("/");
- if(0 < i)
+ if (0 < i)
{
str = str.substring(0, i);
}
-
// chop to server.name
i = str.indexOf(":");
- if(0 < i)
+ if (0 < i)
{
str = str.substring(0, i);
}
-
return str;
}
-
/****************************************
* Find the :PORT form http://server.ect:PORT/some/file.xxx
*
@@ -269,29 +264,24 @@
String str = url;
// chop to "server.name:x/thing"
int i = str.indexOf("//");
- if(i < 0)
+ if (i > 0)
{
- return 80;
- }
- str = str.substring(i + 2);
-
+ str = str.substring(i + 2);
+ }
// chop to server.name:xx
i = str.indexOf("/");
- if(0 < i)
+ if (0 < i)
{
str = str.substring(0, i);
}
-
// chop XX
i = str.indexOf(":");
- if(0 < i)
+ if (0 < i)
{
return Integer.parseInt(str.substring(i + 1).trim());
}
-
return 80;
}
-
/****************************************
* Find the /some/file.xxxx form http://server.ect:PORT/some/file.xxx
*
@@ -301,21 +291,17 @@
{
String str = url;
int i = str.indexOf("//");
- if(i < 0)
+ if (i > 0)
{
- return str;
- }
-
- str = str.substring(i + 2);
+ str = str.substring(i + 2);
+ }
i = str.indexOf("/");
- if(i < 0)
+ if (i < 0)
{
- return str;
+ return "";
}
-
return str.substring(i);
}
-
/****************************************
* Returns the next token in a string
*
@@ -326,13 +312,12 @@
String getToken(StringTokenizer tk)
{
String str = "";
- if(tk.hasMoreTokens())
+ if (tk.hasMoreTokens())
{
str = tk.nextToken();
}
return str;
}
-
/****************************************
* Returns the remainder of a tokenized string
*
@@ -343,16 +328,14 @@
String getRemainder(StringTokenizer tk)
{
String str = "";
- if(tk.hasMoreTokens())
+ if (tk.hasMoreTokens())
{
str = tk.nextToken();
}
- while(tk.hasMoreTokens())
+ while (tk.hasMoreTokens())
{
str += " " + tk.nextToken();
}
-
return str;
}
-
}
1.8 +259 -270
jakarta-jmeter/src/protocol/http/org/apache/jmeter/protocol/http/sampler/HTTPSampler.java
Index: HTTPSampler.java
===================================================================
RCS file:
/home/cvs/jakarta-jmeter/src/protocol/http/org/apache/jmeter/protocol/http/sampler/HTTPSampler.java,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -r1.7 -r1.8
--- HTTPSampler.java 23 Aug 2002 22:51:46 -0000 1.7
+++ HTTPSampler.java 25 Aug 2002 19:42:21 -0000 1.8
@@ -64,7 +64,6 @@
import java.util.ArrayList;
import java.util.Collection;
import java.util.Iterator;
-
import org.apache.jmeter.config.Arguments;
import org.apache.jmeter.config.ConfigTestElement;
import org.apache.jmeter.protocol.http.control.AuthManager;
@@ -80,7 +79,6 @@
import org.apache.jmeter.util.SSLManager;
import org.apache.log.Hierarchy;
import org.apache.log.Logger;
-
/****************************************
* A sampler which understands all the parts necessary to read statistics about
* HTTP requests, including cookies and authentication.
@@ -93,7 +91,6 @@
{
public final static String HEADERS = "headers";
public final static String HEADER = "header";
-
public final static String ARGUMENTS = "HTTPsampler.Arguments";
public final static String AUTH_MANAGER = "HTTPSampler.auth_manager";
public final static String COOKIE_MANAGER = "HTTPSampler.cookie_manager";
@@ -117,39 +114,31 @@
public final static String NORMAL_FORM = "normal_form";
public final static String MULTIPART_FORM = "multipart_form";
protected static String encoding = "iso-8859-1";
-
private static final PostWriter postWriter = new PostWriter();
-
public void setFileField(String value)
{
- setProperty(FILE_FIELD,value);
+ setProperty(FILE_FIELD, value);
}
-
public String getFileField()
{
return getPropertyAsString(FILE_FIELD);
}
-
public void setFilename(String value)
{
- setProperty(FILE_NAME,value);
+ setProperty(FILE_NAME, value);
}
-
public String getFilename()
{
return getPropertyAsString(FILE_NAME);
}
-
public void setProtocol(String value)
{
- setProperty(PROTOCOL,value);
+ setProperty(PROTOCOL, value);
}
-
public String getProtocol()
{
return getPropertyAsString(PROTOCOL);
}
-
/**
* Sets the Path attribute of the UrlConfig object
*
@@ -157,13 +146,13 @@
*/
public void setPath(String path)
{
- if(GET.equals(getMethod()))
+ if (GET.equals(getMethod()))
{
int index = path.indexOf("?");
- if(index > -1)
+ if (index > -1)
{
- setProperty(PATH,path.substring(0,index));
- parseArguments(path.substring(index+1));
+ setProperty(PATH, path.substring(0, index));
+ parseArguments(path.substring(index + 1));
}
else
{
@@ -173,222 +162,195 @@
else
{
setProperty(PATH, path);
- }
+ }
}
-
public String getPath()
{
return getPropertyAsString(PATH);
}
-
public void setFollowRedirects(boolean value)
{
setProperty(FOLLOW_REDIRECTS, new Boolean(value));
}
-
public boolean getFollowRedirects()
{
return getPropertyAsBoolean(FOLLOW_REDIRECTS);
}
-
public void setMethod(String value)
{
- setProperty(METHOD,value);
+ setProperty(METHOD, value);
}
-
public String getMethod()
{
return getPropertyAsString(METHOD);
}
-
public void setUseKeepAlive(boolean value)
{
setProperty(USE_KEEPALIVE, new Boolean(value));
}
-
public boolean getUseKeepAlive()
{
return getPropertyAsBoolean(USE_KEEPALIVE);
}
-
- public void addEncodedArgument(String name,String value,String metaData)
+ public void addEncodedArgument(String name, String value, String metaData)
{
Arguments args = getArguments();
- HTTPArgument arg = new HTTPArgument(name,value,metaData,true);
- if(arg.getName().equals(arg.getEncodedName()) &&
arg.getValue().equals(arg.getEncodedValue()))
+ HTTPArgument arg = new HTTPArgument(name, value, metaData, true);
+ if (arg.getName().equals(arg.getEncodedName())
+ && arg.getValue().equals(arg.getEncodedValue()))
{
arg.setAlwaysEncode(false);
}
args.addArgument(arg);
}
-
- public void addArgument(String name,String value)
+ public void addArgument(String name, String value)
{
Arguments args = this.getArguments();
- args.addArgument(new HTTPArgument(name,value));
+ args.addArgument(new HTTPArgument(name, value));
}
-
- public void addArgument(String name,String value,String metadata)
+ public void addArgument(String name, String value, String metadata)
{
Arguments args = this.getArguments();
- args.addArgument(new HTTPArgument(name,value,metadata));
+ args.addArgument(new HTTPArgument(name, value, metadata));
}
-
public void setPort(int value)
{
- setProperty(PORT,new Integer(value));
+ setProperty(PORT, new Integer(value));
}
-
public int getPort()
{
int port = getPropertyAsInt(PORT);
- if(port == 0)
+ if (port == 0)
{
port = 80;
setPort(port);
}
return port;
}
-
public void setDomain(String value)
{
- setProperty(DOMAIN,value);
+ setProperty(DOMAIN, value);
}
-
public String getDomain()
{
- return (String)getProperty(DOMAIN);
+ return (String) getProperty(DOMAIN);
}
-
public void setArguments(Arguments value)
{
- setProperty(ARGUMENTS,value);
+ setProperty(ARGUMENTS, value);
}
-
public Arguments getArguments()
{
- return (Arguments)getProperty(ARGUMENTS);
+ return (Arguments) getProperty(ARGUMENTS);
}
-
public void setAuthManager(AuthManager value)
{
- setProperty(AUTH_MANAGER,value);
+ setProperty(AUTH_MANAGER, value);
}
-
public AuthManager getAuthManager()
{
- return (AuthManager)getProperty(AUTH_MANAGER);
+ return (AuthManager) getProperty(AUTH_MANAGER);
}
-
public void setHeaderManager(HeaderManager value)
{
- setProperty(HEADER_MANAGER,value);
+ setProperty(HEADER_MANAGER, value);
}
-
public HeaderManager getHeaderManager()
{
- return (HeaderManager)getProperty(HEADER_MANAGER);
+ return (HeaderManager) getProperty(HEADER_MANAGER);
}
-
public void setCookieManager(CookieManager value)
{
- setProperty(COOKIE_MANAGER,value);
+ setProperty(COOKIE_MANAGER, value);
}
-
public CookieManager getCookieManager()
{
- return (CookieManager)getProperty(COOKIE_MANAGER);
+ return (CookieManager) getProperty(COOKIE_MANAGER);
}
-
public void setMimetype(String value)
{
- setProperty(MIMETYPE,value);
+ setProperty(MIMETYPE, value);
}
-
public String getMimetype()
{
- return (String)getProperty(MIMETYPE);
+ return (String) getProperty(MIMETYPE);
}
-
protected void addCustomTestElement(TestElement element)
{
- if(element instanceof Arguments)
+ if (element instanceof Arguments)
{
- if(getProperty(ARGUMENTS) != null)
+ if (getProperty(ARGUMENTS) != null)
{
-
((Arguments)getProperty(ARGUMENTS)).addTestElement(element);
+ ((Arguments)
getProperty(ARGUMENTS)).addTestElement(element);
}
else
{
- setProperty(ARGUMENTS,element);
+ setProperty(ARGUMENTS, element);
}
}
- else if(element instanceof AuthManager)
+ else if (element instanceof AuthManager)
{
- if(getProperty(AUTH_MANAGER) != null)
+ if (getProperty(AUTH_MANAGER) != null)
{
-
((TestElement)getProperty(AUTH_MANAGER)).addTestElement(element);
+ ((TestElement)
getProperty(AUTH_MANAGER)).addTestElement(element);
}
else
{
- setProperty(AUTH_MANAGER,element);
+ setProperty(AUTH_MANAGER, element);
}
}
- else if(element instanceof CookieManager)
+ else if (element instanceof CookieManager)
{
- if(getProperty(COOKIE_MANAGER) != null)
+ if (getProperty(COOKIE_MANAGER) != null)
{
-
((TestElement)getProperty(COOKIE_MANAGER)).addTestElement(element);
+ ((TestElement)
getProperty(COOKIE_MANAGER)).addTestElement(element);
}
else
{
- setProperty(COOKIE_MANAGER,element);
+ setProperty(COOKIE_MANAGER, element);
}
}
- else if(element instanceof HeaderManager)
+ else if (element instanceof HeaderManager)
{
- if(getProperty(HEADER_MANAGER) != null)
+ if (getProperty(HEADER_MANAGER) != null)
{
-
((TestElement)getProperty(HEADER_MANAGER)).addTestElement(element);
+ ((TestElement)
getProperty(HEADER_MANAGER)).addTestElement(element);
}
else
{
- setProperty(HEADER_MANAGER,element);
+ setProperty(HEADER_MANAGER, element);
}
}
- else if(element instanceof HTTPSampler ||
- element instanceof ConfigTestElement)
+ else if (
+ element instanceof HTTPSampler || element instanceof
ConfigTestElement)
{
this.mergeIn(element);
}
}
-
/****************************************
* !ToDo (Field description)
***************************************/
protected final static String NON_HTTP_RESPONSE_CODE =
- "Non HTTP response code";
+ "Non HTTP response code";
/****************************************
* !ToDo (Field description)
***************************************/
protected final static String NON_HTTP_RESPONSE_MESSAGE =
- "Non HTTP response message";
-
- private static Logger log =
Hierarchy.getDefaultHierarchy().getLoggerFor("jmeter.protocol.http");
-
+ "Non HTTP response message";
+ private static Logger log =
+ Hierarchy.getDefaultHierarchy().getLoggerFor("jmeter.protocol.http");
/****************************************
* Holds a list of URLs sampled - so we're not flooding stdout with debug
* information
***************************************/
private ArrayList m_sampledURLs = new ArrayList();
-
/****************************************
* Constructor for the HTTPSampler object
***************************************/
- public HTTPSampler() {
+ public HTTPSampler()
+ {
setArguments(new Arguments());
}
-
public HTTPSampler(URL u)
{
setMethod(GET);
@@ -401,7 +363,6 @@
setUseKeepAlive(true);
setArguments(new Arguments());
}
-
/****************************************
* Do a sampling and return its results.
*
@@ -414,12 +375,10 @@
{
return sample(false);
}
-
public SampleResult sample()
{
return sample(false);
}
-
/**
* !ToDoo (Method description)
*
@@ -429,10 +388,10 @@
public URL getUrl() throws MalformedURLException
{
String pathAndQuery = null;
-
- if (this.getMethod().equals(HTTPSampler.GET) &&
getQueryString().length() > 0)
+ if (this.getMethod().equals(HTTPSampler.GET)
+ && getQueryString().length() > 0)
{
- if(this.getPath().indexOf("?") > -1)
+ if (this.getPath().indexOf("?") > -1)
{
pathAndQuery = this.getPath() + "&" + getQueryString();
}
@@ -445,23 +404,23 @@
{
pathAndQuery = this.getPath();
}
-
if (!pathAndQuery.startsWith("/"))
{
pathAndQuery = "/" + pathAndQuery;
}
-
if (getPort() == 0)
{
return new URL(getProtocol(), getDomain(), pathAndQuery);
}
else
{
- return new URL(getProtocol(), (String)
getProperty(HTTPSampler.DOMAIN), getPort(),
- pathAndQuery);
+ return new URL(
+ getProtocol(),
+ (String) getProperty(HTTPSampler.DOMAIN),
+ getPort(),
+ pathAndQuery);
}
}
-
/**
* Gets the QueryString attribute of the UrlConfig object
*
@@ -484,10 +443,11 @@
first = false;
}
buf.append(item.getEncodedName());
- if ( item.getMetaData() == null) {
- buf.append("=");
- }
- else
+ if (item.getMetaData() == null)
+ {
+ buf.append("=");
+ }
+ else
{
buf.append(item.getMetaData());
}
@@ -495,7 +455,6 @@
}
return buf.toString();
}
-
/****************************************
* Send POST data from <code>Entry</code> to the open connection.
*
@@ -504,12 +463,10 @@
*@param url contains the query string for POST
*@exception IOException if an I/O exception occurs
***************************************/
- public void sendPostData(URLConnection connection)
- throws IOException
+ public void sendPostData(URLConnection connection) throws IOException
{
- postWriter.sendPostData(connection,this);
+ postWriter.sendPostData(connection, this);
}
-
/****************************************
* Returns a <code>HttpURLConnection</code> with request method(GET or POST),
* headers, cookies, authorization properly set for the URL request
@@ -519,14 +476,24 @@
*@return <code>HttpURLConnection</code> of the URL request
*@exception IOException if an I/O Exception occurs
***************************************/
- protected HttpURLConnection setupConnection(URL u,String method) throws
IOException
+ protected HttpURLConnection setupConnection(URL u, String method)
+ throws IOException
{
HttpURLConnection conn;
- conn = (HttpURLConnection)u.openConnection();
+ conn = (HttpURLConnection) u.openConnection();
// delegate SSL specific stuff to SSLManager so that compilation still
works otherwise.
- if("https".equals(u.getProtocol()))
+ if ("https".equals(u.getProtocol()))
{
- SSLManager.getInstance().setContext(conn);
+ try
+ {
+ SSLManager.getInstance().setContext(conn);
+ }
+ catch (Exception e)
+ {
+ log.warn(
+ "You may have forgotten to set the
ssl.provider property in jmeter.properties",
+ e);
+ }
}
// [Jordi <[EMAIL PROTECTED]>]
// I've not been able to find out why we're not using this
@@ -556,14 +523,13 @@
setConnectionAuthorization(conn, u, getAuthManager());
return conn;
}
-
- //Mark Walsh 2002-08-03, modified to also parse a parameter name value
- //string, where string contains only the parameter name and no equal sign.
+ //Mark Walsh 2002-08-03, modified to also parse a parameter name value
+ //string, where string contains only the parameter name and no equal sign.
/**
* This method allows a proxy server to send over the raw text from a browser's
* output stream to be parsed and stored correctly into the UrlConfig object.
*/
- public void parseArguments(String queryString)
+ public void parseArguments(String queryString)
{
String[] args = JMeterUtils.split(queryString, "&");
for (int i = 0; i < args.length; i++)
@@ -573,38 +539,38 @@
// string contains name
// empty string
// find end of parameter name
- int endOfNameIndex=0;
+ int endOfNameIndex = 0;
String metaData = ""; // records the existance of an equal sign
- if (args[i].indexOf("=") != -1)
+ if (args[i].indexOf("=") != -1)
{
endOfNameIndex = args[i].indexOf("="); // case of
name=value, name=
- metaData="=";
- }
- else
- {
- metaData="";
- if (args[i].length() > 0)
+ metaData = "=";
+ }
+ else
+ {
+ metaData = "";
+ if (args[i].length() > 0)
{
- endOfNameIndex = args[i].length() ; // case
name
- }
- else
+ endOfNameIndex = args[i].length(); // case name
+ }
+ else
{
- endOfNameIndex=0; //case where name value
string is empty
+ endOfNameIndex = 0; //case where name value
string is empty
}
}
- // parse name
- String name=""; // for empty string
- if (args[i].length() >0) {
- name = args[i].substring(0,endOfNameIndex); //for non empty
string
- }
-
- // parse value
- String value="";
- if ((endOfNameIndex+1) < args[i].length()) {
- value = args[i].substring(endOfNameIndex+1,args[i].length());
- }
-
- if (name.length() > 0)
+ // parse name
+ String name = ""; // for empty string
+ if (args[i].length() > 0)
+ {
+ name = args[i].substring(0, endOfNameIndex); //for non
empty string
+ }
+ // parse value
+ String value = "";
+ if ((endOfNameIndex + 1) < args[i].length())
+ {
+ value = args[i].substring(endOfNameIndex + 1,
args[i].length());
+ }
+ if (name.length() > 0)
{
// In JDK 1.2, the decode() method has a throws clause:
// "throws Exception". In JDK 1.3, the method does not
have
@@ -612,17 +578,21 @@
// we need to add a try/catch around the method call.
try
{
- addEncodedArgument(name,value, metaData);
+ addEncodedArgument(name, value, metaData);
}
catch (Exception e)
{
- log.error("UrlConfig:parseArguments(): Unable
to parse argument=[" + value + "]");
- log.error("UrlConfig:parseArguments():
queryString=[" + queryString + "]",e);
+ log.error(
+ "UrlConfig:parseArguments(): Unable to
parse argument=["
+ + value
+ + "]");
+ log.error(
+ "UrlConfig:parseArguments():
queryString=[" + queryString + "]",
+ e);
}
}
}
}
-
/****************************************
* Reads the response from the URL connection
*
@@ -638,13 +608,13 @@
{
in = new BufferedInputStream(conn.getInputStream());
}
- catch(Exception e)
+ catch (Exception e)
{
in = new BufferedInputStream(conn.getErrorStream());
}
java.io.ByteArrayOutputStream w = new ByteArrayOutputStream();
int x = 0;
- while((x = in.read(buffer)) > -1)
+ while ((x = in.read(buffer)) > -1)
{
w.write(buffer, 0, x);
}
@@ -653,7 +623,6 @@
w.close();
return w.toByteArray();
}
-
/****************************************
* Gets the ResponseHeaders from the URLConnection, save them to the
* SampleResults object.
@@ -661,11 +630,11 @@
*@param conn connection from which the headers are read
*@param res where the headers read are stored
***************************************/
- protected byte[] getResponseHeaders(HttpURLConnection conn, SampleResult res)
throws IOException
+ protected byte[] getResponseHeaders(HttpURLConnection conn, SampleResult res)
+ throws IOException
{
StringBuffer headerBuf = new StringBuffer();
//PrintWriter headerBytes = new PrintWriter(output);
-
// either 'HTTP/1.0' or 'HTTP/1.1'
headerBuf.append(conn.getHeaderField(0).substring(0, 8));
headerBuf.append(" ");
@@ -673,9 +642,9 @@
headerBuf.append(" ");
headerBuf.append(conn.getResponseMessage());
headerBuf.append("\n");
- for(int i = 1; conn.getHeaderFieldKey(i) != null; i++)
+ for (int i = 1; conn.getHeaderFieldKey(i) != null; i++)
{
-
if(!conn.getHeaderFieldKey(i).equalsIgnoreCase("transfer-encoding"))
+ if
(!conn.getHeaderFieldKey(i).equalsIgnoreCase("transfer-encoding"))
{
headerBuf.append(conn.getHeaderFieldKey(i));
headerBuf.append(": ");
@@ -686,7 +655,6 @@
headerBuf.append("\n");
return headerBuf.toString().getBytes("8859_1");
}
-
/*
* Uploading a file - put in separate sampler
* else if (contentType.equals(MULTIPART_FORM))
@@ -705,18 +673,20 @@
*@param cookieManager the <code>CookieManager</code> containing all the
* cookies for this <code>UrlConfig</code>
***************************************/
- private void setConnectionCookie(HttpURLConnection conn, URL u, CookieManager
cookieManager)
+ private void setConnectionCookie(
+ HttpURLConnection conn,
+ URL u,
+ CookieManager cookieManager)
{
- if(cookieManager != null)
+ if (cookieManager != null)
{
String cookieHeader = cookieManager.getCookieHeaderForURL(u);
- if(cookieHeader != null)
+ if (cookieHeader != null)
{
conn.setRequestProperty("Cookie", cookieHeader);
}
}
}
-
/****************************************
* Extracts all the required headers for that particular URL request and set
* them in the <code>HttpURLConnection</code> passed in
@@ -727,23 +697,25 @@
*@param headerManager the <code>HeaderManager</code> containing all the
* cookies for this <code>UrlConfig</code>
***************************************/
- private void setConnectionHeaders(HttpURLConnection conn, URL u, HeaderManager
headerManager)
+ private void setConnectionHeaders(
+ HttpURLConnection conn,
+ URL u,
+ HeaderManager headerManager)
{
- if(headerManager != null)
+ if (headerManager != null)
{
Collection headers = headerManager.getHeaders();
- if(headers != null)
+ if (headers != null)
{
Iterator i = headers.iterator();
- while(i.hasNext())
+ while (i.hasNext())
{
- Header header = (Header)i.next();
+ Header header = (Header) i.next();
conn.setRequestProperty(header.getName(),
header.getValue());
}
}
}
}
-
/****************************************
* Extracts all the required authorization for that particular URL request and
* set them in the <code>HttpURLConnection</code> passed in
@@ -754,18 +726,20 @@
*@param authManager the <code>AuthManager</code> containing all the cookies
* for this <code>UrlConfig</code>
***************************************/
- private void setConnectionAuthorization(HttpURLConnection conn, URL u,
AuthManager authManager)
+ private void setConnectionAuthorization(
+ HttpURLConnection conn,
+ URL u,
+ AuthManager authManager)
{
- if(authManager != null)
+ if (authManager != null)
{
String authHeader = authManager.getAuthHeaderForURL(u);
- if(authHeader != null)
+ if (authHeader != null)
{
conn.setRequestProperty("Authorization", authHeader);
}
}
}
-
/****************************************
* Get the response code of the URL connection and divide it by 100 thus
* returning 2(for 2xx response codes), 3(for 3xx reponse codes), etc
@@ -775,22 +749,24 @@
*@param time time when the URL request was first started
*@return HTTP response code divided by 100
***************************************/
- private int getErrorLevel(HttpURLConnection conn, SampleResult res, long time)
throws IOException
+ private int getErrorLevel(
+ HttpURLConnection conn,
+ SampleResult res,
+ long time)
+ throws IOException
{
int errorLevel = 200;
String message = null;
- errorLevel = ((HttpURLConnection)conn).getResponseCode();
- message = ((HttpURLConnection)conn).getResponseMessage();
+ errorLevel = ((HttpURLConnection) conn).getResponseCode();
+ message = ((HttpURLConnection) conn).getResponseMessage();
res.setResponseCode(String.valueOf(errorLevel));
res.setResponseMessage(message);
return errorLevel;
}
-
public void removeArguments()
{
- setProperty(HTTPSampler.ARGUMENTS,new Arguments());
+ setProperty(HTTPSampler.ARGUMENTS, new Arguments());
}
-
/****************************************
* Follow redirection manually. Normally if the web server does a redirection
* the intermediate page is not returned. Only the resultant page and the
@@ -804,23 +780,26 @@
*@param urlConfig !ToDo (Parameter description)
*@exception MalformedURLException if URL is not understood
***************************************/
- private void redirectUrl(HttpURLConnection conn, URL u) throws
MalformedURLException
+ private void redirectUrl(HttpURLConnection conn, URL u)
+ throws MalformedURLException
{
String loc = conn.getHeaderField("Location");
- if(loc != null)
+ if (loc != null)
{
- if(loc.indexOf("http") == -1)
+ if (loc.indexOf("http") == -1)
{
String tempURL = u.toString();
- if(loc.startsWith("/"))
+ if (loc.startsWith("/"))
{
int ind = tempURL.indexOf("//") + 2;
- loc = tempURL.substring(0,
tempURL.indexOf("/", ind) + 1) + loc.substring(1);
+ loc =
+ tempURL.substring(0,
tempURL.indexOf("/", ind) + 1)
+ + loc.substring(1);
}
else
{
- loc = u.toString().substring(0,
- u.toString().lastIndexOf('/')
+ 1) + loc;
+ loc =
+ u.toString().substring(0,
u.toString().lastIndexOf('/') + 1) + loc;
}
}
}
@@ -831,7 +810,6 @@
removeArguments();
parseArguments(newUrl.getQuery());
}
-
/****************************************
* Samples <code>Entry</code> passed in and stores the result in
<code>SampleResult</code>
*
@@ -844,7 +822,7 @@
log.debug("Start : sample2");
long time = 0L;
SampleResult res = new SampleResult();
- if(redirected)
+ if (redirected)
{
//url.removeArguments();
// [Jordi <[EMAIL PROTECTED]>
@@ -862,16 +840,14 @@
res.setSampleLabel(getName());
// specify the data to the result.
res.setSamplerData(this);
-
/****************************************
* END - cached logging hack
***************************************/
-
- if(log.isDebugEnabled())
+ if (log.isDebugEnabled())
{
log.debug("sample2 : sampling url - " + u);
}
- conn = setupConnection(u,getMethod());
+ conn = setupConnection(u, getMethod());
// [Jordi <[EMAIL PROTECTED]>]
// There's some illegality here... see my comment in
sendPostData.
// Also, we don't seem to be including the time needed to send
the POST
@@ -879,61 +855,62 @@
// TO-DO: Is there something I'm missing here?
// [/Jordi]
time = System.currentTimeMillis();
- if(!redirected &&
- getProperty(HTTPSampler.METHOD).equals(HTTPSampler.POST))
+ if (!redirected
+ &&
getProperty(HTTPSampler.METHOD).equals(HTTPSampler.POST))
{
sendPostData(conn);
}
conn.connect();
saveConnectionCookies(conn, u, getCookieManager());
-
int errorLevel = 0;
try
{
errorLevel = getErrorLevel(conn, res, time);
}
- catch(IOException e)
+ catch (IOException e)
{
res.setSuccessful(false);
- time = bundleResponseInResult(time,res,conn);
+ time = bundleResponseInResult(time, res, conn);
return res;
- }
- if(errorLevel/100 == 2 || errorLevel == 304)
+ }
+ if (errorLevel / 100 == 2 || errorLevel == 304)
{
time = bundleResponseInResult(time, res, conn);
}
- else if(errorLevel/100 == 3)
+ else if (errorLevel / 100 == 3)
{
- if(redirected || !getFollowRedirects())
+ if (redirected || !getFollowRedirects())
{
- time = bundleResponseInResult(time,res,conn);
+ time = bundleResponseInResult(time, res, conn);
}
else
{
redirectUrl(conn, u);
-
time = System.currentTimeMillis() - time;
res = sample(true);
- time += res.getTime();
+ time += res.getTime();
}
}
else
{
// Could not sample the URL
- time = bundleResponseInResult(time,res,conn);
+ time = bundleResponseInResult(time, res, conn);
res.setSuccessful(false);
}
res.setTime(time);
log.debug("End : sample2");
return res;
}
- catch(IOException ex)
+ catch (IOException ex)
{
- log.error("",ex);
+ log.error("", ex);
res.setDataType(res.TEXT);
- try {
+ try
+ {
res.setResponseData(readResponse(conn));
- } catch (IOException e) {
+ }
+ catch (IOException e)
+ {
res.setResponseData(ex.toString().getBytes());
}
res.setResponseCode(NON_HTTP_RESPONSE_CODE);
@@ -945,36 +922,36 @@
{
try
{
- // the server can request that the connection be
closed,
- // but if we requested that the server close the
connection
- // the server should echo back our 'close' request.
- // Otherwise, let the server disconnect the connection
- // when its timout period is reached.
- String connection = conn.getHeaderField("Connection");
- if (connection == null ||
connection.equalsIgnoreCase("close"))
+ // calling disconnect doesn't close the connection
immediately, but
+ // indicates we're through with it. The JVM should
close it when
+ // necessary.
+ if (conn != null)
conn.disconnect();
}
- catch(Exception e){}
+ catch (Exception e)
+ {
+ }
}
log.debug("End : sample2");
return res;
}
-
- private long bundleResponseInResult(long time, SampleResult
- res, HttpURLConnection conn) throws IOException,
- FileNotFoundException {
+ private long bundleResponseInResult(
+ long time,
+ SampleResult res,
+ HttpURLConnection conn)
+ throws IOException, FileNotFoundException
+ {
byte[] ret = readResponse(conn);
byte[] head = getResponseHeaders(conn, res);
time = System.currentTimeMillis() - time;
- byte[] complete = new byte[ret.length+head.length];
- System.arraycopy(head,0,complete,0,head.length);
- System.arraycopy(ret,0,complete,head.length,ret.length);
+ byte[] complete = new byte[ret.length + head.length];
+ System.arraycopy(head, 0, complete, 0, head.length);
+ System.arraycopy(ret, 0, complete, head.length, ret.length);
res.setResponseData(complete);
res.setSuccessful(true);
res.setDataType(res.TEXT);
return time;
}
-
/****************************************
* From the <code>HttpURLConnection</code>, store all the "set-cookie" key-pair
* values in the cookieManager of the <code>UrlConfig</code>
@@ -985,149 +962,161 @@
*@param cookieManager the <code>CookieManager</code> containing all the
* cookies for this <code>UrlConfig</code>
***************************************/
- private void saveConnectionCookies(HttpURLConnection conn, URL u,
CookieManager cookieManager)
+ private void saveConnectionCookies(
+ HttpURLConnection conn,
+ URL u,
+ CookieManager cookieManager)
{
- if(cookieManager != null)
+ if (cookieManager != null)
{
- for(int i = 1; conn.getHeaderFieldKey(i) != null; i++)
+ for (int i = 1; conn.getHeaderFieldKey(i) != null; i++)
{
-
if(conn.getHeaderFieldKey(i).equalsIgnoreCase("set-cookie"))
+ if
(conn.getHeaderFieldKey(i).equalsIgnoreCase("set-cookie"))
{
cookieManager.addCookieFromHeader(conn.getHeaderField(i), u);
}
}
}
}
-
public String toString()
{
- try {
- return this.getUrl().toString()+((POST.equals(getMethod())) ?
- "\nQuery Data: "+getQueryString() : "");
- } catch(MalformedURLException e) {
+ try
+ {
+ return this.getUrl().toString()
+ + ((POST.equals(getMethod())) ? "\nQuery Data: " +
getQueryString() : "");
+ }
+ catch (MalformedURLException e)
+ {
return "";
}
}
-
public static class Test extends junit.framework.TestCase
{
public Test(String name)
{
super(name);
}
-
public void testMakingUrl() throws Exception
{
HTTPSampler config = new HTTPSampler();
config.setProtocol("http");
config.setMethod(HTTPSampler.GET);
- config.addArgument("param1","value1");
+ config.addArgument("param1", "value1");
config.setPath("/index.html");
config.setDomain("www.apache.org");
-
assertEquals("http://www.apache.org:80/index.html?param1=value1",config.getUrl().toString());
+ assertEquals(
+ "http://www.apache.org:80/index.html?param1=value1",
+ config.getUrl().toString());
}
-
public void testMakingUrl2() throws Exception
{
HTTPSampler config = new HTTPSampler();
config.setProtocol("http");
config.setMethod(HTTPSampler.GET);
- config.addArgument("param1","value1");
+ config.addArgument("param1", "value1");
config.setPath("/index.html?p1=p2");
config.setDomain("www.apache.org");
-
assertEquals("http://www.apache.org:80/index.html?param1=value1&p1=p2",config.getUrl().toString());
+ assertEquals(
+
"http://www.apache.org:80/index.html?param1=value1&p1=p2",
+ config.getUrl().toString());
}
-
public void testMakingUrl3() throws Exception
{
HTTPSampler config = new HTTPSampler();
config.setProtocol("http");
config.setMethod(HTTPSampler.POST);
- config.addArgument("param1","value1");
+ config.addArgument("param1", "value1");
config.setPath("/index.html?p1=p2");
config.setDomain("www.apache.org");
-
assertEquals("http://www.apache.org:80/index.html?p1=p2",config.getUrl().toString());
+ assertEquals(
+ "http://www.apache.org:80/index.html?p1=p2",
+ config.getUrl().toString());
}
-
- // test cases for making Url, and exercise method addArgument(String
name,String value,String metadata)
+ // test cases for making Url, and exercise method addArgument(String
name,String value,String metadata)
public void testMakingUrl4() throws Exception
{
HTTPSampler config = new HTTPSampler();
config.setProtocol("http");
config.setMethod(HTTPSampler.GET);
- config.addArgument("param1","value1","=");
+ config.addArgument("param1", "value1", "=");
config.setPath("/index.html");
config.setDomain("www.apache.org");
-
assertEquals("http://www.apache.org:80/index.html?param1=value1",config.getUrl().toString());
+ assertEquals(
+ "http://www.apache.org:80/index.html?param1=value1",
+ config.getUrl().toString());
}
-
public void testMakingUrl5() throws Exception
{
HTTPSampler config = new HTTPSampler();
config.setProtocol("http");
config.setMethod(HTTPSampler.GET);
- config.addArgument("param1","","=");
+ config.addArgument("param1", "", "=");
config.setPath("/index.html");
config.setDomain("www.apache.org");
-
assertEquals("http://www.apache.org:80/index.html?param1=",config.getUrl().toString());
+ assertEquals(
+ "http://www.apache.org:80/index.html?param1=",
+ config.getUrl().toString());
}
-
public void testMakingUrl6() throws Exception
{
HTTPSampler config = new HTTPSampler();
config.setProtocol("http");
config.setMethod(HTTPSampler.GET);
- config.addArgument("param1","","");
+ config.addArgument("param1", "", "");
config.setPath("/index.html");
config.setDomain("www.apache.org");
-
assertEquals("http://www.apache.org:80/index.html?param1",config.getUrl().toString());
+ assertEquals(
+ "http://www.apache.org:80/index.html?param1",
+ config.getUrl().toString());
}
-
- // test cases for making Url, and exercise method
parseArguments(String queryString)
+ // test cases for making Url, and exercise method
parseArguments(String queryString)
public void testMakingUrl7() throws Exception
{
HTTPSampler config = new HTTPSampler();
config.setProtocol("http");
config.setMethod(HTTPSampler.GET);
- config. parseArguments("param1=value1");
+ config.parseArguments("param1=value1");
config.setPath("/index.html");
config.setDomain("www.apache.org");
-
assertEquals("http://www.apache.org:80/index.html?param1=value1",config.getUrl().toString());
+ assertEquals(
+ "http://www.apache.org:80/index.html?param1=value1",
+ config.getUrl().toString());
}
-
public void testMakingUrl8() throws Exception
{
HTTPSampler config = new HTTPSampler();
config.setProtocol("http");
config.setMethod(HTTPSampler.GET);
- config. parseArguments("param1=");
+ config.parseArguments("param1=");
config.setPath("/index.html");
config.setDomain("www.apache.org");
-
assertEquals("http://www.apache.org:80/index.html?param1=",config.getUrl().toString());
+ assertEquals(
+ "http://www.apache.org:80/index.html?param1=",
+ config.getUrl().toString());
}
-
public void testMakingUrl9() throws Exception
{
HTTPSampler config = new HTTPSampler();
config.setProtocol("http");
config.setMethod(HTTPSampler.GET);
- config. parseArguments("param1");
+ config.parseArguments("param1");
config.setPath("/index.html");
config.setDomain("www.apache.org");
-
assertEquals("http://www.apache.org:80/index.html?param1",config.getUrl().toString());
+ assertEquals(
+ "http://www.apache.org:80/index.html?param1",
+ config.getUrl().toString());
}
-
public void testMakingUrl10() throws Exception
{
HTTPSampler config = new HTTPSampler();
config.setProtocol("http");
config.setMethod(HTTPSampler.GET);
- config. parseArguments("");
+ config.parseArguments("");
config.setPath("/index.html");
config.setDomain("www.apache.org");
-
assertEquals("http://www.apache.org:80/index.html",config.getUrl().toString());
+ assertEquals(
+ "http://www.apache.org:80/index.html",
+ config.getUrl().toString());
}
-
}
-
}
--
To unsubscribe, e-mail: <mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>