You are viewing a plain text version of this content. The canonical link for it is here.
Posted to jmeter-dev@jakarta.apache.org by se...@apache.org on 2008/07/06 22:28:50 UTC
svn commit: r674342 [2/3] - in
/jakarta/jmeter/trunk/src/components/org/apache/jmeter/assertions: ./ gui/
Modified: jakarta/jmeter/trunk/src/components/org/apache/jmeter/assertions/gui/AssertionGui.java
URL: http://svn.apache.org/viewvc/jakarta/jmeter/trunk/src/components/org/apache/jmeter/assertions/gui/AssertionGui.java?rev=674342&r1=674341&r2=674342&view=diff
==============================================================================
--- jakarta/jmeter/trunk/src/components/org/apache/jmeter/assertions/gui/AssertionGui.java (original)
+++ jakarta/jmeter/trunk/src/components/org/apache/jmeter/assertions/gui/AssertionGui.java Sun Jul 6 13:28:49 2008
@@ -46,46 +46,46 @@
*
*/
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$
+ /** 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$
- /** Radio button indicating that the text response should be tested. */
- private JRadioButton responseStringButton;
+ /** Radio button indicating that the text response should be tested. */
+ private JRadioButton responseStringButton;
- /** Radio button indicating that the URL should be tested. */
- private JRadioButton urlButton;
+ /** Radio button indicating that the URL should be tested. */
+ private JRadioButton urlButton;
- /** Radio button indicating that the responseMessage should be tested. */
- private JRadioButton responseMessageButton;
-
- /** Radio button indicating that the responseCode should be tested. */
- private JRadioButton responseCodeButton;
-
- /** Radio button indicating that the headers should be tested. */
- private JRadioButton responseHeadersButton;
-
- /**
- * Checkbox to indicate whether the response should be forced successful
- * before testing. This is intended for use when checking the status code or
- * status message.
- */
- private JCheckBox assumeSuccess;
-
- /**
- * Radio button indicating to test if the field contains one of the
- * patterns.
- */
- private JRadioButton containsBox;
-
- /**
- * Radio button indicating to test if the field matches one of the patterns.
- */
- private JRadioButton matchesBox;
-
- /**
- * Radio button indicating if the field equals the string.
- */
- private JRadioButton equalsBox;
+ /** Radio button indicating that the responseMessage should be tested. */
+ private JRadioButton responseMessageButton;
+
+ /** Radio button indicating that the responseCode should be tested. */
+ private JRadioButton responseCodeButton;
+
+ /** Radio button indicating that the headers should be tested. */
+ private JRadioButton responseHeadersButton;
+
+ /**
+ * Checkbox to indicate whether the response should be forced successful
+ * before testing. This is intended for use when checking the status code or
+ * status message.
+ */
+ private JCheckBox assumeSuccess;
+
+ /**
+ * Radio button indicating to test if the field contains one of the
+ * patterns.
+ */
+ private JRadioButton containsBox;
+
+ /**
+ * Radio button indicating to test if the field matches one of the patterns.
+ */
+ private JRadioButton matchesBox;
+
+ /**
+ * Radio button indicating if the field equals the string.
+ */
+ private JRadioButton equalsBox;
/**
* Radio button indicating if the field contains the string.
@@ -93,84 +93,84 @@
private JRadioButton substringBox;
/**
- * Checkbox indicating to test that the field does NOT contain/match the
- * patterns.
- */
- private JCheckBox notBox;
-
- /** A table of patterns to test against. */
- private JTable stringTable;
-
- /** Button to add a new pattern. */
- private JButton addPattern;
-
- /** Button to delete a pattern. */
- private JButton deletePattern;
-
- /** Table model for the pattern table. */
- private PowerTableModel tableModel;
-
- /**
- * Create a new AssertionGui panel.
- */
- public AssertionGui() {
- init();
- }
-
- public String getLabelResource() {
- return "assertion_title"; // $NON-NLS-1$
- }
-
- /* Implements JMeterGUIComponent.createTestElement() */
- public TestElement createTestElement() {
- ResponseAssertion el = new ResponseAssertion();
- modifyTestElement(el);
- return el;
- }
-
- /* Implements JMeterGUIComponent.modifyTestElement(TestElement) */
- public void modifyTestElement(TestElement el) {
- configureTestElement(el);
- if (el instanceof ResponseAssertion) {
- ResponseAssertion ra = (ResponseAssertion) el;
-
- ra.clearTestStrings();
- String[] testStrings = tableModel.getData().getColumn(COL_NAME);
- for (int i = 0; i < testStrings.length; i++) {
- ra.addTestString(testStrings[i]);
- }
-
- if (responseStringButton.isSelected()) {
- ra.setTestFieldResponseData();
- } else if (responseCodeButton.isSelected()) {
- ra.setTestFieldResponseCode();
- } else if (responseMessageButton.isSelected()) {
- ra.setTestFieldResponseMessage();
- } else if (responseHeadersButton.isSelected()) {
- ra.setTestFieldResponseHeaders();
- } else { // Assume URL
- ra.setTestFieldURL();
- }
-
- ra.setAssumeSuccess(assumeSuccess.isSelected());
-
- if (containsBox.isSelected()) {
- ra.setToContainsType();
- } else if (equalsBox.isSelected()) {
+ * Checkbox indicating to test that the field does NOT contain/match the
+ * patterns.
+ */
+ private JCheckBox notBox;
+
+ /** A table of patterns to test against. */
+ private JTable stringTable;
+
+ /** Button to add a new pattern. */
+ private JButton addPattern;
+
+ /** Button to delete a pattern. */
+ private JButton deletePattern;
+
+ /** Table model for the pattern table. */
+ private PowerTableModel tableModel;
+
+ /**
+ * Create a new AssertionGui panel.
+ */
+ public AssertionGui() {
+ init();
+ }
+
+ public String getLabelResource() {
+ return "assertion_title"; // $NON-NLS-1$
+ }
+
+ /* Implements JMeterGUIComponent.createTestElement() */
+ public TestElement createTestElement() {
+ ResponseAssertion el = new ResponseAssertion();
+ modifyTestElement(el);
+ return el;
+ }
+
+ /* Implements JMeterGUIComponent.modifyTestElement(TestElement) */
+ public void modifyTestElement(TestElement el) {
+ configureTestElement(el);
+ if (el instanceof ResponseAssertion) {
+ ResponseAssertion ra = (ResponseAssertion) el;
+
+ ra.clearTestStrings();
+ String[] testStrings = tableModel.getData().getColumn(COL_NAME);
+ for (int i = 0; i < testStrings.length; i++) {
+ ra.addTestString(testStrings[i]);
+ }
+
+ if (responseStringButton.isSelected()) {
+ ra.setTestFieldResponseData();
+ } else if (responseCodeButton.isSelected()) {
+ ra.setTestFieldResponseCode();
+ } else if (responseMessageButton.isSelected()) {
+ ra.setTestFieldResponseMessage();
+ } else if (responseHeadersButton.isSelected()) {
+ ra.setTestFieldResponseHeaders();
+ } else { // Assume URL
+ ra.setTestFieldURL();
+ }
+
+ ra.setAssumeSuccess(assumeSuccess.isSelected());
+
+ if (containsBox.isSelected()) {
+ ra.setToContainsType();
+ } else if (equalsBox.isSelected()) {
ra.setToEqualsType();
} else if (substringBox.isSelected()) {
ra.setToSubstringType();
- } else {
- ra.setToMatchType();
- }
-
- if (notBox.isSelected()) {
- ra.setToNotType();
- } else {
- ra.unsetNotType();
- }
- }
- }
+ } else {
+ ra.setToMatchType();
+ }
+
+ if (notBox.isSelected()) {
+ ra.setToNotType();
+ } else {
+ ra.unsetNotType();
+ }
+ }
+ }
/**
* Implements JMeterGUIComponent.clearGui
@@ -191,220 +191,220 @@
notBox.setSelected(false);
}
- /**
- * A newly created component can be initialized with the contents of a Test
- * Element object by calling this method. The component is responsible for
- * querying the Test Element object for the relevant information to display
- * in its GUI.
- *
- * @param el
- * the TestElement to configure
- */
- public void configure(TestElement el) {
- super.configure(el);
- ResponseAssertion model = (ResponseAssertion) el;
+ /**
+ * A newly created component can be initialized with the contents of a Test
+ * Element object by calling this method. The component is responsible for
+ * querying the Test Element object for the relevant information to display
+ * in its GUI.
+ *
+ * @param el
+ * the TestElement to configure
+ */
+ public void configure(TestElement el) {
+ super.configure(el);
+ ResponseAssertion model = (ResponseAssertion) el;
- if (model.isContainsType()) {
- containsBox.setSelected(true);
+ if (model.isContainsType()) {
+ containsBox.setSelected(true);
} else if (model.isEqualsType()) {
equalsBox.setSelected(true);
} else if (model.isSubstringType()) {
substringBox.setSelected(true);
- } else {
- matchesBox.setSelected(true);
- }
-
- notBox.setSelected(model.isNotType());
-
- if (model.isTestFieldResponseData()) {
- responseStringButton.setSelected(true);
- } else if (model.isTestFieldResponseCode()) {
- responseCodeButton.setSelected(true);
- } else if (model.isTestFieldResponseMessage()) {
- responseMessageButton.setSelected(true);
- } else if (model.isTestFieldResponseHeaders()) {
- responseHeadersButton.setSelected(true);
- } else // Assume it is the URL
- {
- urlButton.setSelected(true);
- }
-
- assumeSuccess.setSelected(model.getAssumeSuccess());
-
- tableModel.clearData();
- PropertyIterator tests = model.getTestStrings().iterator();
- while (tests.hasNext()) {
- tableModel.addRow(new Object[] { tests.next().getStringValue() });
- }
-
- if (model.getTestStrings().size() == 0) {
- deletePattern.setEnabled(false);
- } else {
- deletePattern.setEnabled(true);
- }
-
- tableModel.fireTableDataChanged();
- }
-
- /**
- * Initialize the GUI components and layout.
- */
- private void init() {
- setLayout(new BorderLayout());
- Box box = Box.createVerticalBox();
- setBorder(makeBorder());
-
- box.add(makeTitlePanel());
- box.add(createFieldPanel());
- box.add(createTypePanel());
- add(box, BorderLayout.NORTH);
- add(createStringPanel(), BorderLayout.CENTER);
- }
-
- /**
- * Create a panel allowing the user to choose which response field should be
- * tested.
- *
- * @return a new panel for selecting the response field
- */
- private JPanel createFieldPanel() {
- JPanel panel = new JPanel();
- panel.setBorder(BorderFactory.createTitledBorder(JMeterUtils.getResString("assertion_resp_field"))); //$NON-NLS-1$
-
- responseStringButton = new JRadioButton(JMeterUtils.getResString("assertion_text_resp")); //$NON-NLS-1$
- urlButton = new JRadioButton(JMeterUtils.getResString("assertion_url_samp")); //$NON-NLS-1$
- responseCodeButton = new JRadioButton(JMeterUtils.getResString("assertion_code_resp")); //$NON-NLS-1$
- responseMessageButton = new JRadioButton(JMeterUtils.getResString("assertion_message_resp")); //$NON-NLS-1$
- responseHeadersButton = new JRadioButton(JMeterUtils.getResString("assertion_headers")); //$NON-NLS-1$
-
- ButtonGroup group = new ButtonGroup();
- group.add(responseStringButton);
- group.add(urlButton);
- group.add(responseCodeButton);
- group.add(responseMessageButton);
- group.add(responseHeadersButton);
-
- panel.add(responseStringButton);
- panel.add(urlButton);
- panel.add(responseCodeButton);
- panel.add(responseMessageButton);
- panel.add(responseHeadersButton);
-
- responseStringButton.setSelected(true);
-
- assumeSuccess = new JCheckBox(JMeterUtils.getResString("assertion_assume_success")); //$NON-NLS-1$
- panel.add(assumeSuccess);
-
- return panel;
- }
-
- /**
- * Create a panel allowing the user to choose what type of test should be
- * performed.
- *
- * @return a new panel for selecting the type of assertion test
- */
- private JPanel createTypePanel() {
- JPanel panel = new JPanel();
- panel.setBorder(BorderFactory.createTitledBorder(JMeterUtils.getResString("assertion_pattern_match_rules"))); //$NON-NLS-1$
-
- ButtonGroup group = new ButtonGroup();
-
- containsBox = new JRadioButton(JMeterUtils.getResString("assertion_contains")); //$NON-NLS-1$
- group.add(containsBox);
- containsBox.setSelected(true);
- panel.add(containsBox);
-
- matchesBox = new JRadioButton(JMeterUtils.getResString("assertion_matches")); //$NON-NLS-1$
- group.add(matchesBox);
- panel.add(matchesBox);
-
- equalsBox = new JRadioButton(JMeterUtils.getResString("assertion_equals")); //$NON-NLS-1$
- group.add(equalsBox);
- panel.add(equalsBox);
+ } else {
+ matchesBox.setSelected(true);
+ }
+
+ notBox.setSelected(model.isNotType());
+
+ if (model.isTestFieldResponseData()) {
+ responseStringButton.setSelected(true);
+ } else if (model.isTestFieldResponseCode()) {
+ responseCodeButton.setSelected(true);
+ } else if (model.isTestFieldResponseMessage()) {
+ responseMessageButton.setSelected(true);
+ } else if (model.isTestFieldResponseHeaders()) {
+ responseHeadersButton.setSelected(true);
+ } else // Assume it is the URL
+ {
+ urlButton.setSelected(true);
+ }
+
+ assumeSuccess.setSelected(model.getAssumeSuccess());
+
+ tableModel.clearData();
+ PropertyIterator tests = model.getTestStrings().iterator();
+ while (tests.hasNext()) {
+ tableModel.addRow(new Object[] { tests.next().getStringValue() });
+ }
+
+ if (model.getTestStrings().size() == 0) {
+ deletePattern.setEnabled(false);
+ } else {
+ deletePattern.setEnabled(true);
+ }
+
+ tableModel.fireTableDataChanged();
+ }
+
+ /**
+ * Initialize the GUI components and layout.
+ */
+ private void init() {
+ setLayout(new BorderLayout());
+ Box box = Box.createVerticalBox();
+ setBorder(makeBorder());
+
+ box.add(makeTitlePanel());
+ box.add(createFieldPanel());
+ box.add(createTypePanel());
+ add(box, BorderLayout.NORTH);
+ add(createStringPanel(), BorderLayout.CENTER);
+ }
+
+ /**
+ * Create a panel allowing the user to choose which response field should be
+ * tested.
+ *
+ * @return a new panel for selecting the response field
+ */
+ private JPanel createFieldPanel() {
+ JPanel panel = new JPanel();
+ panel.setBorder(BorderFactory.createTitledBorder(JMeterUtils.getResString("assertion_resp_field"))); //$NON-NLS-1$
+
+ responseStringButton = new JRadioButton(JMeterUtils.getResString("assertion_text_resp")); //$NON-NLS-1$
+ urlButton = new JRadioButton(JMeterUtils.getResString("assertion_url_samp")); //$NON-NLS-1$
+ responseCodeButton = new JRadioButton(JMeterUtils.getResString("assertion_code_resp")); //$NON-NLS-1$
+ responseMessageButton = new JRadioButton(JMeterUtils.getResString("assertion_message_resp")); //$NON-NLS-1$
+ responseHeadersButton = new JRadioButton(JMeterUtils.getResString("assertion_headers")); //$NON-NLS-1$
+
+ ButtonGroup group = new ButtonGroup();
+ group.add(responseStringButton);
+ group.add(urlButton);
+ group.add(responseCodeButton);
+ group.add(responseMessageButton);
+ group.add(responseHeadersButton);
+
+ panel.add(responseStringButton);
+ panel.add(urlButton);
+ panel.add(responseCodeButton);
+ panel.add(responseMessageButton);
+ panel.add(responseHeadersButton);
+
+ responseStringButton.setSelected(true);
+
+ assumeSuccess = new JCheckBox(JMeterUtils.getResString("assertion_assume_success")); //$NON-NLS-1$
+ panel.add(assumeSuccess);
+
+ return panel;
+ }
+
+ /**
+ * Create a panel allowing the user to choose what type of test should be
+ * performed.
+ *
+ * @return a new panel for selecting the type of assertion test
+ */
+ private JPanel createTypePanel() {
+ JPanel panel = new JPanel();
+ panel.setBorder(BorderFactory.createTitledBorder(JMeterUtils.getResString("assertion_pattern_match_rules"))); //$NON-NLS-1$
+
+ ButtonGroup group = new ButtonGroup();
+
+ containsBox = new JRadioButton(JMeterUtils.getResString("assertion_contains")); //$NON-NLS-1$
+ group.add(containsBox);
+ containsBox.setSelected(true);
+ panel.add(containsBox);
+
+ matchesBox = new JRadioButton(JMeterUtils.getResString("assertion_matches")); //$NON-NLS-1$
+ group.add(matchesBox);
+ panel.add(matchesBox);
+
+ equalsBox = new JRadioButton(JMeterUtils.getResString("assertion_equals")); //$NON-NLS-1$
+ group.add(equalsBox);
+ panel.add(equalsBox);
substringBox = new JRadioButton(JMeterUtils.getResString("assertion_substring")); //$NON-NLS-1$
group.add(substringBox);
panel.add(substringBox);
- notBox = new JCheckBox(JMeterUtils.getResString("assertion_not")); //$NON-NLS-1$
- panel.add(notBox);
+ notBox = new JCheckBox(JMeterUtils.getResString("assertion_not")); //$NON-NLS-1$
+ panel.add(notBox);
+
+ return panel;
+ }
+
+ /**
+ * Create a panel allowing the user to supply a list of string patterns to
+ * test against.
+ *
+ * @return a new panel for adding string patterns
+ */
+ private JPanel createStringPanel() {
+ tableModel = new PowerTableModel(new String[] { COL_NAME }, new Class[] { String.class });
+ stringTable = new JTable(tableModel);
+
+ TextAreaCellRenderer renderer = new TextAreaCellRenderer();
+ stringTable.setRowHeight(renderer.getPreferredHeight());
+ stringTable.setDefaultRenderer(String.class, renderer);
+ stringTable.setDefaultEditor(String.class, new TextAreaTableCellEditor());
+ stringTable.setPreferredScrollableViewportSize(new Dimension(100, 70));
+
+ JPanel panel = new JPanel();
+ panel.setLayout(new BorderLayout());
+ panel.setBorder(BorderFactory.createTitledBorder(JMeterUtils.getResString("assertion_patterns_to_test"))); //$NON-NLS-1$
+
+ panel.add(new JScrollPane(stringTable), BorderLayout.CENTER);
+ panel.add(createButtonPanel(), BorderLayout.SOUTH);
+
+ return panel;
+ }
- return panel;
- }
+ /**
+ * Create a panel with buttons to add and delete string patterns.
+ *
+ * @return the new panel with add and delete buttons
+ */
+ private JPanel createButtonPanel() {
+ addPattern = new JButton(JMeterUtils.getResString("add")); //$NON-NLS-1$
+ addPattern.addActionListener(new AddPatternListener());
+
+ deletePattern = new JButton(JMeterUtils.getResString("delete")); //$NON-NLS-1$
+ deletePattern.addActionListener(new ClearPatternsListener());
+ deletePattern.setEnabled(false);
+
+ JPanel buttonPanel = new JPanel();
+ buttonPanel.add(addPattern);
+ buttonPanel.add(deletePattern);
+ return buttonPanel;
+ }
- /**
- * Create a panel allowing the user to supply a list of string patterns to
- * test against.
- *
- * @return a new panel for adding string patterns
- */
- private JPanel createStringPanel() {
- tableModel = new PowerTableModel(new String[] { COL_NAME }, new Class[] { String.class });
- stringTable = new JTable(tableModel);
-
- TextAreaCellRenderer renderer = new TextAreaCellRenderer();
- stringTable.setRowHeight(renderer.getPreferredHeight());
- stringTable.setDefaultRenderer(String.class, renderer);
- stringTable.setDefaultEditor(String.class, new TextAreaTableCellEditor());
- stringTable.setPreferredScrollableViewportSize(new Dimension(100, 70));
-
- JPanel panel = new JPanel();
- panel.setLayout(new BorderLayout());
- panel.setBorder(BorderFactory.createTitledBorder(JMeterUtils.getResString("assertion_patterns_to_test"))); //$NON-NLS-1$
-
- panel.add(new JScrollPane(stringTable), BorderLayout.CENTER);
- panel.add(createButtonPanel(), BorderLayout.SOUTH);
-
- return panel;
- }
-
- /**
- * Create a panel with buttons to add and delete string patterns.
- *
- * @return the new panel with add and delete buttons
- */
- private JPanel createButtonPanel() {
- addPattern = new JButton(JMeterUtils.getResString("add")); //$NON-NLS-1$
- addPattern.addActionListener(new AddPatternListener());
-
- deletePattern = new JButton(JMeterUtils.getResString("delete")); //$NON-NLS-1$
- deletePattern.addActionListener(new ClearPatternsListener());
- deletePattern.setEnabled(false);
-
- JPanel buttonPanel = new JPanel();
- buttonPanel.add(addPattern);
- buttonPanel.add(deletePattern);
- return buttonPanel;
- }
-
- /**
- * An ActionListener for deleting a pattern.
- *
- */
- private class ClearPatternsListener implements ActionListener {
- public void actionPerformed(ActionEvent e) {
- int index = stringTable.getSelectedRow();
- if (index > -1) {
- stringTable.getCellEditor(index, stringTable.getSelectedColumn()).cancelCellEditing();
- tableModel.removeRow(index);
- tableModel.fireTableDataChanged();
- }
- if (stringTable.getModel().getRowCount() == 0) {
- deletePattern.setEnabled(false);
- }
- }
- }
-
- /**
- * An ActionListener for adding a pattern.
- *
- */
- private class AddPatternListener implements ActionListener {
- public void actionPerformed(ActionEvent e) {
- tableModel.addNewRow();
- deletePattern.setEnabled(true);
- tableModel.fireTableDataChanged();
- }
- }
+ /**
+ * An ActionListener for deleting a pattern.
+ *
+ */
+ private class ClearPatternsListener implements ActionListener {
+ public void actionPerformed(ActionEvent e) {
+ int index = stringTable.getSelectedRow();
+ if (index > -1) {
+ stringTable.getCellEditor(index, stringTable.getSelectedColumn()).cancelCellEditing();
+ tableModel.removeRow(index);
+ tableModel.fireTableDataChanged();
+ }
+ if (stringTable.getModel().getRowCount() == 0) {
+ deletePattern.setEnabled(false);
+ }
+ }
+ }
+
+ /**
+ * An ActionListener for adding a pattern.
+ *
+ */
+ private class AddPatternListener implements ActionListener {
+ public void actionPerformed(ActionEvent e) {
+ tableModel.addNewRow();
+ deletePattern.setEnabled(true);
+ tableModel.fireTableDataChanged();
+ }
+ }
}
Modified: jakarta/jmeter/trunk/src/components/org/apache/jmeter/assertions/gui/BeanShellAssertionGui.java
URL: http://svn.apache.org/viewvc/jakarta/jmeter/trunk/src/components/org/apache/jmeter/assertions/gui/BeanShellAssertionGui.java?rev=674342&r1=674341&r2=674342&view=diff
==============================================================================
--- jakarta/jmeter/trunk/src/components/org/apache/jmeter/assertions/gui/BeanShellAssertionGui.java (original)
+++ jakarta/jmeter/trunk/src/components/org/apache/jmeter/assertions/gui/BeanShellAssertionGui.java Sun Jul 6 13:28:49 2008
@@ -37,61 +37,61 @@
private JCheckBox resetInterpreter;// reset the bsh.Interpreter before each execution
- private JTextField filename;// script file name (if present)
+ private JTextField filename;// script file name (if present)
- private JTextField parameters;// parameters to pass to script file (or script)
+ private JTextField parameters;// parameters to pass to script file (or script)
- private JTextArea scriptField;// script area
+ private JTextArea scriptField;// script area
- public BeanShellAssertionGui() {
- init();
- }
+ public BeanShellAssertionGui() {
+ init();
+ }
- public void configure(TestElement element) {
- scriptField.setText(element.getPropertyAsString(BeanShellAssertion.SCRIPT));
- filename.setText(element.getPropertyAsString(BeanShellAssertion.FILENAME));
- parameters.setText(element.getPropertyAsString(BeanShellAssertion.PARAMETERS));
+ public void configure(TestElement element) {
+ scriptField.setText(element.getPropertyAsString(BeanShellAssertion.SCRIPT));
+ filename.setText(element.getPropertyAsString(BeanShellAssertion.FILENAME));
+ parameters.setText(element.getPropertyAsString(BeanShellAssertion.PARAMETERS));
resetInterpreter.setSelected(element.getPropertyAsBoolean(BeanShellAssertion.RESET_INTERPRETER));
- super.configure(element);
- }
+ super.configure(element);
+ }
- public TestElement createTestElement() {
- BeanShellAssertion sampler = new BeanShellAssertion();
- modifyTestElement(sampler);
- return sampler;
- }
-
- /**
- * Modifies a given TestElement to mirror the data in the gui components.
- *
- * @see org.apache.jmeter.gui.JMeterGUIComponent#modifyTestElement(TestElement)
- */
- public void modifyTestElement(TestElement te) {
- te.clear();
- this.configureTestElement(te);
- te.setProperty(BeanShellAssertion.SCRIPT, scriptField.getText());
- te.setProperty(BeanShellAssertion.FILENAME, filename.getText());
- te.setProperty(BeanShellAssertion.PARAMETERS, parameters.getText());
+ public TestElement createTestElement() {
+ BeanShellAssertion sampler = new BeanShellAssertion();
+ modifyTestElement(sampler);
+ return sampler;
+ }
+
+ /**
+ * Modifies a given TestElement to mirror the data in the gui components.
+ *
+ * @see org.apache.jmeter.gui.JMeterGUIComponent#modifyTestElement(TestElement)
+ */
+ public void modifyTestElement(TestElement te) {
+ te.clear();
+ this.configureTestElement(te);
+ te.setProperty(BeanShellAssertion.SCRIPT, scriptField.getText());
+ te.setProperty(BeanShellAssertion.FILENAME, filename.getText());
+ te.setProperty(BeanShellAssertion.PARAMETERS, parameters.getText());
te.setProperty(new BooleanProperty(BeanShellAssertion.RESET_INTERPRETER, resetInterpreter.isSelected()));
- }
+ }
- public String getLabelResource() {
- return "bsh_assertion_title"; // $NON-NLS-1$
- }
-
- private JPanel createFilenamePanel()// TODO ought to be a FileChooser ...
- {
- JLabel label = new JLabel(JMeterUtils.getResString("bsh_script_file")); //$NON-NLS-1$
-
- filename = new JTextField(10);
- filename.setName(BeanShellAssertion.FILENAME);
- label.setLabelFor(filename);
-
- JPanel filenamePanel = new JPanel(new BorderLayout(5, 0));
- filenamePanel.add(label, BorderLayout.WEST);
- filenamePanel.add(filename, BorderLayout.CENTER);
- return filenamePanel;
- }
+ public String getLabelResource() {
+ return "bsh_assertion_title"; // $NON-NLS-1$
+ }
+
+ private JPanel createFilenamePanel()// TODO ought to be a FileChooser ...
+ {
+ JLabel label = new JLabel(JMeterUtils.getResString("bsh_script_file")); //$NON-NLS-1$
+
+ filename = new JTextField(10);
+ filename.setName(BeanShellAssertion.FILENAME);
+ label.setLabelFor(filename);
+
+ JPanel filenamePanel = new JPanel(new BorderLayout(5, 0));
+ filenamePanel.add(label, BorderLayout.WEST);
+ filenamePanel.add(filename, BorderLayout.CENTER);
+ return filenamePanel;
+ }
private JPanel createResetPanel() {
resetInterpreter = new JCheckBox(JMeterUtils.getResString("bsh_script_reset_interpreter")); // $NON-NLS-1$
@@ -100,65 +100,65 @@
JPanel resetInterpreterPanel = new JPanel(new BorderLayout());
resetInterpreterPanel.add(resetInterpreter, BorderLayout.WEST);
return resetInterpreterPanel;
- }
+ }
- private JPanel createParameterPanel() {
- JLabel label = new JLabel(JMeterUtils.getResString("bsh_script_parameters")); //$NON-NLS-1$
+ private JPanel createParameterPanel() {
+ JLabel label = new JLabel(JMeterUtils.getResString("bsh_script_parameters")); //$NON-NLS-1$
- parameters = new JTextField(10);
- parameters.setName(BeanShellAssertion.PARAMETERS);
- label.setLabelFor(parameters);
-
- JPanel parameterPanel = new JPanel(new BorderLayout(5, 0));
- parameterPanel.add(label, BorderLayout.WEST);
- parameterPanel.add(parameters, BorderLayout.CENTER);
- return parameterPanel;
- }
-
- private void init() {
- setLayout(new BorderLayout(0, 5));
- setBorder(makeBorder());
-
- Box box = Box.createVerticalBox();
- box.add(makeTitlePanel());
- box.add(createResetPanel());
- box.add(createParameterPanel());
- box.add(createFilenamePanel());
- add(box, BorderLayout.NORTH);
-
- JPanel panel = createScriptPanel();
- add(panel, BorderLayout.CENTER);
- // Don't let the input field shrink too much
- add(Box.createVerticalStrut(panel.getPreferredSize().height), BorderLayout.WEST);
- }
-
- private JPanel createScriptPanel() {
- scriptField = new JTextArea();
- scriptField.setRows(4);
- scriptField.setLineWrap(true);
- scriptField.setWrapStyleWord(true);
-
- JLabel label = new JLabel(JMeterUtils.getResString("bsh_assertion_script")); //$NON-NLS-1$
- label.setLabelFor(scriptField);
-
- JPanel panel = new JPanel(new BorderLayout());
- panel.add(label, BorderLayout.NORTH);
- panel.add(new JScrollPane(scriptField), BorderLayout.CENTER);
-
- JTextArea explain = new JTextArea(JMeterUtils.getResString("bsh_assertion_script_variables")); //$NON-NLS-1$
- explain.setLineWrap(true);
- explain.setEditable(false);
- explain.setBackground(this.getBackground());
- panel.add(explain, BorderLayout.SOUTH);
-
- return panel;
- }
-
- public void clearGui() {
- super.clearGui();
- filename.setText(""); // $NON-NLS-1$
- parameters.setText(""); // $NON-NLS-1$
- scriptField.setText(""); // $NON-NLS-1$
+ parameters = new JTextField(10);
+ parameters.setName(BeanShellAssertion.PARAMETERS);
+ label.setLabelFor(parameters);
+
+ JPanel parameterPanel = new JPanel(new BorderLayout(5, 0));
+ parameterPanel.add(label, BorderLayout.WEST);
+ parameterPanel.add(parameters, BorderLayout.CENTER);
+ return parameterPanel;
+ }
+
+ private void init() {
+ setLayout(new BorderLayout(0, 5));
+ setBorder(makeBorder());
+
+ Box box = Box.createVerticalBox();
+ box.add(makeTitlePanel());
+ box.add(createResetPanel());
+ box.add(createParameterPanel());
+ box.add(createFilenamePanel());
+ add(box, BorderLayout.NORTH);
+
+ JPanel panel = createScriptPanel();
+ add(panel, BorderLayout.CENTER);
+ // Don't let the input field shrink too much
+ add(Box.createVerticalStrut(panel.getPreferredSize().height), BorderLayout.WEST);
+ }
+
+ private JPanel createScriptPanel() {
+ scriptField = new JTextArea();
+ scriptField.setRows(4);
+ scriptField.setLineWrap(true);
+ scriptField.setWrapStyleWord(true);
+
+ JLabel label = new JLabel(JMeterUtils.getResString("bsh_assertion_script")); //$NON-NLS-1$
+ label.setLabelFor(scriptField);
+
+ JPanel panel = new JPanel(new BorderLayout());
+ panel.add(label, BorderLayout.NORTH);
+ panel.add(new JScrollPane(scriptField), BorderLayout.CENTER);
+
+ JTextArea explain = new JTextArea(JMeterUtils.getResString("bsh_assertion_script_variables")); //$NON-NLS-1$
+ explain.setLineWrap(true);
+ explain.setEditable(false);
+ explain.setBackground(this.getBackground());
+ panel.add(explain, BorderLayout.SOUTH);
+
+ return panel;
+ }
+
+ public void clearGui() {
+ super.clearGui();
+ filename.setText(""); // $NON-NLS-1$
+ parameters.setText(""); // $NON-NLS-1$
+ scriptField.setText(""); // $NON-NLS-1$
resetInterpreter.setSelected(false);
- }
+ }
}
Modified: jakarta/jmeter/trunk/src/components/org/apache/jmeter/assertions/gui/DurationAssertionGui.java
URL: http://svn.apache.org/viewvc/jakarta/jmeter/trunk/src/components/org/apache/jmeter/assertions/gui/DurationAssertionGui.java?rev=674342&r1=674341&r2=674342&view=diff
==============================================================================
--- jakarta/jmeter/trunk/src/components/org/apache/jmeter/assertions/gui/DurationAssertionGui.java (original)
+++ jakarta/jmeter/trunk/src/components/org/apache/jmeter/assertions/gui/DurationAssertionGui.java Sun Jul 6 13:28:49 2008
@@ -32,35 +32,35 @@
public class DurationAssertionGui extends AbstractAssertionGui {
- private JTextField duration;
+ private JTextField duration;
- public DurationAssertionGui() {
- init();
- }
-
- public String getLabelResource() {
- return "duration_assertion_title"; // $NON-NLS-1$
- }
-
- public String getDurationAttributesTitle() {
- return JMeterUtils.getResString("duration_assertion_duration_test"); // $NON-NLS-1$
- }
-
- public TestElement createTestElement() {
- DurationAssertion el = new DurationAssertion();
- modifyTestElement(el);
- return el;
- }
-
- /**
- * Modifies a given TestElement to mirror the data in the gui components.
- *
- * @see org.apache.jmeter.gui.JMeterGUIComponent#modifyTestElement(TestElement)
- */
- public void modifyTestElement(TestElement el) {
- configureTestElement(el);
- el.setProperty(DurationAssertion.DURATION_KEY,duration.getText());
- }
+ public DurationAssertionGui() {
+ init();
+ }
+
+ public String getLabelResource() {
+ return "duration_assertion_title"; // $NON-NLS-1$
+ }
+
+ public String getDurationAttributesTitle() {
+ return JMeterUtils.getResString("duration_assertion_duration_test"); // $NON-NLS-1$
+ }
+
+ public TestElement createTestElement() {
+ DurationAssertion el = new DurationAssertion();
+ modifyTestElement(el);
+ return el;
+ }
+
+ /**
+ * Modifies a given TestElement to mirror the data in the gui components.
+ *
+ * @see org.apache.jmeter.gui.JMeterGUIComponent#modifyTestElement(TestElement)
+ */
+ public void modifyTestElement(TestElement el) {
+ configureTestElement(el);
+ el.setProperty(DurationAssertion.DURATION_KEY,duration.getText());
+ }
/**
* Implements JMeterGUIComponent.clearGui
@@ -71,35 +71,35 @@
duration.setText(""); //$NON-NLS-1$
}
- public void configure(TestElement el) {
- super.configure(el);
- duration.setText(el.getPropertyAsString(DurationAssertion.DURATION_KEY));
- }
-
- private void init() {
- setLayout(new BorderLayout(0, 10));
- setBorder(makeBorder());
-
- add(makeTitlePanel(), BorderLayout.NORTH);
-
- JPanel mainPanel = new JPanel(new BorderLayout());
-
- // USER_INPUT
- VerticalPanel durationPanel = new VerticalPanel();
- durationPanel.setBorder(BorderFactory.createTitledBorder(BorderFactory.createEtchedBorder(),
- getDurationAttributesTitle()));
-
- JPanel labelPanel = new JPanel(new BorderLayout(5, 0));
- JLabel durationLabel =
- new JLabel(JMeterUtils.getResString("duration_assertion_label")); // $NON-NLS-1$
- labelPanel.add(durationLabel, BorderLayout.WEST);
-
- duration = new JTextField();
- labelPanel.add(duration, BorderLayout.CENTER);
- durationLabel.setLabelFor(duration);
- durationPanel.add(labelPanel);
-
- mainPanel.add(durationPanel, BorderLayout.NORTH);
- add(mainPanel, BorderLayout.CENTER);
- }
+ public void configure(TestElement el) {
+ super.configure(el);
+ duration.setText(el.getPropertyAsString(DurationAssertion.DURATION_KEY));
+ }
+
+ private void init() {
+ setLayout(new BorderLayout(0, 10));
+ setBorder(makeBorder());
+
+ add(makeTitlePanel(), BorderLayout.NORTH);
+
+ JPanel mainPanel = new JPanel(new BorderLayout());
+
+ // USER_INPUT
+ VerticalPanel durationPanel = new VerticalPanel();
+ durationPanel.setBorder(BorderFactory.createTitledBorder(BorderFactory.createEtchedBorder(),
+ getDurationAttributesTitle()));
+
+ JPanel labelPanel = new JPanel(new BorderLayout(5, 0));
+ JLabel durationLabel =
+ new JLabel(JMeterUtils.getResString("duration_assertion_label")); // $NON-NLS-1$
+ labelPanel.add(durationLabel, BorderLayout.WEST);
+
+ duration = new JTextField();
+ labelPanel.add(duration, BorderLayout.CENTER);
+ durationLabel.setLabelFor(duration);
+ durationPanel.add(labelPanel);
+
+ mainPanel.add(durationPanel, BorderLayout.NORTH);
+ add(mainPanel, BorderLayout.CENTER);
+ }
}
Modified: jakarta/jmeter/trunk/src/components/org/apache/jmeter/assertions/gui/HTMLAssertionGui.java
URL: http://svn.apache.org/viewvc/jakarta/jmeter/trunk/src/components/org/apache/jmeter/assertions/gui/HTMLAssertionGui.java?rev=674342&r1=674341&r2=674342&view=diff
==============================================================================
--- jakarta/jmeter/trunk/src/components/org/apache/jmeter/assertions/gui/HTMLAssertionGui.java (original)
+++ jakarta/jmeter/trunk/src/components/org/apache/jmeter/assertions/gui/HTMLAssertionGui.java Sun Jul 6 13:28:49 2008
@@ -49,100 +49,100 @@
*/
public class HTMLAssertionGui extends AbstractAssertionGui implements KeyListener, ActionListener {
- private static final Logger log = LoggingManager.getLoggerForClass();
+ private static final Logger log = LoggingManager.getLoggerForClass();
- private static final long serialVersionUID = 1L;
+ private static final long serialVersionUID = 1L;
- // Names for the fields
- private static final String WARNING_THRESHOLD_FIELD = "warningThresholdField"; // $NON-NLS-1$
+ // Names for the fields
+ private static final String WARNING_THRESHOLD_FIELD = "warningThresholdField"; // $NON-NLS-1$
- private static final String ERROR_THRESHOLD_FIELD = "errorThresholdField"; // $NON-NLS-1$
+ private static final String ERROR_THRESHOLD_FIELD = "errorThresholdField"; // $NON-NLS-1$
- // instance attributes
- private JTextField errorThresholdField = null;
-
- private JTextField warningThresholdField = null;
-
- private JCheckBox errorsOnly = null;
-
- private JComboBox docTypeBox = null;
-
- private JRadioButton htmlRadioButton = null;
-
- private JRadioButton xhtmlRadioButton = null;
-
- private JRadioButton xmlRadioButton = null;
-
- private FilePanel filePanel = null;
-
- /**
- * The constructor.
- */
- public HTMLAssertionGui() {
- init();
- }
-
- /**
- * Returns the label to be shown within the JTree-Component.
- */
- public String getLabelResource() {
- return "html_assertion_title"; // $NON-NLS-1$
- }
-
- /**
- * @see org.apache.jmeter.gui.JMeterGUIComponent#createTestElement()
- */
- public TestElement createTestElement() {
- HTMLAssertion el = new HTMLAssertion();
- modifyTestElement(el);
- return el;
- }
-
- /**
- * Modifies a given TestElement to mirror the data in the gui components.
- *
- * @see org.apache.jmeter.gui.JMeterGUIComponent#modifyTestElement(TestElement)
- */
- public void modifyTestElement(TestElement inElement) {
-
- log.debug("HTMLAssertionGui.modifyTestElement() called");
-
- configureTestElement(inElement);
-
- String errorThresholdString = errorThresholdField.getText();
- long errorThreshold = 0;
-
- try {
- errorThreshold = Long.parseLong(errorThresholdString);
- } catch (NumberFormatException e) {
- errorThreshold = 0;
- }
- ((HTMLAssertion) inElement).setErrorThreshold(errorThreshold);
-
- String warningThresholdString = warningThresholdField.getText();
- long warningThreshold = 0;
- try {
- warningThreshold = Long.parseLong(warningThresholdString);
- } catch (NumberFormatException e) {
- warningThreshold = 0;
- }
- ((HTMLAssertion) inElement).setWarningThreshold(warningThreshold);
-
- String docTypeString = docTypeBox.getSelectedItem().toString();
- ((HTMLAssertion) inElement).setDoctype(docTypeString);
-
- boolean trackErrorsOnly = errorsOnly.isSelected();
- ((HTMLAssertion) inElement).setErrorsOnly(trackErrorsOnly);
-
- if (htmlRadioButton.isSelected()) {
- ((HTMLAssertion) inElement).setHTML();
- } else if (xhtmlRadioButton.isSelected()) {
- ((HTMLAssertion) inElement).setXHTML();
- } else {
- ((HTMLAssertion) inElement).setXML();
- }
- ((HTMLAssertion) inElement).setFilename(filePanel.getFilename());
- }
+ // instance attributes
+ private JTextField errorThresholdField = null;
+
+ private JTextField warningThresholdField = null;
+
+ private JCheckBox errorsOnly = null;
+
+ private JComboBox docTypeBox = null;
+
+ private JRadioButton htmlRadioButton = null;
+
+ private JRadioButton xhtmlRadioButton = null;
+
+ private JRadioButton xmlRadioButton = null;
+
+ private FilePanel filePanel = null;
+
+ /**
+ * The constructor.
+ */
+ public HTMLAssertionGui() {
+ init();
+ }
+
+ /**
+ * Returns the label to be shown within the JTree-Component.
+ */
+ public String getLabelResource() {
+ return "html_assertion_title"; // $NON-NLS-1$
+ }
+
+ /**
+ * @see org.apache.jmeter.gui.JMeterGUIComponent#createTestElement()
+ */
+ public TestElement createTestElement() {
+ HTMLAssertion el = new HTMLAssertion();
+ modifyTestElement(el);
+ return el;
+ }
+
+ /**
+ * Modifies a given TestElement to mirror the data in the gui components.
+ *
+ * @see org.apache.jmeter.gui.JMeterGUIComponent#modifyTestElement(TestElement)
+ */
+ public void modifyTestElement(TestElement inElement) {
+
+ log.debug("HTMLAssertionGui.modifyTestElement() called");
+
+ configureTestElement(inElement);
+
+ String errorThresholdString = errorThresholdField.getText();
+ long errorThreshold = 0;
+
+ try {
+ errorThreshold = Long.parseLong(errorThresholdString);
+ } catch (NumberFormatException e) {
+ errorThreshold = 0;
+ }
+ ((HTMLAssertion) inElement).setErrorThreshold(errorThreshold);
+
+ String warningThresholdString = warningThresholdField.getText();
+ long warningThreshold = 0;
+ try {
+ warningThreshold = Long.parseLong(warningThresholdString);
+ } catch (NumberFormatException e) {
+ warningThreshold = 0;
+ }
+ ((HTMLAssertion) inElement).setWarningThreshold(warningThreshold);
+
+ String docTypeString = docTypeBox.getSelectedItem().toString();
+ ((HTMLAssertion) inElement).setDoctype(docTypeString);
+
+ boolean trackErrorsOnly = errorsOnly.isSelected();
+ ((HTMLAssertion) inElement).setErrorsOnly(trackErrorsOnly);
+
+ if (htmlRadioButton.isSelected()) {
+ ((HTMLAssertion) inElement).setHTML();
+ } else if (xhtmlRadioButton.isSelected()) {
+ ((HTMLAssertion) inElement).setXHTML();
+ } else {
+ ((HTMLAssertion) inElement).setXML();
+ }
+ ((HTMLAssertion) inElement).setFilename(filePanel.getFilename());
+ }
/**
* Implements JMeterGUIComponent.clearGui
@@ -160,200 +160,200 @@
errorsOnly.setSelected(false);
}
- /**
- * Configures the associated test element.
- *
- * @param inElement
- */
- public void configure(TestElement inElement) {
- super.configure(inElement);
- HTMLAssertion lAssertion = (HTMLAssertion) inElement;
- errorThresholdField.setText(String.valueOf(lAssertion.getErrorThreshold()));
- warningThresholdField.setText(String.valueOf(lAssertion.getWarningThreshold()));
- errorsOnly.setSelected(lAssertion.isErrorsOnly());
- docTypeBox.setSelectedItem(lAssertion.getDoctype());
- if (lAssertion.isHTML()) {
- htmlRadioButton.setSelected(true);
- } else if (lAssertion.isXHTML()) {
- xhtmlRadioButton.setSelected(true);
- } else {
- xmlRadioButton.setSelected(true);
- }
- if (lAssertion.isErrorsOnly()) {
- warningThresholdField.setEnabled(false);
- warningThresholdField.setEditable(false);
- }
- else {
- warningThresholdField.setEnabled(true);
- warningThresholdField.setEditable(true);
- }
- filePanel.setFilename(lAssertion.getFilename());
- }
-
- /**
- * Inits the GUI.
- */
- private void init() {
-
- setLayout(new BorderLayout(0, 10));
- setBorder(makeBorder());
-
- add(makeTitlePanel(), BorderLayout.NORTH);
-
- JPanel mainPanel = new JPanel(new BorderLayout());
-
- // USER_INPUT
- VerticalPanel assertionPanel = new VerticalPanel();
- assertionPanel.setBorder(BorderFactory.createTitledBorder(BorderFactory.createEtchedBorder(), "Tidy Settings"));
-
- // doctype
- HorizontalPanel docTypePanel = new HorizontalPanel();
- docTypeBox = new JComboBox(new Object[] { "omit", "auto", "strict", "loose" });
- // docTypePanel.add(new
- // JLabel(JMeterUtils.getResString("duration_assertion_label"))); //$NON-NLS-1$
- docTypePanel.add(new JLabel("Doctype:"));
- docTypePanel.add(docTypeBox);
- assertionPanel.add(docTypePanel);
-
- // format (HMTL, XHTML, XML)
- VerticalPanel formatPanel = new VerticalPanel();
- formatPanel.setBorder(BorderFactory.createTitledBorder(BorderFactory.createEtchedBorder(), "Format"));
- htmlRadioButton = new JRadioButton("HTML", true); //$NON-NLS-1$
- xhtmlRadioButton = new JRadioButton("XHTML", false); //$NON-NLS-1$
- xmlRadioButton = new JRadioButton("XML", false); //$NON-NLS-1$
- ButtonGroup buttonGroup = new ButtonGroup();
- buttonGroup.add(htmlRadioButton);
- buttonGroup.add(xhtmlRadioButton);
- buttonGroup.add(xmlRadioButton);
- formatPanel.add(htmlRadioButton);
- formatPanel.add(xhtmlRadioButton);
- formatPanel.add(xmlRadioButton);
- assertionPanel.add(formatPanel);
-
- // errors only
- errorsOnly = new JCheckBox("Errors only", false);
- errorsOnly.addActionListener(this);
- assertionPanel.add(errorsOnly);
-
- // thresholds
- HorizontalPanel thresholdPanel = new HorizontalPanel();
- thresholdPanel.add(new JLabel("Error threshold:"));
- errorThresholdField = new JTextField("0", 5); // $NON-NLS-1$
- errorThresholdField.setName(ERROR_THRESHOLD_FIELD);
- errorThresholdField.addKeyListener(this);
- thresholdPanel.add(errorThresholdField);
- thresholdPanel.add(new JLabel("Warning threshold:"));
- warningThresholdField = new JTextField("0", 5); // $NON-NLS-1$
- warningThresholdField.setName(WARNING_THRESHOLD_FIELD);
- warningThresholdField.addKeyListener(this);
- thresholdPanel.add(warningThresholdField);
- assertionPanel.add(thresholdPanel);
-
- // file panel
- filePanel = new FilePanel(JMeterUtils.getResString("html_assertion_file"), ".txt"); //$NON-NLS-1$ //$NON-NLS-2$
- assertionPanel.add(filePanel);
-
- mainPanel.add(assertionPanel, BorderLayout.NORTH);
- add(mainPanel, BorderLayout.CENTER);
- }
-
- /**
- * This method is called if one of the threshold field looses the focus
- *
- * @param inEvent
- */
- public void focusLost(FocusEvent inEvent) {
- log.debug("HTMLAssertionGui.focusLost() called");
-
- String errorThresholdString = errorThresholdField.getText();
- if (errorThresholdString != null) {
- boolean isInvalid = false;
- try {
- long errorThreshold = Long.parseLong(errorThresholdString);
- if (errorThreshold < 0) {
- isInvalid = true;
- }
- } catch (NumberFormatException ex) {
- isInvalid = true;
- }
- if (isInvalid) {
- log.warn("HTMLAssertionGui: Error threshold Not a valid number!");
- JOptionPane.showMessageDialog(null, "Threshold for errors is invalid", "Error",
- JOptionPane.ERROR_MESSAGE);
- }
- }
-
- String warningThresholdString = warningThresholdField.getText();
- if (warningThresholdString != null) {
- boolean isInvalid = false;
- try {
- long warningThreshold = Long.parseLong(warningThresholdString);
- if (warningThreshold < 0) {
- isInvalid = true;
- }
- } catch (NumberFormatException ex) {
- isInvalid = true;
- }
- if (isInvalid) {
- log.warn("HTMLAssertionGui: Error threshold Not a valid number!");
- JOptionPane.showMessageDialog(null, "Threshold for warnings is invalid", "Error",
- JOptionPane.ERROR_MESSAGE);
- }
- }
- }
-
- /**
- * @see java.awt.event.FocusListener#focusGained(java.awt.event.FocusEvent)
- */
- public void focusGained(FocusEvent e) {
-
- }
-
- /**
- * This method is called from erros-only checkbox
- *
- * @see java.awt.event.ActionListener#actionPerformed(java.awt.event.ActionEvent)
- */
- public void actionPerformed(ActionEvent e) {
- if (errorsOnly.isSelected()) {
- warningThresholdField.setEnabled(false);
- warningThresholdField.setEditable(false);
- } else {
- warningThresholdField.setEnabled(true);
- warningThresholdField.setEditable(true);
- }
- }
-
- public void keyPressed(KeyEvent e) {
- }
-
- public void keyReleased(KeyEvent e) {
- String fieldName = e.getComponent().getName();
-
- if (fieldName.equals(WARNING_THRESHOLD_FIELD)) {
- validateInteger(warningThresholdField);
- }
-
- if (fieldName.equals(ERROR_THRESHOLD_FIELD)) {
- validateInteger(errorThresholdField);
- }
- }
-
- private void validateInteger(JTextField field){
- try {
- Integer.parseInt(field.getText());
- } catch (NumberFormatException nfe) {
- int length = field.getText().length();
- if (length > 0) {
- JOptionPane.showMessageDialog(this, "Only digits allowed", "Invalid data",
- JOptionPane.WARNING_MESSAGE);
- // Drop the last character:
- field.setText(field.getText().substring(0, length-1));
- }
- }
-
- }
- public void keyTyped(KeyEvent e) {
- }
+ /**
+ * Configures the associated test element.
+ *
+ * @param inElement
+ */
+ public void configure(TestElement inElement) {
+ super.configure(inElement);
+ HTMLAssertion lAssertion = (HTMLAssertion) inElement;
+ errorThresholdField.setText(String.valueOf(lAssertion.getErrorThreshold()));
+ warningThresholdField.setText(String.valueOf(lAssertion.getWarningThreshold()));
+ errorsOnly.setSelected(lAssertion.isErrorsOnly());
+ docTypeBox.setSelectedItem(lAssertion.getDoctype());
+ if (lAssertion.isHTML()) {
+ htmlRadioButton.setSelected(true);
+ } else if (lAssertion.isXHTML()) {
+ xhtmlRadioButton.setSelected(true);
+ } else {
+ xmlRadioButton.setSelected(true);
+ }
+ if (lAssertion.isErrorsOnly()) {
+ warningThresholdField.setEnabled(false);
+ warningThresholdField.setEditable(false);
+ }
+ else {
+ warningThresholdField.setEnabled(true);
+ warningThresholdField.setEditable(true);
+ }
+ filePanel.setFilename(lAssertion.getFilename());
+ }
+
+ /**
+ * Inits the GUI.
+ */
+ private void init() {
+
+ setLayout(new BorderLayout(0, 10));
+ setBorder(makeBorder());
+
+ add(makeTitlePanel(), BorderLayout.NORTH);
+
+ JPanel mainPanel = new JPanel(new BorderLayout());
+
+ // USER_INPUT
+ VerticalPanel assertionPanel = new VerticalPanel();
+ assertionPanel.setBorder(BorderFactory.createTitledBorder(BorderFactory.createEtchedBorder(), "Tidy Settings"));
+
+ // doctype
+ HorizontalPanel docTypePanel = new HorizontalPanel();
+ docTypeBox = new JComboBox(new Object[] { "omit", "auto", "strict", "loose" });
+ // docTypePanel.add(new
+ // JLabel(JMeterUtils.getResString("duration_assertion_label"))); //$NON-NLS-1$
+ docTypePanel.add(new JLabel("Doctype:"));
+ docTypePanel.add(docTypeBox);
+ assertionPanel.add(docTypePanel);
+
+ // format (HMTL, XHTML, XML)
+ VerticalPanel formatPanel = new VerticalPanel();
+ formatPanel.setBorder(BorderFactory.createTitledBorder(BorderFactory.createEtchedBorder(), "Format"));
+ htmlRadioButton = new JRadioButton("HTML", true); //$NON-NLS-1$
+ xhtmlRadioButton = new JRadioButton("XHTML", false); //$NON-NLS-1$
+ xmlRadioButton = new JRadioButton("XML", false); //$NON-NLS-1$
+ ButtonGroup buttonGroup = new ButtonGroup();
+ buttonGroup.add(htmlRadioButton);
+ buttonGroup.add(xhtmlRadioButton);
+ buttonGroup.add(xmlRadioButton);
+ formatPanel.add(htmlRadioButton);
+ formatPanel.add(xhtmlRadioButton);
+ formatPanel.add(xmlRadioButton);
+ assertionPanel.add(formatPanel);
+
+ // errors only
+ errorsOnly = new JCheckBox("Errors only", false);
+ errorsOnly.addActionListener(this);
+ assertionPanel.add(errorsOnly);
+
+ // thresholds
+ HorizontalPanel thresholdPanel = new HorizontalPanel();
+ thresholdPanel.add(new JLabel("Error threshold:"));
+ errorThresholdField = new JTextField("0", 5); // $NON-NLS-1$
+ errorThresholdField.setName(ERROR_THRESHOLD_FIELD);
+ errorThresholdField.addKeyListener(this);
+ thresholdPanel.add(errorThresholdField);
+ thresholdPanel.add(new JLabel("Warning threshold:"));
+ warningThresholdField = new JTextField("0", 5); // $NON-NLS-1$
+ warningThresholdField.setName(WARNING_THRESHOLD_FIELD);
+ warningThresholdField.addKeyListener(this);
+ thresholdPanel.add(warningThresholdField);
+ assertionPanel.add(thresholdPanel);
+
+ // file panel
+ filePanel = new FilePanel(JMeterUtils.getResString("html_assertion_file"), ".txt"); //$NON-NLS-1$ //$NON-NLS-2$
+ assertionPanel.add(filePanel);
+
+ mainPanel.add(assertionPanel, BorderLayout.NORTH);
+ add(mainPanel, BorderLayout.CENTER);
+ }
+
+ /**
+ * This method is called if one of the threshold field looses the focus
+ *
+ * @param inEvent
+ */
+ public void focusLost(FocusEvent inEvent) {
+ log.debug("HTMLAssertionGui.focusLost() called");
+
+ String errorThresholdString = errorThresholdField.getText();
+ if (errorThresholdString != null) {
+ boolean isInvalid = false;
+ try {
+ long errorThreshold = Long.parseLong(errorThresholdString);
+ if (errorThreshold < 0) {
+ isInvalid = true;
+ }
+ } catch (NumberFormatException ex) {
+ isInvalid = true;
+ }
+ if (isInvalid) {
+ log.warn("HTMLAssertionGui: Error threshold Not a valid number!");
+ JOptionPane.showMessageDialog(null, "Threshold for errors is invalid", "Error",
+ JOptionPane.ERROR_MESSAGE);
+ }
+ }
+
+ String warningThresholdString = warningThresholdField.getText();
+ if (warningThresholdString != null) {
+ boolean isInvalid = false;
+ try {
+ long warningThreshold = Long.parseLong(warningThresholdString);
+ if (warningThreshold < 0) {
+ isInvalid = true;
+ }
+ } catch (NumberFormatException ex) {
+ isInvalid = true;
+ }
+ if (isInvalid) {
+ log.warn("HTMLAssertionGui: Error threshold Not a valid number!");
+ JOptionPane.showMessageDialog(null, "Threshold for warnings is invalid", "Error",
+ JOptionPane.ERROR_MESSAGE);
+ }
+ }
+ }
+
+ /**
+ * @see java.awt.event.FocusListener#focusGained(java.awt.event.FocusEvent)
+ */
+ public void focusGained(FocusEvent e) {
+
+ }
+
+ /**
+ * This method is called from erros-only checkbox
+ *
+ * @see java.awt.event.ActionListener#actionPerformed(java.awt.event.ActionEvent)
+ */
+ public void actionPerformed(ActionEvent e) {
+ if (errorsOnly.isSelected()) {
+ warningThresholdField.setEnabled(false);
+ warningThresholdField.setEditable(false);
+ } else {
+ warningThresholdField.setEnabled(true);
+ warningThresholdField.setEditable(true);
+ }
+ }
+
+ public void keyPressed(KeyEvent e) {
+ }
+
+ public void keyReleased(KeyEvent e) {
+ String fieldName = e.getComponent().getName();
+
+ if (fieldName.equals(WARNING_THRESHOLD_FIELD)) {
+ validateInteger(warningThresholdField);
+ }
+
+ if (fieldName.equals(ERROR_THRESHOLD_FIELD)) {
+ validateInteger(errorThresholdField);
+ }
+ }
+
+ private void validateInteger(JTextField field){
+ try {
+ Integer.parseInt(field.getText());
+ } catch (NumberFormatException nfe) {
+ int length = field.getText().length();
+ if (length > 0) {
+ JOptionPane.showMessageDialog(this, "Only digits allowed", "Invalid data",
+ JOptionPane.WARNING_MESSAGE);
+ // Drop the last character:
+ field.setText(field.getText().substring(0, length-1));
+ }
+ }
+
+ }
+ public void keyTyped(KeyEvent e) {
+ }
}
Modified: jakarta/jmeter/trunk/src/components/org/apache/jmeter/assertions/gui/MD5HexAssertionGUI.java
URL: http://svn.apache.org/viewvc/jakarta/jmeter/trunk/src/components/org/apache/jmeter/assertions/gui/MD5HexAssertionGUI.java?rev=674342&r1=674341&r2=674342&view=diff
==============================================================================
--- jakarta/jmeter/trunk/src/components/org/apache/jmeter/assertions/gui/MD5HexAssertionGUI.java (original)
+++ jakarta/jmeter/trunk/src/components/org/apache/jmeter/assertions/gui/MD5HexAssertionGUI.java Sun Jul 6 13:28:49 2008
@@ -36,70 +36,70 @@
public class MD5HexAssertionGUI extends AbstractAssertionGui {
- private JTextField md5HexInput;
+ private JTextField md5HexInput;
- public MD5HexAssertionGUI() {
- init();
- }
-
- private void init() {
-
- setLayout(new BorderLayout(0, 10));
- setBorder(makeBorder());
-
- add(makeTitlePanel(), BorderLayout.NORTH);
-
- JPanel mainPanel = new JPanel(new BorderLayout());
-
- // USER_INPUT
- HorizontalPanel md5HexPanel = new HorizontalPanel();
- md5HexPanel.setBorder(BorderFactory.createTitledBorder(BorderFactory.createEtchedBorder(),
- JMeterUtils.getResString("md5hex_assertion_md5hex_test"))); // $NON-NLS-1$
-
- md5HexPanel.add(new JLabel(JMeterUtils.getResString("md5hex_assertion_label"))); //$NON-NLS-1$
-
- md5HexInput = new JTextField(25);
- // md5HexInput.addFocusListener(this);
- md5HexPanel.add(md5HexInput);
-
- mainPanel.add(md5HexPanel, BorderLayout.NORTH);
- add(mainPanel, BorderLayout.CENTER);
-
- }
-
- public void configure(TestElement el) {
- super.configure(el);
- MD5HexAssertion assertion = (MD5HexAssertion) el;
- this.md5HexInput.setText(String.valueOf(assertion.getAllowedMD5Hex()));
- }
-
- public String getLabelResource() {
- return "md5hex_assertion_title"; // $NON-NLS-1$
- }
-
- /*
- * @return
- */
- public TestElement createTestElement() {
-
- MD5HexAssertion el = new MD5HexAssertion();
- modifyTestElement(el);
- return el;
-
- }
-
- /*
- * @param element
- */
- public void modifyTestElement(TestElement element) {
- configureTestElement(element);
- String md5HexString = this.md5HexInput.getText();
- // initialize to empty string, this will fail the assertion
- if (md5HexString == null || md5HexString.length() == 0) {
- md5HexString = "";
- }
- ((MD5HexAssertion) element).setAllowedMD5Hex(md5HexString);
- }
+ public MD5HexAssertionGUI() {
+ init();
+ }
+
+ private void init() {
+
+ setLayout(new BorderLayout(0, 10));
+ setBorder(makeBorder());
+
+ add(makeTitlePanel(), BorderLayout.NORTH);
+
+ JPanel mainPanel = new JPanel(new BorderLayout());
+
+ // USER_INPUT
+ HorizontalPanel md5HexPanel = new HorizontalPanel();
+ md5HexPanel.setBorder(BorderFactory.createTitledBorder(BorderFactory.createEtchedBorder(),
+ JMeterUtils.getResString("md5hex_assertion_md5hex_test"))); // $NON-NLS-1$
+
+ md5HexPanel.add(new JLabel(JMeterUtils.getResString("md5hex_assertion_label"))); //$NON-NLS-1$
+
+ md5HexInput = new JTextField(25);
+ // md5HexInput.addFocusListener(this);
+ md5HexPanel.add(md5HexInput);
+
+ mainPanel.add(md5HexPanel, BorderLayout.NORTH);
+ add(mainPanel, BorderLayout.CENTER);
+
+ }
+
+ public void configure(TestElement el) {
+ super.configure(el);
+ MD5HexAssertion assertion = (MD5HexAssertion) el;
+ this.md5HexInput.setText(String.valueOf(assertion.getAllowedMD5Hex()));
+ }
+
+ public String getLabelResource() {
+ return "md5hex_assertion_title"; // $NON-NLS-1$
+ }
+
+ /*
+ * @return
+ */
+ public TestElement createTestElement() {
+
+ MD5HexAssertion el = new MD5HexAssertion();
+ modifyTestElement(el);
+ return el;
+
+ }
+
+ /*
+ * @param element
+ */
+ public void modifyTestElement(TestElement element) {
+ configureTestElement(element);
+ String md5HexString = this.md5HexInput.getText();
+ // initialize to empty string, this will fail the assertion
+ if (md5HexString == null || md5HexString.length() == 0) {
+ md5HexString = "";
+ }
+ ((MD5HexAssertion) element).setAllowedMD5Hex(md5HexString);
+ }
/**
* Implements JMeterGUIComponent.clearGui
Modified: jakarta/jmeter/trunk/src/components/org/apache/jmeter/assertions/gui/SizeAssertionGui.java
URL: http://svn.apache.org/viewvc/jakarta/jmeter/trunk/src/components/org/apache/jmeter/assertions/gui/SizeAssertionGui.java?rev=674342&r1=674341&r2=674342&view=diff
==============================================================================
--- jakarta/jmeter/trunk/src/components/org/apache/jmeter/assertions/gui/SizeAssertionGui.java (original)
+++ jakarta/jmeter/trunk/src/components/org/apache/jmeter/assertions/gui/SizeAssertionGui.java Sun Jul 6 13:28:49 2008
@@ -39,48 +39,48 @@
public class SizeAssertionGui extends AbstractAssertionGui implements FocusListener, ActionListener {
- private JTextField size;
+ private JTextField size;
- private JRadioButton equalButton, notequalButton, greaterthanButton, lessthanButton, greaterthanequalButton,
- lessthanequalButton;
+ private JRadioButton equalButton, notequalButton, greaterthanButton, lessthanButton, greaterthanequalButton,
+ lessthanequalButton;
- private int execState; // store the operator
+ private int execState; // store the operator
- public SizeAssertionGui() {
- init();
- }
-
- public String getLabelResource() {
- return "size_assertion_title"; //$NON-NLS-1$
- }
-
- public String getSizeAttributesTitle() {
- return JMeterUtils.getResString("size_assertion_size_test"); //$NON-NLS-1$
- }
-
- public TestElement createTestElement() {
- SizeAssertion el = new SizeAssertion();
- modifyTestElement(el);
- return el;
- }
-
- /**
- * Modifies a given TestElement to mirror the data in the gui components.
- *
- * @see org.apache.jmeter.gui.JMeterGUIComponent#modifyTestElement(TestElement)
- */
- public void modifyTestElement(TestElement el) {
- configureTestElement(el);
- String sizeString = size.getText();
- long assertionSize = 0;
- try {
- assertionSize = Long.parseLong(sizeString);
- } catch (NumberFormatException e) {
- assertionSize = Long.MAX_VALUE;
- }
- ((SizeAssertion) el).setAllowedSize(assertionSize);
- ((SizeAssertion) el).setCompOper(getState());
- }
+ public SizeAssertionGui() {
+ init();
+ }
+
+ public String getLabelResource() {
+ return "size_assertion_title"; //$NON-NLS-1$
+ }
+
+ public String getSizeAttributesTitle() {
+ return JMeterUtils.getResString("size_assertion_size_test"); //$NON-NLS-1$
+ }
+
+ public TestElement createTestElement() {
+ SizeAssertion el = new SizeAssertion();
+ modifyTestElement(el);
+ return el;
+ }
+
+ /**
+ * Modifies a given TestElement to mirror the data in the gui components.
+ *
+ * @see org.apache.jmeter.gui.JMeterGUIComponent#modifyTestElement(TestElement)
+ */
+ public void modifyTestElement(TestElement el) {
+ configureTestElement(el);
+ String sizeString = size.getText();
+ long assertionSize = 0;
+ try {
+ assertionSize = Long.parseLong(sizeString);
+ } catch (NumberFormatException e) {
+ assertionSize = Long.MAX_VALUE;
+ }
+ ((SizeAssertion) el).setAllowedSize(assertionSize);
+ ((SizeAssertion) el).setCompOper(getState());
+ }
/**
* Implements JMeterGUIComponent.clearGui
@@ -98,126 +98,126 @@
execState = SizeAssertion.EQUAL;
}
- public void configure(TestElement el) {
- super.configure(el);
- SizeAssertion assertion = (SizeAssertion) el;
- size.setText(String.valueOf(assertion.getAllowedSize()));
- setState(assertion.getCompOper());
- }
-
- /**
- * Set the state of the radio Button
- */
- public void setState(int state) {
- if (state == SizeAssertion.EQUAL) {
- equalButton.setSelected(true);
- execState = state;
- } else if (state == SizeAssertion.NOTEQUAL) {
- notequalButton.setSelected(true);
- execState = state;
- } else if (state == SizeAssertion.GREATERTHAN) {
- greaterthanButton.setSelected(true);
- execState = state;
- } else if (state == SizeAssertion.LESSTHAN) {
- lessthanButton.setSelected(true);
- execState = state;
- } else if (state == SizeAssertion.GREATERTHANEQUAL) {
- greaterthanequalButton.setSelected(true);
- execState = state;
- } else if (state == SizeAssertion.LESSTHANEQUAL) {
- lessthanequalButton.setSelected(true);
- execState = state;
- }
- }
-
- /**
- * Get the state of the radio Button
- */
- public int getState() {
- return execState;
- }
-
- private void init() {
- setLayout(new VerticalLayout(5, VerticalLayout.BOTH, VerticalLayout.TOP));
- setBorder(makeBorder());
-
- add(makeTitlePanel());
-
- // USER_INPUT
- JPanel sizePanel = new JPanel();
- sizePanel.setBorder(BorderFactory.createTitledBorder(BorderFactory.createEtchedBorder(),
- getSizeAttributesTitle()));
-
- sizePanel.add(new JLabel(JMeterUtils.getResString("size_assertion_label"))); //$NON-NLS-1$
- size = new JTextField(5);
- size.addFocusListener(this);
- sizePanel.add(size);
-
- sizePanel.add(createComparatorButtonPanel());
-
- add(sizePanel);
- }
-
- private Box createComparatorButtonPanel() {
- ButtonGroup group = new ButtonGroup();
-
- equalButton = createComparatorButton("=", SizeAssertion.EQUAL, group); //$NON-NLS-1$
- notequalButton = createComparatorButton("!=", SizeAssertion.NOTEQUAL, group); //$NON-NLS-1$
- greaterthanButton = createComparatorButton(">", SizeAssertion.GREATERTHAN, group); //$NON-NLS-1$
- lessthanButton = createComparatorButton("<", SizeAssertion.LESSTHAN, group); //$NON-NLS-1$
- greaterthanequalButton = createComparatorButton(">=", SizeAssertion.GREATERTHANEQUAL, group); //$NON-NLS-1$
- lessthanequalButton = createComparatorButton("<=", SizeAssertion.LESSTHANEQUAL, group); //$NON-NLS-1$
-
- equalButton.setSelected(true);
- execState = Integer.parseInt(equalButton.getActionCommand());
-
- // Put the check boxes in a column in a panel
- Box checkPanel = Box.createVerticalBox();
- JLabel compareLabel = new JLabel(JMeterUtils.getResString("size_assertion_comparator_label")); //$NON-NLS-1$
- checkPanel.add(compareLabel);
- checkPanel.add(equalButton);
- checkPanel.add(notequalButton);
- checkPanel.add(greaterthanButton);
- checkPanel.add(lessthanButton);
- checkPanel.add(greaterthanequalButton);
- checkPanel.add(lessthanequalButton);
- return checkPanel;
- }
-
- private JRadioButton createComparatorButton(String name, int value, ButtonGroup group) {
- JRadioButton button = new JRadioButton(name);
- button.setActionCommand(String.valueOf(value));
- button.addActionListener(this);
- group.add(button);
- return button;
- }
-
- public void focusLost(FocusEvent e) {
- boolean isInvalid = false;
- String sizeString = size.getText();
- if (sizeString != null) {
- try {
- long assertionSize = Long.parseLong(sizeString);
- if (assertionSize < 0) {
- isInvalid = true;
- }
- } catch (NumberFormatException ex) {
- isInvalid = true;
- }
- if (isInvalid) {
- JOptionPane.showMessageDialog(null,
- JMeterUtils.getResString("size_assertion_input_error"), //$NON-NLS-1$
- "Error",
- JOptionPane.ERROR_MESSAGE);
- }
- }
- }
-
- public void focusGained(FocusEvent e) {
- }
-
- public void actionPerformed(ActionEvent e) {
- int comparator = Integer.parseInt(e.getActionCommand());
- execState = comparator;
- }
+ public void configure(TestElement el) {
+ super.configure(el);
+ SizeAssertion assertion = (SizeAssertion) el;
+ size.setText(String.valueOf(assertion.getAllowedSize()));
+ setState(assertion.getCompOper());
+ }
+
+ /**
+ * Set the state of the radio Button
+ */
+ public void setState(int state) {
+ if (state == SizeAssertion.EQUAL) {
+ equalButton.setSelected(true);
+ execState = state;
+ } else if (state == SizeAssertion.NOTEQUAL) {
+ notequalButton.setSelected(true);
+ execState = state;
+ } else if (state == SizeAssertion.GREATERTHAN) {
+ greaterthanButton.setSelected(true);
+ execState = state;
+ } else if (state == SizeAssertion.LESSTHAN) {
+ lessthanButton.setSelected(true);
+ execState = state;
+ } else if (state == SizeAssertion.GREATERTHANEQUAL) {
+ greaterthanequalButton.setSelected(true);
+ execState = state;
+ } else if (state == SizeAssertion.LESSTHANEQUAL) {
+ lessthanequalButton.setSelected(true);
+ execState = state;
+ }
+ }
+
+ /**
+ * Get the state of the radio Button
+ */
+ public int getState() {
+ return execState;
+ }
+
+ private void init() {
+ setLayout(new VerticalLayout(5, VerticalLayout.BOTH, VerticalLayout.TOP));
+ setBorder(makeBorder());
+
+ add(makeTitlePanel());
+
+ // USER_INPUT
+ JPanel sizePanel = new JPanel();
+ sizePanel.setBorder(BorderFactory.createTitledBorder(BorderFactory.createEtchedBorder(),
+ getSizeAttributesTitle()));
+
+ sizePanel.add(new JLabel(JMeterUtils.getResString("size_assertion_label"))); //$NON-NLS-1$
+ size = new JTextField(5);
+ size.addFocusListener(this);
+ sizePanel.add(size);
+
+ sizePanel.add(createComparatorButtonPanel());
+
+ add(sizePanel);
+ }
+
+ private Box createComparatorButtonPanel() {
+ ButtonGroup group = new ButtonGroup();
+
+ equalButton = createComparatorButton("=", SizeAssertion.EQUAL, group); //$NON-NLS-1$
+ notequalButton = createComparatorButton("!=", SizeAssertion.NOTEQUAL, group); //$NON-NLS-1$
+ greaterthanButton = createComparatorButton(">", SizeAssertion.GREATERTHAN, group); //$NON-NLS-1$
+ lessthanButton = createComparatorButton("<", SizeAssertion.LESSTHAN, group); //$NON-NLS-1$
+ greaterthanequalButton = createComparatorButton(">=", SizeAssertion.GREATERTHANEQUAL, group); //$NON-NLS-1$
+ lessthanequalButton = createComparatorButton("<=", SizeAssertion.LESSTHANEQUAL, group); //$NON-NLS-1$
+
+ equalButton.setSelected(true);
+ execState = Integer.parseInt(equalButton.getActionCommand());
+
+ // Put the check boxes in a column in a panel
+ Box checkPanel = Box.createVerticalBox();
+ JLabel compareLabel = new JLabel(JMeterUtils.getResString("size_assertion_comparator_label")); //$NON-NLS-1$
+ checkPanel.add(compareLabel);
+ checkPanel.add(equalButton);
+ checkPanel.add(notequalButton);
+ checkPanel.add(greaterthanButton);
+ checkPanel.add(lessthanButton);
+ checkPanel.add(greaterthanequalButton);
+ checkPanel.add(lessthanequalButton);
+ return checkPanel;
+ }
+
+ private JRadioButton createComparatorButton(String name, int value, ButtonGroup group) {
+ JRadioButton button = new JRadioButton(name);
+ button.setActionCommand(String.valueOf(value));
+ button.addActionListener(this);
+ group.add(button);
+ return button;
+ }
+
+ public void focusLost(FocusEvent e) {
+ boolean isInvalid = false;
+ String sizeString = size.getText();
+ if (sizeString != null) {
+ try {
+ long assertionSize = Long.parseLong(sizeString);
+ if (assertionSize < 0) {
+ isInvalid = true;
+ }
+ } catch (NumberFormatException ex) {
+ isInvalid = true;
+ }
+ if (isInvalid) {
+ JOptionPane.showMessageDialog(null,
+ JMeterUtils.getResString("size_assertion_input_error"), //$NON-NLS-1$
+ "Error",
+ JOptionPane.ERROR_MESSAGE);
+ }
+ }
+ }
+
+ public void focusGained(FocusEvent e) {
+ }
+
+ public void actionPerformed(ActionEvent e) {
+ int comparator = Integer.parseInt(e.getActionCommand());
+ execState = comparator;
+ }
}
Modified: jakarta/jmeter/trunk/src/components/org/apache/jmeter/assertions/gui/XMLAssertionGui.java
URL: http://svn.apache.org/viewvc/jakarta/jmeter/trunk/src/components/org/apache/jmeter/assertions/gui/XMLAssertionGui.java?rev=674342&r1=674341&r2=674342&view=diff
==============================================================================
--- jakarta/jmeter/trunk/src/components/org/apache/jmeter/assertions/gui/XMLAssertionGui.java (original)
+++ jakarta/jmeter/trunk/src/components/org/apache/jmeter/assertions/gui/XMLAssertionGui.java Sun Jul 6 13:28:49 2008
@@ -23,51 +23,51 @@
import org.apache.jorphan.gui.layout.VerticalLayout;
public class XMLAssertionGui extends AbstractAssertionGui {
- /**
- * The constructor.
- */
- public XMLAssertionGui() {
- init();
- }
-
- /**
- * Returns the label to be shown within the JTree-Component.
- */
- public String getLabelResource() {
- return "xml_assertion_title"; // $NON-NLS-1$
- }
-
- public TestElement createTestElement() {
- XMLAssertion el = new XMLAssertion();
- modifyTestElement(el);
- return el;
- }
-
- /**
- * Modifies a given TestElement to mirror the data in the gui components.
- *
- * @see org.apache.jmeter.gui.JMeterGUIComponent#modifyTestElement(TestElement)
- */
- public void modifyTestElement(TestElement el) {
- configureTestElement(el);
- }
-
- /**
- * Configures the associated test element.
- *
- * @param el
- */
- public void configure(TestElement el) {
- super.configure(el);
- }
-
- /**
- * Inits the GUI.
- */
- private void init() {
- setLayout(new VerticalLayout(5, VerticalLayout.BOTH, VerticalLayout.TOP));
- setBorder(makeBorder());
+ /**
+ * The constructor.
+ */
+ public XMLAssertionGui() {
+ init();
+ }
+
+ /**
+ * Returns the label to be shown within the JTree-Component.
+ */
+ public String getLabelResource() {
+ return "xml_assertion_title"; // $NON-NLS-1$
+ }
+
+ public TestElement createTestElement() {
+ XMLAssertion el = new XMLAssertion();
+ modifyTestElement(el);
+ return el;
+ }
+
+ /**
+ * Modifies a given TestElement to mirror the data in the gui components.
+ *
+ * @see org.apache.jmeter.gui.JMeterGUIComponent#modifyTestElement(TestElement)
+ */
+ public void modifyTestElement(TestElement el) {
+ configureTestElement(el);
+ }
+
+ /**
+ * Configures the associated test element.
+ *
+ * @param el
+ */
+ public void configure(TestElement el) {
+ super.configure(el);
+ }
+
+ /**
+ * Inits the GUI.
+ */
+ private void init() {
+ setLayout(new VerticalLayout(5, VerticalLayout.BOTH, VerticalLayout.TOP));
+ setBorder(makeBorder());
- add(makeTitlePanel());
- }
+ add(makeTitlePanel());
+ }
}
Modified: jakarta/jmeter/trunk/src/components/org/apache/jmeter/assertions/gui/XMLConfPanel.java
URL: http://svn.apache.org/viewvc/jakarta/jmeter/trunk/src/components/org/apache/jmeter/assertions/gui/XMLConfPanel.java?rev=674342&r1=674341&r2=674342&view=diff
==============================================================================
--- jakarta/jmeter/trunk/src/components/org/apache/jmeter/assertions/gui/XMLConfPanel.java (original)
+++ jakarta/jmeter/trunk/src/components/org/apache/jmeter/assertions/gui/XMLConfPanel.java Sun Jul 6 13:28:49 2008
@@ -30,46 +30,46 @@
import org.apache.jmeter.util.JMeterUtils;
public class XMLConfPanel extends JPanel {
- private JCheckBox validate, tolerant, whitespace, namespace;
+ private JCheckBox validate, tolerant, whitespace, namespace;
- private JCheckBox quiet; // Should Tidy be quiet?
-
- private JCheckBox reportErrors; // Report Tidy errors as Assertion failure?
-
- private JCheckBox showWarnings; // Show Tidy warnings ?
-
- /**
- *
- */
- public XMLConfPanel() {
- super();
- init();
- }
-
- /**
- * @param isDoubleBuffered
- */
- public XMLConfPanel(boolean isDoubleBuffered) {
- super(isDoubleBuffered);
- init();
- }
-
- private void init() {
- Box tidyOptions = Box.createHorizontalBox();
- tidyOptions.setBorder(BorderFactory.createEtchedBorder());
- tidyOptions.add(getTolerant());
- quiet = new JCheckBox(JMeterUtils.getResString("xpath_tidy_quiet"),true);//$NON-NLS-1$
- reportErrors = new JCheckBox(JMeterUtils.getResString("xpath_tidy_report_errors"),true);//$NON-NLS-1$
- showWarnings = new JCheckBox(JMeterUtils.getResString("xpath_tidy_show_warnings"),true);//$NON-NLS-1$
- tidyOptions.add(quiet);
- tidyOptions.add(reportErrors);
- tidyOptions.add(showWarnings);
- add(tidyOptions);
- add(getNamespace());
- add(getValidate());
- add(getWhitespace());
- setDefaultValues();
- }
+ private JCheckBox quiet; // Should Tidy be quiet?
+
+ private JCheckBox reportErrors; // Report Tidy errors as Assertion failure?
+
+ private JCheckBox showWarnings; // Show Tidy warnings ?
+
+ /**
+ *
+ */
+ public XMLConfPanel() {
+ super();
+ init();
+ }
+
+ /**
+ * @param isDoubleBuffered
+ */
+ public XMLConfPanel(boolean isDoubleBuffered) {
+ super(isDoubleBuffered);
+ init();
+ }
+
+ private void init() {
+ Box tidyOptions = Box.createHorizontalBox();
+ tidyOptions.setBorder(BorderFactory.createEtchedBorder());
+ tidyOptions.add(getTolerant());
+ quiet = new JCheckBox(JMeterUtils.getResString("xpath_tidy_quiet"),true);//$NON-NLS-1$
+ reportErrors = new JCheckBox(JMeterUtils.getResString("xpath_tidy_report_errors"),true);//$NON-NLS-1$
+ showWarnings = new JCheckBox(JMeterUtils.getResString("xpath_tidy_show_warnings"),true);//$NON-NLS-1$
+ tidyOptions.add(quiet);
+ tidyOptions.add(reportErrors);
+ tidyOptions.add(showWarnings);
+ add(tidyOptions);
+ add(getNamespace());
+ add(getValidate());
+ add(getWhitespace());
+ setDefaultValues();
+ }
public void setDefaultValues() {
setWhitespace(false);
@@ -82,114 +82,114 @@
tolerant();
}
- /**
- * @return Returns the namespace.
- */
+ /**
+ * @return Returns the namespace.
+ */
private JCheckBox getNamespace() {
- if (namespace == null) {
- namespace = new JCheckBox(JMeterUtils.getResString("xml_namespace_button")); //$NON-NLS-1$
- }
- return namespace;
- }
-
- /**
- * @return Returns the tolerant.
- */
+ if (namespace == null) {
+ namespace = new JCheckBox(JMeterUtils.getResString("xml_namespace_button")); //$NON-NLS-1$
+ }
+ return namespace;
+ }
+
+ /**
+ * @return Returns the tolerant.
+ */
private JCheckBox getTolerant() {
- if (tolerant == null) {
- tolerant = new JCheckBox(JMeterUtils.getResString("xml_tolerant_button")); //$NON-NLS-1$
- tolerant.addActionListener(new ActionListener() {
-
- public void actionPerformed(ActionEvent e) {
- tolerant();
- }
- });
- }
- return tolerant;
- }
-
- /**
- * @return Returns the validate.
- */
- private JCheckBox getValidate() {
- if (validate == null) {
- validate = new JCheckBox(JMeterUtils.getResString("xml_validate_button")); //$NON-NLS-1$
- }
- return validate;
- }
-
- /**
- * @return Returns the whitespace.
- */
- private JCheckBox getWhitespace() {
- if (whitespace == null) {
- whitespace = new JCheckBox(JMeterUtils.getResString("xml_whitespace_button")); //$NON-NLS-1$
- }
- return whitespace;
- }
-
- private boolean isNamespace() {
- return getNamespace().isSelected();
- }
-
- private void setNamespace(boolean namespace) {
- getNamespace().setSelected(namespace);
- }
-
- private boolean isTolerant() {
- return getTolerant().isSelected();
- }
-
- private void setTolerant(boolean tolerant) {
- getTolerant().setSelected(tolerant);
- }
-
- private boolean isWhitespace() {
- return getWhitespace().isSelected();
- }
-
- private void setWhitespace(boolean whitespace) {
- getWhitespace().setSelected(whitespace);
- }
-
- private boolean isValidate() {
- return getValidate().isSelected();
- }
-
- private void setValidate(boolean validating) {
- getValidate().setSelected(validating);
- }
-
- private void tolerant() {
- final boolean isTolerant = isTolerant();
- getValidate().setEnabled(!isTolerant);
- getWhitespace().setEnabled(!isTolerant);
- getNamespace().setEnabled(!isTolerant);
- quiet.setEnabled(isTolerant);
- reportErrors.setEnabled(isTolerant);
- showWarnings.setEnabled(isTolerant);
- }
-
- // Called by XPathAssertionGui
- public void modifyTestElement(XPathAssertion assertion) {
- assertion.setValidating(isValidate());
- assertion.setWhitespace(isWhitespace());
- assertion.setTolerant(isTolerant());
- assertion.setNamespace(isNamespace());
- assertion.setShowWarnings(showWarnings.isSelected());
- assertion.setReportErrors(reportErrors.isSelected());
- assertion.setQuiet(quiet.isSelected());
- }
-
- // Called by XPathAssertionGui
- public void configure(XPathAssertion assertion) {
- setWhitespace(assertion.isWhitespace());
- setValidate(assertion.isValidating());
- setTolerant(assertion.isTolerant());
- setNamespace(assertion.isNamespace());
- quiet.setSelected(assertion.isQuiet());
- showWarnings.setSelected(assertion.showWarnings());
- reportErrors.setSelected(assertion.reportErrors());
- tolerant();
- }
+ if (tolerant == null) {
+ tolerant = new JCheckBox(JMeterUtils.getResString("xml_tolerant_button")); //$NON-NLS-1$
+ tolerant.addActionListener(new ActionListener() {
+
+ public void actionPerformed(ActionEvent e) {
+ tolerant();
+ }
+ });
+ }
+ return tolerant;
+ }
+
+ /**
+ * @return Returns the validate.
+ */
+ private JCheckBox getValidate() {
+ if (validate == null) {
+ validate = new JCheckBox(JMeterUtils.getResString("xml_validate_button")); //$NON-NLS-1$
+ }
+ return validate;
+ }
+
+ /**
+ * @return Returns the whitespace.
+ */
+ private JCheckBox getWhitespace() {
+ if (whitespace == null) {
+ whitespace = new JCheckBox(JMeterUtils.getResString("xml_whitespace_button")); //$NON-NLS-1$
+ }
+ return whitespace;
+ }
+
+ private boolean isNamespace() {
+ return getNamespace().isSelected();
+ }
+
+ private void setNamespace(boolean namespace) {
+ getNamespace().setSelected(namespace);
+ }
+
+ private boolean isTolerant() {
+ return getTolerant().isSelected();
+ }
+
+ private void setTolerant(boolean tolerant) {
+ getTolerant().setSelected(tolerant);
+ }
+
+ private boolean isWhitespace() {
+ return getWhitespace().isSelected();
+ }
+
+ private void setWhitespace(boolean whitespace) {
+ getWhitespace().setSelected(whitespace);
+ }
+
+ private boolean isValidate() {
+ return getValidate().isSelected();
+ }
+
+ private void setValidate(boolean validating) {
+ getValidate().setSelected(validating);
+ }
+
+ private void tolerant() {
+ final boolean isTolerant = isTolerant();
+ getValidate().setEnabled(!isTolerant);
+ getWhitespace().setEnabled(!isTolerant);
+ getNamespace().setEnabled(!isTolerant);
+ quiet.setEnabled(isTolerant);
+ reportErrors.setEnabled(isTolerant);
+ showWarnings.setEnabled(isTolerant);
+ }
+
+ // Called by XPathAssertionGui
+ public void modifyTestElement(XPathAssertion assertion) {
+ assertion.setValidating(isValidate());
+ assertion.setWhitespace(isWhitespace());
+ assertion.setTolerant(isTolerant());
+ assertion.setNamespace(isNamespace());
+ assertion.setShowWarnings(showWarnings.isSelected());
+ assertion.setReportErrors(reportErrors.isSelected());
+ assertion.setQuiet(quiet.isSelected());
+ }
+
+ // Called by XPathAssertionGui
+ public void configure(XPathAssertion assertion) {
+ setWhitespace(assertion.isWhitespace());
+ setValidate(assertion.isValidating());
+ setTolerant(assertion.isTolerant());
+ setNamespace(assertion.isNamespace());
+ quiet.setSelected(assertion.isQuiet());
+ showWarnings.setSelected(assertion.showWarnings());
+ reportErrors.setSelected(assertion.reportErrors());
+ tolerant();
+ }
}
---------------------------------------------------------------------
To unsubscribe, e-mail: jmeter-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: jmeter-dev-help@jakarta.apache.org