mirror of https://github.com/apache/jmeter.git
Enhance PowerTableModel to support header resource names; use this to fix locale changes in Proxy, Response Assertion, Cookie Manager
git-svn-id: https://svn.apache.org/repos/asf/jakarta/jmeter/trunk@713239 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
24022e90fc
commit
6968d61eec
|
|
@ -47,7 +47,8 @@ import org.apache.jmeter.util.JMeterUtils;
|
|||
*/
|
||||
public class AssertionGui extends AbstractAssertionGui {
|
||||
/** The name of the table column in the list of patterns. */
|
||||
private static final String COL_NAME = JMeterUtils.getResString("assertion_patterns_to_test"); //$NON-NLS-1$
|
||||
|
||||
private static final String COL_RESOURCE_NAME = "assertion_patterns_to_test"; //$NON-NLS-1$
|
||||
|
||||
/** Radio button indicating that the text response should be tested. */
|
||||
private JRadioButton responseStringButton;
|
||||
|
|
@ -137,7 +138,7 @@ public class AssertionGui extends AbstractAssertionGui {
|
|||
saveScopeSettings(ra);
|
||||
|
||||
ra.clearTestStrings();
|
||||
String[] testStrings = tableModel.getData().getColumn(COL_NAME);
|
||||
String[] testStrings = tableModel.getData().getColumn(COL_RESOURCE_NAME);
|
||||
for (int i = 0; i < testStrings.length; i++) {
|
||||
ra.addTestString(testStrings[i]);
|
||||
}
|
||||
|
|
@ -345,7 +346,7 @@ public class AssertionGui extends AbstractAssertionGui {
|
|||
* @return a new panel for adding string patterns
|
||||
*/
|
||||
private JPanel createStringPanel() {
|
||||
tableModel = new PowerTableModel(new String[] { COL_NAME }, new Class[] { String.class });
|
||||
tableModel = new PowerTableModel(new String[] { COL_RESOURCE_NAME }, new Class[] { String.class }, true);
|
||||
stringTable = new JTable(tableModel);
|
||||
|
||||
TextAreaCellRenderer renderer = new TextAreaCellRenderer();
|
||||
|
|
|
|||
|
|
@ -24,6 +24,7 @@ import java.util.List;
|
|||
|
||||
import javax.swing.table.DefaultTableModel;
|
||||
|
||||
import org.apache.jmeter.util.JMeterUtils;
|
||||
import org.apache.jorphan.collections.Data;
|
||||
import org.apache.jorphan.logging.LoggingManager;
|
||||
import org.apache.log.Logger;
|
||||
|
|
@ -31,19 +32,39 @@ import org.apache.log.Logger;
|
|||
public class PowerTableModel extends DefaultTableModel {
|
||||
private static final Logger log = LoggingManager.getLoggerForClass();
|
||||
|
||||
Data model = new Data();
|
||||
private Data model = new Data();
|
||||
|
||||
Class[] columnClasses;
|
||||
private Class[] columnClasses;
|
||||
|
||||
public PowerTableModel(String[] headers, Class[] cc) {
|
||||
if (headers.length != cc.length){
|
||||
throw new IllegalArgumentException("Header and column array sizes differ");
|
||||
}
|
||||
model.setHeaders(headers);
|
||||
columnClasses = cc;
|
||||
private final boolean headersAreResouceNames;
|
||||
|
||||
/**
|
||||
* Define a table with fixed headers.
|
||||
*
|
||||
* @param headers list of header names
|
||||
* @param columnClasses list of column classes
|
||||
*/
|
||||
public PowerTableModel(String[] headers, Class[] columnClasses) {
|
||||
this(headers, columnClasses, false);
|
||||
}
|
||||
|
||||
public PowerTableModel() {
|
||||
/**
|
||||
* Define a table with header names that can be locale-sensitive.
|
||||
* If the useAsResourceNames parameter is true, then the header
|
||||
* values are assumed to be resource names when generating the column headings.
|
||||
* The column names in the data table are not translated.
|
||||
*
|
||||
* @param headers list of header names
|
||||
* @param columnClasses list of column classes
|
||||
* @param useAsResourceNames set true to use the headers as resource names
|
||||
*/
|
||||
public PowerTableModel(String[] headers, Class[] columnClasses, boolean useAsResourceNames) {
|
||||
if (headers.length != columnClasses.length){
|
||||
throw new IllegalArgumentException("Header and column array sizes differ");
|
||||
}
|
||||
this.model.setHeaders(headers);
|
||||
this.columnClasses = columnClasses;
|
||||
this.headersAreResouceNames = useAsResourceNames;
|
||||
}
|
||||
|
||||
public void setRowValues(int row, Object[] values) {
|
||||
|
|
@ -237,7 +258,11 @@ public class PowerTableModel extends DefaultTableModel {
|
|||
* @return the ColumnName value
|
||||
*/
|
||||
public String getColumnName(int column) {
|
||||
return model.getHeaders()[column];
|
||||
String rawName = model.getHeaders()[column];
|
||||
if (headersAreResouceNames){
|
||||
return JMeterUtils.getResString(rawName);
|
||||
}
|
||||
return rawName;
|
||||
}
|
||||
|
||||
public boolean isCellEditable(int row, int column) {
|
||||
|
|
|
|||
|
|
@ -59,6 +59,7 @@ public class CookiePanel extends AbstractConfigGui implements ActionListener {
|
|||
|
||||
private static final Logger log = LoggingManager.getLoggerForClass();
|
||||
|
||||
//++ Action command names
|
||||
private static final String ADD_COMMAND = "Add"; //$NON-NLS-1$
|
||||
|
||||
private static final String DELETE_COMMAND = "Delete"; //$NON-NLS-1$
|
||||
|
|
@ -66,6 +67,7 @@ public class CookiePanel extends AbstractConfigGui implements ActionListener {
|
|||
private static final String LOAD_COMMAND = "Load"; //$NON-NLS-1$
|
||||
|
||||
private static final String SAVE_COMMAND = "Save"; //$NON-NLS-1$
|
||||
//--
|
||||
|
||||
private JTable cookieTable;
|
||||
|
||||
|
|
@ -73,14 +75,12 @@ public class CookiePanel extends AbstractConfigGui implements ActionListener {
|
|||
|
||||
private JCheckBox clearEachIteration;
|
||||
|
||||
private static final String clearEachIterationLabel = "clear_cookies_per_iter"; //$NON-NLS-1$
|
||||
|
||||
private static final String[] columnNames = {
|
||||
JMeterUtils.getResString("name"), //$NON-NLS-1$
|
||||
JMeterUtils.getResString("value"), //$NON-NLS-1$
|
||||
JMeterUtils.getResString("domain"), //$NON-NLS-1$
|
||||
JMeterUtils.getResString("path"), //$NON-NLS-1$
|
||||
JMeterUtils.getResString("secure"), //$NON-NLS-1$
|
||||
private static final String[] COLUMN_RESOURCE_NAMES = {
|
||||
("name"), //$NON-NLS-1$
|
||||
("value"), //$NON-NLS-1$
|
||||
("domain"), //$NON-NLS-1$
|
||||
("path"), //$NON-NLS-1$
|
||||
("secure"), //$NON-NLS-1$
|
||||
// removed expiration because it's just an annoyance for static cookies
|
||||
};
|
||||
|
||||
|
|
@ -292,8 +292,9 @@ public class CookiePanel extends AbstractConfigGui implements ActionListener {
|
|||
* Shows the main cookie configuration panel.
|
||||
*/
|
||||
private void init() {
|
||||
tableModel = new PowerTableModel(columnNames, columnClasses);
|
||||
clearEachIteration = new JCheckBox(JMeterUtils.getResString(clearEachIterationLabel), false);
|
||||
tableModel = new PowerTableModel(COLUMN_RESOURCE_NAMES, columnClasses, true);
|
||||
clearEachIteration =
|
||||
new JCheckBox(JMeterUtils.getResString("clear_cookies_per_iter"), false); //$NON-NLS-1$
|
||||
policy = new JLabeledChoice(
|
||||
JMeterUtils.getResString("cookie_manager_policy"), //$NON-NLS-1$
|
||||
policies);
|
||||
|
|
|
|||
|
|
@ -178,9 +178,10 @@ public class ProxyControlGui extends LogicControllerGui implements JMeterGUIComp
|
|||
private static final String DELETE_EXCLUDE = "delete_exclude"; // $NON-NLS-1$
|
||||
//- action names
|
||||
|
||||
private static final String INCLUDE_COL = JMeterUtils.getResString("patterns_to_include"); // $NON-NLS-1$
|
||||
// Resource names for column headers
|
||||
private static final String INCLUDE_COL = "patterns_to_include"; // $NON-NLS-1$
|
||||
|
||||
private static final String EXCLUDE_COL = JMeterUtils.getResString("patterns_to_exclude"); // $NON-NLS-1$
|
||||
private static final String EXCLUDE_COL = "patterns_to_exclude"; // $NON-NLS-1$
|
||||
|
||||
// Used by itemListener
|
||||
private static final String PORTFIELD = "portField"; // $NON-NLS-1$
|
||||
|
|
@ -690,7 +691,7 @@ public class ProxyControlGui extends LogicControllerGui implements JMeterGUIComp
|
|||
}
|
||||
|
||||
private JPanel createIncludePanel() {
|
||||
includeModel = new PowerTableModel(new String[] { INCLUDE_COL }, new Class[] { String.class });
|
||||
includeModel = new PowerTableModel(new String[] { INCLUDE_COL }, new Class[] { String.class }, true);
|
||||
includeTable = new JTable(includeModel);
|
||||
includeTable.setPreferredScrollableViewportSize(new Dimension(100, 30));
|
||||
|
||||
|
|
@ -705,7 +706,7 @@ public class ProxyControlGui extends LogicControllerGui implements JMeterGUIComp
|
|||
}
|
||||
|
||||
private JPanel createExcludePanel() {
|
||||
excludeModel = new PowerTableModel(new String[] { EXCLUDE_COL }, new Class[] { String.class });
|
||||
excludeModel = new PowerTableModel(new String[] { EXCLUDE_COL }, new Class[] { String.class }, true);
|
||||
excludeTable = new JTable(excludeModel);
|
||||
excludeTable.setPreferredScrollableViewportSize(new Dimension(100, 30));
|
||||
|
||||
|
|
|
|||
|
|
@ -164,6 +164,7 @@ These are implemented in the AbstractTestElement class which all elements should
|
|||
<li>Bug 44941 - Throughput controllers should not share global counters</li>
|
||||
<li>Various ReceiveSubscriber thread-safety fixes</li>
|
||||
<li>JMSPublisher and Subscriber fixes: thread-safety, support dynamic locale changes, locale independence for JMX attribute values</li>
|
||||
<li>Enhance PowerTableModel to support header resource names; use this to fix locale changes in Proxy, Response Assertion, Cookie Manager</li>
|
||||
</ul>
|
||||
|
||||
<h3>Improvements</h3>
|
||||
|
|
|
|||
Loading…
Reference in New Issue