Author: pmouawad
Date: Tue May 30 21:48:32 2017
New Revision: 1796949
URL: http://svn.apache.org/viewvc?rev=1796949&view=rev
Log:
Bug 61135 - CookieManager : Drop Implementation select box and cleanup class
Bugzilla Id: 61135
Modified:
jmeter/trunk/src/protocol/http/org/apache/jmeter/protocol/http/control/CookieManager.java
jmeter/trunk/src/protocol/http/org/apache/jmeter/protocol/http/gui/CookiePanel.java
jmeter/trunk/xdocs/changes.xml
Modified:
jmeter/trunk/src/protocol/http/org/apache/jmeter/protocol/http/control/CookieManager.java
URL:
http://svn.apache.org/viewvc/jmeter/trunk/src/protocol/http/org/apache/jmeter/protocol/http/control/CookieManager.java?rev=1796949&r1=1796948&r2=1796949&view=diff
==============================================================================
---
jmeter/trunk/src/protocol/http/org/apache/jmeter/protocol/http/control/CookieManager.java
(original)
+++
jmeter/trunk/src/protocol/http/org/apache/jmeter/protocol/http/control/CookieManager.java
Tue May 30 21:48:32 2017
@@ -103,10 +103,8 @@ public class CookieManager extends Confi
* The default policy for new CookieManager elements is defined by
* {@link org.apache.jmeter.protocol.http.gui.CookiePanel#DEFAULT_POLICY
CookiePanel#DEFAULT_POLICY}
*
- * @deprecated not intended for use outside this class (should have been
created private)
*/
- @Deprecated
- public static final String DEFAULT_POLICY =
CookieSpecs.BROWSER_COMPATIBILITY;
+ private static final String DEFAULT_POLICY = CookieSpecs.STANDARD;
/**
* Defines the implementation that is assumed when the JMX file does not
contain an entry for it
@@ -115,10 +113,8 @@ public class CookieManager extends Confi
* The default implementation for new CookieManager elements is defined by
* {@link
org.apache.jmeter.protocol.http.gui.CookiePanel#DEFAULT_IMPLEMENTATION
CookiePanel#DEFAULT_IMPLEMENTATION}
*
- * @deprecated not intended for use outside this class (should have been
created private)
*/
- @Deprecated
- public static final String DEFAULT_IMPLEMENTATION =
"org.apache.jmeter.protocol.http.control.HC3CookieHandler";
+ private static final String DEFAULT_IMPLEMENTATION =
HC4CookieHandler.class.getName();
public CookieManager() {
clearCookies(); // Ensure that there is always a collection available
Modified:
jmeter/trunk/src/protocol/http/org/apache/jmeter/protocol/http/gui/CookiePanel.java
URL:
http://svn.apache.org/viewvc/jmeter/trunk/src/protocol/http/org/apache/jmeter/protocol/http/gui/CookiePanel.java?rev=1796949&r1=1796948&r2=1796949&view=diff
==============================================================================
---
jmeter/trunk/src/protocol/http/org/apache/jmeter/protocol/http/gui/CookiePanel.java
(original)
+++
jmeter/trunk/src/protocol/http/org/apache/jmeter/protocol/http/gui/CookiePanel.java
Tue May 30 21:48:32 2017
@@ -24,23 +24,16 @@ import java.awt.FlowLayout;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.io.IOException;
-import java.util.Collections;
-import java.util.HashMap;
-import java.util.List;
import javax.swing.BorderFactory;
-import javax.swing.ComboBoxModel;
-import javax.swing.DefaultComboBoxModel;
import javax.swing.JButton;
import javax.swing.JCheckBox;
-import javax.swing.JComboBox;
import javax.swing.JFileChooser;
import javax.swing.JPanel;
import javax.swing.JScrollPane;
import javax.swing.JTable;
import javax.swing.ListSelectionModel;
-import org.apache.commons.lang3.ClassUtils;
import org.apache.jmeter.config.gui.AbstractConfigGui;
import org.apache.jmeter.gui.util.FileDialoger;
import org.apache.jmeter.gui.util.HeaderAsPropertyRenderer;
@@ -79,15 +72,7 @@ public class CookiePanel extends Abstrac
private static final String LOAD_COMMAND = "Load"; //$NON-NLS-1$
private static final String SAVE_COMMAND = "Save"; //$NON-NLS-1$
-
- private static final String HANDLER_COMMAND = "Handler"; // $NON-NLS-1$
//--
-
- /**
- * The default implementation that is used when creating a new
CookieManager
- */
- private static final String DEFAULT_IMPLEMENTATION =
HC4CookieHandler.class.getName();
-
/**
* The default policy that is used when creating a new CookieManager
*/
@@ -99,10 +84,6 @@ public class CookiePanel extends Abstrac
private JCheckBox clearEachIteration;
- private JComboBox<String> selectHandlerPanel;
-
- private HashMap<String, String> handlerMap = new HashMap<>();
-
private static final String[] COLUMN_RESOURCE_NAMES = {
"name", //$NON-NLS-1$
"value", //$NON-NLS-1$
@@ -215,38 +196,6 @@ public class CookiePanel extends Abstrac
} catch (IOException ex) {
JMeterUtils.reportErrorToUser(ex.getMessage(), "Error saving
cookies");
}
- } else if (action.equals(HANDLER_COMMAND)) {
- String cookieHandlerClass =
handlerMap.get(selectHandlerPanel.getSelectedItem());
- CookieHandler handlerImpl = getCookieHandler(cookieHandlerClass);
- policy.setValues(handlerImpl.getPolicies());
- policy.setText(handlerImpl.getDefaultPolicy());
- }
- }
-
- /**
- * @param cookieHandlerClass CookieHandler class name
- * @return {@link CookieHandler}
- */
- private static CookieHandler getCookieHandler(String cookieHandlerClass) {
- try {
- return (CookieHandler)
- ClassUtils.getClass(cookieHandlerClass).newInstance();
- } catch (Exception e) {
- log.error("Error creating implementation:"+cookieHandlerClass+ ",
will default to:"+DEFAULT_IMPLEMENTATION, e);
- return getCookieHandler(DEFAULT_IMPLEMENTATION);
- }
- }
-
- /**
- * @param className CookieHandler class name
- * @return cookie policies
- */
- private static String[] getPolicies(String className) {
- try {
- return getCookieHandler(className).getPolicies();
- } catch (Exception e) {
- log.error("Error getting cookie policies from
implementation:"+className, e);
- return getPolicies(DEFAULT_IMPLEMENTATION);
}
}
@@ -273,7 +222,6 @@ public class CookiePanel extends Abstrac
}
cookieManager.setClearEachIteration(clearEachIteration.isSelected());
cookieManager.setCookiePolicy(policy.getText());
-
cookieManager.setImplementation(handlerMap.get(selectHandlerPanel.getSelectedItem()));
}
}
@@ -286,8 +234,6 @@ public class CookiePanel extends Abstrac
tableModel.clearData();
clearEachIteration.setSelected(false);
- selectHandlerPanel.setSelectedItem(DEFAULT_IMPLEMENTATION
- .substring(DEFAULT_IMPLEMENTATION.lastIndexOf('.') + 1));
policy.setText(DEFAULT_POLICY);
configureButtonsState();
}
@@ -334,8 +280,6 @@ public class CookiePanel extends Abstrac
CookieManager cookieManager = (CookieManager) el;
populateTable(cookieManager);
clearEachIteration.setSelected((cookieManager).getClearEachIteration());
- String fullImpl = cookieManager.getImplementation();
-
selectHandlerPanel.setSelectedItem(fullImpl.substring(fullImpl.lastIndexOf('.')
+ 1));
// must set policy after setting handler (which may change the policy)
policy.setText(cookieManager.getPolicy());
}
@@ -349,7 +293,7 @@ public class CookiePanel extends Abstrac
new JCheckBox(JMeterUtils.getResString("clear_cookies_per_iter"),
false); //$NON-NLS-1$
policy = new JLabeledChoice(
JMeterUtils.getResString("cookie_manager_policy"),
//$NON-NLS-1$
- getPolicies(DEFAULT_IMPLEMENTATION));
+ new HC4CookieHandler().getPolicies());
setLayout(new BorderLayout());
setBorder(makeBorder());
JPanel northPanel = new JPanel();
@@ -363,8 +307,6 @@ public class CookiePanel extends Abstrac
optionsPane.add(clearEachIteration);
JPanel policyTypePane = new JPanel();
policyTypePane.setLayout(new FlowLayout(FlowLayout.LEFT, 0, 0));
- policyTypePane.add(GuiUtils.createLabelCombo(
- JMeterUtils.getResString("cookie_implementation_choose"),
createComboHandler())); // $NON-NLS-1$
policyTypePane.add(policy);
optionsPane.add(policyTypePane);
northPanel.add(optionsPane);
@@ -415,38 +357,4 @@ public class CookiePanel extends Abstrac
buttonPanel.add(saveButton);
return buttonPanel;
}
-
- /**
- * Create the drop-down list to changer render
- * @return List of all render (implement ResultsRender)
- */
- private JComboBox<String> createComboHandler() {
- ComboBoxModel<String> nodesModel = new DefaultComboBoxModel<>();
- // drop-down list for renderer
- selectHandlerPanel = new JComboBox<>(nodesModel);
- selectHandlerPanel.setActionCommand(HANDLER_COMMAND);
- selectHandlerPanel.addActionListener(this);
-
- // if no results render in jmeter.properties, load Standard (default)
- List<String> classesToAdd = Collections.emptyList();
- try {
- classesToAdd =
JMeterUtils.findClassesThatExtend(CookieHandler.class);
- } catch (IOException e1) {
- // ignored
- }
- String tmpName = null;
- for (String clazz : classesToAdd) {
- String shortClazz = clazz.substring(clazz.lastIndexOf('.') + 1);
- if (DEFAULT_IMPLEMENTATION.equals(clazz)) {
- tmpName = shortClazz;
- }
- handlerMap.put(shortClazz, clazz);
- }
- // Only add to selectHandlerPanel after handlerMap has been initialized
- for (String shortClazz : handlerMap.keySet()) {
- selectHandlerPanel.addItem(shortClazz);
- }
- nodesModel.setSelectedItem(tmpName); // preset to default impl
- return selectHandlerPanel;
- }
}
Modified: jmeter/trunk/xdocs/changes.xml
URL:
http://svn.apache.org/viewvc/jmeter/trunk/xdocs/changes.xml?rev=1796949&r1=1796948&r2=1796949&view=diff
==============================================================================
--- jmeter/trunk/xdocs/changes.xml [utf-8] (original)
+++ jmeter/trunk/xdocs/changes.xml [utf-8] Tue May 30 21:48:32 2017
@@ -77,6 +77,8 @@ Summary
<ch_section>Incompatible changes</ch_section>
<li>In InfluxDbBackendListenerClient, statut property has been renamed to
status</li>
+<li>In CookieManager, DEFAULT_IMPLEMENTATION and DEFAULT_IMPLEMENTATION
constants are now private.
+<note>If you're using ignorecookies with HC3CookieHandler (< JMeter 3.1)
configuration will be reset, ensure you put it back </note></li>
<h3>Removed elements or functions</h3>
<h3>Logging changes</h3>
@@ -88,6 +90,7 @@ Summary
<h3>HTTP Samplers and Test Script Recorder</h3>
<ul>
<li><bug>61056</bug>HTTP : Support brotli decoding</li>
+ <li><bug>61135</bug>CookieManager : Drop Implementation select box and
cleanup class</li>
</ul>
<h3>Other samplers</h3>